Something went wrong. Try again.
A local-first note taking app
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657/** * Standalone test for the Subtext TCP client. * * Run this directly with Node.js while the subtext daemon is running: * * npx tsx src/subtext/testClient.ts * * Or compile first: * * npx tsc src/subtext/testClient.ts --outDir /tmp/subtext-test --module commonjs * node /tmp/subtext-test/testClient.js */
import { SubtextTCPClient } from './tcpClient';
async function main() { const client = new SubtextTCPClient();
console.log('--- ping ---'); const pong = await client.ping(); console.log('ping result:', pong);
console.log('\n--- listFiles ---'); const files = await client.listFiles(); console.log('files:', files);
console.log('\n--- createFile ---'); const testPath = 'test.md'; const initialState = new Uint8Array([0, 0, 0, 0, 1]); // minimal empty doc envelope try { await client.createFile(testPath, initialState); console.log('created', testPath); } catch (e) { console.error('create failed:', e); }
console.log('\n--- fileExists ---'); const exists = await client.fileExists(testPath); console.log(testPath, 'exists:', exists);
console.log('\n--- getFullState ---'); const state = await client.getFullState(testPath); console.log(testPath, 'state length:', state?.length ?? null);
console.log('\n--- listFiles again ---'); const files2 = await client.listFiles(); console.log('files:', files2);
client.disconnect(); console.log('\nDone.');}
main().catch((e) => { console.error('Fatal:', e); process.exit(1);});