@lix-js/sdk 0.9.0 → 0.11.0
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.
- package/README.md +28 -12
- package/dist/binding-types.d.ts +7 -4
- package/dist/binding.browser.js +1 -1
- package/dist/binding.node.js +7 -4
- package/dist/bundled-plugins/plugin_csv.lixplugin +0 -0
- package/dist/bundled-plugins/plugin_markdown.lixplugin +0 -0
- package/dist/bundled-plugins.js +4 -4
- package/dist/client-state.d.ts +16 -3
- package/dist/client-state.js +137 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/lix.d.ts +7 -4
- package/dist/lix.js +16 -2
- package/dist/open-lix.d.ts +1 -5
- package/dist/open-lix.js +12 -33
- package/dist/remote/client.d.ts +1 -0
- package/dist/remote/client.js +156 -7
- package/dist/remote/protocol.d.ts +19 -1
- package/dist/remote/protocol.js +20 -3
- package/dist/result.d.ts +2 -1
- package/dist/result.js +12 -0
- package/dist/types.d.ts +22 -4
- package/dist/wasm/lix_js_sdk.d.ts +8 -2
- package/dist/wasm/lix_js_sdk.js +28 -7
- package/dist/wasm/lix_js_sdk_bg.wasm +0 -0
- package/dist/wasm/lix_js_sdk_bg.wasm.d.ts +5 -2
- package/dist/worker/client.js +42 -1
- package/dist/worker/factory.browser.d.ts +2 -0
- package/dist/worker/factory.browser.js +2 -0
- package/dist/worker/factory.node.d.ts +2 -0
- package/dist/worker/factory.node.js +5 -0
- package/dist/worker/host.js +6 -0
- package/dist/worker/protocol.d.ts +6 -0
- package/package.json +5 -5
- package/dist/bundled-plugins/plugin_csv_v2.lixplugin +0 -0
- package/dist/bundled-plugins/plugin_markdown_incremental_v2.lixplugin +0 -0
package/dist/worker/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createWorkerConnection } from "#worker-factory";
|
|
1
|
+
import { createWorkerConnection, openDirectLixBinding } from "#worker-factory";
|
|
2
2
|
import { snapshotPersistenceAfterCommitError } from "../snapshot-persistence.js";
|
|
3
3
|
import { deserializeWorkerError, } from "./protocol.js";
|
|
4
4
|
const MAX_IDLE_WORKERS = 1;
|
|
@@ -26,6 +26,41 @@ export async function openLixWorker(storage, onDisposed, telemetry) {
|
|
|
26
26
|
}
|
|
27
27
|
/** Opens the local worker transport behind the semantic Lix binding. */
|
|
28
28
|
export async function openLixWorkerBinding(storage, onDisposed, telemetry) {
|
|
29
|
+
if (openDirectLixBinding) {
|
|
30
|
+
const telemetryDispatch = telemetry
|
|
31
|
+
? (span) => {
|
|
32
|
+
try {
|
|
33
|
+
telemetry.onSpan(span);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Telemetry is observational and must not fail engine commands.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
: undefined;
|
|
40
|
+
const binding = await openDirectLixBinding(storage, telemetryDispatch);
|
|
41
|
+
if (!onDisposed)
|
|
42
|
+
return binding;
|
|
43
|
+
let disposed = false;
|
|
44
|
+
return new Proxy(binding, {
|
|
45
|
+
get(target, property, receiver) {
|
|
46
|
+
if (property === "close") {
|
|
47
|
+
return async () => {
|
|
48
|
+
try {
|
|
49
|
+
await target.close();
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
if (!disposed) {
|
|
53
|
+
disposed = true;
|
|
54
|
+
onDisposed();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
const value = Reflect.get(target, property, receiver);
|
|
60
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
29
64
|
const client = await openLixWorker(storage, onDisposed, telemetry);
|
|
30
65
|
return workerBinding(client);
|
|
31
66
|
}
|
|
@@ -95,12 +130,15 @@ function workerBinding(client) {
|
|
|
95
130
|
return workerTransactionBinding(request, transactionId);
|
|
96
131
|
},
|
|
97
132
|
activeBranchId: () => request({ kind: "activeBranchId" }),
|
|
133
|
+
activeAccountId: () => request({ kind: "activeAccountId" }),
|
|
98
134
|
clientStateEntries: () => request({ kind: "clientState.entries" }),
|
|
99
135
|
clientStateGet: (key) => request({ kind: "clientState.get", key }),
|
|
100
136
|
clientStateSet: (key, value) => request({ kind: "clientState.set", key, value }),
|
|
101
137
|
clientStateDelete: (key) => request({ kind: "clientState.delete", key }),
|
|
102
138
|
createBranch: (options) => request({ kind: "createBranch", options }),
|
|
103
139
|
createCheckpoint: () => request({ kind: "createCheckpoint" }),
|
|
140
|
+
undo: () => request({ kind: "undo" }),
|
|
141
|
+
redo: () => request({ kind: "redo" }),
|
|
104
142
|
switchBranch: (options) => request({ kind: "switchBranch", options }),
|
|
105
143
|
importFilesystemPaths: (paths) => request({ kind: "importFilesystemPaths", paths }),
|
|
106
144
|
mergeBranchPreview: (options) => request({ kind: "mergeBranchPreview", options }),
|
|
@@ -158,6 +196,7 @@ function persistentSnapshotBinding(binding, storage, namespace) {
|
|
|
158
196
|
};
|
|
159
197
|
},
|
|
160
198
|
activeBranchId: () => binding.activeBranchId(),
|
|
199
|
+
activeAccountId: () => binding.activeAccountId(),
|
|
161
200
|
clientStateEntries: () => {
|
|
162
201
|
const method = binding.clientStateEntries;
|
|
163
202
|
if (!method)
|
|
@@ -184,6 +223,8 @@ function persistentSnapshotBinding(binding, storage, namespace) {
|
|
|
184
223
|
},
|
|
185
224
|
createBranch: (branchOptions) => afterMutation(binding.createBranch(branchOptions)),
|
|
186
225
|
createCheckpoint: () => afterMutation(binding.createCheckpoint()),
|
|
226
|
+
undo: () => afterMutation(binding.undo()),
|
|
227
|
+
redo: () => afterMutation(binding.redo()),
|
|
187
228
|
switchBranch: (branchOptions) => afterMutation(binding.switchBranch(branchOptions)),
|
|
188
229
|
importFilesystemPaths: (paths) => afterMutation(binding.importFilesystemPaths(paths)),
|
|
189
230
|
mergeBranchPreview: (branchOptions) => binding.mergeBranchPreview(branchOptions),
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { LixBinding, LixStorageConfig, TelemetryDispatch } from "../binding-types.js";
|
|
1
2
|
import type { WorkerConnection } from "./protocol.js";
|
|
3
|
+
export declare const openDirectLixBinding: undefined | ((storage: LixStorageConfig, telemetry?: TelemetryDispatch) => Promise<LixBinding>);
|
|
2
4
|
export declare function createWorkerConnection(): WorkerConnection;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/// <reference lib="webworker" />
|
|
2
|
+
// Browser/Wasm execution stays off the main thread.
|
|
3
|
+
export const openDirectLixBinding = undefined;
|
|
2
4
|
export function createWorkerConnection() {
|
|
3
5
|
const worker = new Worker(new URL("./entry.browser.js", import.meta.url), {
|
|
4
6
|
type: "module",
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { LixBinding, LixStorageConfig, TelemetryDispatch } from "../binding-types.js";
|
|
1
2
|
import type { WorkerConnection } from "./protocol.js";
|
|
2
3
|
export declare function createWorkerConnection(): WorkerConnection;
|
|
4
|
+
export declare const openDirectLixBinding: (storage: LixStorageConfig, telemetry?: TelemetryDispatch) => Promise<LixBinding>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Worker } from "node:worker_threads";
|
|
2
|
+
import { openLixBinding } from "../binding.node.js";
|
|
2
3
|
export function createWorkerConnection() {
|
|
3
4
|
const worker = new Worker(new URL("./entry.node.js", import.meta.url), {
|
|
4
5
|
name: "lix",
|
|
@@ -33,3 +34,7 @@ export function createWorkerConnection() {
|
|
|
33
34
|
},
|
|
34
35
|
};
|
|
35
36
|
}
|
|
37
|
+
/// Native Lix already owns a dedicated serialized engine actor. Routing it
|
|
38
|
+
/// through a second JavaScript worker adds two message-port hops per query
|
|
39
|
+
/// without adding isolation or concurrency.
|
|
40
|
+
export const openDirectLixBinding = (storage, telemetry) => openLixBinding(storage, telemetry);
|
package/dist/worker/host.js
CHANGED
|
@@ -87,6 +87,8 @@ export function startWorkerHost(endpoint) {
|
|
|
87
87
|
}
|
|
88
88
|
case "activeBranchId":
|
|
89
89
|
return requiredLix().activeBranchId();
|
|
90
|
+
case "activeAccountId":
|
|
91
|
+
return requiredLix().activeAccountId();
|
|
90
92
|
case "clientState.entries":
|
|
91
93
|
return requiredClientStateMethod("clientStateEntries")();
|
|
92
94
|
case "clientState.get":
|
|
@@ -99,6 +101,10 @@ export function startWorkerHost(endpoint) {
|
|
|
99
101
|
return requiredLix().createBranch(operation.options);
|
|
100
102
|
case "createCheckpoint":
|
|
101
103
|
return requiredLix().createCheckpoint();
|
|
104
|
+
case "undo":
|
|
105
|
+
return requiredLix().undo();
|
|
106
|
+
case "redo":
|
|
107
|
+
return requiredLix().redo();
|
|
102
108
|
case "switchBranch":
|
|
103
109
|
return requiredLix().switchBranch(operation.options);
|
|
104
110
|
case "mergeBranchPreview":
|
|
@@ -33,6 +33,8 @@ export type WorkerOperation = {
|
|
|
33
33
|
transactionId: number;
|
|
34
34
|
} | {
|
|
35
35
|
kind: "activeBranchId";
|
|
36
|
+
} | {
|
|
37
|
+
kind: "activeAccountId";
|
|
36
38
|
} | {
|
|
37
39
|
kind: "clientState.entries";
|
|
38
40
|
} | {
|
|
@@ -50,6 +52,10 @@ export type WorkerOperation = {
|
|
|
50
52
|
options: CreateBranchOptions;
|
|
51
53
|
} | {
|
|
52
54
|
kind: "createCheckpoint";
|
|
55
|
+
} | {
|
|
56
|
+
kind: "undo";
|
|
57
|
+
} | {
|
|
58
|
+
kind: "redo";
|
|
53
59
|
} | {
|
|
54
60
|
kind: "switchBranch";
|
|
55
61
|
options: SwitchBranchOptions;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lix-js/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"typecheck": "tsc -p tsconfig.test.json --noEmit"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
-
"@lix-js/sdk-darwin-arm64": "0.
|
|
61
|
-
"@lix-js/sdk-linux-arm64": "0.
|
|
62
|
-
"@lix-js/sdk-linux-x64": "0.
|
|
63
|
-
"@lix-js/sdk-win32-x64": "0.
|
|
60
|
+
"@lix-js/sdk-darwin-arm64": "0.11.0",
|
|
61
|
+
"@lix-js/sdk-linux-arm64": "0.11.0",
|
|
62
|
+
"@lix-js/sdk-linux-x64": "0.11.0",
|
|
63
|
+
"@lix-js/sdk-win32-x64": "0.11.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"@vitest/browser-playwright": "4.1.10",
|
|
Binary file
|
|
Binary file
|