@lix-js/sdk 0.8.4 → 0.10.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.
Files changed (49) hide show
  1. package/README.md +105 -22
  2. package/dist/binding-types.d.ts +21 -2
  3. package/dist/binding.browser.d.ts +2 -2
  4. package/dist/binding.browser.js +3 -3
  5. package/dist/binding.node.d.ts +2 -2
  6. package/dist/binding.node.js +18 -4
  7. package/dist/bundled-plugins/plugin_csv.lixplugin +0 -0
  8. package/dist/bundled-plugins/plugin_markdown.lixplugin +0 -0
  9. package/dist/bundled-plugins.js +2 -2
  10. package/dist/client-state.d.ts +53 -0
  11. package/dist/client-state.js +318 -0
  12. package/dist/index.d.ts +2 -1
  13. package/dist/lix.d.ts +47 -0
  14. package/dist/lix.js +378 -0
  15. package/dist/local-storage-adapter.d.ts +26 -0
  16. package/dist/local-storage-adapter.js +117 -0
  17. package/dist/open-lix.d.ts +3 -34
  18. package/dist/open-lix.js +99 -170
  19. package/dist/remote/client.d.ts +9 -0
  20. package/dist/remote/client.js +1150 -0
  21. package/dist/remote/protocol.d.ts +178 -0
  22. package/dist/remote/protocol.js +367 -0
  23. package/dist/remote/sse.d.ts +12 -0
  24. package/dist/remote/sse.js +87 -0
  25. package/dist/snapshot-persistence.d.ts +7 -0
  26. package/dist/snapshot-persistence.js +26 -0
  27. package/dist/types.d.ts +68 -1
  28. package/dist/wasm/lix_js_sdk.d.ts +22 -4
  29. package/dist/wasm/lix_js_sdk.js +96 -17
  30. package/dist/wasm/lix_js_sdk_bg.wasm +0 -0
  31. package/dist/wasm/lix_js_sdk_bg.wasm.d.ts +11 -2
  32. package/dist/worker/client.d.ts +23 -4
  33. package/dist/worker/client.js +329 -11
  34. package/dist/worker/factory.browser.d.ts +2 -0
  35. package/dist/worker/factory.browser.js +2 -0
  36. package/dist/worker/factory.node.d.ts +2 -0
  37. package/dist/worker/factory.node.js +5 -0
  38. package/dist/worker/host.js +36 -2
  39. package/dist/worker/protocol.d.ts +32 -2
  40. package/dist/workerd.js +1 -3
  41. package/package.json +19 -16
  42. package/dist/bundled-plugins/plugin_md_v2.lixplugin +0 -0
  43. package/dist/jco/js-component-bindgen-component.core.wasm +0 -0
  44. package/dist/jco/js-component-bindgen-component.core2.wasm +0 -0
  45. package/dist/jco/js-component-bindgen-component.js +0 -13662
  46. package/dist/jco-transpile.browser.d.ts +0 -14
  47. package/dist/jco-transpile.browser.js +0 -22
  48. package/dist/plugin-runtime.d.ts +0 -45
  49. package/dist/plugin-runtime.js +0 -124
package/dist/lix.js ADDED
@@ -0,0 +1,378 @@
1
+ import { invalidArgument } from "./errors.js";
2
+ import { ACTIVE_BRANCH_CLIENT_STATE_KEY, unavailableClientState, } from "./client-state.js";
3
+ import { normalizeOptionals, wrapExecuteResult } from "./result.js";
4
+ import { isSnapshotPersistenceAfterCommitError } from "./snapshot-persistence.js";
5
+ import { normalizeParam, toNativeValue } from "./value.js";
6
+ const transactionFinalizer = new FinalizationRegistry(({ transaction, onFinish }) => {
7
+ void transaction
8
+ .rollback()
9
+ .catch(() => undefined)
10
+ .finally(onFinish);
11
+ });
12
+ const observeFinalizer = new FinalizationRegistry(({ observe, onClose }) => {
13
+ onClose();
14
+ void observe.then((events) => {
15
+ events?.close();
16
+ });
17
+ });
18
+ export class Lix {
19
+ binding;
20
+ managedClientState;
21
+ closePromise;
22
+ clientState;
23
+ #activeBranchListeners = new Set();
24
+ #inFlightOperations = new Set();
25
+ #observations = new Map();
26
+ #nextObservationId = 0;
27
+ #transactionsOpening = 0;
28
+ #activeTransactions = 0;
29
+ #acceptingOperations = true;
30
+ constructor(binding, managedClientState) {
31
+ this.binding = binding;
32
+ this.managedClientState = managedClientState;
33
+ this.clientState = managedClientState
34
+ ? {
35
+ get: (key) => managedClientState.get(key),
36
+ set: (key, value) => this.#runOperation(() => managedClientState.set(key, value)),
37
+ delete: (key) => this.#runOperation(() => managedClientState.delete(key)),
38
+ subscribe: (listener) => {
39
+ this.#assertAcceptingOperations();
40
+ return managedClientState.subscribe(listener);
41
+ },
42
+ }
43
+ : unavailableClientState();
44
+ }
45
+ async execute(sql, params = [], options) {
46
+ assertExecuteArgs("lix", sql, params, options);
47
+ return this.#runOperation(async () => wrapExecuteResult(await this.binding.execute(sql, params.map((param, index) => toNativeValue(normalizeParam(param, index))), options)));
48
+ }
49
+ async executeBatch(statements, options) {
50
+ const normalizedStatements = normalizeBatchStatements(statements, options);
51
+ return this.#runOperation(async () => {
52
+ const results = await this.binding.executeBatch(normalizedStatements, options);
53
+ return results.map(wrapExecuteResult);
54
+ });
55
+ }
56
+ observe(sql, params = []) {
57
+ assertSqlArgs("observe", "lix", sql, params);
58
+ const observationId = ++this.#nextObservationId;
59
+ let events;
60
+ events = new ObserveEvents(this.#runOperation(() => this.binding.observe(sql, params.map((param, index) => toNativeValue(normalizeParam(param, index))))), () => this.#observations.delete(observationId));
61
+ this.#observations.set(observationId, new WeakRef(events));
62
+ return events;
63
+ }
64
+ async beginTransaction() {
65
+ return this.#runOperation(async () => {
66
+ this.#transactionsOpening += 1;
67
+ try {
68
+ const binding = await this.binding.beginTransaction();
69
+ this.#activeTransactions += 1;
70
+ let active = true;
71
+ return new LixTransaction(binding, () => {
72
+ if (!active)
73
+ return;
74
+ active = false;
75
+ this.#activeTransactions -= 1;
76
+ });
77
+ }
78
+ finally {
79
+ this.#transactionsOpening -= 1;
80
+ }
81
+ });
82
+ }
83
+ async activeBranchId() {
84
+ return this.#runOperation(() => this.binding.activeBranchId());
85
+ }
86
+ async activeAccountId() {
87
+ return this.#runOperation(() => this.binding.activeAccountId());
88
+ }
89
+ /** Subscribes to successful branch switches made through this Lix handle. */
90
+ subscribeActiveBranch(listener) {
91
+ if (typeof listener !== "function") {
92
+ throw new TypeError("subscribeActiveBranch() requires a function");
93
+ }
94
+ this.#assertAcceptingOperations();
95
+ this.#activeBranchListeners.add(listener);
96
+ return () => this.#activeBranchListeners.delete(listener);
97
+ }
98
+ async createBranch(options) {
99
+ return this.#runOperation(() => this.binding.createBranch(options));
100
+ }
101
+ async createCheckpoint() {
102
+ return this.#runOperation(() => this.binding.createCheckpoint());
103
+ }
104
+ async undo() {
105
+ return this.#runOperation(() => this.binding.undo());
106
+ }
107
+ async redo() {
108
+ return this.#runOperation(() => this.binding.redo());
109
+ }
110
+ async switchBranch(options) {
111
+ return this.#runOperation(async () => {
112
+ const receipt = await this.binding.switchBranch(options);
113
+ try {
114
+ if (this.managedClientState) {
115
+ await this.managedClientState.set(ACTIVE_BRANCH_CLIENT_STATE_KEY, receipt.branchId);
116
+ }
117
+ }
118
+ catch {
119
+ // The remote branch switch already committed. Client persistence is a
120
+ // best-effort reopen preference and cannot turn that success into a
121
+ // rejected switch with ambiguous branch state.
122
+ }
123
+ for (const listener of [...this.#activeBranchListeners]) {
124
+ try {
125
+ listener();
126
+ }
127
+ catch {
128
+ // Observers do not participate in the completed branch transaction.
129
+ }
130
+ }
131
+ return receipt;
132
+ });
133
+ }
134
+ async mergeBranchPreview(options) {
135
+ return this.#runOperation(async () => normalizeOptionals(await this.binding.mergeBranchPreview(options)));
136
+ }
137
+ async mergeBranch(options) {
138
+ return this.#runOperation(async () => {
139
+ const receipt = normalizeOptionals(await this.binding.mergeBranch(options));
140
+ receipt.createdMergeCommitId ??= null;
141
+ return receipt;
142
+ });
143
+ }
144
+ async close() {
145
+ if (!this.closePromise) {
146
+ if (this.#transactionsOpening > 0 || this.#activeTransactions > 0) {
147
+ throw activeTransactionCloseError();
148
+ }
149
+ // Flip the public lifecycle gate before the first await. Operations that
150
+ // already entered the gate are allowed to finish; later calls fail closed.
151
+ this.#acceptingOperations = false;
152
+ for (const observation of this.#observations.values()) {
153
+ observation.deref()?.close();
154
+ }
155
+ this.#observations.clear();
156
+ this.closePromise = (async () => {
157
+ await Promise.allSettled([...this.#inFlightOperations]);
158
+ await this.binding.close();
159
+ await this.managedClientState?.close();
160
+ this.#activeBranchListeners.clear();
161
+ })();
162
+ }
163
+ await this.closePromise;
164
+ }
165
+ #runOperation(operation) {
166
+ try {
167
+ this.#assertAcceptingOperations();
168
+ const result = operation();
169
+ this.#inFlightOperations.add(result);
170
+ void result.then(() => this.#inFlightOperations.delete(result), () => this.#inFlightOperations.delete(result));
171
+ return result;
172
+ }
173
+ catch (error) {
174
+ return Promise.reject(error);
175
+ }
176
+ }
177
+ #assertAcceptingOperations() {
178
+ if (this.#acceptingOperations)
179
+ return;
180
+ const error = new Error("Lix is closed");
181
+ error.name = "LixError";
182
+ error.code = "LIX_ERROR_CLOSED";
183
+ throw error;
184
+ }
185
+ }
186
+ function activeTransactionCloseError() {
187
+ const error = new Error("cannot close Lix while an explicit transaction is active");
188
+ error.name = "LixError";
189
+ error.code = "LIX_INVALID_TRANSACTION_STATE";
190
+ return error;
191
+ }
192
+ export class ObserveEvents {
193
+ onClose;
194
+ setup = {};
195
+ closed = false;
196
+ observeBinding;
197
+ constructor(observeBinding, onClose = () => undefined) {
198
+ this.onClose = onClose;
199
+ const setup = this.setup;
200
+ this.observeBinding = observeBinding.catch((error) => {
201
+ setup.error = error;
202
+ return undefined;
203
+ });
204
+ observeFinalizer.register(this, { observe: this.observeBinding, onClose: this.onClose }, this);
205
+ }
206
+ async next() {
207
+ if (this.closed)
208
+ return undefined;
209
+ const binding = await this.observeBinding;
210
+ if (binding === undefined) {
211
+ throw this.setup.error;
212
+ }
213
+ const event = await binding.next();
214
+ if (event == null) {
215
+ return undefined;
216
+ }
217
+ return {
218
+ sequence: event.sequence,
219
+ mutationSequence: event.mutationSequence,
220
+ result: wrapExecuteResult(event.rows),
221
+ };
222
+ }
223
+ close() {
224
+ if (this.closed)
225
+ return;
226
+ this.closed = true;
227
+ this.onClose();
228
+ observeFinalizer.unregister(this);
229
+ void this.observeBinding.then((binding) => {
230
+ binding?.close();
231
+ });
232
+ }
233
+ }
234
+ export class LixTransaction {
235
+ binding;
236
+ onFinish;
237
+ finishPromise;
238
+ finished = false;
239
+ constructor(binding, onFinish = () => undefined) {
240
+ this.binding = binding;
241
+ this.onFinish = onFinish;
242
+ transactionFinalizer.register(this, { transaction: binding, onFinish: this.onFinish }, this);
243
+ }
244
+ async execute(sql, params = [], options) {
245
+ assertExecuteArgs("lixTransaction", sql, params, options);
246
+ return wrapExecuteResult(await this.binding.execute(sql, params.map((param, index) => toNativeValue(normalizeParam(param, index))), options));
247
+ }
248
+ async commit() {
249
+ return this.finish("transaction.commit");
250
+ }
251
+ async rollback() {
252
+ return this.finish("transaction.rollback");
253
+ }
254
+ async finish(kind) {
255
+ if (this.finished)
256
+ throw transactionClosedError();
257
+ if (!this.finishPromise) {
258
+ this.finishPromise = (async () => {
259
+ if (kind === "transaction.commit")
260
+ await this.binding.commit();
261
+ else
262
+ await this.binding.rollback();
263
+ this.finished = true;
264
+ transactionFinalizer.unregister(this);
265
+ this.onFinish();
266
+ })();
267
+ }
268
+ try {
269
+ await this.finishPromise;
270
+ }
271
+ catch (error) {
272
+ if (isSnapshotPersistenceAfterCommitError(error)) {
273
+ // The transaction finished in Rust; only durable snapshot saving
274
+ // failed. Release the transaction lifecycle while reporting that
275
+ // durability failure to the caller.
276
+ this.finished = true;
277
+ transactionFinalizer.unregister(this);
278
+ this.onFinish();
279
+ throw error;
280
+ }
281
+ this.finishPromise = undefined;
282
+ throw error;
283
+ }
284
+ }
285
+ }
286
+ function transactionClosedError() {
287
+ const error = new Error("Lix transaction is closed");
288
+ error.name = "LixError";
289
+ error.code = "LIX_INVALID_TRANSACTION_STATE";
290
+ return error;
291
+ }
292
+ function assertExecuteArgs(receiver, sql, params, options) {
293
+ assertSqlArgs("execute", receiver, sql, params);
294
+ if (options === undefined) {
295
+ return;
296
+ }
297
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
298
+ throw invalidArgument("execute", "options", "object", typeof options, receiver);
299
+ }
300
+ if (options.originKey !== undefined &&
301
+ typeof options.originKey !== "string") {
302
+ throw invalidArgument("execute", "options.originKey", "string", typeof options.originKey, receiver);
303
+ }
304
+ if (options.idempotencyKey !== undefined &&
305
+ typeof options.idempotencyKey !== "string") {
306
+ throw invalidArgument("execute", "options.idempotencyKey", "string", typeof options.idempotencyKey, receiver);
307
+ }
308
+ }
309
+ function assertSqlArgs(operation, receiver, sql, params) {
310
+ if (typeof sql !== "string") {
311
+ throw invalidArgument(operation, "sql", "string", typeof sql, receiver);
312
+ }
313
+ if (!Array.isArray(params)) {
314
+ throw invalidArgument(operation, "params", "array", typeof params, receiver);
315
+ }
316
+ }
317
+ function normalizeBatchStatements(statements, options) {
318
+ if (!Array.isArray(statements)) {
319
+ throw invalidArgument("executeBatch", "statements", "array", typeof statements);
320
+ }
321
+ if (statements.length === 0) {
322
+ throw invalidArgument("executeBatch", "statements", "non-empty array", "empty array");
323
+ }
324
+ assertBatchOptions(options);
325
+ return statements.map((statement, statementIndex) => {
326
+ try {
327
+ if (!statement ||
328
+ typeof statement !== "object" ||
329
+ Array.isArray(statement)) {
330
+ throw invalidArgument("executeBatch", `statements[${statementIndex}]`, "object", Array.isArray(statement) ? "array" : typeof statement);
331
+ }
332
+ if (typeof statement.sql !== "string") {
333
+ throw invalidArgument("executeBatch", `statements[${statementIndex}].sql`, "string", typeof statement.sql);
334
+ }
335
+ const params = statement.params ?? [];
336
+ if (!Array.isArray(params)) {
337
+ throw invalidArgument("executeBatch", `statements[${statementIndex}].params`, "array", typeof params);
338
+ }
339
+ return {
340
+ sql: statement.sql,
341
+ params: params.map((param, parameterIndex) => toNativeValue(normalizeParam(param, parameterIndex))),
342
+ };
343
+ }
344
+ catch (error) {
345
+ throw withBatchStatementIndex(error, statementIndex);
346
+ }
347
+ });
348
+ }
349
+ function assertBatchOptions(options) {
350
+ if (options === undefined)
351
+ return;
352
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
353
+ throw invalidArgument("executeBatch", "options", "object", typeof options);
354
+ }
355
+ if (options.originKey !== undefined &&
356
+ typeof options.originKey !== "string") {
357
+ throw invalidArgument("executeBatch", "options.originKey", "string", typeof options.originKey);
358
+ }
359
+ if (options.idempotencyKey !== undefined &&
360
+ typeof options.idempotencyKey !== "string") {
361
+ throw invalidArgument("executeBatch", "options.idempotencyKey", "string", typeof options.idempotencyKey);
362
+ }
363
+ }
364
+ function withBatchStatementIndex(error, statementIndex) {
365
+ if (!error || typeof error !== "object")
366
+ return error;
367
+ const lixError = error;
368
+ const details = lixError.details;
369
+ lixError.details = {
370
+ ...(details && typeof details === "object" && !Array.isArray(details)
371
+ ? details
372
+ : details === undefined
373
+ ? {}
374
+ : { cause: details }),
375
+ statementIndex,
376
+ };
377
+ return error;
378
+ }
@@ -0,0 +1,26 @@
1
+ import type { LixSnapshotStorage } from "./types.js";
2
+ /** The subset of the browser Storage API used by {@link LocalStorage}. */
3
+ export type WebStorageLike = Pick<Storage, "getItem" | "setItem">;
4
+ export type LocalStorageOptions = {
5
+ /**
6
+ * Storage implementation to wrap. Defaults to `globalThis.localStorage`.
7
+ * Supplying this is useful for non-browser hosts and tests.
8
+ */
9
+ storage?: WebStorageLike;
10
+ /** Prefix used to isolate Lix snapshots from other application records. */
11
+ prefix?: string;
12
+ };
13
+ /**
14
+ * Persists opaque Lix snapshots in the browser's localStorage.
15
+ *
16
+ * Import this adapter from `@lix-js/sdk/local-storage-adapter`. Keeping it in
17
+ * a separate entrypoint avoids referencing browser storage in applications
18
+ * that do not use it.
19
+ */
20
+ export declare class LocalStorage implements LixSnapshotStorage {
21
+ #private;
22
+ constructor(options?: LocalStorageOptions);
23
+ load(namespace: string): Promise<Uint8Array | undefined>;
24
+ save(namespace: string, snapshot: Uint8Array): Promise<void>;
25
+ }
26
+ export type { LixSnapshotStorage } from "./types.js";
@@ -0,0 +1,117 @@
1
+ const SNAPSHOT_FORMAT = "lix-snapshot";
2
+ const SNAPSHOT_VERSION = 1;
3
+ const DEFAULT_PREFIX = "@lix-js/sdk/snapshot/v1";
4
+ /**
5
+ * Persists opaque Lix snapshots in the browser's localStorage.
6
+ *
7
+ * Import this adapter from `@lix-js/sdk/local-storage-adapter`. Keeping it in
8
+ * a separate entrypoint avoids referencing browser storage in applications
9
+ * that do not use it.
10
+ */
11
+ export class LocalStorage {
12
+ #storage;
13
+ #prefix;
14
+ constructor(options = {}) {
15
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
16
+ throw new TypeError("LocalStorage options must be an object");
17
+ }
18
+ if (options.prefix !== undefined &&
19
+ (typeof options.prefix !== "string" || options.prefix.length === 0)) {
20
+ throw new TypeError("LocalStorage prefix must be a non-empty string");
21
+ }
22
+ const storage = options.storage ?? defaultLocalStorage();
23
+ if (!storage ||
24
+ typeof storage.getItem !== "function" ||
25
+ typeof storage.setItem !== "function") {
26
+ throw new TypeError("LocalStorage storage must implement getItem() and setItem()");
27
+ }
28
+ this.#storage = storage;
29
+ this.#prefix = options.prefix ?? DEFAULT_PREFIX;
30
+ }
31
+ async load(namespace) {
32
+ const key = this.#key(namespace);
33
+ const stored = this.#storage.getItem(key);
34
+ if (stored === null)
35
+ return undefined;
36
+ let value;
37
+ try {
38
+ value = JSON.parse(stored);
39
+ }
40
+ catch (error) {
41
+ throw invalidSnapshot(key, "record is not valid JSON", error);
42
+ }
43
+ if (!isSnapshotEnvelope(value)) {
44
+ throw invalidSnapshot(key, "record has an unsupported format or version");
45
+ }
46
+ try {
47
+ return base64ToBytes(value.data);
48
+ }
49
+ catch (error) {
50
+ throw invalidSnapshot(key, "record contains invalid base64", error);
51
+ }
52
+ }
53
+ async save(namespace, snapshot) {
54
+ const key = this.#key(namespace);
55
+ if (!(snapshot instanceof Uint8Array)) {
56
+ throw new TypeError("LocalStorage snapshot must be a Uint8Array");
57
+ }
58
+ const envelope = {
59
+ format: SNAPSHOT_FORMAT,
60
+ version: SNAPSHOT_VERSION,
61
+ data: bytesToBase64(snapshot),
62
+ };
63
+ this.#storage.setItem(key, JSON.stringify(envelope));
64
+ }
65
+ #key(namespace) {
66
+ if (typeof namespace !== "string" || namespace.length === 0) {
67
+ throw new TypeError("LocalStorage snapshot namespace must be a non-empty string");
68
+ }
69
+ return `${this.#prefix}:${encodeURIComponent(namespace)}`;
70
+ }
71
+ }
72
+ function defaultLocalStorage() {
73
+ const storage = globalThis.localStorage;
74
+ if (storage === undefined) {
75
+ throw new Error("LocalStorage requires browser localStorage or an explicit storage option");
76
+ }
77
+ return storage;
78
+ }
79
+ function isSnapshotEnvelope(value) {
80
+ if (!value || typeof value !== "object" || Array.isArray(value))
81
+ return false;
82
+ const envelope = value;
83
+ return (envelope.format === SNAPSHOT_FORMAT &&
84
+ envelope.version === SNAPSHOT_VERSION &&
85
+ typeof envelope.data === "string");
86
+ }
87
+ function bytesToBase64(bytes) {
88
+ let binary = "";
89
+ const chunkSize = 0x8000;
90
+ for (let offset = 0; offset < bytes.length; offset += chunkSize) {
91
+ binary += String.fromCharCode(...bytes.subarray(offset, offset + chunkSize));
92
+ }
93
+ return btoa(binary);
94
+ }
95
+ function base64ToBytes(base64) {
96
+ if (!isCanonicalBase64(base64)) {
97
+ throw new Error("invalid base64");
98
+ }
99
+ const binary = atob(base64);
100
+ const bytes = new Uint8Array(binary.length);
101
+ for (let index = 0; index < binary.length; index += 1) {
102
+ bytes[index] = binary.charCodeAt(index);
103
+ }
104
+ return bytes;
105
+ }
106
+ function isCanonicalBase64(value) {
107
+ if (value.length === 0)
108
+ return true;
109
+ if (value.length % 4 !== 0)
110
+ return false;
111
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value);
112
+ }
113
+ function invalidSnapshot(key, reason, cause) {
114
+ return new Error(`Invalid Lix snapshot in localStorage key '${key}': ${reason}`, {
115
+ cause,
116
+ });
117
+ }
@@ -1,5 +1,6 @@
1
- import { LixWorkerClient } from "./worker/client.js";
2
- import type { CreateBranchOptions, CreateBranchReceipt, ExecuteOptions, ExecuteResult, LocalFilesystemOptions, MergeBranchOptions, MergeBranchPreview, MergeBranchReceipt, ObserveEvent, OpenLixOptions, SqlParam, SQLiteOptions, SwitchBranchOptions, SwitchBranchReceipt } from "./types.js";
1
+ import { Lix } from "./lix.js";
2
+ import type { LocalFilesystemOptions, OpenLixOptions, SQLiteOptions } from "./types.js";
3
+ export { Lix, LixTransaction, ObserveEvents } from "./lix.js";
3
4
  export declare class SQLite {
4
5
  readonly path: string;
5
6
  constructor(options: SQLiteOptions);
@@ -14,35 +15,3 @@ export declare class LocalFilesystem {
14
15
  private client;
15
16
  }
16
17
  export declare function openLix(options?: OpenLixOptions): Promise<Lix>;
17
- export declare class Lix {
18
- private readonly client;
19
- private closePromise;
20
- constructor(client: LixWorkerClient);
21
- execute(sql: string, params?: SqlParam[], options?: ExecuteOptions): Promise<ExecuteResult>;
22
- observe(sql: string, params?: SqlParam[]): ObserveEvents;
23
- beginTransaction(): Promise<LixTransaction>;
24
- activeBranchId(): Promise<string>;
25
- createBranch(options: CreateBranchOptions): Promise<CreateBranchReceipt>;
26
- switchBranch(options: SwitchBranchOptions): Promise<SwitchBranchReceipt>;
27
- mergeBranchPreview(options: MergeBranchOptions): Promise<MergeBranchPreview>;
28
- mergeBranch(options: MergeBranchOptions): Promise<MergeBranchReceipt>;
29
- close(): Promise<void>;
30
- }
31
- export declare class ObserveEvents {
32
- private readonly client;
33
- private readonly setup;
34
- private closed;
35
- private readonly observeId;
36
- constructor(client: LixWorkerClient, observeId: Promise<number>);
37
- next(): Promise<ObserveEvent | undefined>;
38
- close(): void;
39
- }
40
- export declare class LixTransaction {
41
- private readonly client;
42
- private readonly transactionId;
43
- constructor(client: LixWorkerClient, transactionId: number);
44
- execute(sql: string, params?: SqlParam[], options?: ExecuteOptions): Promise<ExecuteResult>;
45
- commit(): Promise<void>;
46
- rollback(): Promise<void>;
47
- private finish;
48
- }