@evolu/common 8.15.1 → 8.16.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/Console.d.ts +24 -46
- package/dist/src/Console.d.ts.map +1 -1
- package/dist/src/Console.js +34 -29
- package/dist/src/Error.d.ts +10 -6
- package/dist/src/Error.d.ts.map +1 -1
- package/dist/src/Error.js +52 -20
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +16 -12
- package/dist/src/Task.d.ts +3 -1
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +15 -13
- package/dist/src/Worker.d.ts +3 -0
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +6 -1
- package/dist/src/local-first/Db.d.ts.map +1 -1
- package/dist/src/local-first/Db.js +7 -7
- package/dist/src/local-first/Shared.d.ts +55 -39
- package/dist/src/local-first/Shared.d.ts.map +1 -1
- package/dist/src/local-first/Shared.js +264 -318
- package/package.json +1 -1
- package/src/Console.test.ts +75 -247
- package/src/Console.ts +68 -110
- package/src/Error.test.ts +85 -0
- package/src/Error.ts +48 -22
- package/src/Sqlite.ts +19 -11
- package/src/Task.test.ts +46 -0
- package/src/Task.ts +17 -13
- package/src/Worker.ts +6 -1
- package/src/local-first/Db.ts +12 -8
- package/src/local-first/Shared.test.ts +414 -39
- package/src/local-first/Shared.ts +386 -438
package/src/Worker.ts
CHANGED
|
@@ -656,6 +656,9 @@ export const testCreateMessagePort: CreateMessagePort = <Input, Output = never>(
|
|
|
656
656
|
/**
|
|
657
657
|
* Creates an in-memory {@link BroadcastChannel} for testing.
|
|
658
658
|
*
|
|
659
|
+
* Like a native channel, it structured-clones each message, so posting a value
|
|
660
|
+
* that cannot be cloned throws.
|
|
661
|
+
*
|
|
659
662
|
* @group Testing
|
|
660
663
|
*/
|
|
661
664
|
export const testCreateBroadcastChannel = <Input, Output = Input>(
|
|
@@ -667,7 +670,9 @@ export const testCreateBroadcastChannel = <Input, Output = Input>(
|
|
|
667
670
|
const disposables = disposer.move();
|
|
668
671
|
|
|
669
672
|
return {
|
|
670
|
-
postMessage:
|
|
673
|
+
postMessage: (message) => {
|
|
674
|
+
channel.postMessage(structuredClone(message));
|
|
675
|
+
},
|
|
671
676
|
get onMessage() {
|
|
672
677
|
return channel.onMessage;
|
|
673
678
|
},
|
package/src/local-first/Db.ts
CHANGED
|
@@ -137,7 +137,10 @@ import type {
|
|
|
137
137
|
EvoluInput,
|
|
138
138
|
SharedWorkerId,
|
|
139
139
|
} from "./Shared.ts";
|
|
140
|
-
import {
|
|
140
|
+
import {
|
|
141
|
+
consoleEntryOrErrorBroadcastChannelName,
|
|
142
|
+
postConsoleEntry,
|
|
143
|
+
} from "./Shared.ts";
|
|
141
144
|
import {
|
|
142
145
|
createBaseSqliteStorage,
|
|
143
146
|
createBaseSqliteStorageTables,
|
|
@@ -229,6 +232,13 @@ export const startDbWorker =
|
|
|
229
232
|
self.onMessage = (message) => resolve(ok(message));
|
|
230
233
|
}),
|
|
231
234
|
);
|
|
235
|
+
// Tabs report the errors this worker logs as an UnknownError, so it
|
|
236
|
+
// forwards them even for a silent app, whose tabs do not print them.
|
|
237
|
+
deps.console.setLevel(
|
|
238
|
+
initMessage.consoleLevel === "silent"
|
|
239
|
+
? "error"
|
|
240
|
+
: initMessage.consoleLevel,
|
|
241
|
+
);
|
|
232
242
|
|
|
233
243
|
const port = disposer.use(
|
|
234
244
|
deps.createMessagePort<DbWorkerOutput, DbWorkerInput>(initMessage.port),
|
|
@@ -242,11 +252,7 @@ export const startDbWorker =
|
|
|
242
252
|
disposer.defer(
|
|
243
253
|
deps.consoleStoreOutputEntry.subscribe(() => {
|
|
244
254
|
const entry = deps.consoleStoreOutputEntry.get();
|
|
245
|
-
if (entry)
|
|
246
|
-
consoleEntryOrErrorBroadcastChannel.postMessage({
|
|
247
|
-
type: "ConsoleEntry",
|
|
248
|
-
entry,
|
|
249
|
-
});
|
|
255
|
+
if (entry) postConsoleEntry(consoleEntryOrErrorBroadcastChannel, entry);
|
|
250
256
|
}),
|
|
251
257
|
);
|
|
252
258
|
|
|
@@ -310,7 +316,6 @@ export const startDbWorker =
|
|
|
310
316
|
// waits on. The tab leader lock is unaffected.
|
|
311
317
|
port.postMessage({
|
|
312
318
|
type: "LeaderRefused",
|
|
313
|
-
name: initMessage.name,
|
|
314
319
|
error: startup.error,
|
|
315
320
|
});
|
|
316
321
|
return ok();
|
|
@@ -322,7 +327,6 @@ export const startDbWorker =
|
|
|
322
327
|
|
|
323
328
|
port.postMessage({
|
|
324
329
|
type: "LeaderAcquired",
|
|
325
|
-
name: initMessage.name,
|
|
326
330
|
clock: initialClock,
|
|
327
331
|
});
|
|
328
332
|
|