feat: add brew app connection

- initialize tcp communication with brew app
- WIP value editor sync

Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
pakintada@gmail.com 2026-04-03 17:25:27 +07:00
parent 08f7626dcb
commit 274025ed33
14 changed files with 431 additions and 69 deletions

View file

@ -0,0 +1,28 @@
import { get, writable } from 'svelte/store';
import { addNotification } from './noti';
const adbWriter: any = writable(null);
async function sendToAndroid(message: any) {
let writer: any = get(adbWriter);
console.log('writer', writer);
if (!writer) {
addNotification('ERR:No active connection');
return;
}
try {
const encoder = new TextEncoder();
console.log(writer);
await writer.write(encoder.encode(JSON.stringify(message) + '\n'));
console.log('sent!');
} catch (error) {
console.error('write failed', error);
}
}
// helper function for checking if connection is ok
function isAdbWriterAvailable() {
return get(adbWriter) != null;
}
export { sendToAndroid, adbWriter, isAdbWriterAvailable };