From f3850cae1d1a3b3ded56d8d52f4e74e010656ba7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 17 Apr 2026 21:50:56 +0100 Subject: [PATCH] [AI] api: add browser entry point Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/api/index.browser.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 packages/api/index.browser.ts diff --git a/packages/api/index.browser.ts b/packages/api/index.browser.ts new file mode 100644 index 0000000000..d0988708ce --- /dev/null +++ b/packages/api/index.browser.ts @@ -0,0 +1,25 @@ +import { init as initLootCore } from '@actual-app/core/server/main'; +import type { InitConfig, lib } from '@actual-app/core/server/main'; + +export * from './methods'; +export * as utils from './utils'; + +let internalLib: typeof lib | null = null; + +export async function init(config: InitConfig = {}) { + internalLib = await initLootCore(config); + return internalLib; +} + +export async function shutdown() { + if (internalLib) { + try { + await internalLib.send('sync'); + } catch { + // most likely no budget loaded, so sync failed + } + + await internalLib.send('close-budget'); + internalLib = null; + } +}