@effect/sql-sqlite-wasm 4.0.0-beta.70 → 4.0.0-beta.72
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/dist/SqliteClient.d.ts +4 -4
- package/dist/SqliteClient.js +4 -4
- package/package.json +3 -3
- package/src/OpfsWorker.ts +35 -15
- package/src/SqliteClient.ts +4 -4
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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ACJ,CAAC,CAAC,CAACkC,IAAI,CAAC/D,MAAM,CAACgE,MAAM,CAAC","ignoreList":[]}
|
package/dist/SqliteClient.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface SqliteClient extends Client.SqlClient {
|
|
|
35
35
|
readonly updateValues: never;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Service tag for the SQLite WASM client.
|
|
39
39
|
*
|
|
40
40
|
* @category tags
|
|
41
41
|
* @since 4.0.0
|
|
@@ -81,16 +81,16 @@ export declare const makeMemory: (options: SqliteClientMemoryConfig) => Effect.E
|
|
|
81
81
|
*/
|
|
82
82
|
export declare const make: (options: SqliteClientConfig) => Effect.Effect<SqliteClient, SqlError, Scope.Scope | Reactivity.Reactivity>;
|
|
83
83
|
/**
|
|
84
|
-
* Fiber
|
|
84
|
+
* Fiber reference that stores transferables to include with worker-backed SQLite WASM query messages.
|
|
85
85
|
*
|
|
86
|
-
* @category
|
|
86
|
+
* @category transferables
|
|
87
87
|
* @since 4.0.0
|
|
88
88
|
*/
|
|
89
89
|
export declare const Transferables: Context.Reference<readonly Transferable[]>;
|
|
90
90
|
/**
|
|
91
91
|
* Runs an effect with the supplied transferables attached to worker-backed SQLite WASM query messages.
|
|
92
92
|
*
|
|
93
|
-
* @category
|
|
93
|
+
* @category transferables
|
|
94
94
|
* @since 4.0.0
|
|
95
95
|
*/
|
|
96
96
|
export declare const withTransferables: (transferables: ReadonlyArray<Transferable>) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
package/dist/SqliteClient.js
CHANGED
|
@@ -60,7 +60,7 @@ const classifyError = (cause, message, operation) => classifySqliteError(cause,
|
|
|
60
60
|
*/
|
|
61
61
|
export const TypeId = "~@effect/sql-sqlite-wasm/SqliteClient";
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
63
|
+
* Service tag for the SQLite WASM client.
|
|
64
64
|
*
|
|
65
65
|
* @category tags
|
|
66
66
|
* @since 4.0.0
|
|
@@ -332,9 +332,9 @@ function rowToObject(columns, row) {
|
|
|
332
332
|
const extractObject = rows => rows[1].map(row => rowToObject(rows[0], row));
|
|
333
333
|
const extractRows = rows => rows[1];
|
|
334
334
|
/**
|
|
335
|
-
* Fiber
|
|
335
|
+
* Fiber reference that stores transferables to include with worker-backed SQLite WASM query messages.
|
|
336
336
|
*
|
|
337
|
-
* @category
|
|
337
|
+
* @category transferables
|
|
338
338
|
* @since 4.0.0
|
|
339
339
|
*/
|
|
340
340
|
export const Transferables = /*#__PURE__*/Context.Reference("@effect/sql-sqlite-wasm/currentTransferables", {
|
|
@@ -343,7 +343,7 @@ export const Transferables = /*#__PURE__*/Context.Reference("@effect/sql-sqlite-
|
|
|
343
343
|
/**
|
|
344
344
|
* Runs an effect with the supplied transferables attached to worker-backed SQLite WASM query messages.
|
|
345
345
|
*
|
|
346
|
-
* @category
|
|
346
|
+
* @category transferables
|
|
347
347
|
* @since 4.0.0
|
|
348
348
|
*/
|
|
349
349
|
export const withTransferables = transferables => effect => Effect.provideService(effect, Transferables, transferables);
|
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.72",
|
|
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.72"
|
|
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.72"
|
|
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
|
*/
|
package/src/SqliteClient.ts
CHANGED
|
@@ -88,7 +88,7 @@ export interface SqliteClient extends Client.SqlClient {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
*
|
|
91
|
+
* Service tag for the SQLite WASM client.
|
|
92
92
|
*
|
|
93
93
|
* @category tags
|
|
94
94
|
* @since 4.0.0
|
|
@@ -473,9 +473,9 @@ const extractObject = (rows: [Array<string>, Array<any>]) => rows[1].map((row) =
|
|
|
473
473
|
const extractRows = (rows: [Array<string>, Array<any>]) => rows[1]
|
|
474
474
|
|
|
475
475
|
/**
|
|
476
|
-
* Fiber
|
|
476
|
+
* Fiber reference that stores transferables to include with worker-backed SQLite WASM query messages.
|
|
477
477
|
*
|
|
478
|
-
* @category
|
|
478
|
+
* @category transferables
|
|
479
479
|
* @since 4.0.0
|
|
480
480
|
*/
|
|
481
481
|
export const Transferables = Context.Reference<ReadonlyArray<Transferable>>(
|
|
@@ -486,7 +486,7 @@ export const Transferables = Context.Reference<ReadonlyArray<Transferable>>(
|
|
|
486
486
|
/**
|
|
487
487
|
* Runs an effect with the supplied transferables attached to worker-backed SQLite WASM query messages.
|
|
488
488
|
*
|
|
489
|
-
* @category
|
|
489
|
+
* @category transferables
|
|
490
490
|
* @since 4.0.0
|
|
491
491
|
*/
|
|
492
492
|
export const withTransferables =
|