@evolu/web 3.0.0-next.0 → 3.0.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/LICENSE +21 -0
- package/dist/src/Platform.d.ts +3 -1
- package/dist/src/Platform.d.ts.map +1 -1
- package/dist/src/Platform.js +3 -0
- package/dist/src/Sqlite.d.ts.map +1 -1
- package/dist/src/Sqlite.js +138 -57
- package/dist/src/Task.d.ts +9 -19
- package/dist/src/Task.d.ts.map +1 -1
- package/dist/src/Task.js +10 -59
- package/dist/src/Worker.d.ts +25 -3
- package/dist/src/Worker.d.ts.map +1 -1
- package/dist/src/Worker.js +231 -12
- package/dist/src/index.d.ts +5 -4
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/local-first/Db.worker.js +3 -4
- package/dist/src/local-first/Evolu.d.ts +8 -2
- package/dist/src/local-first/Evolu.d.ts.map +1 -1
- package/dist/src/local-first/Evolu.js +40 -8
- package/dist/src/local-first/LocalAuth.d.ts.map +1 -1
- package/dist/src/local-first/Shared.worker.js +108 -4
- package/dist/src/local-first/index.d.ts +1 -1
- package/package.json +17 -14
- package/src/Platform.ts +5 -1
- package/src/Sqlite.ts +47 -18
- package/src/Task.ts +23 -70
- package/src/Worker.ts +181 -13
- package/src/index.ts +5 -4
- package/src/local-first/Db.worker.ts +5 -6
- package/src/local-first/Evolu.ts +64 -5
- package/src/local-first/Shared.worker.ts +46 -6
- package/src/local-first/index.ts +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Evolu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/src/Platform.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { PositiveInt, type ReloadApp } from "@evolu/common";
|
|
2
|
+
/** Returns the amount of logical processors available to the browser. */
|
|
3
|
+
export declare const availableParallelism: () => PositiveInt;
|
|
2
4
|
export declare const reloadApp: ReloadApp;
|
|
3
5
|
//# sourceMappingURL=Platform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../../src/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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"}
|
package/dist/src/Platform.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { PositiveInt } from "@evolu/common";
|
|
2
|
+
/** Returns the amount of logical processors available to the browser. */
|
|
3
|
+
export const availableParallelism = () => PositiveInt.orThrow(globalThis.navigator.hardwareConcurrency);
|
|
1
4
|
export const reloadApp = (url) => {
|
|
2
5
|
if (typeof document === "undefined") {
|
|
3
6
|
return;
|
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;AA4BnE,eAAO,MAAM,sBAAsB,EAAE,kBA6GlC,CAAC"}
|
package/dist/src/Sqlite.js
CHANGED
|
@@ -1,3 +1,55 @@
|
|
|
1
|
+
var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
|
|
2
|
+
if (value !== null && value !== void 0) {
|
|
3
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
4
|
+
var dispose, inner;
|
|
5
|
+
if (async) {
|
|
6
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
7
|
+
dispose = value[Symbol.asyncDispose];
|
|
8
|
+
}
|
|
9
|
+
if (dispose === void 0) {
|
|
10
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
11
|
+
dispose = value[Symbol.dispose];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
15
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
17
|
+
}
|
|
18
|
+
else if (async) {
|
|
19
|
+
env.stack.push({ async: true });
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
|
|
24
|
+
return function (env) {
|
|
25
|
+
function fail(e) {
|
|
26
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
27
|
+
env.hasError = true;
|
|
28
|
+
}
|
|
29
|
+
var r, s = 0;
|
|
30
|
+
function next() {
|
|
31
|
+
while (r = env.stack.pop()) {
|
|
32
|
+
try {
|
|
33
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
34
|
+
if (r.dispose) {
|
|
35
|
+
var result = r.dispose.call(r.value);
|
|
36
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
37
|
+
}
|
|
38
|
+
else s |= 1;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
fail(e);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
45
|
+
if (env.hasError) throw env.error;
|
|
46
|
+
}
|
|
47
|
+
return next();
|
|
48
|
+
};
|
|
49
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
50
|
+
var e = new Error(message);
|
|
51
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
52
|
+
});
|
|
1
53
|
import { bytesToHex, createPreparedStatementsCache, ok } from "@evolu/common";
|
|
2
54
|
import sqlite3InitModule, {} from "@evolu/sqlite-wasm";
|
|
3
55
|
// @ts-expect-error Missing types.
|
|
@@ -14,68 +66,97 @@ globalThis.sqlite3ApiConfig = {
|
|
|
14
66
|
};
|
|
15
67
|
// Init ASAP.
|
|
16
68
|
const sqlite3Promise = sqlite3InitModule();
|
|
69
|
+
const fileName = "evolu1.db";
|
|
17
70
|
export const createWasmSqliteDriver = (name, options) => async () => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
71
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
72
|
+
try {
|
|
73
|
+
const sqlite3 = await sqlite3Promise;
|
|
74
|
+
const disposer = __addDisposableResource(env_1, new DisposableStack(), false);
|
|
75
|
+
const useDatabase = (database) => disposer.adopt(database, (database) => {
|
|
76
|
+
database.close();
|
|
77
|
+
});
|
|
78
|
+
let deleteDatabaseFile = false;
|
|
79
|
+
const createOpfsSAHPoolVfs = async (options) => {
|
|
80
|
+
const pool = await sqlite3.installOpfsSAHPoolVfs(options);
|
|
81
|
+
if (pool.isPaused())
|
|
82
|
+
await pool.unpauseVfs();
|
|
83
|
+
disposer.defer(() => {
|
|
84
|
+
if (deleteDatabaseFile)
|
|
85
|
+
pool.unlink(`/${fileName}`);
|
|
86
|
+
pool.pauseVfs();
|
|
32
87
|
});
|
|
33
|
-
|
|
34
|
-
|
|
88
|
+
return pool;
|
|
89
|
+
};
|
|
90
|
+
let db;
|
|
91
|
+
switch (options?.mode) {
|
|
92
|
+
case "memory":
|
|
93
|
+
db = useDatabase(new sqlite3.oo1.DB(":memory:"));
|
|
94
|
+
break;
|
|
95
|
+
case "encrypted": {
|
|
96
|
+
// MultipleCiphers encryption requires its VFS wrapper for OPFS SAH-pool.
|
|
97
|
+
// @ts-expect-error Missing types (update @evolu/sqlite-wasm types)
|
|
98
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
99
|
+
sqlite3.capi.sqlite3mc_vfs_create("opfs", 1);
|
|
100
|
+
const pool = await createOpfsSAHPoolVfs({
|
|
101
|
+
directory: `.${name}`,
|
|
102
|
+
});
|
|
103
|
+
db = useDatabase(new pool.OpfsSAHPoolDb(
|
|
104
|
+
// SQLite normalizes this URI filename to SAH-pool path "/evolu1.db".
|
|
105
|
+
`file:${fileName}?vfs=multipleciphers-opfs-sahpool`));
|
|
106
|
+
db.exec(`
|
|
35
107
|
PRAGMA cipher = 'sqlcipher';
|
|
36
108
|
PRAGMA key = "x'${bytesToHex(options.encryptionKey)}'";
|
|
37
109
|
`);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
default: {
|
|
113
|
+
const pool = await createOpfsSAHPoolVfs({ name });
|
|
114
|
+
db = useDatabase(new pool.OpfsSAHPoolDb(`file:${fileName}`));
|
|
115
|
+
}
|
|
43
116
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
117
|
+
const cache = disposer.use(createPreparedStatementsCache((sql) => db.prepare(sql), (statement) => {
|
|
118
|
+
statement.finalize();
|
|
119
|
+
}));
|
|
120
|
+
const disposables = disposer.move();
|
|
121
|
+
return ok({
|
|
122
|
+
exec: (query) => {
|
|
123
|
+
const prepared = cache.get(query);
|
|
124
|
+
if (prepared) {
|
|
125
|
+
if (query.parameters.length > 0)
|
|
126
|
+
prepared.bind(query.parameters);
|
|
127
|
+
const rows = [];
|
|
128
|
+
while (prepared.step()) {
|
|
129
|
+
rows.push(prepared.get({}));
|
|
130
|
+
}
|
|
131
|
+
prepared.reset();
|
|
132
|
+
return {
|
|
133
|
+
rows: rows,
|
|
134
|
+
changes: db.changes(),
|
|
135
|
+
};
|
|
60
136
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
137
|
+
const rows = db.exec(query.sql, {
|
|
138
|
+
returnValue: "resultRows",
|
|
139
|
+
rowMode: "object",
|
|
140
|
+
bind: query.parameters,
|
|
141
|
+
});
|
|
142
|
+
const changes = db.changes();
|
|
143
|
+
return { rows, changes };
|
|
144
|
+
},
|
|
145
|
+
export: () => sqlite3.capi.sqlite3_js_db_export(db),
|
|
146
|
+
deleteDatabase: () => {
|
|
147
|
+
deleteDatabaseFile = true;
|
|
148
|
+
disposables.dispose();
|
|
149
|
+
},
|
|
150
|
+
[Symbol.dispose]: () => {
|
|
151
|
+
disposables.dispose();
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
catch (e_1) {
|
|
156
|
+
env_1.error = e_1;
|
|
157
|
+
env_1.hasError = true;
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
__disposeResources(env_1);
|
|
161
|
+
}
|
|
81
162
|
};
|
package/dist/src/Task.d.ts
CHANGED
|
@@ -1,23 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Web
|
|
2
|
+
* Web-specific Task utilities.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { type
|
|
6
|
+
import { type DisposableRun, type RunCustomDeps } from "@evolu/common";
|
|
7
7
|
/**
|
|
8
|
-
* Creates a {@link
|
|
8
|
+
* Creates a root {@link Run} for the browser.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* Locks request keeps waiting until the browser grants the lock. Only the
|
|
13
|
-
* returned lease releases it.
|
|
14
|
-
*/
|
|
15
|
-
export declare const createLeaderLock: () => LeaderLock;
|
|
16
|
-
/**
|
|
17
|
-
* Creates {@link Run} for the browser with global error handling.
|
|
18
|
-
*
|
|
19
|
-
* Registers `error` and `unhandledrejection` handlers that log errors to the
|
|
20
|
-
* console. Handlers are removed when the Run is disposed.
|
|
10
|
+
* Defects are reported with the browser's global `reportError`. A custom
|
|
11
|
+
* `reportDefect` dependency overrides the browser default.
|
|
21
12
|
*
|
|
22
13
|
* ### Example
|
|
23
14
|
*
|
|
@@ -28,11 +19,10 @@ export declare const createLeaderLock: () => LeaderLock;
|
|
|
28
19
|
* }),
|
|
29
20
|
* });
|
|
30
21
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* stack.use(await run.orThrow(startApp()));
|
|
22
|
+
* const run = createRun({ console });
|
|
23
|
+
* const appPromise = run.ok(startApp());
|
|
35
24
|
* ```
|
|
36
25
|
*/
|
|
37
|
-
export declare
|
|
26
|
+
export declare function createRun(): DisposableRun;
|
|
27
|
+
export declare function createRun<D extends object>(deps: RunCustomDeps<D>): DisposableRun<D>;
|
|
38
28
|
//# 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,
|
|
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;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,IAAI,aAAa,CAAC;AAC3C,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EACxC,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,GACrB,aAAa,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/src/Task.js
CHANGED
|
@@ -1,63 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Web
|
|
2
|
+
* Web-specific Task utilities.
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { createRun as createCommonRun,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export const createLeaderLock = () => ({
|
|
16
|
-
lock: (name) => async () => {
|
|
17
|
-
const acquired = Promise.withResolvers();
|
|
18
|
-
const release = Promise.withResolvers();
|
|
19
|
-
void globalThis.navigator.locks.request(`evolu-leaderlock-${name}`, { mode: "exclusive" }, async () => {
|
|
20
|
-
acquired.resolve();
|
|
21
|
-
await release.promise;
|
|
22
|
-
});
|
|
23
|
-
await acquired.promise;
|
|
24
|
-
return ok({
|
|
25
|
-
[Symbol.asyncDispose]: async () => {
|
|
26
|
-
release.resolve();
|
|
27
|
-
return Promise.resolve();
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
/**
|
|
33
|
-
* Creates {@link Run} for the browser with global error handling.
|
|
34
|
-
*
|
|
35
|
-
* Registers `error` and `unhandledrejection` handlers that log errors to the
|
|
36
|
-
* console. Handlers are removed when the Run is disposed.
|
|
37
|
-
*
|
|
38
|
-
* ### Example
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* const console = createConsole({
|
|
42
|
-
* formatter: createConsoleFormatter()({
|
|
43
|
-
* timestampFormat: "relative",
|
|
44
|
-
* }),
|
|
45
|
-
* });
|
|
46
|
-
*
|
|
47
|
-
* await using run = createRun({ console });
|
|
48
|
-
* await using stack = new AsyncDisposableStack();
|
|
49
|
-
*
|
|
50
|
-
* stack.use(await run.orThrow(startApp()));
|
|
51
|
-
* ```
|
|
52
|
-
*/
|
|
53
|
-
export const createRun = (deps) => {
|
|
54
|
-
const run = createCommonRun(deps);
|
|
55
|
-
const console = run.deps.console.child("global");
|
|
56
|
-
globalThis.addEventListener("error", (event) => {
|
|
57
|
-
console.error("error", createUnknownError(event.error));
|
|
58
|
-
}, { signal: run.signal });
|
|
59
|
-
globalThis.addEventListener("unhandledrejection", (event) => {
|
|
60
|
-
console.error("unhandledrejection", createUnknownError(event.reason));
|
|
61
|
-
}, { signal: run.signal });
|
|
62
|
-
return run;
|
|
63
|
-
};
|
|
6
|
+
import { createRun as createCommonRun, } from "@evolu/common";
|
|
7
|
+
export function createRun(deps) {
|
|
8
|
+
const reportDefect = (reported) => {
|
|
9
|
+
globalThis.reportError(reported);
|
|
10
|
+
};
|
|
11
|
+
return deps === undefined
|
|
12
|
+
? createCommonRun({ reportDefect })
|
|
13
|
+
: createCommonRun({ reportDefect, ...deps });
|
|
14
|
+
}
|
package/dist/src/Worker.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
import type { CreateMessagePort, MessageChannel, SharedWorker, SharedWorkerSelf, Worker, WorkerDeps, WorkerSelf } from "@evolu/common";
|
|
1
|
+
import type { CreateBroadcastChannel, CreateBroadcastChannelDep, CreateMessageChannelDep, CreateMessagePort, MessageChannel, SharedWorker, SharedWorkerSelf, Worker, WorkerDeps, WorkerSelf } from "@evolu/common";
|
|
2
2
|
/** Creates a {@link Worker} from a Web Worker. */
|
|
3
3
|
export declare const createWorker: <Input, Output>(nativeWorker: globalThis.Worker) => Worker<Input, Output>;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Installs a one-tab SharedWorker polyfill backed by a Web Worker.
|
|
6
|
+
*
|
|
7
|
+
* Use it before constructing a SharedWorker in browsers without native
|
|
8
|
+
* SharedWorker support.
|
|
9
|
+
*/
|
|
10
|
+
export declare const installOneTabSharedWorkerPolyfill: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a {@link SharedWorker} from a Web SharedWorker.
|
|
13
|
+
*
|
|
14
|
+
* Call {@link installOneTabSharedWorkerPolyfill} first to support browsers
|
|
15
|
+
* without native SharedWorker support.
|
|
16
|
+
*/
|
|
5
17
|
export declare const createSharedWorker: <Input, Output = never>(nativeSharedWorker: globalThis.SharedWorker) => SharedWorker<Input, Output>;
|
|
6
18
|
/**
|
|
7
19
|
* Creates a {@link MessageChannel} from a Web MessageChannel.
|
|
@@ -21,6 +33,8 @@ export declare const createMessageChannel: <Input, Output = never>() => MessageC
|
|
|
21
33
|
* Use this for ports received via postMessage transfer.
|
|
22
34
|
*/
|
|
23
35
|
export declare const createMessagePort: CreateMessagePort;
|
|
36
|
+
/** Creates an Evolu {@link BroadcastChannel} from a Web BroadcastChannel. */
|
|
37
|
+
export declare const createBroadcastChannel: CreateBroadcastChannel;
|
|
24
38
|
/**
|
|
25
39
|
* Creates an Evolu {@link WorkerSelf} from a Web `DedicatedWorkerGlobalScope`
|
|
26
40
|
* (`self` inside a dedicated worker).
|
|
@@ -33,6 +47,14 @@ export declare const createWorkerSelf: <Input, Output = never>(nativeSelf: globa
|
|
|
33
47
|
* Disposing closes the shared worker scope for all connected clients.
|
|
34
48
|
*/
|
|
35
49
|
export declare const createSharedWorkerSelf: <Input, Output = never>(nativeSelf: globalThis.SharedWorkerGlobalScope) => SharedWorkerSelf<Input, Output>;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a one-tab {@link SharedWorkerSelf} polyfill for browsers without
|
|
52
|
+
* native SharedWorker support.
|
|
53
|
+
*
|
|
54
|
+
* Delivers one synthetic `onConnect` port, queues startup messages until
|
|
55
|
+
* `onMessage` is set, and does not share state across tabs.
|
|
56
|
+
*/
|
|
57
|
+
export declare const createOneTabSharedWorkerSelfPolyfill: <Input, Output = never>(nativeSelf: globalThis.DedicatedWorkerGlobalScope) => SharedWorkerSelf<Input, Output>;
|
|
36
58
|
/** Creates deps shared by web worker entry points. */
|
|
37
|
-
export declare const createWorkerDeps: () => WorkerDeps;
|
|
59
|
+
export declare const createWorkerDeps: () => WorkerDeps & CreateBroadcastChannelDep & CreateMessageChannelDep;
|
|
38
60
|
//# sourceMappingURL=Worker.d.ts.map
|
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,
|
|
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,sBAsCpC,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,CAkBhC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oCAAoC,GAAI,KAAK,EAAE,MAAM,GAAG,KAAK,cAC5D,UAAU,CAAC,0BAA0B,KAChD,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAyEhC,CAAC;AAEF,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,QAAO,UAAU,GAC5C,yBAAyB,GACzB,uBAWD,CAAC"}
|