mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-06 20:15:33 -05:00
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>