@evolu/common 8.10.0 → 8.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/dist/src/Config.d.ts +22 -22
- package/dist/src/Config.d.ts.map +1 -1
- package/dist/src/Console.d.ts +62 -7
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +20 -4
- package/dist/src/Crypto.d.ts +76 -4
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +55 -4
- package/dist/src/Error.d.ts +45 -0
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +69 -0
- package/dist/src/Fs.d.ts +92 -18
- package/dist/src/Fs.d.ts.map +1 -1
- package/dist/src/Fs.js +2 -0
- package/dist/src/Identicon.d.ts +2 -2
- package/dist/src/Identicon.js +2 -2
- package/dist/src/LeakDetector.d.ts +22 -3
- package/dist/src/LeakDetector.d.ts.map +1 -1
- package/dist/src/LeakDetector.js +12 -2
- package/dist/src/LockManager.d.ts +8 -0
- package/dist/src/LockManager.d.ts.map +1 -1
- package/dist/src/LockManager.js +6 -0
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +5 -0
- package/dist/src/Platform.d.ts +47 -7
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +24 -5
- package/dist/src/Random.d.ts +25 -2
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Random.js +14 -2
- package/dist/src/Resource.d.ts +156 -1
- package/dist/src/Resource.d.ts.map +1 -1
- package/dist/src/Resource.js +201 -72
- package/dist/src/Schedule.d.ts +11 -10
- package/dist/src/Schedule.d.ts.map +1 -1
- package/dist/src/Schedule.js +1 -1
- package/dist/src/Sqlite.d.ts +132 -16
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +63 -9
- package/dist/src/Task.d.ts +15 -4
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +41 -15
- package/dist/src/Test.d.ts +9 -0
- package/dist/src/Test.d.ts.map +1 -1
- package/dist/src/Test.js +4 -0
- package/dist/src/Time.d.ts +106 -9
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +55 -4
- package/dist/src/Type.d.ts +1455 -1310
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +1274 -517
- package/dist/src/WebSocket.d.ts +164 -13
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +133 -24
- package/dist/src/Worker.d.ts +90 -8
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +28 -2
- package/dist/src/index.d.ts +6 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -3
- package/dist/src/local-first/Db.d.ts +52 -3
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +412 -137
- package/dist/src/local-first/Evolu.d.ts +336 -211
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +102 -15
- package/dist/src/local-first/Owner.d.ts +13 -30
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +13 -30
- package/dist/src/local-first/Protocol.d.ts +94 -16
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +118 -38
- package/dist/src/local-first/Query.d.ts +8 -15
- package/dist/src/local-first/Query.d.ts.map +1 -1
- package/dist/src/local-first/Schema.d.ts +335 -21
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Schema.js +214 -17
- package/dist/src/local-first/Shared.d.ts +537 -22
- package/dist/src/local-first/Shared.d.ts.map +1 -1
- package/dist/src/local-first/Shared.js +1437 -234
- package/dist/src/local-first/Storage.d.ts +192 -14
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/dist/src/local-first/Storage.js +81 -20
- package/dist/src/local-first/Timestamp.d.ts +392 -41
- package/dist/src/local-first/Timestamp.d.ts.map +1 -1
- package/dist/src/local-first/Timestamp.js +403 -81
- package/dist/src/local-first/index.d.ts +0 -1
- package/dist/src/local-first/index.d.ts.map +1 -1
- package/dist/src/local-first/index.js +0 -1
- package/package.json +1 -1
- package/src/Assert.test.ts +2 -5
- package/src/Config.test.ts +2 -6
- package/src/Config.ts +133 -133
- package/src/Console.ts +62 -7
- package/src/Crypto.ts +76 -4
- package/src/Eq.test.ts +2 -3
- package/src/Error.test.ts +76 -3
- package/src/Error.ts +71 -0
- package/src/Fs.ts +92 -18
- package/src/Identicon.ts +2 -2
- package/src/LeakDetector.ts +22 -3
- package/src/LockManager.ts +8 -0
- package/src/Object.test.ts +27 -12
- package/src/Object.ts +5 -0
- package/src/Platform.ts +50 -8
- package/src/Random.ts +25 -2
- package/src/Resource.test.ts +837 -0
- package/src/Resource.ts +235 -15
- package/src/Schedule.test.ts +50 -12
- package/src/Schedule.ts +24 -14
- package/src/Sqlite.ts +137 -17
- package/src/Task.test.ts +189 -8
- package/src/Task.ts +56 -17
- package/src/Test.ts +9 -0
- package/src/Time.ts +106 -9
- package/src/Type.test.ts +946 -1028
- package/src/Type.ts +4195 -3136
- package/src/Types.test.ts +4 -14
- package/src/WebSocket.ts +313 -40
- package/src/Worker.ts +90 -8
- package/src/index.ts +15 -6
- package/src/local-first/Db.ts +644 -339
- package/src/local-first/Evolu.test.ts +686 -21
- package/src/local-first/Evolu.ts +450 -228
- package/src/local-first/Owner.ts +13 -30
- package/src/local-first/Protocol.test.ts +617 -10
- package/src/local-first/Protocol.ts +196 -72
- package/src/local-first/Query.ts +8 -15
- package/src/local-first/Schema.test.ts +143 -0
- package/src/local-first/Schema.ts +363 -24
- package/src/local-first/Shared.test.ts +7731 -559
- package/src/local-first/Shared.ts +2036 -267
- package/src/local-first/Storage.ts +218 -32
- package/src/local-first/Timestamp.test.ts +344 -70
- package/src/local-first/Timestamp.ts +434 -118
- package/src/local-first/index.ts +0 -1
- package/dist/src/local-first/Error.d.ts +0 -12
- package/dist/src/local-first/Error.d.ts.map +0 -1
- package/dist/src/local-first/Error.js +0 -6
- package/dist/src/local-first/LocalAuth.d.ts +0 -150
- package/dist/src/local-first/LocalAuth.d.ts.map +0 -1
- package/dist/src/local-first/LocalAuth.js +0 -179
- package/src/local-first/Error.ts +0 -17
- package/src/local-first/LocalAuth.ts +0 -457
package/dist/src/Worker.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { ConsoleDep, ConsoleStoreOutputEntryDep } from "./Console.ts";
|
|
|
8
8
|
/**
|
|
9
9
|
* Typed, disposable Worker.
|
|
10
10
|
*
|
|
11
|
+
* @group Core
|
|
11
12
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Worker
|
|
12
13
|
*/
|
|
13
14
|
export interface Worker<Input, Output = never> extends MessagePort<Input, Output> {
|
|
@@ -18,6 +19,7 @@ export interface Worker<Input, Output = never> extends MessagePort<Input, Output
|
|
|
18
19
|
* A shared worker is shared across multiple clients (tabs, windows, iframes)
|
|
19
20
|
* and provides a port for bidirectional communication with each client.
|
|
20
21
|
*
|
|
22
|
+
* @group Core
|
|
21
23
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker
|
|
22
24
|
*/
|
|
23
25
|
export interface SharedWorker<Input, Output = never> extends Disposable {
|
|
@@ -33,6 +35,7 @@ export interface SharedWorker<Input, Output = never> extends Disposable {
|
|
|
33
35
|
* end periodically sends "alive" messages and stale ports are pruned after a
|
|
34
36
|
* timeout.
|
|
35
37
|
*
|
|
38
|
+
* @group Core
|
|
36
39
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
|
|
37
40
|
*/
|
|
38
41
|
export interface MessagePort<Input, Output = never> extends Disposable {
|
|
@@ -78,6 +81,8 @@ export interface MessagePort<Input, Output = never> extends Disposable {
|
|
|
78
81
|
* Intentionally scoped to types Evolu uses. The web platform defines additional
|
|
79
82
|
* transferable types (`ImageBitmap`, `OffscreenCanvas`, `ReadableStream`, etc.)
|
|
80
83
|
* that can be added here if needed.
|
|
84
|
+
*
|
|
85
|
+
* @group Core
|
|
81
86
|
*/
|
|
82
87
|
export type Transferable = NativeMessagePort<any, any> | ArrayBuffer;
|
|
83
88
|
/**
|
|
@@ -86,6 +91,8 @@ export type Transferable = NativeMessagePort<any, any> | ArrayBuffer;
|
|
|
86
91
|
* Exists because `postMessage` transfer requires the native object itself, not
|
|
87
92
|
* a wrapper. Ensures type-safe wiring between {@link MessagePort.native} and
|
|
88
93
|
* {@link CreateMessagePort} without exposing platform details.
|
|
94
|
+
*
|
|
95
|
+
* @group Core
|
|
89
96
|
*/
|
|
90
97
|
export type NativeMessagePort<Input = unknown, Output = never> = Brand<"NativeMessagePort"> & {
|
|
91
98
|
readonly [nativeMessagePortInput]?: Input;
|
|
@@ -93,12 +100,25 @@ export type NativeMessagePort<Input = unknown, Output = never> = Brand<"NativeMe
|
|
|
93
100
|
};
|
|
94
101
|
declare const nativeMessagePortInput: unique symbol;
|
|
95
102
|
declare const nativeMessagePortOutput: unique symbol;
|
|
96
|
-
/**
|
|
103
|
+
/**
|
|
104
|
+
* Factory function to create a {@link MessagePort} from a native port.
|
|
105
|
+
*
|
|
106
|
+
* @group Construction
|
|
107
|
+
*/
|
|
97
108
|
export type CreateMessagePort = <Input, Output = never>(nativePort: NativeMessagePort<Input, Output>) => MessagePort<Input, Output>;
|
|
109
|
+
/**
|
|
110
|
+
* Dependency wrapper for {@link CreateMessagePort}.
|
|
111
|
+
*
|
|
112
|
+
* @group Construction
|
|
113
|
+
*/
|
|
98
114
|
export interface CreateMessagePortDep {
|
|
99
115
|
readonly createMessagePort: CreateMessagePort;
|
|
100
116
|
}
|
|
101
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Common dependencies for worker entry points.
|
|
119
|
+
*
|
|
120
|
+
* @group Core
|
|
121
|
+
*/
|
|
102
122
|
export type WorkerDeps = ConsoleDep & ConsoleStoreOutputEntryDep & CreateMessagePortDep;
|
|
103
123
|
/**
|
|
104
124
|
* Typed, disposable MessageChannel.
|
|
@@ -194,6 +214,7 @@ export type WorkerDeps = ConsoleDep & ConsoleStoreOutputEntryDep & CreateMessage
|
|
|
194
214
|
* ]);
|
|
195
215
|
* ```
|
|
196
216
|
*
|
|
217
|
+
* @group Core
|
|
197
218
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel
|
|
198
219
|
*/
|
|
199
220
|
export interface MessageChannel<Input, Output = never> extends Disposable {
|
|
@@ -202,8 +223,17 @@ export interface MessageChannel<Input, Output = never> extends Disposable {
|
|
|
202
223
|
/** The second port of the channel. */
|
|
203
224
|
readonly port2: MessagePort<Output, Input>;
|
|
204
225
|
}
|
|
205
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* Factory function to create a {@link MessageChannel}.
|
|
228
|
+
*
|
|
229
|
+
* @group Construction
|
|
230
|
+
*/
|
|
206
231
|
export type CreateMessageChannel = <Input, Output = never>() => MessageChannel<Input, Output>;
|
|
232
|
+
/**
|
|
233
|
+
* Dependency wrapper for {@link CreateMessageChannel}.
|
|
234
|
+
*
|
|
235
|
+
* @group Construction
|
|
236
|
+
*/
|
|
207
237
|
export interface CreateMessageChannelDep {
|
|
208
238
|
readonly createMessageChannel: CreateMessageChannel;
|
|
209
239
|
}
|
|
@@ -213,6 +243,7 @@ export interface CreateMessageChannelDep {
|
|
|
213
243
|
* Broadcast channels deliver messages to other channels opened with the same
|
|
214
244
|
* name. The sending channel does not receive its own messages.
|
|
215
245
|
*
|
|
246
|
+
* @group Core
|
|
216
247
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel
|
|
217
248
|
*/
|
|
218
249
|
export interface BroadcastChannel<Input, Output = Input> extends Disposable {
|
|
@@ -221,8 +252,17 @@ export interface BroadcastChannel<Input, Output = Input> extends Disposable {
|
|
|
221
252
|
/** Handler for incoming broadcast messages. */
|
|
222
253
|
onMessage: ((message: Output) => void) | null;
|
|
223
254
|
}
|
|
224
|
-
/**
|
|
255
|
+
/**
|
|
256
|
+
* Factory function to create a {@link BroadcastChannel}.
|
|
257
|
+
*
|
|
258
|
+
* @group Construction
|
|
259
|
+
*/
|
|
225
260
|
export type CreateBroadcastChannel = <Input, Output = Input>(name: string) => BroadcastChannel<Input, Output>;
|
|
261
|
+
/**
|
|
262
|
+
* Dependency wrapper for {@link CreateBroadcastChannel}.
|
|
263
|
+
*
|
|
264
|
+
* @group Construction
|
|
265
|
+
*/
|
|
226
266
|
export interface CreateBroadcastChannelDep {
|
|
227
267
|
readonly createBroadcastChannel: CreateBroadcastChannel;
|
|
228
268
|
}
|
|
@@ -231,6 +271,8 @@ export interface CreateBroadcastChannelDep {
|
|
|
231
271
|
*
|
|
232
272
|
* This is the worker-side counterpart to {@link Worker} — a typed
|
|
233
273
|
* {@link MessagePort} that wraps `self` inside the worker.
|
|
274
|
+
*
|
|
275
|
+
* @group Core
|
|
234
276
|
*/
|
|
235
277
|
export interface WorkerSelf<Input, Output = never> extends MessagePort<Output, Input> {
|
|
236
278
|
}
|
|
@@ -239,6 +281,8 @@ export interface WorkerSelf<Input, Output = never> extends MessagePort<Output, I
|
|
|
239
281
|
*
|
|
240
282
|
* This is the worker-side counterpart to {@link SharedWorker}. It wraps `self`
|
|
241
283
|
* inside the shared worker, providing typed `onConnect` callbacks.
|
|
284
|
+
*
|
|
285
|
+
* @group Core
|
|
242
286
|
*/
|
|
243
287
|
export interface SharedWorkerSelf<Input, Output = never> extends Disposable {
|
|
244
288
|
onConnect: ((port: MessagePort<Output, Input>) => void) | null;
|
|
@@ -248,6 +292,8 @@ export interface SharedWorkerSelf<Input, Output = never> extends Disposable {
|
|
|
248
292
|
*
|
|
249
293
|
* This is a memory-only fallback for platforms without native worker support.
|
|
250
294
|
* Message delivery is asynchronous in-process.
|
|
295
|
+
*
|
|
296
|
+
* @group Construction
|
|
251
297
|
*/
|
|
252
298
|
export declare const createWorker: <Input, Output = never>(initWorker: (self: WorkerSelf<Input, Output>) => void) => Worker<Input, Output>;
|
|
253
299
|
/**
|
|
@@ -258,6 +304,8 @@ export declare const createWorker: <Input, Output = never>(initWorker: (self: Wo
|
|
|
258
304
|
* in-process.
|
|
259
305
|
*
|
|
260
306
|
* Intended usage is one shared worker instance per process/app runtime.
|
|
307
|
+
*
|
|
308
|
+
* @group Construction
|
|
261
309
|
*/
|
|
262
310
|
export declare const createSharedWorker: <Input, Output = never>(initWorker: (self: SharedWorkerSelf<Input, Output>) => void) => SharedWorker<Input, Output>;
|
|
263
311
|
/**
|
|
@@ -265,6 +313,8 @@ export declare const createSharedWorker: <Input, Output = never>(initWorker: (se
|
|
|
265
313
|
*
|
|
266
314
|
* This is a memory-only fallback for platforms without native MessageChannel
|
|
267
315
|
* support. Message delivery is asynchronous in-process.
|
|
316
|
+
*
|
|
317
|
+
* @group Construction
|
|
268
318
|
*/
|
|
269
319
|
export declare const createMessageChannel: CreateMessageChannel;
|
|
270
320
|
/**
|
|
@@ -272,6 +322,8 @@ export declare const createMessageChannel: CreateMessageChannel;
|
|
|
272
322
|
*
|
|
273
323
|
* This is a memory-only fallback for platforms without native MessagePort
|
|
274
324
|
* support. Message delivery through returned ports is asynchronous in-process.
|
|
325
|
+
*
|
|
326
|
+
* @group Construction
|
|
275
327
|
*/
|
|
276
328
|
export declare const createMessagePort: CreateMessagePort;
|
|
277
329
|
/**
|
|
@@ -279,12 +331,16 @@ export declare const createMessagePort: CreateMessagePort;
|
|
|
279
331
|
*
|
|
280
332
|
* This is a memory-only fallback for platforms without native BroadcastChannel
|
|
281
333
|
* support. Message delivery is asynchronous in-process.
|
|
334
|
+
*
|
|
335
|
+
* @group Construction
|
|
282
336
|
*/
|
|
283
337
|
export declare const createBroadcastChannel: CreateBroadcastChannel;
|
|
284
338
|
/**
|
|
285
339
|
* Test {@link Worker} with access to its paired worker-side `self`.
|
|
286
340
|
*
|
|
287
341
|
* Use `self` to simulate messages and behavior from inside the worker.
|
|
342
|
+
*
|
|
343
|
+
* @group Testing
|
|
288
344
|
*/
|
|
289
345
|
export interface TestWorker<Input, Output = never> extends Worker<Input, Output> {
|
|
290
346
|
/** Typed `self` counterpart for worker-side testing assertions. */
|
|
@@ -295,16 +351,26 @@ export interface TestWorker<Input, Output = never> extends Worker<Input, Output>
|
|
|
295
351
|
*
|
|
296
352
|
* Call `connect()` to simulate a client connection and trigger
|
|
297
353
|
* `self.onConnect`.
|
|
354
|
+
*
|
|
355
|
+
* @group Testing
|
|
298
356
|
*/
|
|
299
357
|
export interface TestSharedWorker<Input, Output = never> extends SharedWorker<Input, Output> {
|
|
300
358
|
readonly self: SharedWorkerSelf<Input, Output>;
|
|
301
359
|
readonly connect: () => void;
|
|
302
360
|
}
|
|
303
|
-
/**
|
|
361
|
+
/**
|
|
362
|
+
* {@link MessageChannel} with disposal tracking for testing.
|
|
363
|
+
*
|
|
364
|
+
* @group Testing
|
|
365
|
+
*/
|
|
304
366
|
export interface TestMessageChannel<Input, Output = never> extends MessageChannel<Input, Output> {
|
|
305
367
|
readonly isDisposed: () => boolean;
|
|
306
368
|
}
|
|
307
|
-
/**
|
|
369
|
+
/**
|
|
370
|
+
* {@link BroadcastChannel} with disposal tracking for testing.
|
|
371
|
+
*
|
|
372
|
+
* @group Testing
|
|
373
|
+
*/
|
|
308
374
|
export interface TestBroadcastChannel<Input, Output = Input> extends BroadcastChannel<Input, Output> {
|
|
309
375
|
readonly isDisposed: () => boolean;
|
|
310
376
|
}
|
|
@@ -313,6 +379,8 @@ export interface TestBroadcastChannel<Input, Output = Input> extends BroadcastCh
|
|
|
313
379
|
*
|
|
314
380
|
* The returned worker includes its typed {@link TestWorker.self} counterpart, so
|
|
315
381
|
* tests can exercise dedicated worker communication without a real thread.
|
|
382
|
+
*
|
|
383
|
+
* @group Testing
|
|
316
384
|
*/
|
|
317
385
|
export declare const testCreateWorker: <Input, Output = never>() => TestWorker<Input, Output>;
|
|
318
386
|
/**
|
|
@@ -320,6 +388,8 @@ export declare const testCreateWorker: <Input, Output = never>() => TestWorker<I
|
|
|
320
388
|
*
|
|
321
389
|
* The returned worker includes `self` and `connect` so tests can exercise the
|
|
322
390
|
* full worker ↔ client pipeline without a real worker thread.
|
|
391
|
+
*
|
|
392
|
+
* @group Testing
|
|
323
393
|
*/
|
|
324
394
|
export declare const testCreateSharedWorker: <Input, Output = never>() => TestSharedWorker<Input, Output>;
|
|
325
395
|
/**
|
|
@@ -330,11 +400,21 @@ export declare const testCreateSharedWorker: <Input, Output = never>() => TestSh
|
|
|
330
400
|
*
|
|
331
401
|
* Both ports are registered in the native port registry so
|
|
332
402
|
* {@link testCreateMessagePort} can look them up by their native token.
|
|
403
|
+
*
|
|
404
|
+
* @group Testing
|
|
333
405
|
*/
|
|
334
406
|
export declare const testCreateMessageChannel: <Input, Output = never>() => TestMessageChannel<Input, Output>;
|
|
335
|
-
/**
|
|
407
|
+
/**
|
|
408
|
+
* Creates an in-memory {@link CreateMessagePort} for testing.
|
|
409
|
+
*
|
|
410
|
+
* @group Testing
|
|
411
|
+
*/
|
|
336
412
|
export declare const testCreateMessagePort: CreateMessagePort;
|
|
337
|
-
/**
|
|
413
|
+
/**
|
|
414
|
+
* Creates an in-memory {@link BroadcastChannel} for testing.
|
|
415
|
+
*
|
|
416
|
+
* @group Testing
|
|
417
|
+
*/
|
|
338
418
|
export declare const testCreateBroadcastChannel: <Input, Output = Input>(name: string) => TestBroadcastChannel<Input, Output>;
|
|
339
419
|
/**
|
|
340
420
|
* Waits until scheduled in-memory worker message delivery becomes idle.
|
|
@@ -342,6 +422,8 @@ export declare const testCreateBroadcastChannel: <Input, Output = Input>(name: s
|
|
|
342
422
|
* This observes actual transport tasks instead of waiting for an arbitrary
|
|
343
423
|
* duration. It also waits through message handlers that schedule more worker
|
|
344
424
|
* tasks before the current microtask checkpoint completes.
|
|
425
|
+
*
|
|
426
|
+
* @group Testing
|
|
345
427
|
*/
|
|
346
428
|
export declare const testWaitForWorkerMessage: () => Promise<void>;
|
|
347
429
|
export {};
|
package/dist/src/Worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts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,MAAM,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,MAAM,OAAO,CAAC;CACpC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,OAAK,UAAU,CACnE,KAAK,EACL,MAAM,CASP,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,KAAK,EACL,MAAM,GAAG,KAAK,OACX,gBAAgB,CAAC,KAAK,EAAE,MAAM,CASlC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GACnC,KAAK,EACL,MAAM,GAAG,KAAK,OACX,kBAAkB,CAAC,KAAK,EAAE,MAAM,CAYpC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,iBAE0B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,QACxD,MAAM,KACX,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAiBpC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,QAAO,OAAO,CAAC,IAAI,CAIpD,CAAC"}
|
package/dist/src/Worker.js
CHANGED
|
@@ -62,6 +62,8 @@ import { disposable } from "./Function.js";
|
|
|
62
62
|
*
|
|
63
63
|
* This is a memory-only fallback for platforms without native worker support.
|
|
64
64
|
* Message delivery is asynchronous in-process.
|
|
65
|
+
*
|
|
66
|
+
* @group Construction
|
|
65
67
|
*/
|
|
66
68
|
export const createWorker = (initWorker) => {
|
|
67
69
|
const { worker, self } = createMemoryWorkerPair();
|
|
@@ -76,6 +78,8 @@ export const createWorker = (initWorker) => {
|
|
|
76
78
|
* in-process.
|
|
77
79
|
*
|
|
78
80
|
* Intended usage is one shared worker instance per process/app runtime.
|
|
81
|
+
*
|
|
82
|
+
* @group Construction
|
|
79
83
|
*/
|
|
80
84
|
export const createSharedWorker = (initWorker) => {
|
|
81
85
|
const { worker, self, connect } = createMemorySharedWorkerPair();
|
|
@@ -88,6 +92,8 @@ export const createSharedWorker = (initWorker) => {
|
|
|
88
92
|
*
|
|
89
93
|
* This is a memory-only fallback for platforms without native MessageChannel
|
|
90
94
|
* support. Message delivery is asynchronous in-process.
|
|
95
|
+
*
|
|
96
|
+
* @group Construction
|
|
91
97
|
*/
|
|
92
98
|
export const createMessageChannel = () => {
|
|
93
99
|
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
@@ -145,6 +151,8 @@ export const createMessageChannel = () => {
|
|
|
145
151
|
*
|
|
146
152
|
* This is a memory-only fallback for platforms without native MessagePort
|
|
147
153
|
* support. Message delivery through returned ports is asynchronous in-process.
|
|
154
|
+
*
|
|
155
|
+
* @group Construction
|
|
148
156
|
*/
|
|
149
157
|
export const createMessagePort = (nativePort) => {
|
|
150
158
|
const registration = nativePortRegistry.get(nativePort);
|
|
@@ -156,6 +164,8 @@ export const createMessagePort = (nativePort) => {
|
|
|
156
164
|
*
|
|
157
165
|
* This is a memory-only fallback for platforms without native BroadcastChannel
|
|
158
166
|
* support. Message delivery is asynchronous in-process.
|
|
167
|
+
*
|
|
168
|
+
* @group Construction
|
|
159
169
|
*/
|
|
160
170
|
export const createBroadcastChannel = (name) => {
|
|
161
171
|
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
@@ -217,6 +227,8 @@ const broadcastChannelDispatchesByName = new Map();
|
|
|
217
227
|
*
|
|
218
228
|
* The returned worker includes its typed {@link TestWorker.self} counterpart, so
|
|
219
229
|
* tests can exercise dedicated worker communication without a real thread.
|
|
230
|
+
*
|
|
231
|
+
* @group Testing
|
|
220
232
|
*/
|
|
221
233
|
export const testCreateWorker = () => {
|
|
222
234
|
let self;
|
|
@@ -230,6 +242,8 @@ export const testCreateWorker = () => {
|
|
|
230
242
|
*
|
|
231
243
|
* The returned worker includes `self` and `connect` so tests can exercise the
|
|
232
244
|
* full worker ↔ client pipeline without a real worker thread.
|
|
245
|
+
*
|
|
246
|
+
* @group Testing
|
|
233
247
|
*/
|
|
234
248
|
export const testCreateSharedWorker = () => {
|
|
235
249
|
const { worker, self, connect } = createMemorySharedWorkerPair();
|
|
@@ -246,6 +260,8 @@ export const testCreateSharedWorker = () => {
|
|
|
246
260
|
*
|
|
247
261
|
* Both ports are registered in the native port registry so
|
|
248
262
|
* {@link testCreateMessagePort} can look them up by their native token.
|
|
263
|
+
*
|
|
264
|
+
* @group Testing
|
|
249
265
|
*/
|
|
250
266
|
export const testCreateMessageChannel = () => {
|
|
251
267
|
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
@@ -268,9 +284,17 @@ export const testCreateMessageChannel = () => {
|
|
|
268
284
|
__disposeResources(env_3);
|
|
269
285
|
}
|
|
270
286
|
};
|
|
271
|
-
/**
|
|
287
|
+
/**
|
|
288
|
+
* Creates an in-memory {@link CreateMessagePort} for testing.
|
|
289
|
+
*
|
|
290
|
+
* @group Testing
|
|
291
|
+
*/
|
|
272
292
|
export const testCreateMessagePort = (nativePort) => createMessagePort(nativePort);
|
|
273
|
-
/**
|
|
293
|
+
/**
|
|
294
|
+
* Creates an in-memory {@link BroadcastChannel} for testing.
|
|
295
|
+
*
|
|
296
|
+
* @group Testing
|
|
297
|
+
*/
|
|
274
298
|
export const testCreateBroadcastChannel = (name) => {
|
|
275
299
|
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
276
300
|
try {
|
|
@@ -303,6 +327,8 @@ export const testCreateBroadcastChannel = (name) => {
|
|
|
303
327
|
* This observes actual transport tasks instead of waiting for an arbitrary
|
|
304
328
|
* duration. It also waits through message handlers that schedule more worker
|
|
305
329
|
* tasks before the current microtask checkpoint completes.
|
|
330
|
+
*
|
|
331
|
+
* @group Testing
|
|
306
332
|
*/
|
|
307
333
|
export const testWaitForWorkerMessage = () => new Promise((resolve) => {
|
|
308
334
|
workerTaskIdleWaiters.add(resolve);
|
package/dist/src/index.d.ts
CHANGED
|
@@ -48,16 +48,15 @@ export * from "./Type.ts";
|
|
|
48
48
|
export * from "./Types.ts";
|
|
49
49
|
export * from "./WebSocket.ts";
|
|
50
50
|
export * from "./Worker.ts";
|
|
51
|
-
export type {
|
|
52
|
-
export { AppName, createEvolu } from "./local-first/Evolu.ts";
|
|
53
|
-
export type { AppNameError, Evolu, EvoluConfig, EvoluDeps, UnuseOwner, } from "./local-first/Evolu.ts";
|
|
54
|
-
export * from "./local-first/LocalAuth.ts";
|
|
51
|
+
export type { UnsupportedDbVersionError } from "./local-first/Db.ts";
|
|
52
|
+
export { AppName, createEvolu, testAppName } from "./local-first/Evolu.ts";
|
|
53
|
+
export type { AppNameError, Evolu, EvoluConfig, EvoluDeps, EvoluError, UnuseOwner, } from "./local-first/Evolu.ts";
|
|
55
54
|
export * from "./local-first/Owner.ts";
|
|
56
55
|
export type { SyncOwner } from "./local-first/Owner.ts";
|
|
57
56
|
export { evoluJsonArrayFrom, evoluJsonBuildObject, evoluJsonObjectFrom, getJsonObjectArgs, kyselySql, type InferRow, type KyselyNotNull, type Query, type QueryRows, type Row, } from "./local-first/Query.ts";
|
|
58
|
-
export { createQueryBuilder } from "./local-first/Schema.ts";
|
|
59
|
-
export type { AnyStandardSchemaV1, EvoluSchema, InsertValues, Mutation, MutationKind, MutationOptions, MutationValues, NullableColumnsToOptional, OptionalColumnKeys, RequiredColumnKeys, TableSchema, UpdateValues, UpsertValues, } from "./local-first/Schema.ts";
|
|
57
|
+
export { createQueryBuilder, QuarantineOrigin, QuarantineReason, testEvoluSchema, testLocalOnlyEvoluSchema, TestProjectId, testProjectId, TestTodoId, testTodoId, } from "./local-first/Schema.ts";
|
|
58
|
+
export type { AnyStandardSchemaV1, EvoluSchema, InsertValues, Mutation, MutationKind, MutationOptions, MutationValues, NullableColumnsToOptional, OptionalColumnKeys, RequiredColumnKeys, TableSchema, TestEvoluSchema, UpdateValues, UpsertValues, } from "./local-first/Schema.ts";
|
|
60
59
|
export type { SyncState, } from "./local-first/Shared.ts";
|
|
61
60
|
export { Timestamp, timestampBytesToTimestamp, timestampToTimestampBytes, } from "./local-first/Timestamp.ts";
|
|
62
|
-
export type { TimestampBytes,
|
|
61
|
+
export type { TimestampBytes, TimestampDriftError, TimestampError, } from "./local-first/Timestamp.ts";
|
|
63
62
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAA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B,EACzB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,cAAc,GACf,MAAM,4BAA4B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -47,9 +47,8 @@ export * from "./Type.js";
|
|
|
47
47
|
export * from "./Types.js";
|
|
48
48
|
export * from "./WebSocket.js";
|
|
49
49
|
export * from "./Worker.js";
|
|
50
|
-
export { AppName, createEvolu } from "./local-first/Evolu.js";
|
|
51
|
-
export * from "./local-first/LocalAuth.js";
|
|
50
|
+
export { AppName, createEvolu, testAppName } from "./local-first/Evolu.js";
|
|
52
51
|
export * from "./local-first/Owner.js";
|
|
53
52
|
export { evoluJsonArrayFrom, evoluJsonBuildObject, evoluJsonObjectFrom, getJsonObjectArgs, kyselySql, } from "./local-first/Query.js";
|
|
54
|
-
export { createQueryBuilder } from "./local-first/Schema.js";
|
|
53
|
+
export { createQueryBuilder, QuarantineOrigin, QuarantineReason, testEvoluSchema, testLocalOnlyEvoluSchema, TestProjectId, testProjectId, TestTodoId, testTodoId, } from "./local-first/Schema.js";
|
|
55
54
|
export { Timestamp, timestampBytesToTimestamp, timestampToTimestampBytes, } from "./local-first/Timestamp.js";
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Platform-agnostic Evolu DbWorker.
|
|
3
3
|
*
|
|
4
|
+
* ### Database version
|
|
5
|
+
*
|
|
6
|
+
* Every database records `dbVersion` in `evolu_version`. The version describes
|
|
7
|
+
* Evolu's internal persisted format: the layout of its system tables and the
|
|
8
|
+
* meaning of the data stored in them. It is independent of the application
|
|
9
|
+
* schema, which evolves append-only through {@link ensureSqliteSchema}, and of
|
|
10
|
+
* the network protocol version, which is checked per message. Many Evolu
|
|
11
|
+
* releases can share one database version.
|
|
12
|
+
*
|
|
13
|
+
* Bump `dbVersion` for any change that older code would misread, not only for
|
|
14
|
+
* changed SQL. A new quarantine reason, for example, changes what startup may
|
|
15
|
+
* replay even when its columns are additive. Each bump ships with a migration
|
|
16
|
+
* from the previous version; fresh databases are created at the latest layout
|
|
17
|
+
* directly.
|
|
18
|
+
*
|
|
19
|
+
* Startup holds the database leader lock, then checks the stored version record
|
|
20
|
+
* before it reads the clock, ensures the application schema, or replays
|
|
21
|
+
* quarantine. Databases written before the version record existed hold one
|
|
22
|
+
* `protocolVersion` row instead; that known legacy layout is converted to
|
|
23
|
+
* version 1. A newer stored version refuses startup with
|
|
24
|
+
* {@link UnsupportedDbVersionError}. The refusal returns from the startup
|
|
25
|
+
* transaction before anything is written and is posted to the SharedWorker; the
|
|
26
|
+
* worker then exits and releases its resources. The single version row is
|
|
27
|
+
* created in the same transaction as the other system tables.
|
|
28
|
+
*
|
|
29
|
+
* Code released before the version record existed never reads it. It recognizes
|
|
30
|
+
* an initialized database by the `evolu_version` table alone, so it opens a
|
|
31
|
+
* newer database and replays all quarantine regardless of reason, applying
|
|
32
|
+
* drift quarantine at once without advancing the clock. Renaming the table
|
|
33
|
+
* would make such code fail at startup instead. That was declined: the replay
|
|
34
|
+
* needs drift quarantine and an earlier release on the same device at once, and
|
|
35
|
+
* failing would break a rollback to an earlier release outright.
|
|
36
|
+
*
|
|
4
37
|
* @module
|
|
5
38
|
*/
|
|
6
39
|
import type { ConsoleLevel } from "../Console.ts";
|
|
@@ -8,7 +41,7 @@ import { EncryptionKey } from "../Crypto.ts";
|
|
|
8
41
|
import type { LockManagerDep } from "../LockManager.ts";
|
|
9
42
|
import type { CreateSqliteDriverDep, SqliteSchema } from "../Sqlite.ts";
|
|
10
43
|
import { type Task } from "../Task.ts";
|
|
11
|
-
import { type Name } from "../Type.ts";
|
|
44
|
+
import { PositiveInt, type Name, type Typed } from "../Type.ts";
|
|
12
45
|
import type { CreateBroadcastChannelDep, NativeMessagePort, Worker, WorkerDeps, WorkerSelf } from "../Worker.ts";
|
|
13
46
|
import type { DbWorkerInput, DbWorkerOutput } from "./Shared.ts";
|
|
14
47
|
export type DbWorker = Worker<DbWorkerInit>;
|
|
@@ -27,8 +60,24 @@ export interface CreateDbWorkerDep {
|
|
|
27
60
|
}
|
|
28
61
|
export type DbWorkerDeps = WorkerDeps & CreateBroadcastChannelDep & LockManagerDep & CreateSqliteDriverDep;
|
|
29
62
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
63
|
+
* The stored database version is newer than this code supports. Newer code
|
|
64
|
+
* created or migrated the database, which is left unchanged. This happens when
|
|
65
|
+
* older code opens a database a newer build migrated, for example an older
|
|
66
|
+
* build loaded from a cache, or when the app was downgraded after a newer
|
|
67
|
+
* version migrated the local data. On the web, a refused tab reloads once for
|
|
68
|
+
* each stored version, so it loads the build the server now serves, and the
|
|
69
|
+
* error is reported when that build refuses too. Then close all tabs of the
|
|
70
|
+
* app, which lets a service worker replace a cached older build, or update the
|
|
71
|
+
* app to a version that supports `storedVersion`.
|
|
72
|
+
*/
|
|
73
|
+
export interface UnsupportedDbVersionError extends Typed<"UnsupportedDbVersionError"> {
|
|
74
|
+
readonly storedVersion: PositiveInt;
|
|
75
|
+
readonly supportedVersion: PositiveInt;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Starts the platform-agnostic Evolu DbWorker and owns its resources until
|
|
79
|
+
* startup is refused, the worker receives a dispose message, or its {@link Run}
|
|
80
|
+
* is aborted.
|
|
32
81
|
*/
|
|
33
82
|
export declare const startDbWorker: (self: WorkerSelf<DbWorkerInit>) => Task<void, never, DbWorkerDeps>;
|
|
34
83
|
//# sourceMappingURL=Db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Db.d.ts","sourceRoot":"","sources":["../../../src/local-first/Db.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Db.d.ts","sourceRoot":"","sources":["../../../src/local-first/Db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAcH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,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