Files
actual/packages/api/index.js
Jed Fox 02f1fe48c6 Stop mixing platform-specific code (#1114)
Bundle sizes are unchanged but now we no longer pull in the
Electron-specific FS code on the web version
2023-06-09 16:06:18 -04:00

37 lines
757 B
JavaScript

import fetch from 'node-fetch';
// eslint-disable-next-line import/extensions
import * as bundle from './app/bundle.api.js';
import * as injected from './injected';
let actualApp;
export const internal = bundle.lib;
// DEPRECATED: remove the next line in @actual-app/api v7
export * as methods from './methods';
export * from './methods';
export * as utils from './utils';
export async function init(config = {}) {
if (actualApp) {
return;
}
global.fetch = fetch;
await bundle.init(config);
actualApp = bundle.lib;
injected.override(bundle.lib.send);
return bundle.lib;
}
export async function shutdown() {
if (actualApp) {
await actualApp.send('sync');
await actualApp.send('close-budget');
actualApp = null;
}
}