@syncular/client 0.48.0 → 0.49.2
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 +50 -1
- package/dist/availability.d.ts +1 -1
- package/dist/availability.js +1 -1
- package/dist/client.js +18 -3
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +5 -0
- package/dist/leader-lock.d.ts +18 -7
- package/dist/leader-lock.js +40 -22
- package/dist/multi-tab.d.ts +158 -22
- package/dist/multi-tab.js +361 -10
- package/dist/outbox.d.ts +5 -0
- package/dist/outbox.js +11 -3
- package/dist/outcomes.js +6 -2
- package/dist/previous-version.d.ts +3 -1
- package/dist/previous-version.js +24 -5
- package/dist/reactive-store.js +2 -1
- package/dist/wasm-database.d.ts +6 -0
- package/dist/wasm-database.js +36 -6
- package/dist/worker-entry.d.ts +17 -1
- package/dist/worker-entry.js +74 -4
- package/dist/worker-host.d.ts +45 -26
- package/dist/worker-host.js +172 -310
- package/dist/worker-protocol.d.ts +22 -0
- package/dist/worker-protocol.js +2 -0
- package/package.json +3 -3
- package/src/availability.ts +3 -2
- package/src/client.ts +26 -3
- package/src/errors.ts +6 -0
- package/src/leader-lock.ts +64 -34
- package/src/multi-tab.ts +576 -34
- package/src/outbox.ts +16 -2
- package/src/outcomes.ts +6 -2
- package/src/previous-version.ts +32 -5
- package/src/reactive-store.ts +2 -1
- package/src/wasm-database.ts +64 -6
- package/src/worker-entry.ts +124 -4
- package/src/worker-host.ts +219 -379
- package/src/worker-protocol.ts +24 -0
package/src/worker-protocol.ts
CHANGED
|
@@ -64,6 +64,12 @@ export const NOT_LEADER_CODE = 'client.not_leader';
|
|
|
64
64
|
export const WORKER_FAILED_CODE = 'client.worker_failed';
|
|
65
65
|
/** A page/worker bundle identity changed and a full host reload is required. */
|
|
66
66
|
export const WORKER_RESTART_REQUIRED_CODE = 'client.worker_restart_required';
|
|
67
|
+
/** SPEC §12: local-authority use without `startSyncWorker({ openLocalAuthority })`. */
|
|
68
|
+
export const LOCAL_AUTHORITY_UNCONFIGURED_CODE =
|
|
69
|
+
'client.local_authority_unconfigured';
|
|
70
|
+
|
|
71
|
+
/** SPEC §12.3 local-authority state. */
|
|
72
|
+
export type LocalAuthorityState = 'local' | 'attaching' | 'attached';
|
|
67
73
|
|
|
68
74
|
// ---------------------------------------------------------------------------
|
|
69
75
|
// Init configuration (structured-clone safe)
|
|
@@ -112,10 +118,22 @@ export interface WorkerInitConfig {
|
|
|
112
118
|
readonly headers?: Readonly<Record<string, string>>;
|
|
113
119
|
/** Portable raw keyring installed inside the worker-owned client core. */
|
|
114
120
|
readonly encryption?: EncryptionKeyringConfig;
|
|
121
|
+
/**
|
|
122
|
+
* This tab took the lock from an unreachable leader: take the storage lock
|
|
123
|
+
* from that leader's worker, which fences its database, and retry the open
|
|
124
|
+
* while its OPFS handles drain.
|
|
125
|
+
*/
|
|
126
|
+
readonly takeOverStorage?: boolean;
|
|
115
127
|
/** Open the worker-owned replica behind the fail-closed security gate. */
|
|
116
128
|
readonly authorityReads?: readonly import('./authority').AuthorityReadDeclaration[];
|
|
117
129
|
readonly securityPreflight?: boolean;
|
|
118
130
|
readonly transportEnabled?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* SPEC §12: sync against a local authority in a sibling file until
|
|
133
|
+
* `attachLocalAuthority` moves its rows to `endpoints.syncUrl`. Requires
|
|
134
|
+
* `startSyncWorker({ openLocalAuthority })`.
|
|
135
|
+
*/
|
|
136
|
+
readonly localAuthority?: boolean;
|
|
119
137
|
readonly clientId?: string;
|
|
120
138
|
readonly limits?: SyncClientLimits;
|
|
121
139
|
readonly retainFailedCommits?: boolean;
|
|
@@ -213,6 +231,12 @@ export interface WorkerApi extends Omit<
|
|
|
213
231
|
setHeaders(headers: Readonly<Record<string, string>>): void;
|
|
214
232
|
/** Sever/restore the transport + realtime (offline simulation, demos). */
|
|
215
233
|
setOffline(offline: boolean): void;
|
|
234
|
+
/** SPEC §12.3 state; `undefined` when init did not enable the local authority. */
|
|
235
|
+
localAuthorityState(): LocalAuthorityState | undefined;
|
|
236
|
+
/** SPEC §12.3: upload the local authority's rows to `endpoints.syncUrl`. */
|
|
237
|
+
attachLocalAuthority(): Promise<void>;
|
|
238
|
+
/** SPEC §12.3: roll back a stopped attach and sync locally again. */
|
|
239
|
+
abandonLocalAuthorityAttach(): Promise<void>;
|
|
216
240
|
close(): Promise<void>;
|
|
217
241
|
}
|
|
218
242
|
|