@spirobel/monero-wallet-api 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +40 -4
  2. package/dist/actionlog/actionLogOpened.js +7 -2
  3. package/dist/frost_dkg.wasm +0 -0
  4. package/dist/io/logging.js +1 -1
  5. package/dist/keypairs-seeds/keypairs.js +5 -5
  6. package/dist/monero_wallet_api.wasm +0 -0
  7. package/dist/multisig/DistributedKeyGenerator.js +3 -3
  8. package/dist/multisig/MultiSigTxSigner.js +2 -2
  9. package/dist/multisig/escrow.js +1 -1
  10. package/dist/multisig/multisig.js +4 -0
  11. package/dist/node-interaction/binaryEndpoints.d.ts +3 -3
  12. package/dist/node-interaction/nodeUrl.js +2 -2
  13. package/dist/scanning-syncing/backgroundWorker.d.ts +3 -0
  14. package/dist/scanning-syncing/backgroundWorker.js +38 -8
  15. package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.d.ts +1 -1
  16. package/dist/scanning-syncing/blocksbuffer/blocksBufferFetchLoop.js +1 -1
  17. package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.d.ts +1 -1
  18. package/dist/scanning-syncing/blocksbuffer/blocksbufferCoordination.js +1 -1
  19. package/dist/scanning-syncing/connectionStatus.d.ts +1 -1
  20. package/dist/scanning-syncing/connectionStatus.js +2 -2
  21. package/dist/scanning-syncing/openWallet.js +1 -1
  22. package/dist/scanning-syncing/scanresult/computeKeyImage.d.ts +1 -1
  23. package/dist/scanning-syncing/scanresult/computeKeyImage.js +2 -2
  24. package/dist/scanning-syncing/scanresult/scanCache.d.ts +1 -1
  25. package/dist/scanning-syncing/scanresult/scanCache.js +1 -1
  26. package/dist/scanning-syncing/scanresult/scanCacheOpened.d.ts +1 -1
  27. package/dist/scanning-syncing/scanresult/scanCacheOpened.js +33 -16
  28. package/dist/scanning-syncing/scanresult/scanCoordination.d.ts +2 -2
  29. package/dist/scanning-syncing/scanresult/scanCoordination.js +2 -2
  30. package/dist/scanning-syncing/scanresult/scanLoop.d.ts +1 -1
  31. package/dist/scanning-syncing/scanresult/scanLoop.js +1 -1
  32. package/dist/scanning-syncing/scanresult/scanResult.d.ts +1 -1
  33. package/dist/scanning-syncing/scanresult/scanResult.js +3 -3
  34. package/dist/scanning-syncing/scanresult/scanStats.d.ts +1 -1
  35. package/dist/scanning-syncing/scanresult/scanStats.js +1 -2
  36. package/dist/scanning-syncing/worker-entrypoints/worker.js +1 -1
  37. package/dist/scanning-syncing/worker-mains/cpubound-main.js +1 -1
  38. package/dist/scanning-syncing/worker-mains/multisig-main.d.ts +1 -1
  39. package/dist/scanning-syncing/worker-mains/multisig-main.js +1 -1
  40. package/dist/scanning-syncing/worker-mains/worker.js +9 -1
  41. package/dist/scansettings/scanSettings.js +1 -1
  42. package/dist/scansettings/scanSettingsOpened.d.ts +2 -1
  43. package/dist/scansettings/scanSettingsOpened.js +13 -6
  44. package/dist/send-functionality/inputSelection.d.ts +1 -1
  45. package/dist/send-functionality/transactionBuilding.d.ts +1 -1
  46. package/dist/send-functionality/transactionBuilding.js +3 -3
  47. package/dist/viewpair/ViewPair.d.ts +4 -4
  48. package/dist/viewpair/ViewPair.js +4 -4
  49. package/dist/wasm-processing/wasmLoader.d.ts +10 -0
  50. package/dist/wasm-processing/wasmLoader.js +108 -0
  51. package/dist/worker_unpacked.js +14055 -0
  52. package/dist/xmr3.d.ts +1 -39
  53. package/dist/xmr3.js +10 -37
  54. package/dist/xmr3_common.d.ts +39 -0
  55. package/dist/xmr3_common.js +37 -0
  56. package/dist/xmr3_unpacked.d.ts +9 -0
  57. package/dist/xmr3_unpacked.js +14 -0
  58. package/package.json +9 -2
  59. package/dist/actionlog/actionLog.d.ts +0 -4
  60. package/dist/actionlog/actionLog.js +0 -9
  61. package/dist/actionlog/backend/jsonlBackend.d.ts +0 -19
  62. package/dist/actionlog/backend/jsonlBackend.js +0 -110
  63. package/dist/actionlog/backend/memoryBackend.d.ts +0 -11
  64. package/dist/actionlog/backend/memoryBackend.js +0 -31
  65. package/dist/actionlog/backend.d.ts +0 -12
  66. package/dist/actionlog/backend.js +0 -1
  67. package/dist/actionlog/idbBackend.d.ts +0 -19
  68. package/dist/actionlog/idbBackend.js +0 -98
  69. package/dist/actionlog/jsonlBackend.d.ts +0 -19
  70. package/dist/actionlog/jsonlBackend.js +0 -75
  71. package/dist/actionlog/memoryBackend.d.ts +0 -14
  72. package/dist/actionlog/memoryBackend.js +0 -38
  73. package/dist/actionlog/openMaps.d.ts +0 -11
  74. package/dist/actionlog/openMaps.js +0 -32
  75. package/dist/actionlog/sqliteBackend.d.ts +0 -18
  76. package/dist/actionlog/sqliteBackend.js +0 -105
  77. package/dist/actionlog/toolContext.d.ts +0 -36
  78. package/dist/actionlog/toolContext.js +0 -1
  79. package/dist/actionlog/types.d.ts +0 -62
  80. package/dist/actionlog/types.js +0 -62
  81. package/dist/scanning-syncing/blocksbuffer/getBlocksbinBuffer.d.ts +0 -28
  82. package/dist/scanning-syncing/blocksbuffer/getBlocksbinBuffer.js +0 -54
  83. package/dist/scanning-syncing/scanSettings.d.ts +0 -165
  84. package/dist/scanning-syncing/scanSettings.js +0 -338
  85. package/dist/scanning-syncing/scanresult/reorg.d.ts +0 -3
  86. package/dist/scanning-syncing/scanresult/reorg.js +0 -101
  87. package/dist/scanning-syncing/scansettings/scanSettings.d.ts +0 -165
  88. package/dist/scanning-syncing/scansettings/scanSettings.js +0 -338
  89. package/dist/send-functionality/multisig.d.ts +0 -72
  90. package/dist/send-functionality/multisig.js +0 -97
  91. package/dist/tools/calls/002-content.d.ts +0 -46
  92. package/dist/tools/calls/002-content.js +0 -135
  93. package/dist/tools/calls/002-fail-cleanup.d.ts +0 -27
  94. package/dist/tools/calls/002-fail-cleanup.js +0 -60
  95. package/dist/tools/counterparty.d.ts +0 -3
  96. package/dist/tools/counterparty.js +0 -1
  97. package/dist/tools/monero-tools-content.d.ts +0 -29
  98. package/dist/tools/monero-tools-content.js +0 -80
  99. package/dist/tools/runtimeMessages.d.ts +0 -4
  100. package/dist/tools/runtimeMessages.js +0 -18
  101. package/dist/tools/toolActionLogContext.d.ts +0 -33
  102. package/dist/tools/toolActionLogContext.js +0 -1
  103. package/dist/tools/toolArm.d.ts +0 -47
  104. package/dist/tools/toolArm.js +0 -1
  105. package/dist/tools/ui.d.ts +0 -2
  106. package/dist/tools/ui.js +0 -1
  107. package/dist/tools/worker.d.ts +0 -1
  108. package/dist/tools/worker.js +0 -1
package/dist/xmr3.d.ts CHANGED
@@ -1,39 +1 @@
1
- import "./io/indexedDB";
2
- export type { CacheChangedCallback, CacheChangedCallbackParameters, } from "./scanning-syncing/scanresult/scanCache";
3
- export { NodeUrl } from "./node-interaction/nodeUrl";
4
- export { ViewPair } from "./viewpair/ViewPair";
5
- export { ScanCacheOpened, ManyScanCachesOpened, } from "./scanning-syncing/scanresult/scanCacheOpened";
6
- export * from "./node-interaction/binaryEndpoints";
7
- export * from "./node-interaction/jsonEndpoints";
8
- export * from "./io/readDir";
9
- export * from "./io/atomicWrite";
10
- export * from "./io/sleep";
11
- export { LOGGING_FUNCTIONS, type PossibleLogs, type LogSetting, } from "./io/logging";
12
- export { signTransaction, parseAddress, type ParsedAddress, type ParseAddressError, } from "./send-functionality/transactionBuilding";
13
- export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
14
- export * from "./multisig/multisig";
15
- export * from "./multisig/DistributedKeyGenerator";
16
- export * from "./multisig/escrow";
17
- export * from "./multisig/MultiSigTxSigner";
18
- export { createWebworker, makeWebworkerScript, } from "./scanning-syncing/backgroundWorker";
19
- export { spendable } from "./scanning-syncing/scanresult/scanResult";
20
- export { openWallets, openWallet } from "./scanning-syncing/openWallet";
21
- export * from "./scanning-syncing/blocksbuffer/blocksBufferFetchLoop";
22
- export * from "./scanning-syncing/blocksbuffer/blocksbufferCoordination";
23
- export * from "./scanning-syncing/connectionStatus";
24
- export { ConnectionStatusOpened } from "./scanning-syncing/connectionStatusOpened";
25
- export { ActionLogOpened, type ActionLogOpenedCreateOptions, type ActionLogBackendKind, type ActionLogEvent, type ActionLogEventType, type ActionLogStage, Invocation, type InvocationDisplayStatus, type InvocationState, type ToolPermission, type ToolNotice, type ToolUiCopy, type ToolWorkerContext, } from "./actionlog/actionLogOpened";
26
- export * from "./scansettings/scanSettings";
27
- export { ScanSettingsOpened } from "./scansettings/scanSettingsOpened";
28
- export * from "./scanning-syncing/scanresult/scanResult";
29
- export * from "./scanning-syncing/scanresult/scanStats";
30
- export * from "./scanning-syncing/scanresult/scanCache";
31
- export * from "./scanning-syncing/scanresult/scanCoordination";
32
- export * from "./scanning-syncing/scanresult/scanLoop";
33
- export * from "./keypairs-seeds/writeKeypairs";
34
- export * from "./keypairs-seeds/keypairs";
35
- export * from "./send-functionality/conversion";
36
- export * from "./send-functionality/inputSelection";
37
- export * from "./tools/monero-tools";
38
- export type { ToolArm, ToolContentZone, ToolCounterpartyZone, ToolWorkerZone, ToolInvocationForValidate, } from "./tools/globals";
39
- export { sendToBackground } from "./tools/globals";
1
+ export * from "./xmr3_common";
package/dist/xmr3.js CHANGED
@@ -1,37 +1,10 @@
1
- import "./io/indexedDB";
2
- export { NodeUrl } from "./node-interaction/nodeUrl";
3
- export { ViewPair } from "./viewpair/ViewPair";
4
- export { ScanCacheOpened, ManyScanCachesOpened, } from "./scanning-syncing/scanresult/scanCacheOpened";
5
- export * from "./node-interaction/binaryEndpoints";
6
- export * from "./node-interaction/jsonEndpoints";
7
- export * from "./io/readDir";
8
- export * from "./io/atomicWrite";
9
- export * from "./io/sleep";
10
- export { LOGGING_FUNCTIONS, } from "./io/logging";
11
- export { signTransaction, parseAddress, } from "./send-functionality/transactionBuilding";
12
- export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
13
- export * from "./multisig/multisig";
14
- export * from "./multisig/DistributedKeyGenerator";
15
- export * from "./multisig/escrow";
16
- export * from "./multisig/MultiSigTxSigner";
17
- export { createWebworker, makeWebworkerScript, } from "./scanning-syncing/backgroundWorker";
18
- export { spendable } from "./scanning-syncing/scanresult/scanResult";
19
- export { openWallets, openWallet } from "./scanning-syncing/openWallet";
20
- export * from "./scanning-syncing/blocksbuffer/blocksBufferFetchLoop";
21
- export * from "./scanning-syncing/blocksbuffer/blocksbufferCoordination";
22
- export * from "./scanning-syncing/connectionStatus";
23
- export { ConnectionStatusOpened } from "./scanning-syncing/connectionStatusOpened";
24
- export { ActionLogOpened, Invocation, } from "./actionlog/actionLogOpened";
25
- export * from "./scansettings/scanSettings";
26
- export { ScanSettingsOpened } from "./scansettings/scanSettingsOpened";
27
- export * from "./scanning-syncing/scanresult/scanResult";
28
- export * from "./scanning-syncing/scanresult/scanStats";
29
- export * from "./scanning-syncing/scanresult/scanCache";
30
- export * from "./scanning-syncing/scanresult/scanCoordination";
31
- export * from "./scanning-syncing/scanresult/scanLoop";
32
- export * from "./keypairs-seeds/writeKeypairs";
33
- export * from "./keypairs-seeds/keypairs";
34
- export * from "./send-functionality/conversion";
35
- export * from "./send-functionality/inputSelection";
36
- export * from "./tools/monero-tools";
37
- export { sendToBackground } from "./tools/globals";
1
+ // packed entry, uses inlined wasm and worker code
2
+ // this file injects inlined bytes into loaders
3
+ // internal code imports from xmr3_common to avoid cycles
4
+ import { monero_wallet_api_wasm, frost_dkg_wasm } from "./wasm-processing/wasmFile";
5
+ import { setInlineWasm } from "./wasm-processing/wasmLoader";
6
+ import { workerMainCode } from "./scanning-syncing/worker-entrypoints/worker";
7
+ import { setInlineWorkerCode } from "./scanning-syncing/backgroundWorker";
8
+ setInlineWasm(monero_wallet_api_wasm, frost_dkg_wasm);
9
+ setInlineWorkerCode(workerMainCode);
10
+ export * from "./xmr3_common";
@@ -0,0 +1,39 @@
1
+ import "./io/indexedDB";
2
+ export type { CacheChangedCallback, CacheChangedCallbackParameters, } from "./scanning-syncing/scanresult/scanCache";
3
+ export { NodeUrl } from "./node-interaction/nodeUrl";
4
+ export { ViewPair } from "./viewpair/ViewPair";
5
+ export { ScanCacheOpened, ManyScanCachesOpened, } from "./scanning-syncing/scanresult/scanCacheOpened";
6
+ export * from "./node-interaction/binaryEndpoints";
7
+ export * from "./node-interaction/jsonEndpoints";
8
+ export * from "./io/readDir";
9
+ export * from "./io/atomicWrite";
10
+ export * from "./io/sleep";
11
+ export { LOGGING_FUNCTIONS, type PossibleLogs, type LogSetting, } from "./io/logging";
12
+ export { signTransaction, parseAddress, type ParsedAddress, type ParseAddressError, } from "./send-functionality/transactionBuilding";
13
+ export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
14
+ export * from "./multisig/multisig";
15
+ export * from "./multisig/DistributedKeyGenerator";
16
+ export * from "./multisig/escrow";
17
+ export * from "./multisig/MultiSigTxSigner";
18
+ export { createWebworker, makeWebworkerScript, setWorkerUrl, getWorkerUrl, startWebworkerReady, } from "./scanning-syncing/backgroundWorker";
19
+ export { spendable } from "./scanning-syncing/scanresult/scanResult";
20
+ export { openWallets, openWallet } from "./scanning-syncing/openWallet";
21
+ export * from "./scanning-syncing/blocksbuffer/blocksBufferFetchLoop";
22
+ export * from "./scanning-syncing/blocksbuffer/blocksbufferCoordination";
23
+ export * from "./scanning-syncing/connectionStatus";
24
+ export { ConnectionStatusOpened } from "./scanning-syncing/connectionStatusOpened";
25
+ export { ActionLogOpened, type ActionLogOpenedCreateOptions, type ActionLogBackendKind, type ActionLogEvent, type ActionLogEventType, type ActionLogStage, Invocation, type InvocationDisplayStatus, type InvocationState, type ToolPermission, type ToolNotice, type ToolUiCopy, type ToolWorkerContext, } from "./actionlog/actionLogOpened";
26
+ export * from "./scansettings/scanSettings";
27
+ export { ScanSettingsOpened } from "./scansettings/scanSettingsOpened";
28
+ export * from "./scanning-syncing/scanresult/scanResult";
29
+ export * from "./scanning-syncing/scanresult/scanStats";
30
+ export * from "./scanning-syncing/scanresult/scanCache";
31
+ export * from "./scanning-syncing/scanresult/scanCoordination";
32
+ export * from "./scanning-syncing/scanresult/scanLoop";
33
+ export * from "./keypairs-seeds/writeKeypairs";
34
+ export * from "./keypairs-seeds/keypairs";
35
+ export * from "./send-functionality/conversion";
36
+ export * from "./send-functionality/inputSelection";
37
+ export * from "./tools/monero-tools";
38
+ export type { ToolArm, ToolContentZone, ToolCounterpartyZone, ToolWorkerZone, ToolInvocationForValidate, } from "./tools/globals";
39
+ export { sendToBackground } from "./tools/globals";
@@ -0,0 +1,37 @@
1
+ import "./io/indexedDB";
2
+ export { NodeUrl } from "./node-interaction/nodeUrl";
3
+ export { ViewPair } from "./viewpair/ViewPair";
4
+ export { ScanCacheOpened, ManyScanCachesOpened, } from "./scanning-syncing/scanresult/scanCacheOpened";
5
+ export * from "./node-interaction/binaryEndpoints";
6
+ export * from "./node-interaction/jsonEndpoints";
7
+ export * from "./io/readDir";
8
+ export * from "./io/atomicWrite";
9
+ export * from "./io/sleep";
10
+ export { LOGGING_FUNCTIONS, } from "./io/logging";
11
+ export { signTransaction, parseAddress, } from "./send-functionality/transactionBuilding";
12
+ export { computeKeyImage } from "./scanning-syncing/scanresult/computeKeyImage";
13
+ export * from "./multisig/multisig";
14
+ export * from "./multisig/DistributedKeyGenerator";
15
+ export * from "./multisig/escrow";
16
+ export * from "./multisig/MultiSigTxSigner";
17
+ export { createWebworker, makeWebworkerScript, setWorkerUrl, getWorkerUrl, startWebworkerReady, } from "./scanning-syncing/backgroundWorker";
18
+ export { spendable } from "./scanning-syncing/scanresult/scanResult";
19
+ export { openWallets, openWallet } from "./scanning-syncing/openWallet";
20
+ export * from "./scanning-syncing/blocksbuffer/blocksBufferFetchLoop";
21
+ export * from "./scanning-syncing/blocksbuffer/blocksbufferCoordination";
22
+ export * from "./scanning-syncing/connectionStatus";
23
+ export { ConnectionStatusOpened } from "./scanning-syncing/connectionStatusOpened";
24
+ export { ActionLogOpened, Invocation, } from "./actionlog/actionLogOpened";
25
+ export * from "./scansettings/scanSettings";
26
+ export { ScanSettingsOpened } from "./scansettings/scanSettingsOpened";
27
+ export * from "./scanning-syncing/scanresult/scanResult";
28
+ export * from "./scanning-syncing/scanresult/scanStats";
29
+ export * from "./scanning-syncing/scanresult/scanCache";
30
+ export * from "./scanning-syncing/scanresult/scanCoordination";
31
+ export * from "./scanning-syncing/scanresult/scanLoop";
32
+ export * from "./keypairs-seeds/writeKeypairs";
33
+ export * from "./keypairs-seeds/keypairs";
34
+ export * from "./send-functionality/conversion";
35
+ export * from "./send-functionality/inputSelection";
36
+ export * from "./tools/monero-tools";
37
+ export { sendToBackground } from "./tools/globals";
@@ -0,0 +1,9 @@
1
+ export * from "./xmr3_common";
2
+ export { setWasmUrls, getWasmUrls, getMoneroWasmBytes, getDkgWasmBytes, type WasmUrls, } from "./wasm-processing/wasmLoader";
3
+ export { setWorkerUrl, getWorkerUrl } from "./scanning-syncing/backgroundWorker";
4
+ export type UnpackedConfig = {
5
+ workerUrl: string;
6
+ moneroWasmUrl: string;
7
+ dkgWasmUrl: string;
8
+ };
9
+ export declare function configureUnpacked(config: UnpackedConfig): void;
@@ -0,0 +1,14 @@
1
+ // unpacked entry for chrome store
2
+ // no inlined wasm, no inlined worker code
3
+ // consumer copies wasm files and worker file to dist
4
+ // then calls configureUnpacked before openWallets
5
+ export * from "./xmr3_common";
6
+ export { setWasmUrls, getWasmUrls, getMoneroWasmBytes, getDkgWasmBytes, } from "./wasm-processing/wasmLoader";
7
+ export { setWorkerUrl, getWorkerUrl } from "./scanning-syncing/backgroundWorker";
8
+ import { setWasmUrls } from "./wasm-processing/wasmLoader";
9
+ import { setWorkerUrl } from "./scanning-syncing/backgroundWorker";
10
+ // set worker url and wasm urls in one call
11
+ export function configureUnpacked(config) {
12
+ setWorkerUrl(config.workerUrl);
13
+ setWasmUrls({ monero: config.moneroWasmUrl, dkg: config.dkgWasmUrl });
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spirobel/monero-wallet-api",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "main": "dist/xmr3.js",
5
5
  "module": "dist/xmr3.js",
6
6
  "devDependencies": {
@@ -14,6 +14,10 @@
14
14
  "types": "./dist/xmr3.d.ts",
15
15
  "import": "./dist/xmr3.js"
16
16
  },
17
+ "./unpacked": {
18
+ "types": "./dist/xmr3_unpacked.d.ts",
19
+ "import": "./dist/xmr3_unpacked.js"
20
+ },
17
21
  "./tools": {
18
22
  "types": "./dist/tools/monero-tools.d.ts",
19
23
  "import": "./dist/tools/monero-tools.js"
@@ -50,7 +54,10 @@
50
54
  "copydev": "bun run safewasm && bun run safeworker && bun run copydevworker && bun run copydevwasm",
51
55
  "restoredev": "bun run restorewasm && bun run restoreworker",
52
56
  "refreshdev": "bun run restoredev && bun run inlinesum && bun run copydev",
53
- "build": "bun run buildtypescript && bun run inlinesum",
57
+ "buildworkerunpacked": "bun build ./wallet-api/scanning-syncing/worker-mains/worker.ts --target=browser --outfile dist/worker_unpacked.js",
58
+ "copywasm": "cp ../rust/target/wasm32-wasip1/release/monero_wallet_api.wasm dist/monero_wallet_api.wasm && cp ../frost-dkg/target/wasm32-wasip1/release/frost_dkg.wasm dist/frost_dkg.wasm",
59
+ "buildunpacked": "bun run buildworkerunpacked && bun run copywasm",
60
+ "build": "bun run buildtypescript && bun run inlinesum && bun run buildunpacked",
54
61
  "clean": "rm -rf ./dist"
55
62
  },
56
63
  "type": "module",
@@ -1,4 +0,0 @@
1
- export type ActionLog = {
2
- action: string;
3
- data: string;
4
- };
@@ -1,9 +0,0 @@
1
- // the actionlog datastructure records three types of actions:
2
- // 1. actions that the user has performed (external choice)
3
- // 2. actions as the result of business logic during the execution of a tool call
4
- // 3. actions as the result of business logic during the execution of an automated agreement
5
- //
6
- // tool call: privacy preserving interface between wallet and
7
- // services that manage interaction with other users / wallets,
8
- // set in motion by a user action (external choice to the whole (distributed, concurrent) system)
9
- export {};
@@ -1,19 +0,0 @@
1
- import { type ActionLogBackend, type ActionLogEvent, type InvocationState, type InvocationStatus } from "../actionLogTypes";
2
- export declare class ActionLogJsonlBackend implements ActionLogBackend {
3
- private readonly path;
4
- private eventLog;
5
- private active;
6
- constructor(path: string);
7
- static open(path: string): Promise<ActionLogJsonlBackend>;
8
- private invocationsPath;
9
- private load;
10
- private loadInvocationsFile;
11
- private persistEvents;
12
- private persistInvocations;
13
- append(event: ActionLogEvent): Promise<void>;
14
- events(invocationId: string): Promise<ActionLogEvent[]>;
15
- invocation(invocationId: string): Promise<InvocationState | null>;
16
- invocations(status?: InvocationStatus): Promise<InvocationState[]>;
17
- feed(events: ActionLogEvent[]): Promise<void>;
18
- reload(): Promise<void>;
19
- }
@@ -1,110 +0,0 @@
1
- import { atomicWrite } from "../../io/atomicWrite";
2
- import { ActiveInvocations, invocationStatus, } from "../actionLogTypes";
3
- export class ActionLogJsonlBackend {
4
- path;
5
- eventLog = [];
6
- active = new ActiveInvocations();
7
- constructor(path) {
8
- this.path = path;
9
- }
10
- static async open(path) {
11
- const backend = new ActionLogJsonlBackend(path);
12
- await backend.load();
13
- return backend;
14
- }
15
- invocationsPath() {
16
- const p = this.path;
17
- const i = Math.max(p.lastIndexOf("/"), p.lastIndexOf("\\"));
18
- const dir = i >= 0 ? p.slice(0, i) : ".";
19
- return `${dir}/invocations.jsonl`;
20
- }
21
- async load() {
22
- const loaded = await this.loadInvocationsFile();
23
- const text = await Bun.file(this.path)
24
- .text()
25
- .catch(() => "");
26
- this.eventLog = [];
27
- if (text.trim()) {
28
- for (const line of text.split("\n")) {
29
- const t = line.trim();
30
- if (!t)
31
- continue;
32
- try {
33
- this.eventLog.push(JSON.parse(t));
34
- }
35
- catch {
36
- // skip bad line
37
- }
38
- }
39
- }
40
- if (loaded)
41
- return;
42
- this.active.clear();
43
- for (const event of this.eventLog)
44
- this.active.apply(event);
45
- await this.persistInvocations();
46
- }
47
- async loadInvocationsFile() {
48
- const text = await Bun.file(this.invocationsPath())
49
- .text()
50
- .catch(() => "");
51
- if (!text.trim())
52
- return false;
53
- const states = [];
54
- for (const line of text.split("\n")) {
55
- const t = line.trim();
56
- if (!t)
57
- continue;
58
- try {
59
- states.push(JSON.parse(t));
60
- }
61
- catch {
62
- // skip bad line
63
- }
64
- }
65
- if (!states.length)
66
- return false;
67
- this.active.loadStates(states);
68
- return true;
69
- }
70
- async persistEvents() {
71
- const body = this.eventLog.map((e) => JSON.stringify(e)).join("\n") +
72
- (this.eventLog.length ? "\n" : "");
73
- await atomicWrite(this.path, body);
74
- }
75
- async persistInvocations() {
76
- const rows = this.active.invocations();
77
- const body = rows
78
- .map((s) => JSON.stringify({ ...s, status: invocationStatus(s) }))
79
- .join("\n") + (rows.length ? "\n" : "");
80
- await atomicWrite(this.invocationsPath(), body);
81
- }
82
- async append(event) {
83
- this.eventLog.push(event);
84
- this.active.apply(event);
85
- await this.persistEvents();
86
- await this.persistInvocations();
87
- }
88
- async events(invocationId) {
89
- return this.eventLog.filter((e) => e.invocationId === invocationId);
90
- }
91
- async invocation(invocationId) {
92
- return this.active.invocation(invocationId);
93
- }
94
- async invocations(status) {
95
- return this.active.invocations(status);
96
- }
97
- async feed(events) {
98
- for (const event of events) {
99
- if (this.eventLog.some((e) => e.id === event.id))
100
- continue;
101
- this.eventLog.push(event);
102
- this.active.apply(event);
103
- }
104
- await this.persistEvents();
105
- await this.persistInvocations();
106
- }
107
- async reload() {
108
- await this.load();
109
- }
110
- }
@@ -1,11 +0,0 @@
1
- import { type ActionLogBackend, type ActionLogEvent, type InvocationState, type InvocationStatus } from "../actionLogTypes";
2
- export declare class ActionLogMemoryBackend implements ActionLogBackend {
3
- private eventLog;
4
- private active;
5
- append(event: ActionLogEvent): Promise<void>;
6
- events(invocationId: string): Promise<ActionLogEvent[]>;
7
- invocation(invocationId: string): Promise<InvocationState | null>;
8
- invocations(status?: InvocationStatus): Promise<InvocationState[]>;
9
- feed(events: ActionLogEvent[]): Promise<void>;
10
- reload(): Promise<void>;
11
- }
@@ -1,31 +0,0 @@
1
- import { ActiveInvocations, } from "../actionLogTypes";
2
- export class ActionLogMemoryBackend {
3
- eventLog = [];
4
- active = new ActiveInvocations();
5
- async append(event) {
6
- this.eventLog.push(event);
7
- this.active.apply(event);
8
- }
9
- async events(invocationId) {
10
- return this.eventLog.filter((e) => e.invocationId === invocationId);
11
- }
12
- async invocation(invocationId) {
13
- return this.active.invocation(invocationId);
14
- }
15
- async invocations(status) {
16
- return this.active.invocations(status);
17
- }
18
- async feed(events) {
19
- for (const event of events) {
20
- if (this.eventLog.some((e) => e.id === event.id))
21
- continue;
22
- this.eventLog.push(event);
23
- this.active.apply(event);
24
- }
25
- }
26
- async reload() {
27
- this.active.clear();
28
- for (const event of this.eventLog)
29
- this.active.apply(event);
30
- }
31
- }
@@ -1,12 +0,0 @@
1
- import type { ToolId } from "../tools/monero-tools";
2
- import type { ActionLogEvent, OpenInvocationState } from "./types";
3
- export type ActionLogBackend = {
4
- append(event: ActionLogEvent): Promise<void>;
5
- getBranch(invocationId: string): Promise<ActionLogEvent[]>;
6
- getTip(invocationId: string): Promise<ActionLogEvent | null>;
7
- getOpenByToolId(toolId: ToolId): Promise<OpenInvocationState | null>;
8
- getOpenInvocations(): Promise<OpenInvocationState[]>;
9
- feed?(events: ActionLogEvent[]): Promise<void>;
10
- reload?(): Promise<void>;
11
- close?(): Promise<void>;
12
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import type { ActionLogBackend } from "./backend";
2
- import type { ActionLogEvent, OpenInvocationState } from "./types";
3
- import type { ToolId } from "../tools/monero-tools";
4
- export declare class ActionLogIdbBackend implements ActionLogBackend {
5
- private readonly db;
6
- private open;
7
- private constructor();
8
- static open(dbName?: string): Promise<ActionLogIdbBackend>;
9
- private rebuildOpenMaps;
10
- private getAllEventsOrdered;
11
- append(event: ActionLogEvent): Promise<void>;
12
- getBranch(invocationId: string): Promise<ActionLogEvent[]>;
13
- getTip(invocationId: string): Promise<ActionLogEvent | null>;
14
- getOpenByToolId(toolId: ToolId): Promise<OpenInvocationState | null>;
15
- getOpenInvocations(): Promise<OpenInvocationState[]>;
16
- feed(events: ActionLogEvent[]): Promise<void>;
17
- reload(): Promise<void>;
18
- close(): Promise<void>;
19
- }
@@ -1,98 +0,0 @@
1
- import { OpenInvocationMaps } from "./openMaps";
2
- const DB_NAME_DEFAULT = "monero-actionlog";
3
- const STORE_EVENTS = "events";
4
- export class ActionLogIdbBackend {
5
- db;
6
- open = new OpenInvocationMaps();
7
- constructor(db) {
8
- this.db = db;
9
- }
10
- static async open(dbName = DB_NAME_DEFAULT) {
11
- if (typeof indexedDB === "undefined") {
12
- throw new Error("IndexedDB not available");
13
- }
14
- const db = await openDb(dbName);
15
- const backend = new ActionLogIdbBackend(db);
16
- await backend.rebuildOpenMaps();
17
- return backend;
18
- }
19
- async rebuildOpenMaps() {
20
- this.open.clear();
21
- const events = await this.getAllEventsOrdered();
22
- for (const event of events)
23
- this.open.apply(event);
24
- }
25
- getAllEventsOrdered() {
26
- return new Promise((resolve, reject) => {
27
- const tx = this.db.transaction(STORE_EVENTS, "readonly");
28
- const store = tx.objectStore(STORE_EVENTS);
29
- const req = store.getAll();
30
- req.onerror = () => reject(req.error);
31
- req.onsuccess = () => {
32
- const rows = req.result ?? [];
33
- rows.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
34
- resolve(rows);
35
- };
36
- });
37
- }
38
- async append(event) {
39
- await new Promise((resolve, reject) => {
40
- const tx = this.db.transaction(STORE_EVENTS, "readwrite");
41
- const store = tx.objectStore(STORE_EVENTS);
42
- const req = store.put(event);
43
- req.onerror = () => reject(req.error);
44
- req.onsuccess = () => resolve();
45
- });
46
- this.open.apply(event);
47
- }
48
- async getBranch(invocationId) {
49
- return new Promise((resolve, reject) => {
50
- const tx = this.db.transaction(STORE_EVENTS, "readonly");
51
- const store = tx.objectStore(STORE_EVENTS);
52
- const index = store.index("invocationId");
53
- const req = index.getAll(invocationId);
54
- req.onerror = () => reject(req.error);
55
- req.onsuccess = () => {
56
- const rows = req.result ?? [];
57
- rows.sort((a, b) => a.timestamp.localeCompare(b.timestamp));
58
- resolve(rows);
59
- };
60
- });
61
- }
62
- async getTip(invocationId) {
63
- const branch = await this.getBranch(invocationId);
64
- return branch.length ? branch[branch.length - 1] : null;
65
- }
66
- async getOpenByToolId(toolId) {
67
- return this.open.getOpenByToolId(toolId);
68
- }
69
- async getOpenInvocations() {
70
- return this.open.getOpenInvocations();
71
- }
72
- async feed(events) {
73
- for (const event of events)
74
- await this.append(event);
75
- }
76
- async reload() {
77
- await this.rebuildOpenMaps();
78
- }
79
- async close() {
80
- this.db.close();
81
- }
82
- }
83
- function openDb(name) {
84
- return new Promise((resolve, reject) => {
85
- const req = indexedDB.open(name, 1);
86
- req.onerror = () => reject(req.error);
87
- req.onupgradeneeded = () => {
88
- const db = req.result;
89
- if (!db.objectStoreNames.contains(STORE_EVENTS)) {
90
- const store = db.createObjectStore(STORE_EVENTS, { keyPath: "id" });
91
- store.createIndex("invocationId", "invocationId", { unique: false });
92
- store.createIndex("toolId", "toolId", { unique: false });
93
- store.createIndex("timestamp", "timestamp", { unique: false });
94
- }
95
- };
96
- req.onsuccess = () => resolve(req.result);
97
- });
98
- }
@@ -1,19 +0,0 @@
1
- import type { ActionLogBackend } from "./backend";
2
- import type { ActionLogEvent, OpenInvocationState } from "./types";
3
- import type { ToolId } from "../tools/monero-tools";
4
- export declare class ActionLogJsonlBackend implements ActionLogBackend {
5
- private readonly path;
6
- private events;
7
- private open;
8
- constructor(path: string);
9
- static open(path: string): Promise<ActionLogJsonlBackend>;
10
- private load;
11
- private persist;
12
- append(event: ActionLogEvent): Promise<void>;
13
- getBranch(invocationId: string): Promise<ActionLogEvent[]>;
14
- getTip(invocationId: string): Promise<ActionLogEvent | null>;
15
- getOpenByToolId(toolId: ToolId): Promise<OpenInvocationState | null>;
16
- getOpenInvocations(): Promise<OpenInvocationState[]>;
17
- feed(events: ActionLogEvent[]): Promise<void>;
18
- reload(): Promise<void>;
19
- }
@@ -1,75 +0,0 @@
1
- import { atomicWrite } from "../io/atomicWrite";
2
- import { OpenInvocationMaps } from "./openMaps";
3
- export class ActionLogJsonlBackend {
4
- path;
5
- events = [];
6
- open = new OpenInvocationMaps();
7
- constructor(path) {
8
- this.path = path;
9
- }
10
- static async open(path) {
11
- const backend = new ActionLogJsonlBackend(path);
12
- await backend.load();
13
- return backend;
14
- }
15
- async load() {
16
- const text = await Bun.file(this.path)
17
- .text()
18
- .catch(() => "");
19
- this.events = [];
20
- this.open.clear();
21
- if (!text.trim())
22
- return;
23
- for (const line of text.split("\n")) {
24
- const t = line.trim();
25
- if (!t)
26
- continue;
27
- try {
28
- const event = JSON.parse(t);
29
- this.events.push(event);
30
- this.open.apply(event);
31
- }
32
- catch {
33
- // skip bad line
34
- }
35
- }
36
- }
37
- async persist() {
38
- const body = this.events.map((e) => JSON.stringify(e)).join("\n") +
39
- (this.events.length ? "\n" : "");
40
- await atomicWrite(this.path, body);
41
- }
42
- async append(event) {
43
- this.events.push(event);
44
- this.open.apply(event);
45
- await this.persist();
46
- }
47
- async getBranch(invocationId) {
48
- return this.events.filter((e) => e.invocationId === invocationId);
49
- }
50
- async getTip(invocationId) {
51
- for (let i = this.events.length - 1; i >= 0; i--) {
52
- if (this.events[i].invocationId === invocationId)
53
- return this.events[i];
54
- }
55
- return null;
56
- }
57
- async getOpenByToolId(toolId) {
58
- return this.open.getOpenByToolId(toolId);
59
- }
60
- async getOpenInvocations() {
61
- return this.open.getOpenInvocations();
62
- }
63
- async feed(events) {
64
- for (const event of events) {
65
- if (this.events.some((e) => e.id === event.id))
66
- continue;
67
- this.events.push(event);
68
- this.open.apply(event);
69
- }
70
- await this.persist();
71
- }
72
- async reload() {
73
- await this.load();
74
- }
75
- }