@evolu/web 3.0.1 → 3.1.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/Platform.d.ts +2 -0
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +6 -0
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +8 -2
- package/dist/src/Task.d.ts +12 -2
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +11 -2
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/local-first/LocalAuth.js +6 -3
- package/package.json +2 -2
- package/src/Platform.ts +9 -0
- package/src/Sqlite.ts +14 -2
- package/src/Task.ts +13 -2
- package/src/Worker.ts +12 -3
- package/src/index.ts +1 -1
- package/src/local-first/LocalAuth.ts +6 -3
package/dist/src/Platform.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { PositiveInt, type ReloadApp } from "@evolu/common";
|
|
2
|
+
/** Returns true when the browser runs on an Apple platform. */
|
|
3
|
+
export declare const isApplePlatform: () => boolean;
|
|
2
4
|
/** Returns the amount of logical processors available to the browser. */
|
|
3
5
|
export declare const availableParallelism: () => PositiveInt;
|
|
4
6
|
export declare const reloadApp: ReloadApp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../src/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAE5D,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,QAAO,WACuB,CAAC;AAEhE,eAAO,MAAM,SAAS,EAAE,SAMvB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../src/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAC;AAE5D,+DAA+D;AAC/D,eAAO,MAAM,eAAe,QAAO,OAMlC,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,QAAO,WACuB,CAAC;AAEhE,eAAO,MAAM,SAAS,EAAE,SAMvB,CAAC"}
|
package/dist/src/Platform.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { PositiveInt } from "@evolu/common";
|
|
2
|
+
/** Returns true when the browser runs on an Apple platform. */
|
|
3
|
+
export const isApplePlatform = () => {
|
|
4
|
+
const platform = globalThis.navigator.userAgentData?.platform ??
|
|
5
|
+
globalThis.navigator.platform;
|
|
6
|
+
return /^(?:Mac|iPhone|iPad|iPod)/iu.test(platform);
|
|
7
|
+
};
|
|
2
8
|
/** Returns the amount of logical processors available to the browser. */
|
|
3
9
|
export const availableParallelism = () => PositiveInt.orThrow(globalThis.navigator.hardwareConcurrency);
|
|
4
10
|
export const reloadApp = (url) => {
|
package/dist/src/Sqlite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sqlite.d.ts","sourceRoot":"","sources":["../../src/Sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"Sqlite.d.ts","sourceRoot":"","sources":["../../src/Sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,eAAe,CAAC;AAiCnE,eAAO,MAAM,sBAAsB,EAAE,kBAoHlC,CAAC"}
|
package/dist/src/Sqlite.js
CHANGED
|
@@ -50,7 +50,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
50
50
|
var e = new Error(message);
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
|
-
import { bytesToHex, createPreparedStatementsCache, ok } from "@evolu/common";
|
|
53
|
+
import { bytesToHex, createPreparedStatementsCache, exhaustiveCheck, ok, } from "@evolu/common";
|
|
54
54
|
import sqlite3InitModule, {} from "@evolu/sqlite-wasm";
|
|
55
55
|
// @ts-expect-error Missing types.
|
|
56
56
|
globalThis.sqlite3ApiConfig = {
|
|
@@ -90,6 +90,7 @@ export const createWasmSqliteDriver = (name, options) => async () => {
|
|
|
90
90
|
let db;
|
|
91
91
|
switch (options?.mode) {
|
|
92
92
|
case "memory":
|
|
93
|
+
// oxlint-disable-next-line react/rules-of-hooks -- useDatabase registers disposal and is not a React Hook.
|
|
93
94
|
db = useDatabase(new sqlite3.oo1.DB(":memory:"));
|
|
94
95
|
break;
|
|
95
96
|
case "encrypted": {
|
|
@@ -100,6 +101,7 @@ export const createWasmSqliteDriver = (name, options) => async () => {
|
|
|
100
101
|
const pool = await createOpfsSAHPoolVfs({
|
|
101
102
|
directory: `.${name}`,
|
|
102
103
|
});
|
|
104
|
+
// oxlint-disable-next-line react/rules-of-hooks -- useDatabase registers disposal and is not a React Hook.
|
|
103
105
|
db = useDatabase(new pool.OpfsSAHPoolDb(
|
|
104
106
|
// SQLite normalizes this URI filename to SAH-pool path "/evolu1.db".
|
|
105
107
|
`file:${fileName}?vfs=multipleciphers-opfs-sahpool`));
|
|
@@ -109,10 +111,14 @@ export const createWasmSqliteDriver = (name, options) => async () => {
|
|
|
109
111
|
`);
|
|
110
112
|
break;
|
|
111
113
|
}
|
|
112
|
-
|
|
114
|
+
case undefined: {
|
|
113
115
|
const pool = await createOpfsSAHPoolVfs({ name });
|
|
116
|
+
// oxlint-disable-next-line react/rules-of-hooks -- useDatabase registers disposal and is not a React Hook.
|
|
114
117
|
db = useDatabase(new pool.OpfsSAHPoolDb(`file:${fileName}`));
|
|
118
|
+
break;
|
|
115
119
|
}
|
|
120
|
+
default:
|
|
121
|
+
exhaustiveCheck(options);
|
|
116
122
|
}
|
|
117
123
|
const cache = disposer.use(createPreparedStatementsCache((sql) => db.prepare(sql), (statement) => {
|
|
118
124
|
statement.finalize();
|
package/dist/src/Task.d.ts
CHANGED
|
@@ -13,16 +13,26 @@ import { type DisposableRun, type RunCustomDeps } from "@evolu/common";
|
|
|
13
13
|
* ### Example
|
|
14
14
|
*
|
|
15
15
|
* ```ts
|
|
16
|
+
* import {
|
|
17
|
+
* createConsole,
|
|
18
|
+
* createConsoleFormatter,
|
|
19
|
+
* ok,
|
|
20
|
+
* } from "@evolu/common";
|
|
21
|
+
* import { createRun } from "@evolu/web";
|
|
22
|
+
*
|
|
16
23
|
* const console = createConsole({
|
|
17
24
|
* formatter: createConsoleFormatter()({
|
|
18
25
|
* timestampFormat: "relative",
|
|
19
26
|
* }),
|
|
20
27
|
* });
|
|
21
28
|
*
|
|
22
|
-
*
|
|
23
|
-
* const appPromise = run.ok(
|
|
29
|
+
* await using run = createRun({ console });
|
|
30
|
+
* const appPromise = run.ok(() => ok("started"));
|
|
31
|
+
*
|
|
32
|
+
* expect(await appPromise).toBe("started");
|
|
24
33
|
* ```
|
|
25
34
|
*/
|
|
26
35
|
export declare function createRun(): DisposableRun;
|
|
36
|
+
/** Creates a root {@link Run} for the browser with custom dependencies. */
|
|
27
37
|
export declare function createRun<D extends object>(deps: RunCustomDeps<D>): DisposableRun<D>;
|
|
28
38
|
//# sourceMappingURL=Task.d.ts.map
|
package/dist/src/Task.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB
|
|
1
|
+
{"version":3,"file":"Task.d.ts","sourceRoot":"","sources":["../../src/Task.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAAC;AAE3C,2EAA2E;AAC3E,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/src/Worker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EAGd,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,UAAU,EACV,UAAU,EACX,MAAM,eAAe,CAAC;AAQvB,kDAAkD;AAClD,eAAO,MAAM,YAAY,GAAI,KAAK,EAAE,MAAM,gBAC1B,UAAU,CAAC,MAAM,KAC9B,MAAM,CAAC,KAAK,EAAE,MAAM,CAAuB,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,QAAO,IAiBpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,sBAClC,UAAU,CAAC,YAAY,KAC1C,YAAY,CAAC,KAAK,EAAE,MAAM,CAM5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,OAAK,cAAc,CAC3E,KAAK,EACL,MAAM,CAcP,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBACuB,CAAC;AAExD,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"Worker.d.ts","sourceRoot":"","sources":["../../src/Worker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,sBAAsB,EACtB,yBAAyB,EACzB,uBAAuB,EACvB,iBAAiB,EACjB,cAAc,EAGd,YAAY,EACZ,gBAAgB,EAEhB,MAAM,EACN,UAAU,EACV,UAAU,EACX,MAAM,eAAe,CAAC;AAQvB,kDAAkD;AAClD,eAAO,MAAM,YAAY,GAAI,KAAK,EAAE,MAAM,gBAC1B,UAAU,CAAC,MAAM,KAC9B,MAAM,CAAC,KAAK,EAAE,MAAM,CAAuB,CAAC;AAE/C;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,QAAO,IAiBpD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,sBAClC,UAAU,CAAC,YAAY,KAC1C,YAAY,CAAC,KAAK,EAAE,MAAM,CAM5B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,OAAK,cAAc,CAC3E,KAAK,EACL,MAAM,CAcP,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBACuB,CAAC;AAExD,6EAA6E;AAC7E,eAAO,MAAM,sBAAsB,EAAE,sBAwCpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,cACxC,UAAU,CAAC,0BAA0B,KAChD,UAAU,CAAC,KAAK,EAAE,MAAM,CAAoC,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,cAC9C,UAAU,CAAC,uBAAuB,KAC7C,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAoBhC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oCAAoC,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,cAC5D,UAAU,CAAC,0BAA0B,KAChD,gBAAgB,CAAC,KAAK,EAAE,MAAM,CA2EhC,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,QAAO,UAAU,GAC5C,yBAAyB,GACzB,uBAWD,CAAC"}
|
package/dist/src/Worker.js
CHANGED
|
@@ -50,7 +50,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
|
|
|
50
50
|
var e = new Error(message);
|
|
51
51
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
52
|
});
|
|
53
|
-
import {
|
|
53
|
+
import { assertNonNullable, createConsole, createConsoleStoreOutput, disposable, } from "@evolu/common";
|
|
54
54
|
/** Creates a {@link Worker} from a Web Worker. */
|
|
55
55
|
export const createWorker = (nativeWorker) => wrap(nativeWorker);
|
|
56
56
|
/**
|
|
@@ -134,6 +134,7 @@ export const createBroadcastChannel = (name) => {
|
|
|
134
134
|
let disposed = false;
|
|
135
135
|
disposer.defer(() => {
|
|
136
136
|
disposed = true;
|
|
137
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
137
138
|
nativeBroadcastChannel.onmessage = null;
|
|
138
139
|
nativeBroadcastChannel.close();
|
|
139
140
|
});
|
|
@@ -149,6 +150,7 @@ export const createBroadcastChannel = (name) => {
|
|
|
149
150
|
if (disposed)
|
|
150
151
|
return;
|
|
151
152
|
onMessageHandler = fn;
|
|
153
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
152
154
|
nativeBroadcastChannel.onmessage = fn
|
|
153
155
|
? (event) => {
|
|
154
156
|
fn(event.data);
|
|
@@ -180,12 +182,14 @@ export const createSharedWorkerSelf = (nativeSelf) => {
|
|
|
180
182
|
const self = {
|
|
181
183
|
onConnect: null,
|
|
182
184
|
[Symbol.dispose]: () => {
|
|
185
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
183
186
|
nativeSelf.onconnect = null;
|
|
184
187
|
nativeSelf.close();
|
|
185
188
|
},
|
|
186
189
|
};
|
|
190
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
187
191
|
nativeSelf.onconnect = (e) => {
|
|
188
|
-
|
|
192
|
+
assertNonNullable(self.onConnect, "onConnect must be set before receiving connections");
|
|
189
193
|
self.onConnect(wrap(e.ports[0]));
|
|
190
194
|
};
|
|
191
195
|
return self;
|
|
@@ -209,10 +213,12 @@ export const createOneTabSharedWorkerSelfPolyfill = (nativeSelf) => {
|
|
|
209
213
|
messages.length = 0;
|
|
210
214
|
onConnectHandler = null;
|
|
211
215
|
onMessageHandler = null;
|
|
216
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
212
217
|
nativeSelf.onmessage = null;
|
|
213
218
|
nativeSelf.close();
|
|
214
219
|
});
|
|
215
220
|
const disposables = disposer.move();
|
|
221
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
216
222
|
nativeSelf.onmessage = (event) => {
|
|
217
223
|
if (disposables.disposed)
|
|
218
224
|
return;
|
|
@@ -307,16 +313,19 @@ const wrap = (native) => {
|
|
|
307
313
|
onMessageHandler = fn;
|
|
308
314
|
if (fn) {
|
|
309
315
|
// Messages are queued until onMessage is assigned.
|
|
316
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
310
317
|
native.onmessage = (event) => {
|
|
311
318
|
fn(event.data);
|
|
312
319
|
};
|
|
313
320
|
}
|
|
314
321
|
else {
|
|
322
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
315
323
|
native.onmessage = null;
|
|
316
324
|
}
|
|
317
325
|
},
|
|
318
326
|
native: native,
|
|
319
327
|
[Symbol.dispose]: () => {
|
|
328
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
320
329
|
native.onmessage = null;
|
|
321
330
|
if ("terminate" in native)
|
|
322
331
|
native.terminate();
|
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,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACtE,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -124,9 +124,12 @@ const createCredentialCreationOptions = (deps) => (username, seed, relyingPartyI
|
|
|
124
124
|
displayName: username,
|
|
125
125
|
},
|
|
126
126
|
pubKeyCredParams: [
|
|
127
|
-
|
|
128
|
-
{ type: "public-key", alg: -
|
|
129
|
-
|
|
127
|
+
// Ed25519
|
|
128
|
+
{ type: "public-key", alg: -8 },
|
|
129
|
+
// ES256
|
|
130
|
+
{ type: "public-key", alg: -7 },
|
|
131
|
+
// RS256
|
|
132
|
+
{ type: "public-key", alg: -257 },
|
|
130
133
|
],
|
|
131
134
|
attestation: "none",
|
|
132
135
|
authenticatorSelection: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@evolu/web",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Evolu for web",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"evolu",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@types/web-locks-api": "^0.0.5",
|
|
41
41
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
42
42
|
"user-agent-data-types": "^0.4.2",
|
|
43
|
-
"@evolu/common": "8.
|
|
43
|
+
"@evolu/common": "8.5.0",
|
|
44
44
|
"@evolu/typescript-config": "0.0.2"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
package/src/Platform.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { PositiveInt, type ReloadApp } from "@evolu/common";
|
|
2
2
|
|
|
3
|
+
/** Returns true when the browser runs on an Apple platform. */
|
|
4
|
+
export const isApplePlatform = (): boolean => {
|
|
5
|
+
const platform =
|
|
6
|
+
globalThis.navigator.userAgentData?.platform ??
|
|
7
|
+
globalThis.navigator.platform;
|
|
8
|
+
|
|
9
|
+
return /^(?:Mac|iPhone|iPad|iPod)/iu.test(platform);
|
|
10
|
+
};
|
|
11
|
+
|
|
3
12
|
/** Returns the amount of logical processors available to the browser. */
|
|
4
13
|
export const availableParallelism = (): PositiveInt =>
|
|
5
14
|
PositiveInt.orThrow(globalThis.navigator.hardwareConcurrency);
|
package/src/Sqlite.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { CreateSqliteDriver, SqliteRow } from "@evolu/common";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
bytesToHex,
|
|
4
|
+
createPreparedStatementsCache,
|
|
5
|
+
exhaustiveCheck,
|
|
6
|
+
ok,
|
|
7
|
+
} from "@evolu/common";
|
|
3
8
|
import sqlite3InitModule, {
|
|
4
9
|
type Database,
|
|
5
10
|
type PreparedStatement,
|
|
@@ -53,6 +58,7 @@ export const createWasmSqliteDriver: CreateSqliteDriver =
|
|
|
53
58
|
|
|
54
59
|
switch (options?.mode) {
|
|
55
60
|
case "memory":
|
|
61
|
+
// oxlint-disable-next-line react/rules-of-hooks -- useDatabase registers disposal and is not a React Hook.
|
|
56
62
|
db = useDatabase(new sqlite3.oo1.DB(":memory:"));
|
|
57
63
|
break;
|
|
58
64
|
|
|
@@ -64,6 +70,7 @@ export const createWasmSqliteDriver: CreateSqliteDriver =
|
|
|
64
70
|
const pool = await createOpfsSAHPoolVfs({
|
|
65
71
|
directory: `.${name}`,
|
|
66
72
|
});
|
|
73
|
+
// oxlint-disable-next-line react/rules-of-hooks -- useDatabase registers disposal and is not a React Hook.
|
|
67
74
|
db = useDatabase(
|
|
68
75
|
new pool.OpfsSAHPoolDb(
|
|
69
76
|
// SQLite normalizes this URI filename to SAH-pool path "/evolu1.db".
|
|
@@ -77,10 +84,15 @@ export const createWasmSqliteDriver: CreateSqliteDriver =
|
|
|
77
84
|
break;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
|
-
|
|
87
|
+
case undefined: {
|
|
81
88
|
const pool = await createOpfsSAHPoolVfs({ name });
|
|
89
|
+
// oxlint-disable-next-line react/rules-of-hooks -- useDatabase registers disposal and is not a React Hook.
|
|
82
90
|
db = useDatabase(new pool.OpfsSAHPoolDb(`file:${fileName}`));
|
|
91
|
+
break;
|
|
83
92
|
}
|
|
93
|
+
|
|
94
|
+
default:
|
|
95
|
+
exhaustiveCheck(options);
|
|
84
96
|
}
|
|
85
97
|
|
|
86
98
|
const cache = disposer.use(
|
package/src/Task.ts
CHANGED
|
@@ -20,17 +20,28 @@ import {
|
|
|
20
20
|
* ### Example
|
|
21
21
|
*
|
|
22
22
|
* ```ts
|
|
23
|
+
* import {
|
|
24
|
+
* createConsole,
|
|
25
|
+
* createConsoleFormatter,
|
|
26
|
+
* ok,
|
|
27
|
+
* } from "@evolu/common";
|
|
28
|
+
* import { createRun } from "@evolu/web";
|
|
29
|
+
*
|
|
23
30
|
* const console = createConsole({
|
|
24
31
|
* formatter: createConsoleFormatter()({
|
|
25
32
|
* timestampFormat: "relative",
|
|
26
33
|
* }),
|
|
27
34
|
* });
|
|
28
35
|
*
|
|
29
|
-
*
|
|
30
|
-
* const appPromise = run.ok(
|
|
36
|
+
* await using run = createRun({ console });
|
|
37
|
+
* const appPromise = run.ok(() => ok("started"));
|
|
38
|
+
*
|
|
39
|
+
* expect(await appPromise).toBe("started");
|
|
31
40
|
* ```
|
|
32
41
|
*/
|
|
33
42
|
export function createRun(): DisposableRun;
|
|
43
|
+
|
|
44
|
+
/** Creates a root {@link Run} for the browser with custom dependencies. */
|
|
34
45
|
export function createRun<D extends object>(
|
|
35
46
|
deps: RunCustomDeps<D>,
|
|
36
47
|
): DisposableRun<D>;
|
package/src/Worker.ts
CHANGED
|
@@ -15,7 +15,7 @@ import type {
|
|
|
15
15
|
WorkerSelf,
|
|
16
16
|
} from "@evolu/common";
|
|
17
17
|
import {
|
|
18
|
-
|
|
18
|
+
assertNonNullable,
|
|
19
19
|
createConsole,
|
|
20
20
|
createConsoleStoreOutput,
|
|
21
21
|
disposable,
|
|
@@ -117,6 +117,7 @@ export const createBroadcastChannel: CreateBroadcastChannel = <
|
|
|
117
117
|
|
|
118
118
|
disposer.defer(() => {
|
|
119
119
|
disposed = true;
|
|
120
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
120
121
|
nativeBroadcastChannel.onmessage = null;
|
|
121
122
|
nativeBroadcastChannel.close();
|
|
122
123
|
});
|
|
@@ -134,6 +135,7 @@ export const createBroadcastChannel: CreateBroadcastChannel = <
|
|
|
134
135
|
set onMessage(fn) {
|
|
135
136
|
if (disposed) return;
|
|
136
137
|
onMessageHandler = fn;
|
|
138
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
137
139
|
nativeBroadcastChannel.onmessage = fn
|
|
138
140
|
? (event: MessageEvent<Output>) => {
|
|
139
141
|
fn(event.data);
|
|
@@ -165,14 +167,16 @@ export const createSharedWorkerSelf = <Input, Output = never>(
|
|
|
165
167
|
const self: SharedWorkerSelf<Input, Output> = {
|
|
166
168
|
onConnect: null,
|
|
167
169
|
[Symbol.dispose]: () => {
|
|
170
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
168
171
|
nativeSelf.onconnect = null;
|
|
169
172
|
nativeSelf.close();
|
|
170
173
|
},
|
|
171
174
|
};
|
|
172
175
|
|
|
176
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
173
177
|
nativeSelf.onconnect = (e) => {
|
|
174
|
-
|
|
175
|
-
self.onConnect
|
|
178
|
+
assertNonNullable(
|
|
179
|
+
self.onConnect,
|
|
176
180
|
"onConnect must be set before receiving connections",
|
|
177
181
|
);
|
|
178
182
|
self.onConnect(wrap<Output, Input>(e.ports[0]));
|
|
@@ -203,12 +207,14 @@ export const createOneTabSharedWorkerSelfPolyfill = <Input, Output = never>(
|
|
|
203
207
|
messages.length = 0;
|
|
204
208
|
onConnectHandler = null;
|
|
205
209
|
onMessageHandler = null;
|
|
210
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
206
211
|
nativeSelf.onmessage = null;
|
|
207
212
|
nativeSelf.close();
|
|
208
213
|
});
|
|
209
214
|
|
|
210
215
|
const disposables = disposer.move();
|
|
211
216
|
|
|
217
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
212
218
|
nativeSelf.onmessage = (event: MessageEvent<Input>) => {
|
|
213
219
|
if (disposables.disposed) return;
|
|
214
220
|
|
|
@@ -300,10 +306,12 @@ const wrap = <Input, Output>(
|
|
|
300
306
|
onMessageHandler = fn;
|
|
301
307
|
if (fn) {
|
|
302
308
|
// Messages are queued until onMessage is assigned.
|
|
309
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
303
310
|
native.onmessage = (event: MessageEvent<Output>) => {
|
|
304
311
|
fn(event.data);
|
|
305
312
|
};
|
|
306
313
|
} else {
|
|
314
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
307
315
|
native.onmessage = null;
|
|
308
316
|
}
|
|
309
317
|
},
|
|
@@ -311,6 +319,7 @@ const wrap = <Input, Output>(
|
|
|
311
319
|
native: native as unknown as NativeMessagePort<Input, Output>,
|
|
312
320
|
|
|
313
321
|
[Symbol.dispose]: () => {
|
|
322
|
+
// oxlint-disable-next-line unicorn/prefer-add-event-listener -- This adapter owns and clears one handler.
|
|
314
323
|
native.onmessage = null;
|
|
315
324
|
if ("terminate" in native) native.terminate();
|
|
316
325
|
else native.close();
|
package/src/index.ts
CHANGED
|
@@ -226,9 +226,12 @@ const createCredentialCreationOptions =
|
|
|
226
226
|
displayName: username,
|
|
227
227
|
},
|
|
228
228
|
pubKeyCredParams: [
|
|
229
|
-
|
|
230
|
-
{ type: "public-key", alg: -
|
|
231
|
-
|
|
229
|
+
// Ed25519
|
|
230
|
+
{ type: "public-key", alg: -8 },
|
|
231
|
+
// ES256
|
|
232
|
+
{ type: "public-key", alg: -7 },
|
|
233
|
+
// RS256
|
|
234
|
+
{ type: "public-key", alg: -257 },
|
|
232
235
|
],
|
|
233
236
|
attestation: "none",
|
|
234
237
|
authenticatorSelection: {
|