@g9tm/lynxcontrols-lynxtron
The desktop platform layer (plan/specs/06 §3, §7) for Lynxtron 0.0.28 (Windows, macOS; Linux headless):
@g9tm/lynxcontrols-lynxtron/preload(dist/preload.cjs): set it aslynxPreference.preloadof yourLynxWindow. It exposesg9sqliteandg9hostto the Lynx background thread throughcontextBridge.exposeInLynxBTS.@g9tm/lynxcontrols-lynxtron(Lynx side):createLynxtronSqliteDriver()(aG9SqliteDriver) andcreateLynxtronHostServices()({ host, preferences }forG9Provider services).@g9tm/lynxcontrols-lynxtron/node: the Node side (engine, worker host, preference files) for custom preloads and tests.
// main process (see apps/desktop-host/main.mjs)
process.env.G9_USER_DATA ??= app.getPath('userData');
new LynxWindow({ lynxPreference: { preload: require.resolve('@g9tm/lynxcontrols-lynxtron/preload') } });
// Lynx code
import { createLynxtronHostServices, createLynxtronSqliteDriver } from '@g9tm/lynxcontrols-lynxtron';
const { host, preferences } = createLynxtronHostServices();
const db = createG9Sqlite({ driver: createLynxtronSqliteDriver(), … });
SQLite
- One
worker_threadsworker per open database owns anode:sqliteDatabaseSync(Node 22.18 embedded in Lynxtron), a prepared-statement cache and the session's transaction. Arunbatch is one bridge call. - Values: safe integers as numbers, larger ones as
{ int64 }tags, BLOBs asArrayBuffer(normalized on the Lynx side whatever realm or typed array the bridge hands over), text with NUL rejected (contract D24). - Errors cross as data (
{ ok: false, error }envelopes), socode,sqliteCode,sqlandcompletedStatementssurvive the bridge and becomeG9SqliteErrors. - A worker that dies fails its pending requests with
interrupted, oroutcome-unknownwhen a COMMIT was in flight; the session is then dead (reopen). A worker is terminated only when its database is closed (idle), never mid-statement. - Cancellation: requests of a session queue on the Lynx side; a batch whose signal aborts before its turn never reaches
the worker. Running statements are not interruptible (
capabilities().interrupt === false).
Host services
Preferences live in <userData>/<namespace>.prefs.json (namespace g9), written atomically (temp file, then rename):
a kill mid-write leaves the previous file; a corrupt file reads as empty and is replaced by the next write. exit
closes the app (a desktop has no "move to background"); hideKeyboard is a no-op; there are no safe-area insets.
Tests
npm test runs the driver contract through the worker protocol in process and through real worker threads, crash
recovery, queued cancellation, preference atomicity and the entry points. apps/desktop-host runs the contract
through the real Lynxtron bridge headless (node test/run-headless.mjs; 27/27 on Linux in the cloud).