@g9tm/lynxcontrols-lynxtron

中文文档
1.7.3发布于 2026/11/16MITTypeScriptESM + CJS近 30 天下载 2016

Desktop platform layer for Lynxtron: worker-thread SQLite driver and host services behind a contextBridge preload.

原始使用文档
文档目录3 节
  1. SQLite
  2. Host services
  3. Tests

@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 as lynxPreference.preload of your LynxWindow. It exposes g9sqlite and g9host to the Lynx background thread through contextBridge.exposeInLynxBTS.
  • @g9tm/lynxcontrols-lynxtron (Lynx side): createLynxtronSqliteDriver() (a G9SqliteDriver) and createLynxtronHostServices() ({ host, preferences } for G9Provider 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_threads worker per open database owns a node:sqlite DatabaseSync (Node 22.18 embedded in Lynxtron), a prepared-statement cache and the session's transaction. A run batch is one bridge call.
  • Values: safe integers as numbers, larger ones as { int64 } tags, BLOBs as ArrayBuffer (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), so code, sqliteCode, sql and completedStatements survive the bridge and become G9SqliteErrors.
  • A worker that dies fails its pending requests with interrupted, or outcome-unknown when 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).

版本与发布记录

@g9tm/lynxcontrols-lynxtron 共发布 15 个版本,首次发布于 2026/10/07;过去 12 个月发布了 15 个版本。

版本发布日期距今
1.7.3latest2026/11/16今天
1.7.22026/11/132 天前
1.7.12026/11/133 天前
1.7.02026/11/133 天前
1.6.12026/11/123 天前
1.6.02026/11/123 天前

关于 @g9tm/lynxcontrols-lynxtron 的常见问题

@g9tm/lynxcontrols-lynxtron 是什么?

Desktop platform layer for Lynxtron: worker-thread SQLite driver and host services behind a contextBridge preload.

如何安装 @g9tm/lynxcontrols-lynxtron?

在项目目录运行 npm install @g9tm/lynxcontrols-lynxtron,或使用 pnpm add / yarn add / bun add。

@g9tm/lynxcontrols-lynxtron 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@g9tm/lynxcontrols-lynxtron 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@g9tm/lynxcontrols-lynxtron 可以商用吗?

@g9tm/lynxcontrols-lynxtron 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@g9tm/lynxcontrols-lynxtron 的下载量有多少?

根据 npm 官方下载统计,@g9tm/lynxcontrols-lynxtron 在 2026/10/16 – 2026/11/14 这 30 天内被下载 2,016 次,日均约 67 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@g9tm/lynxcontrols-lynxtron 还在维护吗?

最新版本 1.7.3 发布于 2026/11/16(今天);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/10/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。