mirror of
https://github.com/actualbudget/actual.git
synced 2026-03-21 06:58:47 -05:00
Compare commits
4 Commits
js-proxy
...
claude/bro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
645623a6c9 | ||
|
|
1442747896 | ||
|
|
3e2303e5dc | ||
|
|
332db28e2e |
25
packages/api/index.web.ts
Normal file
25
packages/api/index.web.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 internal: typeof lib | null = null;
|
||||||
|
|
||||||
|
export async function init(config: InitConfig = {}) {
|
||||||
|
internal = await initLootCore(config);
|
||||||
|
return internal;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function shutdown() {
|
||||||
|
if (internal) {
|
||||||
|
try {
|
||||||
|
await internal.send('sync');
|
||||||
|
} catch {
|
||||||
|
// most likely that no budget is loaded, so the sync failed
|
||||||
|
}
|
||||||
|
|
||||||
|
await internal.send('close-budget');
|
||||||
|
internal = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,23 +8,39 @@
|
|||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
"module": "dist/browser.js",
|
||||||
"types": "@types/index.d.ts",
|
"types": "@types/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"development": "./index.ts",
|
"development": "./index.ts",
|
||||||
"default": "./dist/index.js"
|
"browser": {
|
||||||
}
|
"types": "./@types/index.d.ts",
|
||||||
|
"default": "./dist/browser.js"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"default": {
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./@types/index.d.ts",
|
"types": "./@types/index.d.ts",
|
||||||
"default": "./dist/index.js"
|
"default": "./dist/index.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"publishConfig": {
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"browser": {
|
||||||
|
"types": "./@types/index.d.ts",
|
||||||
|
"default": "./dist/browser.js"
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"types": "./@types/index.d.ts",
|
||||||
|
"default": "./dist/index.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "vite build",
|
"build": "yarn build:node && yarn build:browser",
|
||||||
|
"build:node": "vite build",
|
||||||
|
"build:browser": "vite build --config vite.browser.config.ts",
|
||||||
"test": "vitest --run",
|
"test": "vitest --run",
|
||||||
"typecheck": "tsgo -b && tsc-strict"
|
"typecheck": "tsgo -b && tsc-strict"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -18,5 +18,12 @@
|
|||||||
},
|
},
|
||||||
"references": [{ "path": "../crdt" }, { "path": "../loot-core" }],
|
"references": [{ "path": "../crdt" }, { "path": "../loot-core" }],
|
||||||
"include": ["."],
|
"include": ["."],
|
||||||
"exclude": ["**/node_modules/*", "dist", "@types", "*.test.ts", "*.config.ts"]
|
"exclude": [
|
||||||
|
"**/node_modules/*",
|
||||||
|
"dist",
|
||||||
|
"@types",
|
||||||
|
"*.test.ts",
|
||||||
|
"*.config.ts",
|
||||||
|
"*.browser.config.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
26
packages/api/vite.browser.config.ts
Normal file
26
packages/api/vite.browser.config.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import peggyLoader from 'vite-plugin-peggy-loader';
|
||||||
|
|
||||||
|
const distDir = path.resolve(__dirname, 'dist');
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
build: {
|
||||||
|
target: 'esnext',
|
||||||
|
outDir: distDir,
|
||||||
|
emptyOutDir: false,
|
||||||
|
sourcemap: true,
|
||||||
|
lib: {
|
||||||
|
entry: path.resolve(__dirname, 'index.web.ts'),
|
||||||
|
formats: ['es'],
|
||||||
|
fileName: () => 'browser.js',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [peggyLoader()],
|
||||||
|
resolve: {
|
||||||
|
// Default extensions — picks up browser implementations (index.ts)
|
||||||
|
// instead of .api.ts (which resolves to Node.js/Electron code)
|
||||||
|
extensions: ['.js', '.ts', '.tsx', '.json'],
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -304,7 +304,7 @@ export function registerQueryCommand(program: Command) {
|
|||||||
? buildQueryFromFile(parsed, cmdOpts.table)
|
? buildQueryFromFile(parsed, cmdOpts.table)
|
||||||
: buildQueryFromFlags(cmdOpts);
|
: buildQueryFromFlags(cmdOpts);
|
||||||
|
|
||||||
const result = await api.aqlQuery(queryObj);
|
const result = (await api.aqlQuery(queryObj)) as { data: unknown };
|
||||||
|
|
||||||
if (cmdOpts.count) {
|
if (cmdOpts.count) {
|
||||||
printOutput({ count: result.data }, opts.format);
|
printOutput({ count: result.data }, opts.format);
|
||||||
|
|||||||
Reference in New Issue
Block a user