@evolu/common 7.4.0 → 8.0.0-next.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 +4 -61
- package/dist/src/Array.d.ts +343 -102
- package/dist/src/Array.d.ts.map +1 -1
- package/dist/src/Array.js +181 -85
- package/dist/src/Assert.d.ts +57 -11
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +47 -11
- package/dist/src/BigInt.d.ts +6 -1
- package/dist/src/BigInt.d.ts.map +1 -1
- package/dist/src/BigInt.js +5 -0
- package/dist/src/Brand.d.ts +40 -12
- package/dist/src/Brand.d.ts.map +1 -1
- package/dist/src/Brand.js +5 -0
- package/dist/src/Buffer.d.ts +6 -1
- package/dist/src/Buffer.d.ts.map +1 -1
- package/dist/src/Buffer.js +7 -2
- package/dist/src/Cache.d.ts +10 -2
- package/dist/src/Cache.d.ts.map +1 -1
- package/dist/src/Cache.js +6 -0
- package/dist/src/Callbacks.d.ts +10 -7
- package/dist/src/Callbacks.d.ts.map +1 -1
- package/dist/src/Callbacks.js +23 -13
- package/dist/src/Console.d.ts +361 -69
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +217 -117
- package/dist/src/Crypto.d.ts +70 -21
- package/dist/src/Crypto.d.ts.map +1 -1
- package/dist/src/Crypto.js +72 -27
- package/dist/src/Eq.d.ts +22 -2
- package/dist/src/Eq.d.ts.map +1 -1
- package/dist/src/Eq.js +21 -1
- package/dist/src/Error.d.ts +23 -12
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +27 -11
- package/dist/src/Function.d.ts +128 -56
- package/dist/src/Function.d.ts.map +1 -1
- package/dist/src/Function.js +118 -14
- package/dist/src/Identicon.d.ts +5 -0
- package/dist/src/Identicon.d.ts.map +1 -1
- package/dist/src/Identicon.js +6 -1
- package/dist/src/Lookup.d.ts +160 -0
- package/dist/src/Lookup.d.ts.map +1 -0
- package/dist/src/Lookup.js +192 -0
- package/dist/src/Microtask.d.ts +21 -0
- package/dist/src/Microtask.d.ts.map +1 -0
- package/dist/src/Microtask.js +37 -0
- package/dist/src/Number.d.ts +18 -4
- package/dist/src/Number.d.ts.map +1 -1
- package/dist/src/Number.js +23 -1
- package/dist/src/Object.d.ts +110 -5
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/Object.js +108 -5
- package/dist/src/Option.d.ts +58 -0
- package/dist/src/Option.d.ts.map +1 -0
- package/dist/src/Option.js +43 -0
- package/dist/src/Order.d.ts +5 -0
- package/dist/src/Order.d.ts.map +1 -1
- package/dist/src/Order.js +8 -3
- package/dist/src/Platform.d.ts +36 -2
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +10 -6
- package/dist/src/Polyfills.d.ts +27 -0
- package/dist/src/Polyfills.d.ts.map +1 -0
- package/dist/src/Polyfills.js +299 -0
- package/dist/src/Random.d.ts +18 -7
- package/dist/src/Random.d.ts.map +1 -1
- package/dist/src/Random.js +9 -7
- package/dist/src/Redacted.d.ts +7 -4
- package/dist/src/Redacted.d.ts.map +1 -1
- package/dist/src/Redacted.js +5 -0
- package/dist/src/Ref.d.ts +31 -16
- package/dist/src/Ref.d.ts.map +1 -1
- package/dist/src/Ref.js +35 -7
- package/dist/src/RefCount.d.ts +62 -0
- package/dist/src/RefCount.d.ts.map +1 -0
- package/dist/src/RefCount.js +83 -0
- package/dist/src/Relation.d.ts +84 -29
- package/dist/src/Relation.d.ts.map +1 -1
- package/dist/src/Relation.js +83 -105
- package/dist/src/Resource.d.ts +263 -0
- package/dist/src/Resource.d.ts.map +1 -0
- package/dist/src/Resource.js +389 -0
- package/dist/src/Result.d.ts +390 -374
- package/dist/src/Result.d.ts.map +1 -1
- package/dist/src/Result.js +142 -70
- package/dist/src/Schedule.d.ts +953 -0
- package/dist/src/Schedule.d.ts.map +1 -0
- package/dist/src/Schedule.js +1199 -0
- package/dist/src/Set.d.ts +181 -0
- package/dist/src/Set.d.ts.map +1 -0
- package/dist/src/Set.js +137 -0
- package/dist/src/Skiplist.d.ts +6 -1
- package/dist/src/Skiplist.d.ts.map +1 -1
- package/dist/src/Skiplist.js +5 -0
- package/dist/src/Sqlite.d.ts +160 -60
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +290 -190
- package/dist/src/Store.d.ts +36 -28
- package/dist/src/Store.d.ts.map +1 -1
- package/dist/src/Store.js +55 -15
- package/dist/src/String.d.ts +5 -0
- package/dist/src/String.d.ts.map +1 -1
- package/dist/src/String.js +5 -0
- package/dist/src/Task.d.ts +2263 -423
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +1488 -348
- package/dist/src/Test.d.ts +122 -0
- package/dist/src/Test.d.ts.map +1 -0
- package/dist/src/Test.js +66 -0
- package/dist/src/Time.d.ts +201 -48
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +190 -86
- package/dist/src/Tracer.d.ts +48 -0
- package/dist/src/Tracer.d.ts.map +1 -0
- package/dist/src/Tracer.js +6 -0
- package/dist/src/Type.d.ts +582 -209
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +362 -240
- package/dist/src/Types.d.ts +160 -6
- package/dist/src/Types.d.ts.map +1 -1
- package/dist/src/Types.js +22 -2
- package/dist/src/WebSocket.d.ts +113 -58
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +210 -118
- package/dist/src/Worker.d.ts +245 -60
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +220 -64
- package/dist/src/index.d.ts +25 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +19 -3
- package/dist/src/local-first/Db.d.ts +24 -213
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +622 -293
- package/dist/src/local-first/Error.d.ts +12 -0
- package/dist/src/local-first/Error.d.ts.map +1 -0
- package/dist/src/local-first/Error.js +6 -0
- package/dist/src/local-first/Evolu.d.ts +330 -285
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +472 -402
- package/dist/src/local-first/LocalAuth.d.ts +10 -10
- package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
- package/dist/src/local-first/LocalAuth.js +6 -1
- package/dist/src/local-first/Owner.d.ts +70 -27
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Owner.js +27 -14
- package/dist/src/local-first/Protocol.d.ts +58 -50
- package/dist/src/local-first/Protocol.d.ts.map +1 -1
- package/dist/src/local-first/Protocol.js +253 -155
- package/dist/src/local-first/Query.d.ts +133 -43
- package/dist/src/local-first/Query.d.ts.map +1 -1
- package/dist/src/local-first/Query.js +139 -90
- package/dist/src/local-first/Relay.d.ts +18 -38
- package/dist/src/local-first/Relay.d.ts.map +1 -1
- package/dist/src/local-first/Relay.js +59 -171
- package/dist/src/local-first/Schema.d.ts +139 -144
- package/dist/src/local-first/Schema.d.ts.map +1 -1
- package/dist/src/local-first/Schema.js +78 -163
- package/dist/src/local-first/Shared.d.ts +125 -0
- package/dist/src/local-first/Shared.d.ts.map +1 -0
- package/dist/src/local-first/Shared.js +569 -0
- package/dist/src/local-first/Storage.d.ts +50 -53
- package/dist/src/local-first/Storage.d.ts.map +1 -1
- package/dist/src/local-first/Storage.js +121 -173
- package/dist/src/local-first/Timestamp.d.ts +28 -35
- package/dist/src/local-first/Timestamp.d.ts.map +1 -1
- package/dist/src/local-first/Timestamp.js +24 -25
- package/dist/src/local-first/index.d.ts +2 -15
- package/dist/src/local-first/index.d.ts.map +1 -1
- package/dist/src/local-first/index.js +2 -15
- package/package.json +36 -26
- package/src/Array.ts +467 -106
- package/src/Assert.ts +87 -12
- package/src/BigInt.ts +7 -1
- package/src/Brand.ts +41 -12
- package/src/Buffer.ts +10 -4
- package/src/Cache.ts +11 -2
- package/src/Callbacks.ts +33 -23
- package/src/Console.ts +567 -178
- package/src/Crypto.ts +111 -62
- package/src/Eq.ts +30 -3
- package/src/Error.ts +50 -34
- package/src/Function.ts +140 -68
- package/src/Identicon.ts +7 -1
- package/src/Lookup.ts +415 -0
- package/src/Microtask.ts +58 -0
- package/src/Number.ts +40 -7
- package/src/Object.ts +155 -16
- package/src/Option.ts +74 -0
- package/src/Order.ts +11 -3
- package/src/Platform.ts +43 -7
- package/src/Polyfills.ts +465 -0
- package/src/Random.ts +25 -11
- package/src/Redacted.ts +8 -4
- package/src/Ref.ts +72 -21
- package/src/RefCount.ts +170 -0
- package/src/Relation.ts +188 -136
- package/src/Resource.ts +864 -0
- package/src/Result.ts +548 -381
- package/src/Schedule.ts +1471 -0
- package/src/Set.ts +247 -0
- package/src/Skiplist.ts +7 -1
- package/src/Sqlite.ts +409 -304
- package/src/Store.ts +94 -48
- package/src/String.ts +6 -0
- package/src/Task.ts +3685 -740
- package/src/Test.ts +162 -0
- package/src/Time.ts +348 -145
- package/src/Tracer.ts +54 -0
- package/src/Type.ts +1064 -630
- package/src/Types.ts +202 -7
- package/src/WebSocket.ts +311 -178
- package/src/Worker.ts +527 -147
- package/src/index.ts +74 -3
- package/src/local-first/Db.ts +871 -597
- package/src/local-first/Error.ts +17 -0
- package/src/local-first/Evolu.ts +884 -823
- package/src/local-first/LocalAuth.ts +10 -10
- package/src/local-first/Owner.ts +94 -42
- package/src/local-first/Protocol.ts +440 -303
- package/src/local-first/Query.ts +243 -194
- package/src/local-first/Relay.ts +91 -252
- package/src/local-first/Schema.ts +284 -394
- package/src/local-first/Shared.ts +932 -0
- package/src/local-first/Storage.ts +209 -282
- package/src/local-first/Timestamp.ts +38 -45
- package/src/local-first/index.ts +2 -16
- package/LICENSE +0 -21
- package/dist/src/Instances.d.ts +0 -34
- package/dist/src/Instances.d.ts.map +0 -1
- package/dist/src/Instances.js +0 -44
- package/dist/src/Resources.d.ts +0 -118
- package/dist/src/Resources.d.ts.map +0 -1
- package/dist/src/Resources.js +0 -197
- package/dist/src/local-first/Platform.d.ts +0 -25
- package/dist/src/local-first/Platform.d.ts.map +0 -1
- package/dist/src/local-first/Platform.js +0 -1
- package/dist/src/local-first/Public.d.ts +0 -22
- package/dist/src/local-first/Public.d.ts.map +0 -1
- package/dist/src/local-first/Public.js +0 -15
- package/dist/src/local-first/PublicKysely.d.ts +0 -148
- package/dist/src/local-first/PublicKysely.d.ts.map +0 -1
- package/dist/src/local-first/PublicKysely.js +0 -184
- package/dist/src/local-first/Sync.d.ts +0 -112
- package/dist/src/local-first/Sync.d.ts.map +0 -1
- package/dist/src/local-first/Sync.js +0 -529
- package/src/Instances.ts +0 -90
- package/src/Resources.ts +0 -367
- package/src/local-first/Platform.ts +0 -27
- package/src/local-first/Public.ts +0 -42
- package/src/local-first/PublicKysely.ts +0 -239
- package/src/local-first/Sync.ts +0 -960
package/dist/src/Worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAG3E;;;;GAIG;AACH,MAAM,WAAW,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAE,SAAQ,WAAW,CAChE,KAAK,EACL,MAAM,CACP;CAAG;AAEJ;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAE,SAAQ,UAAU;IACrE,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC3C;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAE,SAAQ,UAAU;I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/D;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,QAAa,OAAO,CAAC,IAAI,CAG7D,CAAC"}
|
package/dist/src/Worker.js
CHANGED
|
@@ -1,79 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-agnostic Worker abstractions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
import { assert } from "./Assert.js";
|
|
2
|
-
import {
|
|
7
|
+
import { testWaitForMacrotask } from "./Test.js";
|
|
8
|
+
/**
|
|
9
|
+
* Creates an in-memory {@link Worker}.
|
|
10
|
+
*
|
|
11
|
+
* This is a memory-only fallback for platforms without native worker support.
|
|
12
|
+
* Message delivery is asynchronous in-process.
|
|
13
|
+
*/
|
|
14
|
+
export const createWorker = (initWorker) => {
|
|
15
|
+
const { worker, self } = createMemoryWorkerPair();
|
|
16
|
+
initWorker(self);
|
|
17
|
+
return worker;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Creates an in-memory {@link SharedWorker}.
|
|
21
|
+
*
|
|
22
|
+
* This is a memory-only fallback for platforms without native SharedWorker
|
|
23
|
+
* support. Connection is synchronous while message delivery is asynchronous
|
|
24
|
+
* in-process.
|
|
25
|
+
*
|
|
26
|
+
* Intended usage is one shared worker instance per process/app runtime.
|
|
27
|
+
*/
|
|
28
|
+
export const createSharedWorker = (initWorker) => {
|
|
29
|
+
const { worker, self, connect } = createMemorySharedWorkerPair();
|
|
30
|
+
initWorker(self);
|
|
31
|
+
connect();
|
|
32
|
+
return worker;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Creates an in-memory {@link MessageChannel}.
|
|
36
|
+
*
|
|
37
|
+
* This is a memory-only fallback for platforms without native MessageChannel
|
|
38
|
+
* support. Message delivery is asynchronous in-process.
|
|
39
|
+
*/
|
|
40
|
+
export const createMessageChannel = () => {
|
|
41
|
+
const state1 = {
|
|
42
|
+
handler: null,
|
|
43
|
+
queue: [],
|
|
44
|
+
flushScheduled: false,
|
|
45
|
+
};
|
|
46
|
+
const state2 = {
|
|
47
|
+
handler: null,
|
|
48
|
+
queue: [],
|
|
49
|
+
flushScheduled: false,
|
|
50
|
+
};
|
|
51
|
+
const native1 = createNativeMessagePortToken();
|
|
52
|
+
const native2 = createNativeMessagePortToken();
|
|
53
|
+
const port1 = createTestPort(state1, state2, native1);
|
|
54
|
+
const port2 = createTestPort(state2, state1, native2);
|
|
55
|
+
nativePortRegistry.set(native1, port1);
|
|
56
|
+
nativePortRegistry.set(native2, port2);
|
|
57
|
+
return {
|
|
58
|
+
port1,
|
|
59
|
+
port2,
|
|
60
|
+
[Symbol.dispose]: () => {
|
|
61
|
+
port1[Symbol.dispose]();
|
|
62
|
+
port2[Symbol.dispose]();
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Creates an in-memory {@link MessagePort} from a native token.
|
|
68
|
+
*
|
|
69
|
+
* This is a memory-only fallback for platforms without native MessagePort
|
|
70
|
+
* support. Message delivery through returned ports is asynchronous in-process.
|
|
71
|
+
*/
|
|
72
|
+
export const createMessagePort = (nativePort) => {
|
|
73
|
+
const pair = nativePortRegistry.get(nativePort);
|
|
74
|
+
assert(pair, "Unknown native port — did you transfer it?");
|
|
75
|
+
return pair;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Creates a connected {@link TestWorker} for testing.
|
|
79
|
+
*
|
|
80
|
+
* The returned worker includes its typed {@link TestWorker.self} counterpart, so
|
|
81
|
+
* tests can exercise dedicated worker communication without a real thread.
|
|
82
|
+
*/
|
|
83
|
+
export const testCreateWorker = () => {
|
|
84
|
+
let self;
|
|
85
|
+
const worker = createWorker((nextSelf) => {
|
|
86
|
+
self = nextSelf;
|
|
87
|
+
});
|
|
88
|
+
return Object.assign(worker, { self });
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Creates a connected {@link TestSharedWorker} for testing.
|
|
92
|
+
*
|
|
93
|
+
* The returned worker includes `self` and `connect` so tests can exercise the
|
|
94
|
+
* full worker ↔ client pipeline without a real worker thread.
|
|
95
|
+
*/
|
|
96
|
+
export const testCreateSharedWorker = () => {
|
|
97
|
+
const { worker, self, connect } = createMemorySharedWorkerPair();
|
|
98
|
+
return Object.assign(worker, {
|
|
99
|
+
self,
|
|
100
|
+
connect,
|
|
101
|
+
});
|
|
102
|
+
};
|
|
3
103
|
/**
|
|
4
|
-
* Creates
|
|
5
|
-
*
|
|
104
|
+
* Creates an in-memory {@link MessageChannel} for testing.
|
|
105
|
+
*
|
|
106
|
+
* Messages are queued until `onMessage` is assigned, matching the browser
|
|
107
|
+
* MessagePort behavior where the port message queue starts disabled.
|
|
108
|
+
*
|
|
109
|
+
* Both ports are registered in the native port registry so
|
|
110
|
+
* {@link testCreateMessagePort} can look them up by their native token.
|
|
6
111
|
*/
|
|
7
|
-
export const
|
|
8
|
-
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
112
|
+
export const testCreateMessageChannel = () => {
|
|
113
|
+
const channel = createMessageChannel();
|
|
114
|
+
let disposed = false;
|
|
115
|
+
return {
|
|
116
|
+
port1: channel.port1,
|
|
117
|
+
port2: channel.port2,
|
|
118
|
+
isDisposed: () => disposed,
|
|
119
|
+
[Symbol.dispose]: () => {
|
|
120
|
+
disposed = true;
|
|
121
|
+
channel[Symbol.dispose]();
|
|
122
|
+
},
|
|
15
123
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
124
|
+
};
|
|
125
|
+
/** Creates an in-memory {@link CreateMessagePort} for testing. */
|
|
126
|
+
export const testCreateMessagePort = (nativePort) => createMessagePort(nativePort);
|
|
127
|
+
/**
|
|
128
|
+
* Waits long enough for multi-hop in-memory worker message delivery in tests.
|
|
129
|
+
*
|
|
130
|
+
* Some flows require several queued macrotasks across worker/message-port
|
|
131
|
+
* boundaries; this helper advances that pipeline deterministically.
|
|
132
|
+
*/
|
|
133
|
+
export const testWaitForWorkerMessage = async () => {
|
|
134
|
+
await testWaitForMacrotask();
|
|
135
|
+
await testWaitForMacrotask();
|
|
136
|
+
};
|
|
137
|
+
const createMemoryWorkerPair = () => {
|
|
138
|
+
const channel = createMessageChannel();
|
|
139
|
+
const self = {
|
|
140
|
+
postMessage: channel.port2.postMessage,
|
|
141
|
+
get onMessage() {
|
|
142
|
+
return channel.port2.onMessage;
|
|
143
|
+
},
|
|
144
|
+
set onMessage(value) {
|
|
145
|
+
channel.port2.onMessage = value;
|
|
146
|
+
},
|
|
147
|
+
native: channel.port2.native,
|
|
148
|
+
[Symbol.dispose]: () => {
|
|
149
|
+
channel.port2[Symbol.dispose]();
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
const worker = {
|
|
153
|
+
postMessage: channel.port1.postMessage,
|
|
154
|
+
get onMessage() {
|
|
155
|
+
return channel.port1.onMessage;
|
|
156
|
+
},
|
|
157
|
+
set onMessage(value) {
|
|
158
|
+
channel.port1.onMessage = value;
|
|
159
|
+
},
|
|
160
|
+
native: channel.port1.native,
|
|
161
|
+
[Symbol.dispose]: () => {
|
|
162
|
+
channel[Symbol.dispose]();
|
|
163
|
+
},
|
|
21
164
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
postMessageTransferableError(error);
|
|
32
|
-
}
|
|
165
|
+
return { worker, self };
|
|
166
|
+
};
|
|
167
|
+
const createMemorySharedWorkerPair = () => {
|
|
168
|
+
const channel = createMessageChannel();
|
|
169
|
+
const self = {
|
|
170
|
+
onConnect: null,
|
|
171
|
+
[Symbol.dispose]: () => {
|
|
172
|
+
self.onConnect = null;
|
|
173
|
+
},
|
|
33
174
|
};
|
|
34
175
|
const worker = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
176
|
+
port: channel.port1,
|
|
177
|
+
[Symbol.dispose]: () => {
|
|
178
|
+
channel[Symbol.dispose]();
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
const connect = () => {
|
|
182
|
+
assert(self.onConnect, "onConnect must be set before receiving connections");
|
|
183
|
+
self.onConnect(channel.port2);
|
|
184
|
+
};
|
|
185
|
+
return { worker, self, connect };
|
|
186
|
+
};
|
|
187
|
+
const createPort = (receive, peerReceive, native) => {
|
|
188
|
+
const scheduleFlush = (state) => {
|
|
189
|
+
if (state.flushScheduled)
|
|
190
|
+
return;
|
|
191
|
+
state.flushScheduled = true;
|
|
192
|
+
// Native worker messages are task-queued; use macrotask timing.
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
state.flushScheduled = false;
|
|
195
|
+
const handler = state.handler;
|
|
196
|
+
if (!handler)
|
|
43
197
|
return;
|
|
198
|
+
for (const message of state.queue.splice(0)) {
|
|
199
|
+
handler(message);
|
|
44
200
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
deps = _deps;
|
|
53
|
-
for (const message of pendingMessages) {
|
|
54
|
-
withErrorReporting(onMessage(deps))(message);
|
|
55
|
-
}
|
|
56
|
-
pendingMessages.length = 0;
|
|
57
|
-
})
|
|
58
|
-
.catch(postMessageTransferableError);
|
|
201
|
+
}, 0);
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
postMessage: (message) => {
|
|
205
|
+
peerReceive.queue.push(message);
|
|
206
|
+
scheduleFlush(peerReceive);
|
|
59
207
|
},
|
|
60
|
-
onMessage
|
|
61
|
-
|
|
208
|
+
get onMessage() {
|
|
209
|
+
return receive.handler;
|
|
210
|
+
},
|
|
211
|
+
set onMessage(fn) {
|
|
212
|
+
receive.handler = fn;
|
|
213
|
+
if (fn)
|
|
214
|
+
scheduleFlush(receive);
|
|
215
|
+
},
|
|
216
|
+
native,
|
|
217
|
+
[Symbol.dispose]: () => {
|
|
218
|
+
receive.handler = null;
|
|
219
|
+
receive.flushScheduled = false;
|
|
62
220
|
},
|
|
63
221
|
};
|
|
64
|
-
return worker;
|
|
65
222
|
};
|
|
223
|
+
const createTestPort = (receive, peerReceive, native) => createPort(receive, peerReceive, native);
|
|
224
|
+
const createNativeMessagePortToken = () => ({});
|
|
66
225
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
226
|
+
* Registry mapping native port tokens to their in-memory port counterparts.
|
|
227
|
+
*
|
|
228
|
+
* When {@link testCreateMessageChannel} creates a pair, both ports are
|
|
229
|
+
* registered here. When {@link testCreateMessagePort} wraps a native token
|
|
230
|
+
* (received via `postMessage` transfer), it looks up the actual port.
|
|
231
|
+
*
|
|
232
|
+
* Uses `WeakMap` so entries are garbage collected when the native token is no
|
|
233
|
+
* longer referenced.
|
|
70
234
|
*/
|
|
71
|
-
|
|
72
|
-
init,
|
|
73
|
-
onMessage: (deps) => (message) => {
|
|
74
|
-
const messageType = message.type;
|
|
75
|
-
const handler = handlers[messageType];
|
|
76
|
-
// TypeScript knows handler exists because handlers covers all non-init message types
|
|
77
|
-
handler(deps)(message);
|
|
78
|
-
},
|
|
79
|
-
});
|
|
235
|
+
const nativePortRegistry = new WeakMap();
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript library and local-first platform.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
export * from "./Array.js";
|
|
2
7
|
export * from "./Assert.js";
|
|
3
8
|
export * from "./BigInt.js";
|
|
@@ -11,25 +16,42 @@ export * from "./Eq.js";
|
|
|
11
16
|
export * from "./Error.js";
|
|
12
17
|
export * from "./Function.js";
|
|
13
18
|
export * from "./Identicon.js";
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
19
|
+
export * from "./Lookup.js";
|
|
20
|
+
export * from "./Microtask.js";
|
|
16
21
|
export * from "./Number.js";
|
|
17
22
|
export * from "./Object.js";
|
|
23
|
+
export * from "./Option.js";
|
|
18
24
|
export * from "./Order.js";
|
|
19
25
|
export * from "./Platform.js";
|
|
20
26
|
export * from "./Random.js";
|
|
21
27
|
export * from "./Redacted.js";
|
|
22
28
|
export * from "./Ref.js";
|
|
29
|
+
export * from "./RefCount.js";
|
|
23
30
|
export * from "./Relation.js";
|
|
24
|
-
export * from "./
|
|
31
|
+
export * from "./Resource.js";
|
|
25
32
|
export * from "./Result.js";
|
|
33
|
+
export * from "./Set.js";
|
|
26
34
|
export * from "./Sqlite.js";
|
|
27
35
|
export * from "./Store.js";
|
|
28
36
|
export * from "./String.js";
|
|
29
37
|
export * from "./Task.js";
|
|
38
|
+
export * from "./Test.js";
|
|
30
39
|
export * from "./Time.js";
|
|
40
|
+
export * from "./Tracer.js";
|
|
31
41
|
export * from "./Type.js";
|
|
32
42
|
export * from "./Types.js";
|
|
33
43
|
export * from "./WebSocket.js";
|
|
34
44
|
export * from "./Worker.js";
|
|
45
|
+
export type { EvoluError } from "./local-first/Error.js";
|
|
46
|
+
export { AppName, createEvolu } from "./local-first/Evolu.js";
|
|
47
|
+
export type { AppNameError, Evolu, EvoluConfig, EvoluDeps, UnuseOwner, } from "./local-first/Evolu.js";
|
|
48
|
+
export * from "./local-first/LocalAuth.js";
|
|
49
|
+
export * from "./local-first/Owner.js";
|
|
50
|
+
export type { SyncOwner } from "./local-first/Owner.js";
|
|
51
|
+
export { evoluJsonArrayFrom, evoluJsonBuildObject, evoluJsonObjectFrom, getJsonObjectArgs, kyselySql, type InferRow, type KyselyNotNull, type Query, type QueryRows, type Row, } from "./local-first/Query.js";
|
|
52
|
+
export { createQueryBuilder } from "./local-first/Schema.js";
|
|
53
|
+
export type { AnyStandardSchemaV1, EvoluSchema, InsertValues, Mutation, MutationKind, MutationOptions, MutationValues, NullableColumnsToOptional, OptionalColumnKeys, RequiredColumnKeys, TableSchema, UpdateValues, UpsertValues, } from "./local-first/Schema.js";
|
|
54
|
+
export type { SyncState, } from "./local-first/Shared.js";
|
|
55
|
+
export { Timestamp, timestampBytesToTimestamp, timestampToTimestampBytes, } from "./local-first/Timestamp.js";
|
|
56
|
+
export type { TimestampBytes, TimestampCounterOverflowError, TimestampDriftError, TimestampError, TimestampTimeOutOfRangeError, } from "./local-first/Timestamp.js";
|
|
35
57
|
//# 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,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
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,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CA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Y,EACV,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAIV,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,SAAS,EACT,yBAAyB,EACzB,yBAAyB,GAC1B,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,cAAc,EACd,6BAA6B,EAC7B,mBAAmB,EACnB,cAAc,EACd,4BAA4B,GAC7B,MAAM,4BAA4B,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript library and local-first platform.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
1
6
|
export * from "./Array.js";
|
|
2
7
|
export * from "./Assert.js";
|
|
3
8
|
export * from "./BigInt.js";
|
|
@@ -11,24 +16,35 @@ export * from "./Eq.js";
|
|
|
11
16
|
export * from "./Error.js";
|
|
12
17
|
export * from "./Function.js";
|
|
13
18
|
export * from "./Identicon.js";
|
|
14
|
-
export * from "./
|
|
15
|
-
export * from "./
|
|
19
|
+
export * from "./Lookup.js";
|
|
20
|
+
export * from "./Microtask.js";
|
|
16
21
|
export * from "./Number.js";
|
|
17
22
|
export * from "./Object.js";
|
|
23
|
+
export * from "./Option.js";
|
|
18
24
|
export * from "./Order.js";
|
|
19
25
|
export * from "./Platform.js";
|
|
20
26
|
export * from "./Random.js";
|
|
21
27
|
export * from "./Redacted.js";
|
|
22
28
|
export * from "./Ref.js";
|
|
29
|
+
export * from "./RefCount.js";
|
|
23
30
|
export * from "./Relation.js";
|
|
24
|
-
export * from "./
|
|
31
|
+
export * from "./Resource.js";
|
|
25
32
|
export * from "./Result.js";
|
|
33
|
+
export * from "./Set.js";
|
|
26
34
|
export * from "./Sqlite.js";
|
|
27
35
|
export * from "./Store.js";
|
|
28
36
|
export * from "./String.js";
|
|
29
37
|
export * from "./Task.js";
|
|
38
|
+
export * from "./Test.js";
|
|
30
39
|
export * from "./Time.js";
|
|
40
|
+
export * from "./Tracer.js";
|
|
31
41
|
export * from "./Type.js";
|
|
32
42
|
export * from "./Types.js";
|
|
33
43
|
export * from "./WebSocket.js";
|
|
34
44
|
export * from "./Worker.js";
|
|
45
|
+
export { AppName, createEvolu } from "./local-first/Evolu.js";
|
|
46
|
+
export * from "./local-first/LocalAuth.js";
|
|
47
|
+
export * from "./local-first/Owner.js";
|
|
48
|
+
export { evoluJsonArrayFrom, evoluJsonBuildObject, evoluJsonObjectFrom, getJsonObjectArgs, kyselySql, } from "./local-first/Query.js";
|
|
49
|
+
export { createQueryBuilder } from "./local-first/Schema.js";
|
|
50
|
+
export { Timestamp, timestampBytesToTimestamp, timestampToTimestampBytes, } from "./local-first/Timestamp.js";
|