mirror of
https://github.com/actualbudget/actual.git
synced 2026-05-06 07:01:45 -05:00
[AI] api: add browser entry point
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
packages/api/index.browser.ts
Normal file
25
packages/api/index.browser.ts
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user