@effect/sql-sqlite-wasm 4.0.0-beta.70 → 4.0.0-beta.71
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/OpfsWorker.d.ts.map +1 -1
- package/dist/OpfsWorker.js +35 -15
- package/dist/OpfsWorker.js.map +1 -1
- package/package.json +3 -3
- package/src/OpfsWorker.ts +35 -15
package/dist/OpfsWorker.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpfsWorker.d.ts","sourceRoot":"","sources":["../src/OpfsWorker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OpfsWorker.d.ts","sourceRoot":"","sources":["../src/OpfsWorker.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAuB,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAM5E;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,aAAa,GAAG,OAAO,CAAC,CAAA;IACvE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,GAAG,GACd,SAAS,gBAAgB,KACxB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,QAAQ,CA0EP,CAAA"}
|
package/dist/OpfsWorker.js
CHANGED
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Worker-side entry point for SQLite WASM databases stored in the browser
|
|
3
|
-
* Origin Private File System.
|
|
2
|
+
* Worker-side entry point for SQLite WASM databases stored in the browser's
|
|
3
|
+
* Origin Private File System (OPFS).
|
|
4
4
|
*
|
|
5
5
|
* This module opens `@effect/wa-sqlite` with the OPFS access-handle VFS and
|
|
6
|
-
* serves the message protocol used by
|
|
7
|
-
* dedicated worker, or from a `SharedWorker` connection port,
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* database off the main thread.
|
|
6
|
+
* serves the message protocol used by the worker-backed SQLite WASM client.
|
|
7
|
+
* Run it from a dedicated worker, or from a `SharedWorker` connection port, to
|
|
8
|
+
* keep durable local SQLite storage off the main thread while preserving the
|
|
9
|
+
* database in OPFS.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* the
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* - {@link run} owns one SQLite connection for one OPFS database name.
|
|
14
|
+
* - The worker posts `ready` after opening the database and then handles the
|
|
15
|
+
* client protocol for SQL statements, import, export, update hooks, and
|
|
16
|
+
* close.
|
|
17
|
+
* - The port in {@link OpfsWorkerConfig} is the only communication channel
|
|
18
|
+
* between the client and the worker loop.
|
|
19
|
+
* - Closing the port, sending `close`, or interrupting the surrounding scope
|
|
20
|
+
* releases the SQLite database handle.
|
|
21
|
+
*
|
|
22
|
+
* **Common tasks**
|
|
23
|
+
*
|
|
24
|
+
* Use this module for local-first browser data, offline caches,
|
|
25
|
+
* client-side migrations, and import/export workflows that need OPFS
|
|
26
|
+
* durability. Start {@link run} in the worker script, then connect the
|
|
27
|
+
* application through the worker-backed `SqliteClient` constructor.
|
|
28
|
+
*
|
|
29
|
+
* **Gotchas**
|
|
30
|
+
*
|
|
31
|
+
* OPFS requires browser support and a secure origin. Coordinate multiple tabs
|
|
32
|
+
* or workers before opening or migrating the same database, because this module
|
|
33
|
+
* owns a single connection and does not provide cross-tab locking. Close unused
|
|
34
|
+
* ports so access handles are released promptly.
|
|
35
|
+
*
|
|
36
|
+
* **See also**
|
|
37
|
+
*
|
|
38
|
+
* - {@link OpfsWorkerConfig} for the required worker port and database name.
|
|
39
|
+
* - {@link run} for starting the worker message loop.
|
|
20
40
|
*
|
|
21
41
|
* @since 4.0.0
|
|
22
42
|
*/
|
package/dist/OpfsWorker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpfsWorker.js","names":["WaSqlite","SQLiteESMFactory","AccessHandlePoolVFS","Effect","classifySqliteError","SqlError","classifyError","cause","message","operation","run","options","gen","factory","promise","sqlite3","Factory","vfs","create","vfs_register","db","acquireRelease","try","open_v2","dbName","undefined","catch","reason","sync","close","callback","resume","onMessage","event","messageId","data","port","void","id","deserialize","length","postMessage","serialize","buffer","update_hook","_op","_db","table","rowid","Number","sql","params","results","columns","stmt","statements","bind_collection","step","SQLITE_ROW","column_names","row","push","e","String","addEventListener","removeEventListener","pipe","scoped"],"sources":["../src/OpfsWorker.ts"],"sourcesContent":[null],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"OpfsWorker.js","names":["WaSqlite","SQLiteESMFactory","AccessHandlePoolVFS","Effect","classifySqliteError","SqlError","classifyError","cause","message","operation","run","options","gen","factory","promise","sqlite3","Factory","vfs","create","vfs_register","db","acquireRelease","try","open_v2","dbName","undefined","catch","reason","sync","close","callback","resume","onMessage","event","messageId","data","port","void","id","deserialize","length","postMessage","serialize","buffer","update_hook","_op","_db","table","rowid","Number","sql","params","results","columns","stmt","statements","bind_collection","step","SQLITE_ROW","column_names","row","push","e","String","addEventListener","removeEventListener","pipe","scoped"],"sources":["../src/OpfsWorker.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA;AACA;AACA,OAAO,KAAKA,QAAQ,MAAM,mBAAmB;AAC7C,OAAOC,gBAAgB,MAAM,sCAAsC;AACnE,SAASC,mBAAmB,QAAQ,uDAAuD;AAC3F,OAAO,KAAKC,MAAM,MAAM,eAAe;AACvC,SAASC,mBAAmB,EAAEC,QAAQ,QAAQ,8BAA8B;AAG5E,MAAMC,aAAa,GAAGA,CAACC,KAAc,EAAEC,OAAe,EAAEC,SAAiB,KACvEL,mBAAmB,CAACG,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|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect/sql-sqlite-wasm",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.71",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A SQLite toolkit for Effect",
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@effect/wa-sqlite": "^0.2.1",
|
|
47
|
-
"effect": "^4.0.0-beta.
|
|
47
|
+
"effect": "^4.0.0-beta.71"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@effect/wa-sqlite": "^0.1.2",
|
|
51
|
-
"effect": "^4.0.0-beta.
|
|
51
|
+
"effect": "^4.0.0-beta.71"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"codegen": "effect-utils codegen",
|
package/src/OpfsWorker.ts
CHANGED
|
@@ -1,22 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Worker-side entry point for SQLite WASM databases stored in the browser
|
|
3
|
-
* Origin Private File System.
|
|
2
|
+
* Worker-side entry point for SQLite WASM databases stored in the browser's
|
|
3
|
+
* Origin Private File System (OPFS).
|
|
4
4
|
*
|
|
5
5
|
* This module opens `@effect/wa-sqlite` with the OPFS access-handle VFS and
|
|
6
|
-
* serves the message protocol used by
|
|
7
|
-
* dedicated worker, or from a `SharedWorker` connection port,
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* database off the main thread.
|
|
6
|
+
* serves the message protocol used by the worker-backed SQLite WASM client.
|
|
7
|
+
* Run it from a dedicated worker, or from a `SharedWorker` connection port, to
|
|
8
|
+
* keep durable local SQLite storage off the main thread while preserving the
|
|
9
|
+
* database in OPFS.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* the
|
|
11
|
+
* **Mental model**
|
|
12
|
+
*
|
|
13
|
+
* - {@link run} owns one SQLite connection for one OPFS database name.
|
|
14
|
+
* - The worker posts `ready` after opening the database and then handles the
|
|
15
|
+
* client protocol for SQL statements, import, export, update hooks, and
|
|
16
|
+
* close.
|
|
17
|
+
* - The port in {@link OpfsWorkerConfig} is the only communication channel
|
|
18
|
+
* between the client and the worker loop.
|
|
19
|
+
* - Closing the port, sending `close`, or interrupting the surrounding scope
|
|
20
|
+
* releases the SQLite database handle.
|
|
21
|
+
*
|
|
22
|
+
* **Common tasks**
|
|
23
|
+
*
|
|
24
|
+
* Use this module for local-first browser data, offline caches,
|
|
25
|
+
* client-side migrations, and import/export workflows that need OPFS
|
|
26
|
+
* durability. Start {@link run} in the worker script, then connect the
|
|
27
|
+
* application through the worker-backed `SqliteClient` constructor.
|
|
28
|
+
*
|
|
29
|
+
* **Gotchas**
|
|
30
|
+
*
|
|
31
|
+
* OPFS requires browser support and a secure origin. Coordinate multiple tabs
|
|
32
|
+
* or workers before opening or migrating the same database, because this module
|
|
33
|
+
* owns a single connection and does not provide cross-tab locking. Close unused
|
|
34
|
+
* ports so access handles are released promptly.
|
|
35
|
+
*
|
|
36
|
+
* **See also**
|
|
37
|
+
*
|
|
38
|
+
* - {@link OpfsWorkerConfig} for the required worker port and database name.
|
|
39
|
+
* - {@link run} for starting the worker message loop.
|
|
20
40
|
*
|
|
21
41
|
* @since 4.0.0
|
|
22
42
|
*/
|