@evolu/common 8.0.0-next.3 → 8.0.0-next.4
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/Assert.d.ts +5 -5
- package/dist/src/Assert.d.ts.map +1 -1
- package/dist/src/Assert.js +4 -4
- package/dist/src/Identicon.js +4 -4
- package/dist/src/LockManager.d.ts +74 -0
- package/dist/src/LockManager.d.ts.map +1 -0
- package/dist/src/LockManager.js +103 -0
- package/dist/src/Microtask.d.ts.map +1 -1
- package/dist/src/Microtask.js +90 -26
- package/dist/src/Object.d.ts.map +1 -1
- package/dist/src/RefCount.d.ts.map +1 -1
- package/dist/src/RefCount.js +153 -68
- package/dist/src/Resource.d.ts +6 -6
- package/dist/src/Resource.d.ts.map +1 -1
- package/dist/src/Resource.js +211 -162
- package/dist/src/Schedule.d.ts +5 -5
- package/dist/src/Schedule.d.ts.map +1 -1
- package/dist/src/Schedule.js +53 -44
- package/dist/src/Sqlite.d.ts +2 -0
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +64 -40
- package/dist/src/Task.d.ts +6 -33
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +213 -204
- package/dist/src/Test.d.ts +4 -4
- package/dist/src/Time.d.ts +5 -0
- package/dist/src/Time.d.ts.map +1 -1
- package/dist/src/Time.js +5 -0
- package/dist/src/Type.d.ts +7 -0
- package/dist/src/Type.d.ts.map +1 -1
- package/dist/src/Type.js +7 -0
- package/dist/src/WebSocket.d.ts.map +1 -1
- package/dist/src/WebSocket.js +7 -6
- package/dist/src/Worker.d.ts +42 -8
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +292 -112
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/local-first/Db.d.ts +5 -4
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +44 -38
- package/dist/src/local-first/Evolu.d.ts +3 -2
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +90 -80
- package/dist/src/local-first/Owner.d.ts.map +1 -1
- package/dist/src/local-first/Shared.d.ts +65 -54
- package/dist/src/local-first/Shared.d.ts.map +1 -1
- package/dist/src/local-first/Shared.js +387 -373
- package/package.json +1 -1
- package/src/Array.ts +8 -8
- package/src/Assert.ts +5 -5
- package/src/Identicon.ts +4 -4
- package/src/LockManager.ts +181 -0
- package/src/Microtask.ts +17 -11
- package/src/Object.ts +3 -3
- package/src/RefCount.ts +25 -21
- package/src/Resource.ts +63 -56
- package/src/Schedule.ts +70 -48
- package/src/Set.ts +4 -4
- package/src/Sqlite.ts +41 -30
- package/src/Task.ts +77 -120
- package/src/Test.ts +4 -4
- package/src/Time.ts +7 -0
- package/src/Type.ts +9 -0
- package/src/WebSocket.ts +7 -6
- package/src/Worker.ts +195 -53
- package/src/index.ts +1 -0
- package/src/local-first/Db.ts +69 -46
- package/src/local-first/Evolu.ts +74 -68
- package/src/local-first/Owner.ts +1 -1
- package/src/local-first/Query.ts +1 -1
- package/src/local-first/Shared.ts +472 -464
package/dist/src/Worker.js
CHANGED
|
@@ -1,9 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Typed, disposable worker and messaging primitives.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
7
|
+
if (value !== null && value !== void 0) {
|
|
8
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
9
|
+
var dispose, inner;
|
|
10
|
+
if (async) {
|
|
11
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
12
|
+
dispose = value[Symbol.asyncDispose];
|
|
13
|
+
}
|
|
14
|
+
if (dispose === void 0) {
|
|
15
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16
|
+
dispose = value[Symbol.dispose];
|
|
17
|
+
if (async) inner = dispose;
|
|
18
|
+
}
|
|
19
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
20
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
21
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
22
|
+
}
|
|
23
|
+
else if (async) {
|
|
24
|
+
env.stack.push({ async: true });
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
29
|
+
return function (env) {
|
|
30
|
+
function fail(e) {
|
|
31
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
32
|
+
env.hasError = true;
|
|
33
|
+
}
|
|
34
|
+
var r, s = 0;
|
|
35
|
+
function next() {
|
|
36
|
+
while (r = env.stack.pop()) {
|
|
37
|
+
try {
|
|
38
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
39
|
+
if (r.dispose) {
|
|
40
|
+
var result = r.dispose.call(r.value);
|
|
41
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
42
|
+
}
|
|
43
|
+
else s |= 1;
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
fail(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
50
|
+
if (env.hasError) throw env.error;
|
|
51
|
+
}
|
|
52
|
+
return next();
|
|
53
|
+
};
|
|
54
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
55
|
+
var e = new Error(message);
|
|
56
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
57
|
+
});
|
|
58
|
+
import { assert, assertNotDisposed } from "./Assert.js";
|
|
7
59
|
import { testWaitForMacrotask } from "./Test.js";
|
|
8
60
|
/**
|
|
9
61
|
* Creates an in-memory {@link Worker}.
|
|
@@ -38,46 +90,55 @@ export const createSharedWorker = (initWorker) => {
|
|
|
38
90
|
* support. Message delivery is asynchronous in-process.
|
|
39
91
|
*/
|
|
40
92
|
export const createMessageChannel = () => {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
94
|
+
try {
|
|
95
|
+
const state1 = {
|
|
96
|
+
handler: null,
|
|
97
|
+
queue: [],
|
|
98
|
+
flushScheduled: false,
|
|
99
|
+
flushTimeoutId: null,
|
|
100
|
+
ownerCount: 0,
|
|
101
|
+
pendingTransferCount: 0,
|
|
102
|
+
};
|
|
103
|
+
const state2 = {
|
|
104
|
+
handler: null,
|
|
105
|
+
queue: [],
|
|
106
|
+
flushScheduled: false,
|
|
107
|
+
flushTimeoutId: null,
|
|
108
|
+
ownerCount: 0,
|
|
109
|
+
pendingTransferCount: 0,
|
|
110
|
+
};
|
|
111
|
+
const native1 = createNativeMessagePortToken();
|
|
112
|
+
const native2 = createNativeMessagePortToken();
|
|
113
|
+
const port1Registration = {
|
|
114
|
+
receive: state1,
|
|
115
|
+
peerReceive: state2,
|
|
116
|
+
native: native1,
|
|
117
|
+
};
|
|
118
|
+
const port2Registration = {
|
|
119
|
+
receive: state2,
|
|
120
|
+
peerReceive: state1,
|
|
121
|
+
native: native2,
|
|
122
|
+
};
|
|
123
|
+
const disposer = __addDisposableResource(env_1, new DisposableStack(), false);
|
|
124
|
+
const port1 = disposer.use(createTestPort(port1Registration));
|
|
125
|
+
const port2 = disposer.use(createTestPort(port2Registration));
|
|
126
|
+
const disposables = disposer.move();
|
|
127
|
+
nativePortRegistry.set(native1, port1Registration);
|
|
128
|
+
nativePortRegistry.set(native2, port2Registration);
|
|
129
|
+
return {
|
|
130
|
+
port1,
|
|
131
|
+
port2,
|
|
132
|
+
[Symbol.dispose]: () => disposables.dispose(),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
catch (e_1) {
|
|
136
|
+
env_1.error = e_1;
|
|
137
|
+
env_1.hasError = true;
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
__disposeResources(env_1);
|
|
141
|
+
}
|
|
81
142
|
};
|
|
82
143
|
/**
|
|
83
144
|
* Creates an in-memory {@link MessagePort} from a native token.
|
|
@@ -90,6 +151,68 @@ export const createMessagePort = (nativePort) => {
|
|
|
90
151
|
assert(registration, "Unknown native port — did you transfer it?");
|
|
91
152
|
return createTestPort(registration);
|
|
92
153
|
};
|
|
154
|
+
/**
|
|
155
|
+
* Creates an in-memory {@link BroadcastChannel}.
|
|
156
|
+
*
|
|
157
|
+
* This is a memory-only fallback for platforms without native BroadcastChannel
|
|
158
|
+
* support. Message delivery is asynchronous in-process.
|
|
159
|
+
*/
|
|
160
|
+
export const createBroadcastChannel = (name) => {
|
|
161
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
162
|
+
try {
|
|
163
|
+
let onMessageHandler = null;
|
|
164
|
+
const dispatch = (message) => {
|
|
165
|
+
onMessageHandler?.(message);
|
|
166
|
+
};
|
|
167
|
+
let dispatches = broadcastChannelDispatchesByName.get(name);
|
|
168
|
+
if (!dispatches) {
|
|
169
|
+
dispatches = new Set();
|
|
170
|
+
broadcastChannelDispatchesByName.set(name, dispatches);
|
|
171
|
+
}
|
|
172
|
+
dispatches.add(dispatch);
|
|
173
|
+
const disposer = __addDisposableResource(env_2, new DisposableStack(), false);
|
|
174
|
+
disposer.defer(() => {
|
|
175
|
+
onMessageHandler = null;
|
|
176
|
+
dispatches.delete(dispatch);
|
|
177
|
+
if (dispatches.size === 0)
|
|
178
|
+
broadcastChannelDispatchesByName.delete(name);
|
|
179
|
+
});
|
|
180
|
+
const disposables = disposer.move();
|
|
181
|
+
return {
|
|
182
|
+
postMessage: (message) => {
|
|
183
|
+
assertNotDisposed(disposables);
|
|
184
|
+
const dispatches = broadcastChannelDispatchesByName.get(name);
|
|
185
|
+
assert(dispatches, "Expected broadcast channel dispatches");
|
|
186
|
+
for (const otherDispatch of [...dispatches]) {
|
|
187
|
+
if (otherDispatch === dispatch)
|
|
188
|
+
continue;
|
|
189
|
+
globalThis.setTimeout(() => {
|
|
190
|
+
if (!dispatches.has(otherDispatch))
|
|
191
|
+
return;
|
|
192
|
+
otherDispatch(message);
|
|
193
|
+
}, 0);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
get onMessage() {
|
|
197
|
+
return disposables.disposed ? null : onMessageHandler;
|
|
198
|
+
},
|
|
199
|
+
set onMessage(fn) {
|
|
200
|
+
if (disposables.disposed)
|
|
201
|
+
return;
|
|
202
|
+
onMessageHandler = fn;
|
|
203
|
+
},
|
|
204
|
+
[Symbol.dispose]: () => disposables.dispose(),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
catch (e_2) {
|
|
208
|
+
env_2.error = e_2;
|
|
209
|
+
env_2.hasError = true;
|
|
210
|
+
}
|
|
211
|
+
finally {
|
|
212
|
+
__disposeResources(env_2);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const broadcastChannelDispatchesByName = new Map();
|
|
93
216
|
/**
|
|
94
217
|
* Creates a connected {@link TestWorker} for testing.
|
|
95
218
|
*
|
|
@@ -126,25 +249,62 @@ export const testCreateSharedWorker = () => {
|
|
|
126
249
|
* {@link testCreateMessagePort} can look them up by their native token.
|
|
127
250
|
*/
|
|
128
251
|
export const testCreateMessageChannel = () => {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
252
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
253
|
+
try {
|
|
254
|
+
const disposer = __addDisposableResource(env_3, new DisposableStack(), false);
|
|
255
|
+
const channel = disposer.use(createMessageChannel());
|
|
256
|
+
const disposables = disposer.move();
|
|
257
|
+
return {
|
|
258
|
+
port1: channel.port1,
|
|
259
|
+
port2: channel.port2,
|
|
260
|
+
isDisposed: () => disposables.disposed,
|
|
261
|
+
[Symbol.dispose]: () => disposables.dispose(),
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
catch (e_3) {
|
|
265
|
+
env_3.error = e_3;
|
|
266
|
+
env_3.hasError = true;
|
|
267
|
+
}
|
|
268
|
+
finally {
|
|
269
|
+
__disposeResources(env_3);
|
|
270
|
+
}
|
|
140
271
|
};
|
|
141
272
|
/** Creates an in-memory {@link CreateMessagePort} for testing. */
|
|
142
273
|
export const testCreateMessagePort = (nativePort) => createMessagePort(nativePort);
|
|
274
|
+
/** Creates an in-memory {@link BroadcastChannel} for testing. */
|
|
275
|
+
export const testCreateBroadcastChannel = (name) => {
|
|
276
|
+
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
277
|
+
try {
|
|
278
|
+
const disposer = __addDisposableResource(env_4, new DisposableStack(), false);
|
|
279
|
+
const channel = disposer.use(createBroadcastChannel(name));
|
|
280
|
+
const disposables = disposer.move();
|
|
281
|
+
return {
|
|
282
|
+
postMessage: channel.postMessage,
|
|
283
|
+
get onMessage() {
|
|
284
|
+
return channel.onMessage;
|
|
285
|
+
},
|
|
286
|
+
set onMessage(value) {
|
|
287
|
+
channel.onMessage = value;
|
|
288
|
+
},
|
|
289
|
+
isDisposed: () => disposables.disposed,
|
|
290
|
+
[Symbol.dispose]: () => disposables.dispose(),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
catch (e_4) {
|
|
294
|
+
env_4.error = e_4;
|
|
295
|
+
env_4.hasError = true;
|
|
296
|
+
}
|
|
297
|
+
finally {
|
|
298
|
+
__disposeResources(env_4);
|
|
299
|
+
}
|
|
300
|
+
};
|
|
143
301
|
/**
|
|
144
|
-
* Waits
|
|
302
|
+
* Waits the minimal time necessary for in-memory worker message delivery in
|
|
303
|
+
* tests.
|
|
145
304
|
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
305
|
+
* This is better than `vi.waitFor` when a test only needs to flush the known
|
|
306
|
+
* in-memory worker/message-port pipeline. It encodes that transport boundary
|
|
307
|
+
* once, avoids polling, and keeps worker-focused tests fast and explicit.
|
|
148
308
|
*/
|
|
149
309
|
export const testWaitForWorkerMessage = async () => {
|
|
150
310
|
await testWaitForMacrotask();
|
|
@@ -201,67 +361,87 @@ const createMemorySharedWorkerPair = () => {
|
|
|
201
361
|
return { worker, self, connect };
|
|
202
362
|
};
|
|
203
363
|
const createPort = ({ receive, peerReceive, native, }) => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
state.flushScheduled = false;
|
|
215
|
-
if (state.closed)
|
|
364
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
365
|
+
try {
|
|
366
|
+
const disposer = __addDisposableResource(env_5, new DisposableStack(), false);
|
|
367
|
+
if (receive.pendingTransferCount > 0)
|
|
368
|
+
receive.pendingTransferCount -= 1;
|
|
369
|
+
else
|
|
370
|
+
receive.ownerCount += 1;
|
|
371
|
+
disposer.defer(() => {
|
|
372
|
+
receive.ownerCount -= 1;
|
|
373
|
+
if (receive.ownerCount > 0)
|
|
216
374
|
return;
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
handler(message);
|
|
375
|
+
nativePortRegistry.delete(native);
|
|
376
|
+
if (receive.flushTimeoutId != null) {
|
|
377
|
+
globalThis.clearTimeout(receive.flushTimeoutId);
|
|
378
|
+
receive.flushTimeoutId = null;
|
|
222
379
|
}
|
|
223
|
-
}, 0);
|
|
224
|
-
};
|
|
225
|
-
return {
|
|
226
|
-
postMessage: (message, transfer) => {
|
|
227
|
-
for (const transferable of transfer ?? []) {
|
|
228
|
-
if (transferable instanceof globalThis.ArrayBuffer)
|
|
229
|
-
continue;
|
|
230
|
-
const registration = nativePortRegistry.get(transferable);
|
|
231
|
-
if (!registration)
|
|
232
|
-
continue;
|
|
233
|
-
registration.receive.pendingTransferCount += 1;
|
|
234
|
-
registration.receive.closed = false;
|
|
235
|
-
}
|
|
236
|
-
if (peerReceive.closed)
|
|
237
|
-
return;
|
|
238
|
-
peerReceive.queue.push(message);
|
|
239
|
-
scheduleFlush(peerReceive);
|
|
240
|
-
},
|
|
241
|
-
get onMessage() {
|
|
242
|
-
return isDisposed ? null : receive.handler;
|
|
243
|
-
},
|
|
244
|
-
set onMessage(fn) {
|
|
245
|
-
if (isDisposed || receive.closed)
|
|
246
|
-
return;
|
|
247
|
-
receive.handler = fn;
|
|
248
|
-
if (fn)
|
|
249
|
-
scheduleFlush(receive);
|
|
250
|
-
},
|
|
251
|
-
native,
|
|
252
|
-
[Symbol.dispose]: () => {
|
|
253
|
-
if (isDisposed)
|
|
254
|
-
return;
|
|
255
|
-
isDisposed = true;
|
|
256
|
-
receive.refCount -= 1;
|
|
257
|
-
if (receive.refCount > 0 || receive.pendingTransferCount > 0)
|
|
258
|
-
return;
|
|
259
|
-
receive.closed = true;
|
|
260
380
|
receive.handler = null;
|
|
261
381
|
receive.flushScheduled = false;
|
|
262
382
|
receive.queue.length = 0;
|
|
263
|
-
}
|
|
264
|
-
|
|
383
|
+
});
|
|
384
|
+
const disposables = disposer.move();
|
|
385
|
+
const scheduleFlush = (state) => {
|
|
386
|
+
if (state.flushScheduled || state.ownerCount === 0)
|
|
387
|
+
return;
|
|
388
|
+
state.flushScheduled = true;
|
|
389
|
+
// Native worker messages are task-queued; use macrotask timing.
|
|
390
|
+
state.flushTimeoutId = globalThis.setTimeout(() => {
|
|
391
|
+
state.flushTimeoutId = null;
|
|
392
|
+
state.flushScheduled = false;
|
|
393
|
+
if (state.ownerCount === 0)
|
|
394
|
+
return;
|
|
395
|
+
const firstHandler = state.handler;
|
|
396
|
+
if (!firstHandler)
|
|
397
|
+
return;
|
|
398
|
+
for (const message of state.queue.splice(0)) {
|
|
399
|
+
const handler = state.handler;
|
|
400
|
+
if (!handler)
|
|
401
|
+
return;
|
|
402
|
+
handler(message);
|
|
403
|
+
}
|
|
404
|
+
}, 0);
|
|
405
|
+
};
|
|
406
|
+
return {
|
|
407
|
+
postMessage: (message, transfer) => {
|
|
408
|
+
if (disposables.disposed ||
|
|
409
|
+
receive.ownerCount === 0 ||
|
|
410
|
+
peerReceive.ownerCount === 0)
|
|
411
|
+
return;
|
|
412
|
+
for (const transferable of transfer ?? []) {
|
|
413
|
+
if (transferable instanceof globalThis.ArrayBuffer)
|
|
414
|
+
continue;
|
|
415
|
+
const registration = nativePortRegistry.get(transferable);
|
|
416
|
+
if (!registration)
|
|
417
|
+
continue;
|
|
418
|
+
registration.receive.ownerCount += 1;
|
|
419
|
+
registration.receive.pendingTransferCount += 1;
|
|
420
|
+
}
|
|
421
|
+
peerReceive.queue.push(message);
|
|
422
|
+
scheduleFlush(peerReceive);
|
|
423
|
+
},
|
|
424
|
+
get onMessage() {
|
|
425
|
+
return disposables.disposed ? null : receive.handler;
|
|
426
|
+
},
|
|
427
|
+
set onMessage(fn) {
|
|
428
|
+
if (disposables.disposed || receive.ownerCount === 0)
|
|
429
|
+
return;
|
|
430
|
+
receive.handler = fn;
|
|
431
|
+
if (fn)
|
|
432
|
+
scheduleFlush(receive);
|
|
433
|
+
},
|
|
434
|
+
native,
|
|
435
|
+
[Symbol.dispose]: () => disposables.dispose(),
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
catch (e_5) {
|
|
439
|
+
env_5.error = e_5;
|
|
440
|
+
env_5.hasError = true;
|
|
441
|
+
}
|
|
442
|
+
finally {
|
|
443
|
+
__disposeResources(env_5);
|
|
444
|
+
}
|
|
265
445
|
};
|
|
266
446
|
const createTestPort = (registration) => createPort(registration);
|
|
267
447
|
const createNativeMessagePortToken = () => ({});
|
package/dist/src/index.d.ts
CHANGED
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,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,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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Y,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EACV,YAAY,EACZ,KAAK,EACL,WAAW,EACX,SAAS,EACT,UAAU,GACX,MAAM,wBAAwB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,YAAY,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,SAAS,EACT,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,SAAS,EACd,KAAK,GAAG,GACT,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,YAAY,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
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ConsoleLevel } from "../Console.js";
|
|
7
7
|
import { EncryptionKey } from "../Crypto.js";
|
|
8
|
+
import type { LockManagerDep } from "../LockManager.js";
|
|
8
9
|
import type { CreateSqliteDriverDep, SqliteSchema } from "../Sqlite.js";
|
|
9
|
-
import { type
|
|
10
|
+
import { type Task } from "../Task.js";
|
|
10
11
|
import type { Name } from "../Type.js";
|
|
11
|
-
import type { NativeMessagePort, Worker, WorkerDeps, WorkerSelf } from "../Worker.js";
|
|
12
|
+
import type { CreateBroadcastChannelDep, NativeMessagePort, Worker, WorkerDeps, WorkerSelf } from "../Worker.js";
|
|
12
13
|
import type { DbWorkerInput, DbWorkerOutput } from "./Shared.js";
|
|
13
14
|
export type DbWorker = Worker<DbWorkerInit>;
|
|
14
15
|
export interface DbWorkerInit {
|
|
15
|
-
readonly type: "
|
|
16
|
+
readonly type: "DbWorkerInit";
|
|
16
17
|
readonly name: Name;
|
|
17
18
|
readonly consoleLevel: ConsoleLevel;
|
|
18
19
|
readonly sqliteSchema: SqliteSchema;
|
|
@@ -24,6 +25,6 @@ export type CreateDbWorker = () => DbWorker;
|
|
|
24
25
|
export interface CreateDbWorkerDep {
|
|
25
26
|
readonly createDbWorker: CreateDbWorker;
|
|
26
27
|
}
|
|
27
|
-
export type DbWorkerDeps = WorkerDeps &
|
|
28
|
+
export type DbWorkerDeps = WorkerDeps & CreateBroadcastChannelDep & LockManagerDep & CreateSqliteDriverDep;
|
|
28
29
|
export declare const startDbWorker: (self: WorkerSelf<DbWorkerInit>) => Task<void, never, DbWorkerDeps>;
|
|
29
30
|
//# sourceMappingURL=Db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Db.d.ts","sourceRoot":"","sources":["../../../src/local-first/Db.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,aAAa,EAGd,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Db.d.ts","sourceRoot":"","sources":["../../../src/local-first/Db.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,aAAa,EAGd,MAAM,cA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