@syncular/client 0.1.2 → 0.2.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 +227 -709
- package/dist/apply.d.ts +80 -0
- package/dist/apply.js +301 -0
- package/dist/blob.d.ts +127 -0
- package/dist/blob.js +201 -0
- package/dist/bun-database.d.ts +22 -0
- package/dist/bun-database.js +61 -0
- package/dist/client.d.ts +320 -69
- package/dist/client.js +1627 -163
- package/dist/content-type.d.ts +2 -0
- package/dist/content-type.js +2 -0
- package/dist/database.d.ts +35 -80
- package/dist/database.js +32 -947
- package/dist/encryption.d.ts +47 -0
- package/dist/encryption.js +75 -0
- package/dist/errors.d.ts +8 -22
- package/dist/errors.js +10 -207
- package/dist/http.d.ts +32 -0
- package/dist/http.js +196 -0
- package/dist/index.d.ts +28 -16
- package/dist/index.js +25 -12
- package/dist/invalidation.d.ts +69 -0
- package/dist/invalidation.js +84 -0
- package/dist/leader-lock.d.ts +28 -0
- package/dist/leader-lock.js +38 -0
- package/dist/multi-tab.d.ts +134 -0
- package/dist/multi-tab.js +399 -0
- package/dist/node-database.d.ts +41 -0
- package/dist/node-database.js +133 -0
- package/dist/outbox.d.ts +56 -0
- package/dist/outbox.js +140 -0
- package/dist/schema.d.ts +107 -0
- package/dist/schema.js +267 -0
- package/dist/state.d.ts +40 -0
- package/dist/state.js +77 -0
- package/dist/transport.d.ts +44 -0
- package/dist/transport.js +7 -0
- package/dist/wasm-database.d.ts +30 -0
- package/dist/wasm-database.js +170 -0
- package/dist/window.d.ts +64 -0
- package/dist/window.js +0 -0
- package/dist/worker-entry.d.ts +16 -2
- package/dist/worker-entry.js +300 -456
- package/dist/worker-host.d.ts +174 -0
- package/dist/worker-host.js +536 -0
- package/dist/worker-protocol.d.ts +173 -61
- package/dist/worker-protocol.js +7 -16
- package/package.json +45 -112
- package/src/apply.ts +435 -0
- package/src/blob.ts +333 -0
- package/src/bun-database.ts +75 -0
- package/src/client.ts +2247 -277
- package/src/content-type.ts +2 -0
- package/src/database.ts +63 -1389
- package/src/encryption.ts +123 -0
- package/src/errors.ts +11 -265
- package/src/http.ts +254 -0
- package/src/index.ts +25 -20
- package/src/invalidation.ts +128 -0
- package/src/leader-lock.ts +68 -0
- package/src/multi-tab.ts +550 -0
- package/src/node-database.ts +180 -0
- package/src/outbox.ts +206 -0
- package/src/schema.ts +397 -0
- package/src/state.ts +126 -0
- package/src/transport.ts +52 -0
- package/src/wasm-database.ts +279 -0
- package/src/window.ts +0 -0
- package/src/worker-entry.ts +391 -545
- package/src/worker-host.ts +800 -0
- package/src/worker-protocol.ts +204 -99
- package/dist/auth-leases.d.ts +0 -11
- package/dist/auth-leases.d.ts.map +0 -1
- package/dist/auth-leases.js +0 -140
- package/dist/auth-leases.js.map +0 -1
- package/dist/blob-limits.d.ts +0 -15
- package/dist/blob-limits.d.ts.map +0 -1
- package/dist/blob-limits.js +0 -66
- package/dist/blob-limits.js.map +0 -1
- package/dist/bridge-client.d.ts +0 -69
- package/dist/bridge-client.d.ts.map +0 -1
- package/dist/bridge-client.js +0 -282
- package/dist/bridge-client.js.map +0 -1
- package/dist/client-config.d.ts +0 -6
- package/dist/client-config.d.ts.map +0 -1
- package/dist/client-config.js +0 -18
- package/dist/client-config.js.map +0 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js.map +0 -1
- package/dist/command-history.d.ts +0 -35
- package/dist/command-history.d.ts.map +0 -1
- package/dist/command-history.js +0 -378
- package/dist/command-history.js.map +0 -1
- package/dist/console-diagnostics.d.ts +0 -33
- package/dist/console-diagnostics.d.ts.map +0 -1
- package/dist/console-diagnostics.js +0 -496
- package/dist/console-diagnostics.js.map +0 -1
- package/dist/crdt-yjs/index.d.ts +0 -4
- package/dist/crdt-yjs/index.d.ts.map +0 -1
- package/dist/crdt-yjs/index.js +0 -4
- package/dist/crdt-yjs/index.js.map +0 -1
- package/dist/crdt-yjs/webview-host-facade.d.ts +0 -126
- package/dist/crdt-yjs/webview-host-facade.d.ts.map +0 -1
- package/dist/crdt-yjs/webview-host-facade.js +0 -284
- package/dist/crdt-yjs/webview-host-facade.js.map +0 -1
- package/dist/crdt-yjs/yjs-document-field-adapter.d.ts +0 -153
- package/dist/crdt-yjs/yjs-document-field-adapter.d.ts.map +0 -1
- package/dist/crdt-yjs/yjs-document-field-adapter.js +0 -406
- package/dist/crdt-yjs/yjs-document-field-adapter.js.map +0 -1
- package/dist/crdt-yjs/yjs-prosemirror-bridge.d.ts +0 -73
- package/dist/crdt-yjs/yjs-prosemirror-bridge.d.ts.map +0 -1
- package/dist/crdt-yjs/yjs-prosemirror-bridge.js +0 -169
- package/dist/crdt-yjs/yjs-prosemirror-bridge.js.map +0 -1
- package/dist/database.d.ts.map +0 -1
- package/dist/database.js.map +0 -1
- package/dist/diagnostics.d.ts +0 -10
- package/dist/diagnostics.d.ts.map +0 -1
- package/dist/diagnostics.js +0 -83
- package/dist/diagnostics.js.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js.map +0 -1
- package/dist/generated-bridge.d.ts +0 -365
- package/dist/generated-bridge.d.ts.map +0 -1
- package/dist/generated-bridge.js +0 -250
- package/dist/generated-bridge.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mutations.d.ts +0 -72
- package/dist/mutations.d.ts.map +0 -1
- package/dist/mutations.js +0 -63
- package/dist/mutations.js.map +0 -1
- package/dist/network.d.ts +0 -3
- package/dist/network.d.ts.map +0 -1
- package/dist/network.js +0 -17
- package/dist/network.js.map +0 -1
- package/dist/react/index.d.ts +0 -169
- package/dist/react/index.d.ts.map +0 -1
- package/dist/react/index.js +0 -628
- package/dist/react/index.js.map +0 -1
- package/dist/react-native/index.d.ts +0 -35
- package/dist/react-native/index.d.ts.map +0 -1
- package/dist/react-native/index.js +0 -49
- package/dist/react-native/index.js.map +0 -1
- package/dist/runtime-contract.d.ts +0 -13
- package/dist/runtime-contract.d.ts.map +0 -1
- package/dist/runtime-contract.js +0 -24
- package/dist/runtime-contract.js.map +0 -1
- package/dist/rust-client.d.ts +0 -106
- package/dist/rust-client.d.ts.map +0 -1
- package/dist/rust-client.js +0 -938
- package/dist/rust-client.js.map +0 -1
- package/dist/sentry.d.ts +0 -35
- package/dist/sentry.d.ts.map +0 -1
- package/dist/sentry.js +0 -155
- package/dist/sentry.js.map +0 -1
- package/dist/sql-safety.d.ts +0 -3
- package/dist/sql-safety.d.ts.map +0 -1
- package/dist/sql-safety.js +0 -62
- package/dist/sql-safety.js.map +0 -1
- package/dist/syncular-runtime-artifacts.json +0 -61
- package/dist/tauri/index.d.ts +0 -35
- package/dist/tauri/index.d.ts.map +0 -1
- package/dist/tauri/index.js +0 -114
- package/dist/tauri/index.js.map +0 -1
- package/dist/types.d.ts +0 -1096
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/wasm/.syncular-wasm-profile +0 -1
- package/dist/wasm/syncular-runtime-artifact.json +0 -21
- package/dist/wasm/syncular.d.ts +0 -207
- package/dist/wasm/syncular.js +0 -2341
- package/dist/wasm/syncular_bg.wasm +0 -0
- package/dist/wasm/syncular_bg.wasm.d.ts +0 -97
- package/dist/wasm-bindings/runtime-contract.d.ts +0 -22
- package/dist/wasm-bindings/runtime-contract.d.ts.map +0 -1
- package/dist/wasm-bindings/runtime-contract.js +0 -112
- package/dist/wasm-bindings/runtime-contract.js.map +0 -1
- package/dist/wasm-core/.syncular-wasm-profile +0 -1
- package/dist/wasm-core/syncular-runtime-artifact.json +0 -17
- package/dist/wasm-core/syncular.d.ts +0 -162
- package/dist/wasm-core/syncular.js +0 -1847
- package/dist/wasm-core/syncular_bg.wasm +0 -0
- package/dist/wasm-core/syncular_bg.wasm.d.ts +0 -77
- package/dist/wasm-perf/.syncular-wasm-profile +0 -1
- package/dist/wasm-perf/syncular-runtime-artifact.json +0 -21
- package/dist/wasm-perf/syncular.d.ts +0 -207
- package/dist/wasm-perf/syncular.js +0 -2341
- package/dist/wasm-perf/syncular_bg.wasm +0 -0
- package/dist/wasm-perf/syncular_bg.wasm.d.ts +0 -97
- package/dist/wasm-runtime.d.ts +0 -23
- package/dist/wasm-runtime.d.ts.map +0 -1
- package/dist/wasm-runtime.js +0 -69
- package/dist/wasm-runtime.js.map +0 -1
- package/dist/worker-client.d.ts +0 -123
- package/dist/worker-client.d.ts.map +0 -1
- package/dist/worker-client.js +0 -1735
- package/dist/worker-client.js.map +0 -1
- package/dist/worker-entry.d.ts.map +0 -1
- package/dist/worker-entry.js.map +0 -1
- package/dist/worker-protocol.d.ts.map +0 -1
- package/dist/worker-protocol.js.map +0 -1
- package/dist/worker-realtime.d.ts +0 -39
- package/dist/worker-realtime.d.ts.map +0 -1
- package/dist/worker-realtime.js +0 -677
- package/dist/worker-realtime.js.map +0 -1
- package/src/auth-leases.ts +0 -251
- package/src/blob-limits.ts +0 -98
- package/src/bridge-client.ts +0 -512
- package/src/client-config.ts +0 -29
- package/src/command-history.ts +0 -623
- package/src/console-diagnostics.ts +0 -617
- package/src/crdt-yjs/index.ts +0 -3
- package/src/crdt-yjs/webview-host-facade.ts +0 -477
- package/src/crdt-yjs/yjs-document-field-adapter.ts +0 -733
- package/src/crdt-yjs/yjs-prosemirror-bridge.ts +0 -272
- package/src/diagnostics.ts +0 -116
- package/src/generated-bridge.ts +0 -741
- package/src/mutations.ts +0 -168
- package/src/network.ts +0 -32
- package/src/react/index.ts +0 -1036
- package/src/react-native/index.ts +0 -152
- package/src/runtime-contract.ts +0 -48
- package/src/rust-client.ts +0 -1491
- package/src/sentry.ts +0 -215
- package/src/sql-safety.ts +0 -61
- package/src/tauri/index.ts +0 -211
- package/src/types.ts +0 -1397
- package/src/wasm-bindings/generated-wasm-bindings.d.ts +0 -70
- package/src/wasm-bindings/runtime-contract.ts +0 -158
- package/src/wasm-runtime.ts +0 -145
- package/src/worker-client.ts +0 -2289
- package/src/worker-realtime.ts +0 -843
|
@@ -1,64 +1,176 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
/**
|
|
2
|
+
* The worker RPC protocol (Direction decision 2, 2026-07-03): the whole
|
|
3
|
+
* client core runs in a Web Worker; the UI thread talks to it through
|
|
4
|
+
* this thin, multiplexed postMessage protocol. Exactly SIX message types
|
|
5
|
+
* (`init`, `call`, `ready`, `result`, `error`, `event`) — every logical
|
|
6
|
+
* API method multiplexes over `call`, every notification over `event`.
|
|
7
|
+
*
|
|
8
|
+
* Both sides derive their typing from ONE shared shape: `WorkerApi`.
|
|
9
|
+
* The worker implements it (`worker-entry.ts`); the handle projects it
|
|
10
|
+
* to promises (`worker-host.ts`). Everything crossing the boundary is
|
|
11
|
+
* structured-clone data — no functions, no class instances.
|
|
12
|
+
*
|
|
13
|
+
* Scheduling note (SPEC §8.4): the sync-needed signal is host-driven,
|
|
14
|
+
* and in worker mode the HOST LOOP LIVES IN THE WORKER — wake-ups
|
|
15
|
+
* coalesce into jittered `syncUntilIdle` rounds there (`autoSync`),
|
|
16
|
+
* so the UI thread never has to react to keep data flowing. Events are
|
|
17
|
+
* still forwarded to the handle for visibility.
|
|
18
|
+
*/
|
|
19
|
+
import type { WakeReason } from '@syncular/core';
|
|
20
|
+
import type { BlobRef, CachedBlob } from './blob.js';
|
|
21
|
+
import type { ConflictRecord, LeaseState, MutationInput, PresencePeer, RejectionRecord, SchemaFloor, SubscribeInput, SyncClientLimits, SyncSummary, WindowState } from './client.js';
|
|
22
|
+
import type { SqlRow, SqlValue } from './database.js';
|
|
23
|
+
import type { InvalidationEvent } from './invalidation.js';
|
|
24
|
+
import type { OutboxCommit } from './outbox.js';
|
|
25
|
+
import type { ClientSchema } from './schema.js';
|
|
26
|
+
import type { SubscriptionRecord } from './state.js';
|
|
27
|
+
import type { WindowBase } from './window.js';
|
|
28
|
+
/** The handle exists but this tab lost the leader election (TODO 3.2). */
|
|
29
|
+
export declare const NOT_LEADER_CODE = "client.not_leader";
|
|
30
|
+
/** The worker (or its RPC channel) failed outside protocol semantics. */
|
|
31
|
+
export declare const WORKER_FAILED_CODE = "client.worker_failed";
|
|
32
|
+
export type WorkerDatabaseInit = {
|
|
33
|
+
/** THE persistent mode: opfs-sahpool, named database. */
|
|
34
|
+
readonly mode: 'persistent';
|
|
35
|
+
readonly name: string;
|
|
36
|
+
/** Optional pool directory override (default `.syncular/<name>`). */
|
|
37
|
+
readonly directory?: string;
|
|
38
|
+
} | {
|
|
39
|
+
/**
|
|
40
|
+
* Bootstrap-provided database (tests inject bun:sqlite here). The
|
|
41
|
+
* worker entry MUST have an `openDatabase` override or init fails.
|
|
42
|
+
*/
|
|
43
|
+
readonly mode: 'custom';
|
|
44
|
+
readonly options?: unknown;
|
|
45
|
+
};
|
|
46
|
+
export interface WorkerEndpoints {
|
|
47
|
+
/** POST target for SSP2 sync rounds (§1.1). */
|
|
48
|
+
readonly syncUrl: string;
|
|
49
|
+
/** Segment download base URL; omit when segments are not served. */
|
|
50
|
+
readonly segmentsUrl?: string;
|
|
51
|
+
/** Blob upload/download base URL (§5.9); omit when blobs are unused. */
|
|
52
|
+
readonly blobsUrl?: string;
|
|
53
|
+
/**
|
|
54
|
+
* WebSocket URL for §8 realtime. The literal placeholder `{clientId}`
|
|
55
|
+
* is substituted with the (possibly persisted) client id after start.
|
|
56
|
+
*/
|
|
57
|
+
readonly realtimeUrl?: string;
|
|
13
58
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
59
|
+
export interface WorkerInitConfig {
|
|
60
|
+
readonly schema: ClientSchema;
|
|
61
|
+
readonly database: WorkerDatabaseInit;
|
|
62
|
+
readonly endpoints: WorkerEndpoints;
|
|
63
|
+
readonly clientId?: string;
|
|
64
|
+
readonly limits?: SyncClientLimits;
|
|
65
|
+
/**
|
|
66
|
+
* Worker-side host loop (§8.4): coalesce wake-ups into jittered
|
|
67
|
+
* `syncUntilIdle` rounds inside the worker. Default true.
|
|
68
|
+
*/
|
|
69
|
+
readonly autoSync?: boolean;
|
|
70
|
+
/** Max jitter before a coalesced auto-sync round (default 200 ms). */
|
|
71
|
+
readonly wakeJitterMs?: number;
|
|
24
72
|
}
|
|
25
|
-
|
|
26
|
-
|
|
73
|
+
/** Successful init reply. */
|
|
74
|
+
export interface WorkerInitResult {
|
|
75
|
+
readonly clientId: string;
|
|
27
76
|
}
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
export interface WorkerApi {
|
|
78
|
+
subscribe(input: SubscribeInput): void;
|
|
79
|
+
unsubscribe(id: string): void;
|
|
80
|
+
/** §4.8 windowed subscriptions: set the live units for a window base. */
|
|
81
|
+
setWindow(base: WindowBase, units: readonly string[]): Promise<void>;
|
|
82
|
+
/** §4.8 completeness oracle (I3): the windowed-in units for a base. */
|
|
83
|
+
windowState(base: WindowBase): WindowState;
|
|
84
|
+
mutate(mutations: readonly MutationInput[]): string;
|
|
85
|
+
sync(): Promise<SyncSummary>;
|
|
86
|
+
syncUntilIdle(maxRounds?: number): Promise<SyncSummary>;
|
|
87
|
+
query(sql: string, params?: readonly SqlValue[]): SqlRow[];
|
|
88
|
+
conflicts(): readonly ConflictRecord[];
|
|
89
|
+
rejections(): readonly RejectionRecord[];
|
|
90
|
+
schemaFloor(): SchemaFloor | undefined;
|
|
91
|
+
/** §7.3.5: the opaque auth-lease state, or undefined. */
|
|
92
|
+
leaseState(): LeaseState | undefined;
|
|
93
|
+
/** §7.4.5: true while a schema-bump reset + first re-bootstrap runs. */
|
|
94
|
+
upgrading(): boolean;
|
|
95
|
+
syncNeeded(): boolean;
|
|
96
|
+
pendingCommits(): OutboxCommit[];
|
|
97
|
+
subscriptions(): SubscriptionRecord[];
|
|
98
|
+
subscription(id: string): SubscriptionRecord | undefined;
|
|
99
|
+
connectRealtime(): Promise<void>;
|
|
100
|
+
disconnectRealtime(): void;
|
|
101
|
+
/** §8.6 presence: publish/clear a scope-keyed presence document. */
|
|
102
|
+
setPresence(scopeKey: string, doc: Record<string, unknown> | null): void;
|
|
103
|
+
/** §8.6 presence: the peers currently present on a scope key. */
|
|
104
|
+
presence(scopeKey: string): readonly PresencePeer[];
|
|
105
|
+
/** §5.9 blobs: stage bytes (returns the canonical ref) / resolve bytes. */
|
|
106
|
+
uploadBlob(bytes: Uint8Array, options?: {
|
|
107
|
+
readonly mediaType?: string;
|
|
108
|
+
readonly name?: string;
|
|
109
|
+
}): Promise<BlobRef>;
|
|
110
|
+
fetchBlob(blobIdOrRef: string): Promise<CachedBlob>;
|
|
111
|
+
/** Sever/restore the transport + realtime (offline simulation, demos). */
|
|
112
|
+
setOffline(offline: boolean): void;
|
|
113
|
+
close(): Promise<void>;
|
|
114
|
+
}
|
|
115
|
+
export type WorkerMethod = keyof WorkerApi;
|
|
116
|
+
/** `call` for method M, with args typed straight off `WorkerApi`. */
|
|
117
|
+
export type WorkerCallMessage = {
|
|
118
|
+
[M in WorkerMethod]: {
|
|
119
|
+
readonly t: 'call';
|
|
120
|
+
readonly id: number;
|
|
121
|
+
readonly method: M;
|
|
122
|
+
readonly args: Parameters<WorkerApi[M]>;
|
|
123
|
+
};
|
|
124
|
+
}[WorkerMethod];
|
|
125
|
+
export type MainToWorkerMessage = {
|
|
126
|
+
readonly t: 'init';
|
|
127
|
+
readonly id: number;
|
|
128
|
+
readonly config: WorkerInitConfig;
|
|
129
|
+
} | WorkerCallMessage;
|
|
130
|
+
export interface WorkerErrorShape {
|
|
131
|
+
readonly code: string;
|
|
132
|
+
readonly message: string;
|
|
133
|
+
readonly retryable: boolean;
|
|
134
|
+
}
|
|
135
|
+
export type SyncWorkerEvent = {
|
|
136
|
+
readonly kind: 'sync-needed';
|
|
137
|
+
readonly reason: 'hello' | WakeReason;
|
|
138
|
+
} | {
|
|
139
|
+
readonly kind: 'conflict';
|
|
140
|
+
readonly conflict: ConflictRecord;
|
|
141
|
+
} | {
|
|
142
|
+
/** An autoSync round finished (or failed) inside the worker. */
|
|
143
|
+
readonly kind: 'synced';
|
|
144
|
+
readonly summary?: SyncSummary;
|
|
145
|
+
readonly error?: WorkerErrorShape;
|
|
146
|
+
} | {
|
|
147
|
+
/** §7.4.5: the schema-bump `upgrading` state changed in the worker. */
|
|
148
|
+
readonly kind: 'upgrading';
|
|
149
|
+
readonly upgrading: boolean;
|
|
150
|
+
} | {
|
|
151
|
+
/** §8.6: presence on a scope key changed inside the worker. */
|
|
152
|
+
readonly kind: 'presence';
|
|
153
|
+
readonly scopeKey: string;
|
|
154
|
+
} | {
|
|
155
|
+
/**
|
|
156
|
+
* TODO 3.1 / I1: one coalesced apply-batch invalidation. `Set`s
|
|
157
|
+
* structured-clone across the worker boundary, so the event crosses
|
|
158
|
+
* verbatim — the handle re-emits it to `onInvalidate` listeners.
|
|
159
|
+
*/
|
|
160
|
+
readonly kind: 'invalidate';
|
|
161
|
+
readonly event: InvalidationEvent;
|
|
162
|
+
};
|
|
163
|
+
export type WorkerToMainMessage = {
|
|
164
|
+
readonly t: 'ready';
|
|
165
|
+
} | {
|
|
166
|
+
readonly t: 'result';
|
|
167
|
+
readonly id: number;
|
|
168
|
+
readonly value: unknown;
|
|
169
|
+
} | {
|
|
170
|
+
readonly t: 'error';
|
|
171
|
+
readonly id: number;
|
|
172
|
+
readonly error: WorkerErrorShape;
|
|
173
|
+
} | {
|
|
174
|
+
readonly t: 'event';
|
|
175
|
+
readonly event: SyncWorkerEvent;
|
|
176
|
+
};
|
package/dist/worker-protocol.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
category: definition.category,
|
|
9
|
-
retryable: definition.retryable,
|
|
10
|
-
recommendedAction: definition.recommendedAction,
|
|
11
|
-
...(options.name ? { name: options.name } : {}),
|
|
12
|
-
...(options.stack ? { stack: options.stack } : {}),
|
|
13
|
-
...(options.details !== undefined ? { details: options.details } : {}),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=worker-protocol.js.map
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Client-local error codes (never wire codes; §10 stays server-owned)
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
/** The handle exists but this tab lost the leader election (TODO 3.2). */
|
|
5
|
+
export const NOT_LEADER_CODE = 'client.not_leader';
|
|
6
|
+
/** The worker (or its RPC channel) failed outside protocol semantics. */
|
|
7
|
+
export const WORKER_FAILED_CODE = 'client.worker_failed';
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Syncular
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Syncular TypeScript client core — offline-first sync over SQLite (WASM/OPFS, Bun, Node)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
7
7
|
"homepage": "https://syncular.dev",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "https://github.com/syncular/syncular.git",
|
|
11
|
-
"directory": "packages/client"
|
|
11
|
+
"directory": "packages/web-client"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/syncular/syncular/issues"
|
|
@@ -16,18 +16,15 @@
|
|
|
16
16
|
"keywords": [
|
|
17
17
|
"sync",
|
|
18
18
|
"offline-first",
|
|
19
|
+
"realtime",
|
|
19
20
|
"database",
|
|
20
|
-
"typescript"
|
|
21
|
-
"rust",
|
|
22
|
-
"wasm",
|
|
23
|
-
"sqlite",
|
|
24
|
-
"kysely"
|
|
21
|
+
"typescript"
|
|
25
22
|
],
|
|
26
|
-
"
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
27
25
|
"publishConfig": {
|
|
28
26
|
"access": "public"
|
|
29
27
|
},
|
|
30
|
-
"type": "module",
|
|
31
28
|
"exports": {
|
|
32
29
|
".": {
|
|
33
30
|
"bun": "./src/index.ts",
|
|
@@ -37,130 +34,66 @@
|
|
|
37
34
|
"default": "./dist/index.js"
|
|
38
35
|
}
|
|
39
36
|
},
|
|
40
|
-
"./
|
|
41
|
-
"bun": "./src/
|
|
42
|
-
"browser": "./src/
|
|
43
|
-
"import": {
|
|
44
|
-
"types": "./dist/worker-entry.d.ts",
|
|
45
|
-
"default": "./dist/worker-entry.js"
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"./sentry": {
|
|
49
|
-
"bun": "./src/sentry.ts",
|
|
50
|
-
"browser": "./src/sentry.ts",
|
|
37
|
+
"./bun": {
|
|
38
|
+
"bun": "./src/bun-database.ts",
|
|
39
|
+
"browser": "./src/bun-database.ts",
|
|
51
40
|
"import": {
|
|
52
|
-
"types": "./dist/
|
|
53
|
-
"default": "./dist/
|
|
41
|
+
"types": "./dist/bun-database.d.ts",
|
|
42
|
+
"default": "./dist/bun-database.js"
|
|
54
43
|
}
|
|
55
44
|
},
|
|
56
|
-
"./
|
|
57
|
-
"bun": "./src/
|
|
58
|
-
"browser": "./src/
|
|
45
|
+
"./node": {
|
|
46
|
+
"bun": "./src/node-database.ts",
|
|
47
|
+
"browser": "./src/node-database.ts",
|
|
59
48
|
"import": {
|
|
60
|
-
"types": "./dist/
|
|
61
|
-
"default": "./dist/
|
|
49
|
+
"types": "./dist/node-database.d.ts",
|
|
50
|
+
"default": "./dist/node-database.js"
|
|
62
51
|
}
|
|
63
52
|
},
|
|
64
|
-
"./
|
|
65
|
-
"bun": "./src/
|
|
53
|
+
"./wasm": {
|
|
54
|
+
"bun": "./src/wasm-database.ts",
|
|
55
|
+
"browser": "./src/wasm-database.ts",
|
|
66
56
|
"import": {
|
|
67
|
-
"types": "./dist/
|
|
68
|
-
"default": "./dist/
|
|
57
|
+
"types": "./dist/wasm-database.d.ts",
|
|
58
|
+
"default": "./dist/wasm-database.js"
|
|
69
59
|
}
|
|
70
60
|
},
|
|
71
|
-
"./
|
|
72
|
-
"bun": "./src/
|
|
73
|
-
"
|
|
74
|
-
"types": "./dist/react-native/index.d.ts",
|
|
75
|
-
"default": "./dist/react-native/index.js"
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"./crdt-yjs": {
|
|
79
|
-
"bun": "./src/crdt-yjs/index.ts",
|
|
80
|
-
"browser": "./src/crdt-yjs/index.ts",
|
|
61
|
+
"./worker": {
|
|
62
|
+
"bun": "./src/worker-entry.ts",
|
|
63
|
+
"browser": "./src/worker-entry.ts",
|
|
81
64
|
"import": {
|
|
82
|
-
"types": "./dist/
|
|
83
|
-
"default": "./dist/
|
|
65
|
+
"types": "./dist/worker-entry.d.ts",
|
|
66
|
+
"default": "./dist/worker-entry.js"
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
},
|
|
87
|
-
"scripts": {
|
|
88
|
-
"generate:bridge": "bun scripts/generate-bridge.ts",
|
|
89
|
-
"generate:wasm-types": "bun scripts/generate-wasm-bindings.ts",
|
|
90
|
-
"test": "bun test src/*.test.ts src/react/*.test.ts src/tauri/*.test.ts src/react-native/*.test.ts src/crdt-yjs/*.test.ts",
|
|
91
|
-
"test:wasm:auth": "bun run build:wasm:dev && bun test src/__tests__/auth-hono.wasm.test.ts",
|
|
92
|
-
"test:wasm:hono": "bun run build:wasm:dev && bun test src/__tests__/*-hono.wasm.test.ts",
|
|
93
|
-
"test:wasm:variants": "bun run build:wasm:core && bun test src/__tests__/variant-core.wasm.test.ts",
|
|
94
|
-
"tsgo": "tsgo --noEmit",
|
|
95
|
-
"build:wasm": "bun scripts/build-syncular-wasm.ts --variant full && bun run generate:wasm-types && bun scripts/size-syncular-wasm.ts --check --report ../../.context/wasm-size/syncular-wasm-size.txt",
|
|
96
|
-
"build:wasm:perf": "bun scripts/build-syncular-wasm.ts --out-dir dist/wasm-perf --variant full-perf --artifact-name full-perf --release-opt-level 3",
|
|
97
|
-
"build:wasm:core": "bun scripts/build-syncular-wasm.ts --out-dir dist/wasm-core --features web-owned-sqlite-core --variant core",
|
|
98
|
-
"build:wasm:variants": "bun run build:wasm && bun run build:wasm:perf && bun run build:wasm:core && bun run catalog:wasm && bun run size:wasm:core && bun run size:wasm:perf",
|
|
99
|
-
"build:wasm:dev": "bun scripts/build-syncular-wasm.ts --dev && bun run generate:wasm-types",
|
|
100
|
-
"catalog:wasm": "bun scripts/write-syncular-wasm-catalog.ts --artifact dist/wasm-core --artifact dist/wasm --artifact dist/wasm-perf",
|
|
101
|
-
"size:wasm": "bun scripts/size-syncular-wasm.ts",
|
|
102
|
-
"size:wasm:check": "bun scripts/size-syncular-wasm.ts --check --attribution --report ../../.context/wasm-size/syncular-wasm-size.txt",
|
|
103
|
-
"size:wasm:core": "bun scripts/size-syncular-wasm.ts --wasm dist/wasm-core/syncular_bg.wasm --report ../../.context/wasm-size/syncular-wasm-core-size.txt",
|
|
104
|
-
"size:wasm:perf": "bun scripts/size-syncular-wasm.ts --wasm dist/wasm-perf/syncular_bg.wasm --report ../../.context/wasm-size/syncular-wasm-perf-size.txt",
|
|
105
|
-
"build": "bun run build:wasm:variants && tsgo",
|
|
106
|
-
"release": "syncular-publish"
|
|
107
|
-
},
|
|
108
|
-
"dependencies": {
|
|
109
|
-
"@syncular/core": "0.1.1",
|
|
110
|
-
"kysely": "^0.28.0",
|
|
111
|
-
"kysely-generic-sqlite": "^1.2.1"
|
|
112
|
-
},
|
|
113
|
-
"devDependencies": {
|
|
114
|
-
"@happy-dom/global-registrator": "^20.8.9",
|
|
115
|
-
"@sentry/react": "^10.47.0",
|
|
116
|
-
"@syncular/config": "0.0.0",
|
|
117
|
-
"@testing-library/react": "^16.3.2",
|
|
118
|
-
"@types/react": "^19.2.14",
|
|
119
|
-
"hono": "^4.12.15",
|
|
120
|
-
"react": "*",
|
|
121
|
-
"yjs": "^13.6.30"
|
|
122
|
-
},
|
|
123
70
|
"files": [
|
|
124
|
-
"dist
|
|
125
|
-
"dist/*.d.ts.map",
|
|
126
|
-
"dist/*.js",
|
|
127
|
-
"dist/*.js.map",
|
|
128
|
-
"dist/crdt-yjs",
|
|
129
|
-
"dist/react",
|
|
130
|
-
"dist/react-native",
|
|
131
|
-
"dist/syncular-runtime-artifacts.json",
|
|
132
|
-
"dist/tauri",
|
|
133
|
-
"dist/wasm",
|
|
134
|
-
"dist/wasm-bindings",
|
|
135
|
-
"dist/wasm-core",
|
|
136
|
-
"dist/wasm-perf",
|
|
71
|
+
"dist",
|
|
137
72
|
"src",
|
|
73
|
+
"README.md",
|
|
138
74
|
"!src/**/*.test.ts",
|
|
139
75
|
"!src/**/*.test.tsx",
|
|
140
|
-
"!
|
|
141
|
-
"!dist/**/*.test
|
|
142
|
-
"!dist/**/__tests__/**",
|
|
143
|
-
"!test/**",
|
|
144
|
-
"!tests/**"
|
|
76
|
+
"!dist/**/*.test.js",
|
|
77
|
+
"!dist/**/*.test.d.ts"
|
|
145
78
|
],
|
|
79
|
+
"scripts": {
|
|
80
|
+
"verify:node": "bun build ./test/node-database/verify-node.mjs --target=node --external better-sqlite3 --outfile=./.verify-node.built.mjs && node ./.verify-node.built.mjs"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@sqlite.org/sqlite-wasm": "^3.53.0-build1",
|
|
84
|
+
"@syncular/core": "0.2.0"
|
|
85
|
+
},
|
|
146
86
|
"peerDependencies": {
|
|
147
|
-
"
|
|
148
|
-
"react": "^18.0.0 || ^19.0.0",
|
|
149
|
-
"react-native": "*",
|
|
150
|
-
"yjs": "^13.6.30"
|
|
87
|
+
"better-sqlite3": ">=11"
|
|
151
88
|
},
|
|
152
89
|
"peerDependenciesMeta": {
|
|
153
|
-
"
|
|
154
|
-
"optional": true
|
|
155
|
-
},
|
|
156
|
-
"react": {
|
|
157
|
-
"optional": true
|
|
158
|
-
},
|
|
159
|
-
"react-native": {
|
|
160
|
-
"optional": true
|
|
161
|
-
},
|
|
162
|
-
"yjs": {
|
|
90
|
+
"better-sqlite3": {
|
|
163
91
|
"optional": true
|
|
164
92
|
}
|
|
93
|
+
},
|
|
94
|
+
"devDependencies": {
|
|
95
|
+
"@syncular/server": "0.2.0",
|
|
96
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
97
|
+
"better-sqlite3": "^12.11.1"
|
|
165
98
|
}
|
|
166
99
|
}
|