Files
github-actions[bot] d5a75a831a [AI] api: spawn worker internally; share bootstrap with desktop-client
Removes the last piece of bespoke browser wiring in @actual-app/api so
consumers call api.init({...}) with no worker construction of their own.
Under the hood, the api package now:

  - Spawns its Web Worker itself via `new Worker(new URL('./worker.js',
    import.meta.url), { type: 'module' })`. Consumer bundlers resolve the
    sibling asset at their own build time.
  - Speaks loot-core's existing {id, name, args} / {type:'reply', id,
    result} backend protocol, including the {type:'connect'} handshake
    — same protocol desktop-client's browser-preload.js already feeds.
  - Delegates sqlite bootstrap to loot-core's public init(config) via a
    worker-registered `api-browser/init` handler; server-side dispatch is
    handled by the existing packages/loot-core/src/platform/server/
    connection layer, so no custom {op, payload} shape remains.

The absurd-sql main-thread plumbing (initSQLBackend + __absurd:* filter)
is now a single function in loot-core:
`packages/loot-core/src/platform/client/backend-worker/createBackendWorker`,
consumed by both desktop-client's browser-preload.js and the api's
browser rpc.ts.

Test split moves accordingly: browser-facade.test.ts swaps in a
Worker mock that speaks the new protocol (id, name, args / reply handshake)
and confirms init forwards config via api-browser/init.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-18 09:42:02 +01:00
..