@objectstack/driver-sqlite-wasm 17.3.0 → 17.4.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/CHANGELOG.md +198 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,203 @@
|
|
|
1
1
|
# @objectstack/driver-sqlite-wasm
|
|
2
2
|
|
|
3
|
+
## 17.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7862fb7: `SqliteWasmDriver.initObjects` accepts `tenancy`, `indexes` and `lifecycle` in a **fresh object literal**, inherited from the widened `SqlDriver` — and that inheritance is now asserted rather than assumed.
|
|
8
|
+
|
|
9
|
+
This package overrides neither `initObjects` nor `registerObjectMetadata`, so its published `.d.ts` re-declares none of them and the door it exposes is `SqlDriver`'s, imported from `@objectstack/driver-sql`. Measured on the built declarations: zero re-declarations of `initObjects`, `registerObjectMetadata`, `rotateShards`, `ensureShardTable` or `registerManagedObjectMetadata`. That is the opposite direction of the defect the sibling packages carried — `TursoDriver` overrode `initObjects` with a narrower literal and shadowed a base-class fix for five weeks — and it is recorded here because a consumer reading only this package's changelog would otherwise never learn its accept set moved.
|
|
10
|
+
|
|
11
|
+
`src/sqlite-wasm-16711-inherited-object-def-keys.test.ts` pins the inheritance inside this package's own tsc program: the inherited parameter is not `any`, each key is present on the element type, a fresh literal carrying them compiles and is read at run time, and a misspelling is still `TS2353`. It goes red both ways — if the base narrows again, and if a future override here re-declares the door more narrowly.
|
|
12
|
+
- b72226f: `SqlDriver.initObjects()` and `SqlDriver.registerObjectMetadata()` now declare the `indexes` key they have always read.
|
|
13
|
+
|
|
14
|
+
Both entry points took `Array<{ name; fields?; tenancy? }>`, with no `indexes` in the type. The key was read out of those very objects one call deep anyway, through an `as any`, in `registerManagedObjectMetadata` — and the map it fills, `managedObjectIndexes`, is what `syncDeclaredIndexes` renders every declared UNIQUE from. So the driver's whole index-sync path was driven by a key its own signature said did not exist, while the sibling `detectManagedDrift` on the same class had always declared `indexes?: any[]`: the two halves of one class disagreed about the shape of the same input.
|
|
15
|
+
|
|
16
|
+
That is the shape #4311 already addressed for `tenancy`, one key over, and the comment it left above `initObjects` described `indexes` word for word.
|
|
17
|
+
|
|
18
|
+
**Why nothing tripped over it.** TypeScript's excess-property check fires on a fresh object literal and not on one bound to a variable first, so the same object was accepted or rejected by nothing but where it was spelled — `await driver.initObjects([{ ...bare, indexes: [] }])` was rejected with TS2353, `const o = { ...bare, indexes: [] }; await driver.initObjects([o])` was accepted, and the index was synced either way. Every caller happened to bind first, so the package typechecked green for a reason unrelated to correctness.
|
|
19
|
+
|
|
20
|
+
**Why this matters beyond a compile error.** The loud symptom was a rejected correct call. The quiet one is the reachable branch: an author — or an AI — reading the signature concludes `indexes` is not accepted and drops the key, and a declared UNIQUE is then never synced, with no error at authoring time and no error at boot. The schema says those rows cannot collide; they can.
|
|
21
|
+
|
|
22
|
+
What changed, all inside `SqlDriver`:
|
|
23
|
+
|
|
24
|
+
- `registerObjectMetadata(objects)`, `initObjects(objects)` and the shared `registerManagedObjectMetadata(obj)` helper each gained `indexes?: any[]`, spelled exactly as `detectManagedDrift` already spells it.
|
|
25
|
+
- Every `(obj as any)` cast reading `indexes` off those parameters is gone — the one at the `managedObjectIndexes.set` site and the two inside `initObjects`' own create/alter path. The cast was the evidence that the declaration and the read disagreed; leaving any of them would have fixed the signature while keeping the "the type does not admit me but I read it anyway" path alive. That path is now closed on this parameter.
|
|
26
|
+
|
|
27
|
+
**What the accept set does, precisely — it moves in both directions.** For a **fresh object literal**, which is what an author writes and what the excess-property check judges, this is purely a widening: `{ ...bare, indexes: [...] }` was rejected and is now accepted. For a **variable-bound** argument, which bypasses that check and is judged by ordinary assignability, it is a narrowing: `indexes` spelled as a record, as a `readonly` tuple (`as const`), or as `null` compiled under the previous signatures and is now rejected with TS2322. Measured in both directions, all three shapes, on this package's own `tsc`.
|
|
28
|
+
|
|
29
|
+
That narrowing is deliberate, and the three shapes did **not** all behave the same way before it — the difference is worth stating exactly, because only one of them ever worked:
|
|
30
|
+
|
|
31
|
+
- A **record** and **`null`** never survived the `Array.isArray(obj.indexes)` guard the driver has always applied. That author got no index and no diagnostic — silently, at run time. Rejecting those two at compile time is precisely the failure this change exists to make impossible.
|
|
32
|
+
- A **`readonly` tuple (`as const`)** is a different case, and the only one with anything to lose. `as const` is type-only: at run time the value is a plain array, `Array.isArray` returns `true`, and the index **was** synced. That caller compiled and worked, and is now rejected at compile time. Nothing about its run-time behaviour changed — the rejection is entirely on the type surface.
|
|
33
|
+
|
|
34
|
+
No migration is owed even so. No caller in this repository is affected, and the shape could never have reached `detectManagedDrift` on the same class either, which publishes the very same `any[]` spelling for the very same key — so a `readonly` caller was already unable to use half of this driver's declared-index surface. A caller in that position spells the array without `as const`, or widens it at the call site.
|
|
35
|
+
|
|
36
|
+
The disposition on that corrected ground, recorded here because the ground itself moved: **no `BREAKING` banner and no ADR-0087 disposition**, resting on grounds (i) and (iii) alone — zero affected callers, and the `any[]` spelling already published on `detectManagedDrift` for the same key on the same class. The ground that every newly rejected shape had already been discarded at run time is **not** among them: it is false for the `readonly` tuple, and nothing here leans on it.
|
|
37
|
+
|
|
38
|
+
`@objectstack/driver-sqlite-wasm` is named because `SqliteWasmDriver extends SqlDriver` and overrides neither method, so both widened signatures land in its own published `.d.ts` and its consumers see the identical change. The two packages are in the same fixed version group, so this is a CHANGELOG effect rather than a version one.
|
|
39
|
+
|
|
40
|
+
The `IDataDriver` contract itself did not move: `registerObjectMetadata?(schemas: unknown[])` in `@objectstack/spec` already accepted `unknown[]`, and `SqlDriver` narrowed it on its own. What grew is `SqlDriver`'s own published accept set.
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [fe0d9a4]
|
|
45
|
+
- Updated dependencies [ecd2158]
|
|
46
|
+
- Updated dependencies [f2b5e46]
|
|
47
|
+
- Updated dependencies [2ed6be6]
|
|
48
|
+
- Updated dependencies [ed7243d]
|
|
49
|
+
- Updated dependencies [6ba0db4]
|
|
50
|
+
- Updated dependencies [625b0c3]
|
|
51
|
+
- Updated dependencies [233222e]
|
|
52
|
+
- Updated dependencies [07f40e5]
|
|
53
|
+
- Updated dependencies [54bb2f1]
|
|
54
|
+
- Updated dependencies [ceb4877]
|
|
55
|
+
- Updated dependencies [e9fcd6b]
|
|
56
|
+
- Updated dependencies [90e7e6d]
|
|
57
|
+
- Updated dependencies [2bdabe6]
|
|
58
|
+
- Updated dependencies [ca326b5]
|
|
59
|
+
- Updated dependencies [8f404a5]
|
|
60
|
+
- Updated dependencies [68437d4]
|
|
61
|
+
- Updated dependencies [abb140c]
|
|
62
|
+
- Updated dependencies [8333a6c]
|
|
63
|
+
- Updated dependencies [3e3ecb0]
|
|
64
|
+
- Updated dependencies [3030369]
|
|
65
|
+
- Updated dependencies [d5d8d50]
|
|
66
|
+
- Updated dependencies [e08892d]
|
|
67
|
+
- Updated dependencies [ae05f2e]
|
|
68
|
+
- Updated dependencies [b548e43]
|
|
69
|
+
- Updated dependencies [c463d03]
|
|
70
|
+
- Updated dependencies [64bd6a3]
|
|
71
|
+
- Updated dependencies [13c48c2]
|
|
72
|
+
- Updated dependencies [b0529e1]
|
|
73
|
+
- Updated dependencies [66dc6ab]
|
|
74
|
+
- Updated dependencies [6f94458]
|
|
75
|
+
- Updated dependencies [6e67b86]
|
|
76
|
+
- Updated dependencies [132742f]
|
|
77
|
+
- Updated dependencies [85a2459]
|
|
78
|
+
- Updated dependencies [50dc214]
|
|
79
|
+
- Updated dependencies [e89fa92]
|
|
80
|
+
- Updated dependencies [e9fcd6b]
|
|
81
|
+
- Updated dependencies [8976ea1]
|
|
82
|
+
- Updated dependencies [56fe8c2]
|
|
83
|
+
- Updated dependencies [acabd24]
|
|
84
|
+
- Updated dependencies [ab50c8f]
|
|
85
|
+
- Updated dependencies [6491463]
|
|
86
|
+
- Updated dependencies [89cf4d6]
|
|
87
|
+
- Updated dependencies [21c5dcb]
|
|
88
|
+
- Updated dependencies [001a83b]
|
|
89
|
+
- Updated dependencies [6d4d5d3]
|
|
90
|
+
- Updated dependencies [45cfa1b]
|
|
91
|
+
- Updated dependencies [7862fb7]
|
|
92
|
+
- Updated dependencies [1ca95df]
|
|
93
|
+
- Updated dependencies [a646120]
|
|
94
|
+
- Updated dependencies [2200f8e]
|
|
95
|
+
- Updated dependencies [ed5d557]
|
|
96
|
+
- Updated dependencies [bca21f7]
|
|
97
|
+
- Updated dependencies [e9fcd6b]
|
|
98
|
+
- Updated dependencies [2025b1f]
|
|
99
|
+
- Updated dependencies [1a7a7c9]
|
|
100
|
+
- Updated dependencies [e9fcd6b]
|
|
101
|
+
- Updated dependencies [ef3a138]
|
|
102
|
+
- Updated dependencies [68d5dfd]
|
|
103
|
+
- Updated dependencies [3e21cf0]
|
|
104
|
+
- Updated dependencies [4cfc93b]
|
|
105
|
+
- Updated dependencies [efd6b43]
|
|
106
|
+
- Updated dependencies [859ded3]
|
|
107
|
+
- Updated dependencies [fa125f3]
|
|
108
|
+
- Updated dependencies [74628d9]
|
|
109
|
+
- Updated dependencies [a646120]
|
|
110
|
+
- Updated dependencies [6f1ce7d]
|
|
111
|
+
- Updated dependencies [7778115]
|
|
112
|
+
- Updated dependencies [2c753fe]
|
|
113
|
+
- Updated dependencies [52804cd]
|
|
114
|
+
- Updated dependencies [3f89967]
|
|
115
|
+
- Updated dependencies [53cf263]
|
|
116
|
+
- Updated dependencies [21aabbc]
|
|
117
|
+
- Updated dependencies [9c270bb]
|
|
118
|
+
- Updated dependencies [76c8c5a]
|
|
119
|
+
- Updated dependencies [8f2ecb3]
|
|
120
|
+
- Updated dependencies [a84e1ce]
|
|
121
|
+
- Updated dependencies [bf1054a]
|
|
122
|
+
- Updated dependencies [d8d2776]
|
|
123
|
+
- Updated dependencies [222dc0f]
|
|
124
|
+
- Updated dependencies [e9fcd6b]
|
|
125
|
+
- Updated dependencies [32c917d]
|
|
126
|
+
- Updated dependencies [f9a3c32]
|
|
127
|
+
- Updated dependencies [f502898]
|
|
128
|
+
- Updated dependencies [51ae731]
|
|
129
|
+
- Updated dependencies [af7edfe]
|
|
130
|
+
- Updated dependencies [b60f48b]
|
|
131
|
+
- Updated dependencies [c78c918]
|
|
132
|
+
- Updated dependencies [cf9bda4]
|
|
133
|
+
- Updated dependencies [784cb92]
|
|
134
|
+
- Updated dependencies [7629f4d]
|
|
135
|
+
- Updated dependencies [51df9fd]
|
|
136
|
+
- Updated dependencies [a7da4de]
|
|
137
|
+
- Updated dependencies [de0bcdd]
|
|
138
|
+
- Updated dependencies [70f7d6d]
|
|
139
|
+
- Updated dependencies [c677cda]
|
|
140
|
+
- Updated dependencies [554a160]
|
|
141
|
+
- Updated dependencies [f7da71e]
|
|
142
|
+
- Updated dependencies [7f745c3]
|
|
143
|
+
- Updated dependencies [61821e5]
|
|
144
|
+
- Updated dependencies [5eb24f8]
|
|
145
|
+
- Updated dependencies [2a3decc]
|
|
146
|
+
- Updated dependencies [cc00df2]
|
|
147
|
+
- Updated dependencies [cc00df2]
|
|
148
|
+
- Updated dependencies [f4e6adf]
|
|
149
|
+
- Updated dependencies [ee4a59b]
|
|
150
|
+
- Updated dependencies [4db3c61]
|
|
151
|
+
- Updated dependencies [5ca314a]
|
|
152
|
+
- Updated dependencies [e0af1a8]
|
|
153
|
+
- Updated dependencies [4771bd9]
|
|
154
|
+
- Updated dependencies [414c1fc]
|
|
155
|
+
- Updated dependencies [22c0279]
|
|
156
|
+
- Updated dependencies [0db2947]
|
|
157
|
+
- Updated dependencies [92b5d7f]
|
|
158
|
+
- Updated dependencies [613bfbd]
|
|
159
|
+
- Updated dependencies [abae16a]
|
|
160
|
+
- Updated dependencies [094b8fd]
|
|
161
|
+
- Updated dependencies [c7aca0d]
|
|
162
|
+
- Updated dependencies [33e939f]
|
|
163
|
+
- Updated dependencies [c1d8f98]
|
|
164
|
+
- Updated dependencies [8e0b297]
|
|
165
|
+
- Updated dependencies [d4f9b2a]
|
|
166
|
+
- Updated dependencies [5f7fa1d]
|
|
167
|
+
- Updated dependencies [87f0ccc]
|
|
168
|
+
- Updated dependencies [aedbaef]
|
|
169
|
+
- Updated dependencies [a727043]
|
|
170
|
+
- Updated dependencies [c5d6803]
|
|
171
|
+
- Updated dependencies [10d05bb]
|
|
172
|
+
- Updated dependencies [69602e5]
|
|
173
|
+
- Updated dependencies [c3ce76c]
|
|
174
|
+
- Updated dependencies [7936b29]
|
|
175
|
+
- Updated dependencies [46803fa]
|
|
176
|
+
- Updated dependencies [c2a336c]
|
|
177
|
+
- Updated dependencies [9f890d3]
|
|
178
|
+
- Updated dependencies [0bb2318]
|
|
179
|
+
- Updated dependencies [b72226f]
|
|
180
|
+
- Updated dependencies [f7db8f4]
|
|
181
|
+
- Updated dependencies [1ecee3e]
|
|
182
|
+
- Updated dependencies [9408b7f]
|
|
183
|
+
- Updated dependencies [e9fcd6b]
|
|
184
|
+
- Updated dependencies [9bcd9be]
|
|
185
|
+
- Updated dependencies [b398ad2]
|
|
186
|
+
- Updated dependencies [99261a7]
|
|
187
|
+
- Updated dependencies [81b426f]
|
|
188
|
+
- Updated dependencies [001af1c]
|
|
189
|
+
- Updated dependencies [fb77aa5]
|
|
190
|
+
- Updated dependencies [581d8f8]
|
|
191
|
+
- Updated dependencies [f81afe3]
|
|
192
|
+
- Updated dependencies [40a44b9]
|
|
193
|
+
- Updated dependencies [f89812e]
|
|
194
|
+
- Updated dependencies [7a7fb03]
|
|
195
|
+
- Updated dependencies [8fd246d]
|
|
196
|
+
- Updated dependencies [78bc4ad]
|
|
197
|
+
- @objectstack/spec@17.4.0
|
|
198
|
+
- @objectstack/driver-sql@17.4.0
|
|
199
|
+
- @objectstack/core@17.4.0
|
|
200
|
+
|
|
3
201
|
## 17.3.0
|
|
4
202
|
|
|
5
203
|
### Minor Changes
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/sqlite-wasm-driver.ts","../src/knex-wasm-dialect.ts","../src/wasm-connection.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { SqliteWasmDriver } from './sqlite-wasm-driver.js';\n\nexport { SqliteWasmDriver };\nexport type { SqliteWasmDriverConfig } from './sqlite-wasm-driver.js';\nexport { Client_WasmSqlite } from './knex-wasm-dialect.js';\nexport type { WasmSqliteConnectionSettings } from './knex-wasm-dialect.js';\nexport { WasmSqliteConnection } from './wasm-connection.js';\nexport type { PersistMode, WasmConnectionOptions } from './wasm-connection.js';\n\nexport default {\n id: 'com.objectstack.driver.sqlite-wasm',\n version: '1.0.0',\n\n onEnable: async (context: any) => {\n const { logger, config, drivers } = context;\n logger?.info?.('[SQLite-WASM Driver] Initializing...');\n\n if (drivers) {\n const driver = new SqliteWasmDriver(config);\n drivers.register(driver);\n logger?.info?.(`[SQLite-WASM Driver] Registered driver: ${driver.name}`);\n } else {\n logger?.warn?.('[SQLite-WASM Driver] No driver registry found in context.');\n }\n },\n};\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * SQLite-on-WASM driver for ObjectStack.\n *\n * Extends {@link SqlDriver} so all CRUD / schema / introspection / multi-tenant\n * logic is inherited as-is. Only the Knex transport is swapped to a custom\n * dialect ({@link Client_WasmSqlite}) backed by sql.js + Node `fs` persistence,\n * which lets the same `SqlDriver` codepath run inside StackBlitz WebContainer\n * (Node-in-browser) without the native `better-sqlite3` N-API binding.\n */\n\nimport type { SqlJsStatic } from 'sql.js';\nimport { SqlDriver, type SqlDriverConfig } from '@objectstack/driver-sql';\n\nimport { getClient_WasmSqlite } from './knex-wasm-dialect.js';\nimport type {\n PersistMode,\n WasmConnectionOptions,\n} from './wasm-connection.js';\n\n/** Public configuration for {@link SqliteWasmDriver}. */\nexport interface SqliteWasmDriverConfig {\n /**\n * SQLite filename. Use `:memory:` for an ephemeral database that is never\n * persisted. Any other value is treated as a Node `fs` path and the\n * sql.js database bytes are flushed back to disk according to {@link persist}.\n */\n filename: string;\n\n /**\n * Persistence strategy. Default: `'on-disconnect'`.\n *\n * - `'on-disconnect'` — flush once when the driver disconnects (and on\n * `process.beforeExit`).\n * - `'on-write'` — flush after every mutation. Safest, slowest.\n * - `` `debounced:${ms}` `` — debounce flushes by N milliseconds. Good\n * balance under bursty writes.\n */\n persist?: PersistMode;\n\n /** Pre-loaded sql.js module — skips lazy import. */\n sqlJs?: SqlJsStatic;\n\n /**\n * Override for sql.js's `locateFile`. Defaults to resolving the `.wasm`\n * file inside the installed `sql.js` package, which works in Node and\n * WebContainer.\n */\n locateFile?: (file: string) => string;\n\n /** Knex pool overrides. The dialect already defaults to `{ min: 1, max: 1 }`. */\n pool?: SqlDriverConfig['pool'];\n\n /** Optional logger. Defaults to `console`. */\n logger?: WasmConnectionOptions['logger'];\n}\n\n/**\n * SqlDriver subclass that runs Knex against sql.js (WASM SQLite).\n *\n * Behaves identically to the standard SQLite path — the dialect's\n * {@link Client_WasmSqlite._query} reports `lastID`/`changes` exactly the\n * way better-sqlite3 does, so {@link SqlDriver}'s SQL generation, returning\n * clauses, and schema introspection all keep working.\n */\nexport class SqliteWasmDriver extends SqlDriver {\n public override readonly name: string = 'com.objectstack.driver.sqlite-wasm';\n public override readonly version: string = '1.0.0';\n\n /**\n * Force the SQLite branch in {@link SqlDriver}. The base class detects\n * SQLite by string-matching `config.client`, but we pass the dialect class\n * directly so the string check would miss.\n */\n protected override get isSqlite(): boolean {\n return true;\n }\n\n /**\n * Never WAL (#3941). The base driver switches a file-backed SQLite database to\n * WAL so several processes can share one file. Nothing here is shared: the live\n * database sits in this process's WASM heap, and what reaches disk is a byte\n * image {@link flush} exports from it — another process reads that snapshot,\n * never the database. So the pragma buys this transport nothing.\n *\n * It is also not free. Journal mode is a persistent header change in the\n * operator's file, and under WAL the export path's correctness would rest on\n * sql.js checkpointing the log while `export()` closes and reopens the\n * database. Measured, it does — no row is lost today — which is why this is a\n * declined default and not a bug report. But a transport that persists by\n * serializing an image should not be one implementation detail away from\n * dropping committed rows for a concurrency benefit it cannot use.\n *\n * Declared rather than discovered: sql.js *accepts* `journal_mode = WAL`,\n * because its VFS is memory-backed, so the refusal the base class gets from\n * `:memory:` never comes — and an image whose header already says WAL (one a\n * native run left behind) reports `wal` here too.\n */\n protected override get supportsWalJournal(): boolean {\n return false;\n }\n\n private wasmConfig: SqliteWasmDriverConfig;\n private beforeExitHandler: (() => void) | null = null;\n\n constructor(config: SqliteWasmDriverConfig) {\n const knexConfig = SqliteWasmDriver.toKnexConfig(config);\n super(knexConfig);\n this.wasmConfig = config;\n if (config.logger) this.logger = config.logger as any;\n }\n\n /** Translate the public config into a Knex config that uses our dialect. */\n static toKnexConfig(config: SqliteWasmDriverConfig): SqlDriverConfig {\n return {\n // Knex accepts a Client class as `client`. The dialect's `driverName`\n // is `'wasm-sqlite'` and its `dialect` is `'sqlite3'` so the SQLite\n // query compiler is reused.\n client: getClient_WasmSqlite() as any,\n connection: {\n filename: config.filename,\n persist: config.persist,\n sqlJs: config.sqlJs,\n locateFile: config.locateFile,\n logger: config.logger,\n } as any,\n // sql.js is single-threaded WASM — a single connection per pool keeps\n // semantics consistent with the upstream SQLite dialect.\n pool: config.pool ?? { min: 1, max: 1 },\n useNullAsDefault: true,\n } as SqlDriverConfig;\n }\n\n override async connect(): Promise<void> {\n await super.connect();\n\n // Best-effort flush on process exit so `on-disconnect` mode still saves\n // user data if the host process is shut down without explicit cleanup.\n if (\n this.wasmConfig.filename !== ':memory:' &&\n !this.wasmConfig.filename.startsWith(':') &&\n typeof process !== 'undefined' &&\n typeof process.once === 'function'\n ) {\n this.beforeExitHandler = () => {\n // Fire-and-forget — beforeExit cannot await.\n void this.flush().catch(() => {\n /* ignore */\n });\n };\n process.once('beforeExit', this.beforeExitHandler);\n }\n }\n\n override async disconnect(): Promise<void> {\n if (this.beforeExitHandler && typeof process !== 'undefined') {\n try {\n process.removeListener('beforeExit', this.beforeExitHandler);\n } catch {\n /* ignore */\n }\n this.beforeExitHandler = null;\n }\n await super.disconnect();\n }\n\n /**\n * Force a flush of the in-memory database to disk. No-op for ephemeral\n * databases or when no fs is available.\n */\n async flush(): Promise<void> {\n // Reach into the Knex pool and ask every live connection to flush.\n const knex = (this as any).knex;\n const client = knex?.client;\n const pool = client?.pool;\n if (!pool || typeof pool.numUsed !== 'function') return;\n\n const acquire = client.acquireConnection?.bind(client);\n const release = client.releaseConnection?.bind(client);\n if (!acquire || !release) return;\n\n const conn = await acquire();\n try {\n if (conn && typeof conn.flush === 'function') {\n await conn.flush();\n }\n } finally {\n await release(conn);\n }\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Custom Knex SQLite dialect backed by sql.js (WASM SQLite).\n *\n * Mimics the surface that `Client_BetterSQLite3` presents to Knex so the\n * upstream SQLite3 dialect's query compiler, schema builder, and column\n * compiler all keep working unchanged. Only the transport layer —\n * `_driver` / `acquireRawConnection` / `_query` — is swapped out.\n *\n * ## Why the dialect class is built lazily\n *\n * The class `Client_WasmSqlite extends Client_SQLite3` needs the upstream\n * SQLite3 dialect at class-definition time. Resolving it at module\n * top-level breaks when this file is re-bundled by another tsup/esbuild\n * pass (e.g. `packages/runtime`), because that pass rewrites our runtime\n * `createRequire(import.meta.url)` chain back into a static `__require2`\n * Proxy stub that throws `Dynamic require of \"X\" is not supported`.\n *\n * Building the class inside a lazy factory (`getClient_WasmSqlite()`)\n * keeps the `require` call out of module-init code, so the re-bundler\n * cannot intercept it.\n */\n\nimport { createRequire } from 'node:module';\n\nimport type { SqlJsStatic } from 'sql.js';\n\nimport {\n WasmSqliteConnection,\n type PersistMode,\n type WasmConnectionOptions,\n} from './wasm-connection.js';\n\n// Built lazily — `node:module` is a Node builtin and is left untouched\n// by esbuild/tsup, so the `createRequire` import survives downstream\n// re-bundling. We defer the actual `createRequire(...)` call so that the\n// CJS build (where `import.meta.url` is empty) doesn't blow up at module\n// init; the CJS path uses `globalThis.require` directly anyway.\nlet cachedEsmRequire: any = null;\nfunction getEsmRequire(): any {\n if (cachedEsmRequire) return cachedEsmRequire;\n // `import.meta.url` is replaced with an empty string in CJS output;\n // fall back to the current file/cwd in that case.\n const anchor =\n typeof import.meta !== 'undefined' && (import.meta as any).url\n ? (import.meta as any).url\n : typeof __filename !== 'undefined'\n ? __filename\n : process.cwd() + '/';\n cachedEsmRequire = createRequire(anchor);\n return cachedEsmRequire;\n}\n\n/** Connection settings recognised by the WASM SQLite dialect. */\nexport interface WasmSqliteConnectionSettings {\n filename: string;\n persist?: PersistMode;\n sqlJs?: SqlJsStatic;\n locateFile?: (file: string) => string;\n logger?: WasmConnectionOptions['logger'];\n}\n\n/**\n * Coerce JS values that sql.js cannot bind directly. Mirrors\n * `Client_BetterSQLite3._formatBindings`.\n *\n * `undefined` is mapped to `null`: sql.js's binder only accepts\n * string/number/bigint/boolean/null (and array/blob) and `throw`s a *raw\n * string* — `\"Wrong API use : tried to bind a value of an unknown type\n * (undefined).\"` — for anything else. Because it throws a string rather than\n * an `Error`, it logs as a garbled char-indexed object and aborts the whole\n * write. Mapping to `null` matches the `useNullAsDefault` semantics the\n * dialect is configured with, so a missing/undefined value persists as SQL\n * `NULL` exactly as it would through better-sqlite3.\n */\nfunction formatBindings(bindings: unknown[] | undefined): unknown[] {\n if (!bindings) return [];\n return bindings.map((b) => {\n if (b === undefined) return null;\n if (b instanceof Date) return b.valueOf();\n if (typeof b === 'boolean') return Number(b);\n return b;\n });\n}\n\n/**\n * Mirrors the dispatch in upstream `Client_SQLite3._query`: only\n * `insert/update/counter/del` go through the row-less write path (and even\n * those switch to the read path when a `RETURNING` clause is requested).\n * Everything else — `select`, `first`, `pluck`, `columnInfo`, raw PRAGMA,\n * DDL with no `method` — is read with `all`/row iteration so Knex sees the\n * same response shape it would from better-sqlite3.\n *\n * ⚠️ This answers \"how do I EXECUTE this statement\", never \"does this statement\n * change the database\" — an `INSERT … RETURNING *` is executed down the\n * row-returning branch and mutates. Persistence is classified separately by\n * {@link statementMutatesDatabase}; conflating the two is #4518.\n */\nfunction isRowReturningExecution(method?: string, returning?: unknown): boolean {\n if (method === 'insert' || method === 'update') return !!returning ? true : false;\n if (method === 'counter' || method === 'del') return false;\n return true;\n}\n\n/** Knex `method` values that always denote a mutation. */\nconst MUTATING_METHODS = new Set(['insert', 'update', 'del', 'counter']);\n\n/** Statement-control forms whose persistence is owned by the transaction lifecycle. */\nconst TRANSACTION_CONTROL_RE = /^\\s*(BEGIN|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\\b/i;\n\n/**\n * DDL / schema statements. `BEGIN…RELEASE` share this prefix set in SQLite's\n * grammar but are transaction control, so they are matched (and routed) first.\n */\nconst DDL_RE =\n /^\\s*(CREATE|ALTER|DROP|BEGIN|COMMIT|ROLLBACK|SAVEPOINT|RELEASE|REINDEX|VACUUM|ATTACH|DETACH|TRUNCATE)\\b/i;\n\n/** DML that changes rows, whatever execution branch it happens to run down. */\nconst MUTATING_DML_RE = /^\\s*(INSERT|UPDATE|DELETE|REPLACE|UPSERT)\\b/i;\n\n/**\n * PRAGMA forms that change bytes in the database file: any assignment\n * (`PRAGMA auto_vacuum = INCREMENTAL`, `PRAGMA user_version = 3` — both\n * persistent header state) and `incremental_vacuum`, which actually moves\n * pages. Introspection PRAGMAs (`table_info`, `index_list`, …) are reads.\n */\nconst MUTATING_PRAGMA_RE = /^\\s*PRAGMA\\b(?:[^;]*=|\\s+incremental_vacuum\\b)/i;\n\n/**\n * THE single answer to \"did this statement change the database, so that the\n * in-memory image must eventually be written back to disk?\"\n *\n * It is deliberately independent of which execution branch {@link\n * isRowReturningExecution} picks, because those are different questions and\n * answering them with one predicate is what broke persistence in #4518: the\n * ObjectQL engine writes through `INSERT … RETURNING *` / `UPDATE … RETURNING *`\n * (it needs the stored row back), those run down the row-returning branch, and\n * the dirty flag was only ever set on the other branch. The result was a\n * file-backed database that flushed its schema and then silently stopped\n * recording anything — a cold boot found every table present and every row\n * gone, and `on-disconnect` did not save it either, because the final flush\n * also keys off the same flag.\n *\n * Classifying by BOTH the Knex `method` and the SQL text means a mutation\n * cannot slip through by arriving without a method (`knex.raw('INSERT …')`,\n * seed/migration SQL) or by taking an unexpected branch.\n */\nexport function statementMutatesDatabase(sql: string, method?: string): boolean {\n if (TRANSACTION_CONTROL_RE.test(sql)) return false; // owned by noteTransactionControl\n if (method && MUTATING_METHODS.has(method)) return true;\n if (DDL_RE.test(sql)) return true;\n if (MUTATING_DML_RE.test(sql)) return true;\n return MUTATING_PRAGMA_RE.test(sql);\n}\n\n/**\n * Resolve the upstream `knex/lib/dialects/sqlite3` class at runtime.\n *\n * Tries every escape hatch we have so that this works in:\n * - Plain Node ESM (use `createRequire(import.meta.url)`).\n * - Plain Node CJS (use the ambient `require` on `globalThis`).\n * - Re-bundled ESM where esbuild/tsup has stubbed `__require` — we\n * fall back to `new Function('return require')()` which evades static\n * analysis and grabs the real Node `require` at runtime.\n *\n * Wrapped in a function so the bundler cannot execute it at module init.\n */\nfunction resolveKnexSqlite3Dialect(): any {\n const g = globalThis as any;\n if (typeof g.require === 'function') {\n try {\n return g.require('knex/lib/dialects/sqlite3');\n } catch {\n /* fall through */\n }\n }\n // ESM-safe path: `createRequire` was imported statically at the top of\n // this module from `node:module`. In a pure-ESM process there is no\n // ambient `require`, so this is the only reliable way to load a CJS\n // package like `knex/lib/dialects/sqlite3`.\n return getEsmRequire()('knex/lib/dialects/sqlite3');\n}\n\nlet cachedDialect: any = null;\n\n/**\n * Build (and cache) the `Client_WasmSqlite` class. Building lazily keeps\n * the `require('knex/lib/dialects/sqlite3')` call out of module-init\n * code so downstream re-bundlers (e.g. `packages/runtime`) cannot collapse\n * it into a Dynamic-require stub.\n */\nexport function getClient_WasmSqlite(): any {\n if (cachedDialect) return cachedDialect;\n const Client_SQLite3 = resolveKnexSqlite3Dialect();\n\n class Client_WasmSqlite extends Client_SQLite3 {\n // sql.js has no shared \"driver module\" the way better-sqlite3 does. Knex\n // only uses `this.driver` to construct connections, and we override\n // `acquireRawConnection`, so a sentinel object is enough.\n _driver(): { name: 'sql.js' } {\n return { name: 'sql.js' };\n }\n\n async acquireRawConnection(): Promise<WasmSqliteConnection> {\n const settings = (this as any)\n .connectionSettings as WasmSqliteConnectionSettings;\n\n const conn = new WasmSqliteConnection({\n filename: settings.filename,\n persist: settings.persist,\n sqlJs: settings.sqlJs,\n locateFile: settings.locateFile,\n logger: settings.logger,\n });\n await conn.open(settings.sqlJs, settings.locateFile);\n return conn;\n }\n\n async destroyRawConnection(connection: WasmSqliteConnection): Promise<void> {\n await connection.close();\n }\n\n async _query(\n connection: WasmSqliteConnection,\n obj: any,\n ): Promise<any> {\n if (!obj.sql) throw new Error('The query is empty');\n if (!connection) throw new Error('No connection provided');\n\n const db = connection.raw;\n const bindings = formatBindings(obj.bindings);\n\n // ── 1. EXECUTE ────────────────────────────────────────────────────────\n // Three execution shapes. None of them decides persistence: that is\n // settled once, below, so a statement cannot mutate the database on a\n // branch that forgot to say so (#4518).\n\n // DDL / transaction control have no Knex `method`. sql.js's\n // `prepare`+`step` silently no-ops on many of these (e.g. CREATE TABLE),\n // so route them through `run` which is implemented via `exec` and\n // actually mutates the database. PRAGMA is intentionally excluded — many\n // PRAGMA forms (e.g. `PRAGMA table_info(...)`, `foreign_key_list(...)`)\n // return rows used by Knex's schema introspection/columnInfo, and\n // `db.run` discards those rows.\n if (DDL_RE.test(obj.sql)) {\n db.run(obj.sql, bindings as any);\n obj.response = [];\n } else if (\n isRowReturningExecution(obj.method, obj.returning) ||\n /^\\s*PRAGMA\\b/i.test(obj.sql)\n ) {\n // Row-returning branch. NOTE this is also where `INSERT … RETURNING *`\n // and `UPDATE … RETURNING *` land — statements that very much write.\n const stmt = db.prepare(obj.sql);\n try {\n if (bindings.length) stmt.bind(bindings as any);\n const rows: Record<string, unknown>[] = [];\n while (stmt.step()) {\n rows.push(stmt.getAsObject());\n }\n obj.response = rows;\n } finally {\n stmt.free();\n }\n } else {\n // Row-less write path: execute via `run` and capture SQLite's\n // per-connection lastID / changes counters.\n db.run(obj.sql, bindings as any);\n const changes = db.getRowsModified();\n let lastID: number | bigint = 0;\n if (obj.method === 'insert') {\n const r = db.exec('SELECT last_insert_rowid() AS id');\n lastID = (r?.[0]?.values?.[0]?.[0] as number) ?? 0;\n }\n obj.response = [];\n obj.context = { lastID, changes };\n }\n\n // ── 2. PERSIST ────────────────────────────────────────────────────────\n // Exactly one place decides whether the on-disk image is now stale.\n //\n // Transaction-control statements are routed to `noteTransactionControl`,\n // which owns flushing across the transaction lifecycle: it suppresses\n // flushes while a transaction is open (sql.js `export()` closes+reopens\n // the db, which would abort the txn) and performs a single flush once the\n // transaction fully closes. Routing them away from `markDirty` avoids a\n // second, racing flush on COMMIT.\n if (TRANSACTION_CONTROL_RE.test(obj.sql)) {\n connection.noteTransactionControl(obj.sql);\n } else if (statementMutatesDatabase(obj.sql, obj.method)) {\n connection.markDirty();\n }\n return obj;\n }\n }\n\n Object.assign(Client_WasmSqlite.prototype, {\n dialect: 'sqlite3',\n driverName: 'wasm-sqlite',\n });\n\n cachedDialect = Client_WasmSqlite;\n return Client_WasmSqlite;\n}\n\n/**\n * Back-compat re-export. Prefer `getClient_WasmSqlite()` so the dialect\n * is resolved lazily; the named export triggers the factory on first\n * access of any static property.\n *\n * Note: importing this binding will execute the factory at import time\n * in some bundlers, which defeats the lazy pattern. New code should call\n * `getClient_WasmSqlite()` directly.\n */\nexport const Client_WasmSqlite: any = new Proxy(function () {} as any, {\n get(_t, prop) {\n return (getClient_WasmSqlite() as any)[prop];\n },\n construct(_t, args) {\n const Klass = getClient_WasmSqlite();\n return new Klass(...args);\n },\n apply(_t, thisArg, args) {\n const Klass = getClient_WasmSqlite();\n return Reflect.apply(Klass, thisArg, args);\n },\n});\n\nexport default Client_WasmSqlite;\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Thin wrapper over sql.js {@link Database} that mimics the surface of\n * `better-sqlite3`'s `Database` (only the methods the Knex dialect uses).\n *\n * Persistence is handled here, not in the Knex dialect, so it can be\n * orchestrated per-connection without polluting the SQL execution path.\n */\n\nimport type { Database, SqlJsStatic } from 'sql.js';\n\n/** When to flush the in-memory WASM database to disk. */\nexport type PersistMode =\n | 'on-disconnect'\n | 'on-write'\n | `debounced:${number}`;\n\nexport interface WasmConnectionOptions {\n /**\n * On-disk file path. `:memory:` (or any value starting with `:`) skips\n * persistence entirely and the database lives only for the process.\n */\n filename: string;\n /** When to persist. Default: `on-disconnect`. */\n persist?: PersistMode;\n /** Pre-loaded sql.js module. If omitted, loaded lazily on first connect. */\n sqlJs?: SqlJsStatic;\n /**\n * Optional override for the `.wasm` locator passed to `initSqlJs()`.\n * Defaults to resolving the file from the `sql.js` package on disk\n * (works in Node and WebContainer).\n */\n locateFile?: (file: string) => string;\n /** Optional logger; defaults to `console`. */\n logger?: { warn: (msg: string, meta?: unknown) => void };\n}\n\n/**\n * Detect whether a Node-style `fs` module is available. WebContainer\n * (StackBlitz) provides Node `fs`; pure-browser environments do not.\n */\nasync function tryLoadFs(): Promise<typeof import('node:fs/promises') | null> {\n try {\n return await import('node:fs/promises');\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve a default sql.js WASM locator. We point sql.js at the `.wasm`\n * file shipped inside `sql.js`'s own `dist/` folder. This avoids requiring\n * the caller to host the WASM separately.\n */\nasync function defaultLocateFile(): Promise<((file: string) => string) | undefined> {\n try {\n const { createRequire } = await import('node:module');\n const require = createRequire(import.meta.url);\n const pkgJsonPath = require.resolve('sql.js/package.json');\n const { dirname, join } = await import('node:path');\n const dir = dirname(pkgJsonPath);\n return (file: string) => join(dir, 'dist', file);\n } catch {\n return undefined;\n }\n}\n\nlet cachedSqlJs: Promise<SqlJsStatic> | null = null;\n\nasync function loadSqlJs(\n locateFile?: (file: string) => string,\n): Promise<SqlJsStatic> {\n if (cachedSqlJs) return cachedSqlJs;\n cachedSqlJs = (async () => {\n const mod = await import('sql.js');\n const initSqlJs = (mod as any).default ?? (mod as any);\n const locator = locateFile ?? (await defaultLocateFile());\n const SQL = await initSqlJs(locator ? { locateFile: locator } : undefined);\n return SQL as SqlJsStatic;\n })();\n return cachedSqlJs;\n}\n\n/**\n * A sql.js-backed connection that exposes the `prepare`/`exec`/`close`\n * subset used by Knex's SQLite dialect. Mutations are queued through a\n * configurable persistence strategy so the on-disk file stays in sync.\n */\nexport class WasmSqliteConnection {\n /**\n * Process-wide counter making each atomic-write temp filename unique, so\n * concurrent connections (or overlapping flushes) never target the same\n * temp path. Combined with `process.pid` for cross-process uniqueness.\n */\n private static tmpSeq = 0;\n\n readonly filename: string;\n readonly persist: PersistMode;\n readonly isEphemeral: boolean;\n\n private db!: Database;\n private fs: typeof import('node:fs/promises') | null = null;\n private dirty = false;\n private debounceMs = 0;\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n private flushChain: Promise<void> | null = null;\n private destroyed = false;\n private logger: { warn: (msg: string, meta?: unknown) => void };\n\n /**\n * Whether a `BEGIN…COMMIT/ROLLBACK` transaction is currently open. Tracked\n * because sql.js's {@link Database.export} closes and reopens the database\n * (it has no in-place serialize), and closing a connection rolls back any\n * open transaction. Flushing mid-transaction would therefore silently\n * abort it, leaving the eventual `COMMIT` to fail with\n * \"cannot commit - no transaction is active\". We defer the flush until the\n * transaction fully closes. See {@link noteTransactionControl}.\n */\n private rootTxActive = false;\n /** Open `SAVEPOINT` depth (nested transactions emitted by Knex). */\n private savepointDepth = 0;\n /** A flush was requested while a transaction was open; run it on close. */\n private flushDeferred = false;\n\n /** True while any transaction (root or savepoint) is in flight. */\n private get inTransaction(): boolean {\n return this.rootTxActive || this.savepointDepth > 0;\n }\n\n constructor(opts: WasmConnectionOptions) {\n this.filename = opts.filename;\n this.persist = opts.persist ?? 'on-disconnect';\n this.isEphemeral =\n this.filename === ':memory:' || this.filename.startsWith(':');\n this.logger = opts.logger ?? console;\n\n if (typeof this.persist === 'string' && this.persist.startsWith('debounced:')) {\n const ms = Number(this.persist.slice('debounced:'.length));\n this.debounceMs = Number.isFinite(ms) && ms > 0 ? ms : 250;\n }\n }\n\n /** Open the underlying sql.js database, loading bytes from disk if any. */\n async open(sqlJs?: SqlJsStatic, locateFile?: (file: string) => string): Promise<void> {\n const SQL = sqlJs ?? (await loadSqlJs(locateFile));\n\n if (this.isEphemeral) {\n this.db = new SQL.Database();\n return;\n }\n\n this.fs = await tryLoadFs();\n if (!this.fs) {\n this.logger.warn(\n '[driver-sqlite-wasm] No node:fs available — falling back to in-memory database. ' +\n 'Data will not be persisted across reloads.',\n );\n this.db = new SQL.Database();\n return;\n }\n\n // Ensure parent directory exists, then load bytes if the file exists.\n const { dirname } = await import('node:path');\n const dir = dirname(this.filename);\n if (dir && dir !== '.') {\n await this.fs.mkdir(dir, { recursive: true });\n }\n\n let bytes: Uint8Array | undefined;\n try {\n const buf = await this.fs.readFile(this.filename);\n bytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n } catch (e: any) {\n if (e?.code !== 'ENOENT') throw e;\n }\n\n if (!bytes) {\n this.db = new SQL.Database();\n return;\n }\n\n await this.quarantineOrphanedWal();\n\n // Open the on-disk bytes, but guard against a corrupt image. A torn write\n // (process killed mid-flush before atomic writes existed) or otherwise\n // damaged file makes `new SQL.Database(bytes)` either throw (\"file is not a\n // database\") or open a handle whose every query fails with \"database disk\n // image is malformed\" — which, for a background dispatcher on a tick loop,\n // means the same error spammed forever with no path to recovery. Detect it\n // once at open, quarantine the bad file, and start fresh so the dev server\n // becomes usable again instead of wedging.\n try {\n const candidate = new SQL.Database(bytes);\n this.assertReadable(candidate);\n this.db = candidate;\n } catch (err) {\n await this.quarantineCorruptFile(err);\n this.db = new SQL.Database();\n }\n }\n\n /**\n * Force sql.js to actually read a page so a malformed image surfaces now\n * rather than on the first business query. `PRAGMA quick_check` walks the\n * b-tree structure without the full-scan cost of `integrity_check`; a healthy\n * database returns a single `ok` row. Any thrown error (raw string or Error)\n * or a non-`ok` result is treated as corruption.\n */\n private assertReadable(db: Database): void {\n const res = db.exec('PRAGMA quick_check(1)');\n const first = res?.[0]?.values?.[0]?.[0];\n if (typeof first === 'string' && first.toLowerCase() !== 'ok') {\n throw new Error(`sqlite quick_check failed: ${first}`);\n }\n }\n\n /**\n * Move a corrupt database file aside so its bytes are preserved for\n * post-mortem while a fresh, empty database takes its place. Best-effort:\n * failures here must not prevent the server from booting on a clean DB.\n */\n private async quarantineCorruptFile(cause: unknown): Promise<void> {\n if (!this.fs) return;\n const reason =\n typeof cause === 'string' ? cause : (cause as Error)?.message ?? String(cause);\n const backup = `${this.filename}.corrupt-${Date.now()}`;\n try {\n await this.fs.rename(this.filename, backup);\n this.logger.warn(\n `[driver-sqlite-wasm] Database image at ${this.filename} is corrupt ` +\n `(${reason}). Quarantined to ${backup} and starting from an empty ` +\n `database so the server can boot.`,\n );\n } catch (renameErr) {\n // Could not move it aside (e.g. permissions) — overwrite is still better\n // than looping forever on a malformed image. Warn loudly and continue.\n this.logger.warn(\n `[driver-sqlite-wasm] Database image at ${this.filename} is corrupt ` +\n `(${reason}) and could not be quarantined (${String(renameErr)}). ` +\n `Starting from an empty database; the corrupt file will be overwritten ` +\n `on the next flush.`,\n );\n }\n }\n\n /**\n * Move a write-ahead log left behind by a *real* SQLite aside (#3941).\n *\n * The native driver keeps file-backed databases in WAL mode, and a clean close\n * checkpoints the log away — so a non-empty `<db>-wal` here means the last\n * process died without one. That log is a problem in both directions, and\n * neither is something wasm SQLite can fix: it cannot read the log (we load\n * only the main image, so any transaction still in there is invisible), and it\n * must not leave it in place either — the next {@link flush} rewrites the\n * image, and a real SQLite opening a fresh image beside a stale log would\n * replay frames that no longer belong to it.\n *\n * So rename it, which loses nothing recoverable (the bytes are preserved for a\n * real `sqlite3` to recover from) and disarms the mismatch. Best-effort: this\n * is a dev-only step-down path and must never prevent a boot.\n */\n private async quarantineOrphanedWal(): Promise<void> {\n if (!this.fs) return;\n const wal = `${this.filename}-wal`;\n let size: number;\n try {\n size = (await this.fs.stat(wal)).size;\n } catch {\n return; // no sidecar (the normal case) or an unreadable one\n }\n if (size <= 0) return; // checkpointed-and-truncated: nothing in it\n\n const parked = `${wal}.orphaned-${Date.now()}`;\n try {\n await this.fs.rename(wal, parked);\n this.logger.warn(\n `[driver-sqlite-wasm] ${wal} holds ${size} bytes of write-ahead log that wasm SQLite ` +\n `cannot read — this database was last used in WAL mode and closed uncleanly. Parked it ` +\n `at ${parked} and loaded the main image without it, so anything committed only to the ` +\n `log is NOT in this session. To recover it, rebuild better-sqlite3 (or use \\`sqlite3\\`), ` +\n `restore the log next to the database, and run \\`PRAGMA wal_checkpoint(TRUNCATE)\\`.`,\n );\n } catch (renameErr) {\n this.logger.warn(\n `[driver-sqlite-wasm] ${wal} holds ${size} bytes of write-ahead log that wasm SQLite ` +\n `cannot read, and it could not be moved aside (${String(renameErr)}). Data committed ` +\n `only to the log is missing from this session; checkpoint it with a real sqlite3 before ` +\n `writing further.`,\n );\n }\n }\n\n /**\n * Update transaction state from a transaction-control statement and, when a\n * transaction has just fully closed, run any flush that was deferred while\n * it was open. Called by the Knex dialect for every `BEGIN` / `COMMIT` /\n * `ROLLBACK` / `SAVEPOINT` / `RELEASE` statement.\n *\n * We bias toward \"in transaction\": an unrecognised form leaves the flag set,\n * which at worst delays a flush (safe) rather than exporting mid-transaction\n * (which would abort it).\n */\n noteTransactionControl(sql: string): void {\n const s = sql.trim().toUpperCase();\n if (/^BEGIN\\b/.test(s)) {\n this.rootTxActive = true;\n } else if (/^(COMMIT|END)\\b/.test(s)) {\n // A COMMIT/END ends the whole transaction regardless of savepoint nesting.\n this.rootTxActive = false;\n this.savepointDepth = 0;\n } else if (/^ROLLBACK\\s+TO\\b/.test(s)) {\n // Rolls back to a savepoint but keeps the (outer) transaction open.\n } else if (/^ROLLBACK\\b/.test(s)) {\n this.rootTxActive = false;\n this.savepointDepth = 0;\n } else if (/^SAVEPOINT\\b/.test(s)) {\n this.savepointDepth += 1;\n } else if (/^RELEASE\\b/.test(s)) {\n this.savepointDepth = Math.max(0, this.savepointDepth - 1);\n }\n // If the transaction just fully closed and a flush was deferred while it\n // was open, run it now. We key off `flushDeferred` (set only when\n // `markDirty` actually wanted to flush) rather than `dirty`, so persist\n // modes that don't flush per-write — e.g. `on-disconnect` — still defer to\n // close() instead of flushing on every COMMIT.\n if (!this.inTransaction && this.flushDeferred) {\n this.flushDeferred = false;\n void this.flush();\n }\n }\n\n /**\n * Record that the statement just executed CHANGED the database, and schedule\n * a flush according to {@link persist}.\n *\n * Deliberately takes no argument. It used to filter the caller's Knex\n * `method` against a local write-method allowlist, which made \"did this\n * mutate?\" a decision taken in TWO places — here and in the dialect's\n * execution-path branch — and the two disagreed: an `INSERT … RETURNING`\n * runs down the dialect's ROW-returning branch (it has rows to return), that\n * branch never called this method at all, and so a whole class of committed\n * writes was never marked dirty and never reached disk (#4518). One decision,\n * one owner: {@link statementMutatesDatabase} in the dialect classifies the\n * statement, and this method just does what it is told.\n */\n markDirty(): void {\n if (this.isEphemeral || !this.fs) return;\n this.dirty = true;\n\n if (this.persist === 'on-write') {\n void this.flush();\n return;\n }\n if (this.debounceMs > 0) {\n if (this.debounceTimer) clearTimeout(this.debounceTimer);\n this.debounceTimer = setTimeout(() => {\n this.debounceTimer = null;\n void this.flush();\n }, this.debounceMs);\n }\n // 'on-disconnect' → flush only at close()\n }\n\n /**\n * Force a write of the current database state to disk.\n *\n * Flushes are strictly serialized through a single promise chain: every call\n * appends an export+write step that runs after all previously-queued steps.\n * This matters because sql.js `export()` mutates the live connection (it\n * closes and reopens the database), so two exports must never overlap — and\n * because the returned promise must not resolve until the caller's own write\n * has hit disk (deterministic for tests and for `close()`). Each step\n * re-checks `dirty` at run time, so a no-op write collapses cheaply and a\n * write that arrived mid-flush is captured by the next queued step.\n */\n async flush(): Promise<void> {\n if (this.isEphemeral || !this.fs || this.destroyed) return;\n // Never export while a transaction is open: sql.js's `export()` closes and\n // reopens the database, which rolls back the in-flight transaction and\n // makes the subsequent COMMIT fail. Defer until the transaction closes\n // (handled in `noteTransactionControl`).\n if (this.inTransaction) {\n this.flushDeferred = true;\n return;\n }\n\n const prev = this.flushChain;\n const step = (prev ?? Promise.resolve()).then(async () => {\n if (!this.dirty || this.destroyed || this.inTransaction) return;\n // Snapshot dirty=false before export so a concurrent write re-marks us\n // and is picked up by the next queued step.\n this.dirty = false;\n try {\n const exported = this.db.export();\n // sql.js returns a Uint8Array; Buffer.from on it shares memory but\n // works fine for the atomic write below.\n await this.atomicWriteFile(Buffer.from(exported));\n } catch (err) {\n this.dirty = true; // let a later flush retry\n throw err;\n }\n });\n // Keep the chain tail alive but swallow its rejection there so one failed\n // flush doesn't poison every future flush; the awaited `step` still throws.\n this.flushChain = step.catch(() => {});\n await step;\n }\n\n /**\n * Write the database bytes to disk atomically: write to a sibling temp file,\n * fsync it, then `rename()` it over the target.\n *\n * A plain `writeFile(this.filename, …)` truncates the target and streams the\n * new bytes in place, so a process killed mid-write (a dev-server restart,\n * Ctrl-C, or crash — likely under `on-write`, where every dispatcher tick\n * flushes) leaves a half-written file. sql.js then rejects that file on the\n * next boot with \"database disk image is malformed\". `rename(2)` is atomic\n * within a filesystem, so a reader always sees either the complete old file\n * or the complete new one — never a torn image. The temp file lives in the\n * same directory as the target so the rename stays intra-filesystem.\n */\n private async atomicWriteFile(data: Buffer): Promise<void> {\n if (!this.fs) return;\n const tmp = `${this.filename}.tmp-${process.pid}-${(WasmSqliteConnection.tmpSeq += 1)}`;\n let handle: import('node:fs/promises').FileHandle | undefined;\n try {\n handle = await this.fs.open(tmp, 'w');\n await handle.writeFile(data);\n // Flush the bytes to the platter before the rename so a crash can't leave\n // a renamed-but-empty file behind on filesystems that reorder the two.\n await handle.sync();\n await handle.close();\n handle = undefined;\n await this.fs.rename(tmp, this.filename);\n } catch (err) {\n if (handle) {\n try {\n await handle.close();\n } catch {\n /* ignore */\n }\n }\n // Clean up the temp file so a failed flush doesn't litter the data dir.\n try {\n await this.fs.unlink(tmp);\n } catch {\n /* ignore */\n }\n throw err;\n }\n }\n\n /** Close the database, flushing any pending writes first. */\n async close(): Promise<void> {\n if (this.destroyed) return;\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n // Any transaction still open at close is abandoned and will be rolled back\n // by `db.close()`; clear the flag so the final flush is not deferred and\n // already-committed data is persisted.\n this.rootTxActive = false;\n this.savepointDepth = 0;\n try {\n await this.flush();\n } finally {\n this.destroyed = true;\n try {\n this.db.close();\n } catch {\n /* ignore */\n }\n }\n }\n\n /** Access the raw sql.js database (for the Knex dialect). */\n get raw(): Database {\n return this.db;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,wBAAgD;;;ACWhD,yBAA8B;;;ACxB9B;AA0CA,eAAe,YAA+D;AAC5E,MAAI;AACF,WAAO,MAAM,OAAO,aAAkB;AAAA,EACxC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOA,eAAe,oBAAqE;AAClF,MAAI;AACF,UAAM,EAAE,eAAAA,eAAc,IAAI,MAAM,OAAO,QAAa;AACpD,UAAMC,WAAUD,eAAc,YAAY,GAAG;AAC7C,UAAM,cAAcC,SAAQ,QAAQ,qBAAqB;AACzD,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,OAAO,MAAW;AAClD,UAAM,MAAM,QAAQ,WAAW;AAC/B,WAAO,CAAC,SAAiB,KAAK,KAAK,QAAQ,IAAI;AAAA,EACjD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAI,cAA2C;AAE/C,eAAe,UACb,YACsB;AACtB,MAAI,YAAa,QAAO;AACxB,iBAAe,YAAY;AACzB,UAAM,MAAM,MAAM,OAAO,QAAQ;AACjC,UAAM,YAAa,IAAY,WAAY;AAC3C,UAAM,UAAU,cAAe,MAAM,kBAAkB;AACvD,UAAM,MAAM,MAAM,UAAU,UAAU,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AAQ,eAAe,cAAc,KAAK,iBAAiB;AAAA,MAC7D,QAAQ;AAAA,MAER;AACA,WAAK,oBAAoB;AAAA,IAC3B;AACA,UAAM,MAAM,WAAW;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,QAAuB;AAE3B,UAAM,OAAQ,KAAa;AAC3B,UAAM,SAAS,MAAM;AACrB,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,QAAQ,OAAO,KAAK,YAAY,WAAY;AAEjD,UAAM,UAAU,OAAO,mBAAmB,KAAK,MAAM;AACrD,UAAM,UAAU,OAAO,mBAAmB,KAAK,MAAM;AACrD,QAAI,CAAC,WAAW,CAAC,QAAS;AAE1B,UAAM,OAAO,MAAM,QAAQ;AAC3B,QAAI;AACF,UAAI,QAAQ,OAAO,KAAK,UAAU,YAAY;AAC5C,cAAM,KAAK,MAAM;AAAA,MACnB;AAAA,IACF,UAAE;AACA,YAAM,QAAQ,IAAI;AAAA,IACpB;AAAA,EACF;AACF;;;ADpLA,IAAO,gBAAQ;AAAA,EACb,IAAI;AAAA,EACJ,SAAS;AAAA,EAET,UAAU,OAAO,YAAiB;AAChC,UAAM,EAAE,QAAQ,QAAQ,QAAQ,IAAI;AACpC,YAAQ,OAAO,sCAAsC;AAErD,QAAI,SAAS;AACX,YAAM,SAAS,IAAI,iBAAiB,MAAM;AAC1C,cAAQ,SAAS,MAAM;AACvB,cAAQ,OAAO,2CAA2C,OAAO,IAAI,EAAE;AAAA,IACzE,OAAO;AACL,cAAQ,OAAO,2DAA2D;AAAA,IAC5E;AAAA,EACF;AACF;","names":["createRequire","require","import_meta","Client_WasmSqlite"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sqlite-wasm-driver.ts","../src/knex-wasm-dialect.ts","../src/wasm-connection.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,wBAAgD;;;AC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AY;AAC5C,cAAM,KAAK,MAAM;AAAA,MACnB;AAAA,IACF,UAAE;AACA,YAAM,QAAQ,IAAI;AAAA,IACpB;AAAA,EACF;AACF;;;ADpLA,IAAO,gBAAQ;AAAA,EACb,IAAI;AAAA,EACJ,SAAS;AAAA,EAET,UAAU,OAAO,YAAiB;AAChC,UAAM,EAAE,QAAQ,QAAQ,QAAQ,IAAI;AACpC,YAAQ,OAAO,sCAAsC;AAErD,QAAI,SAAS;AACX,YAAM,SAAS,IAAI,iBAAiB,MAAM;AAC1C,cAAQ,SAAS,MAAM;AACvB,cAAQ,OAAO,2CAA2C,OAAO,IAAI,EAAE;AAAA,IACzE,OAAO;AACL,cAAQ,OAAO,2DAA2D;AAAA,IAC5E;AAAA,EACF;AACF;","names":["createRequire","require","import_meta","Client_WasmSqlite"]}
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sqlite-wasm-driver.ts","../src/knex-wasm-dialect.ts","../src/wasm-connection.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * SQLite-on-WASM driver for ObjectStack.\n *\n * Extends {@link SqlDriver} so all CRUD / schema / introspection / multi-tenant\n * logic is inherited as-is. Only the Knex transport is swapped to a custom\n * dialect ({@link Client_WasmSqlite}) backed by sql.js + Node `fs` persistence,\n * which lets the same `SqlDriver` codepath run inside StackBlitz WebContainer\n * (Node-in-browser) without the native `better-sqlite3` N-API binding.\n */\n\nimport type { SqlJsStatic } from 'sql.js';\nimport { SqlDriver, type SqlDriverConfig } from '@objectstack/driver-sql';\n\nimport { getClient_WasmSqlite } from './knex-wasm-dialect.js';\nimport type {\n PersistMode,\n WasmConnectionOptions,\n} from './wasm-connection.js';\n\n/** Public configuration for {@link SqliteWasmDriver}. */\nexport interface SqliteWasmDriverConfig {\n /**\n * SQLite filename. Use `:memory:` for an ephemeral database that is never\n * persisted. Any other value is treated as a Node `fs` path and the\n * sql.js database bytes are flushed back to disk according to {@link persist}.\n */\n filename: string;\n\n /**\n * Persistence strategy. Default: `'on-disconnect'`.\n *\n * - `'on-disconnect'` — flush once when the driver disconnects (and on\n * `process.beforeExit`).\n * - `'on-write'` — flush after every mutation. Safest, slowest.\n * - `` `debounced:${ms}` `` — debounce flushes by N milliseconds. Good\n * balance under bursty writes.\n */\n persist?: PersistMode;\n\n /** Pre-loaded sql.js module — skips lazy import. */\n sqlJs?: SqlJsStatic;\n\n /**\n * Override for sql.js's `locateFile`. Defaults to resolving the `.wasm`\n * file inside the installed `sql.js` package, which works in Node and\n * WebContainer.\n */\n locateFile?: (file: string) => string;\n\n /** Knex pool overrides. The dialect already defaults to `{ min: 1, max: 1 }`. */\n pool?: SqlDriverConfig['pool'];\n\n /** Optional logger. Defaults to `console`. */\n logger?: WasmConnectionOptions['logger'];\n}\n\n/**\n * SqlDriver subclass that runs Knex against sql.js (WASM SQLite).\n *\n * Behaves identically to the standard SQLite path — the dialect's\n * {@link Client_WasmSqlite._query} reports `lastID`/`changes` exactly the\n * way better-sqlite3 does, so {@link SqlDriver}'s SQL generation, returning\n * clauses, and schema introspection all keep working.\n */\nexport class SqliteWasmDriver extends SqlDriver {\n public override readonly name: string = 'com.objectstack.driver.sqlite-wasm';\n public override readonly version: string = '1.0.0';\n\n /**\n * Force the SQLite branch in {@link SqlDriver}. The base class detects\n * SQLite by string-matching `config.client`, but we pass the dialect class\n * directly so the string check would miss.\n */\n protected override get isSqlite(): boolean {\n return true;\n }\n\n /**\n * Never WAL (#3941). The base driver switches a file-backed SQLite database to\n * WAL so several processes can share one file. Nothing here is shared: the live\n * database sits in this process's WASM heap, and what reaches disk is a byte\n * image {@link flush} exports from it — another process reads that snapshot,\n * never the database. So the pragma buys this transport nothing.\n *\n * It is also not free. Journal mode is a persistent header change in the\n * operator's file, and under WAL the export path's correctness would rest on\n * sql.js checkpointing the log while `export()` closes and reopens the\n * database. Measured, it does — no row is lost today — which is why this is a\n * declined default and not a bug report. But a transport that persists by\n * serializing an image should not be one implementation detail away from\n * dropping committed rows for a concurrency benefit it cannot use.\n *\n * Declared rather than discovered: sql.js *accepts* `journal_mode = WAL`,\n * because its VFS is memory-backed, so the refusal the base class gets from\n * `:memory:` never comes — and an image whose header already says WAL (one a\n * native run left behind) reports `wal` here too.\n */\n protected override get supportsWalJournal(): boolean {\n return false;\n }\n\n private wasmConfig: SqliteWasmDriverConfig;\n private beforeExitHandler: (() => void) | null = null;\n\n constructor(config: SqliteWasmDriverConfig) {\n const knexConfig = SqliteWasmDriver.toKnexConfig(config);\n super(knexConfig);\n this.wasmConfig = config;\n if (config.logger) this.logger = config.logger as any;\n }\n\n /** Translate the public config into a Knex config that uses our dialect. */\n static toKnexConfig(config: SqliteWasmDriverConfig): SqlDriverConfig {\n return {\n // Knex accepts a Client class as `client`. The dialect's `driverName`\n // is `'wasm-sqlite'` and its `dialect` is `'sqlite3'` so the SQLite\n // query compiler is reused.\n client: getClient_WasmSqlite() as any,\n connection: {\n filename: config.filename,\n persist: config.persist,\n sqlJs: config.sqlJs,\n locateFile: config.locateFile,\n logger: config.logger,\n } as any,\n // sql.js is single-threaded WASM — a single connection per pool keeps\n // semantics consistent with the upstream SQLite dialect.\n pool: config.pool ?? { min: 1, max: 1 },\n useNullAsDefault: true,\n } as SqlDriverConfig;\n }\n\n override async connect(): Promise<void> {\n await super.connect();\n\n // Best-effort flush on process exit so `on-disconnect` mode still saves\n // user data if the host process is shut down without explicit cleanup.\n if (\n this.wasmConfig.filename !== ':memory:' &&\n !this.wasmConfig.filename.startsWith(':') &&\n typeof process !== 'undefined' &&\n typeof process.once === 'function'\n ) {\n this.beforeExitHandler = () => {\n // Fire-and-forget — beforeExit cannot await.\n void this.flush().catch(() => {\n /* ignore */\n });\n };\n process.once('beforeExit', this.beforeExitHandler);\n }\n }\n\n override async disconnect(): Promise<void> {\n if (this.beforeExitHandler && typeof process !== 'undefined') {\n try {\n process.removeListener('beforeExit', this.beforeExitHandler);\n } catch {\n /* ignore */\n }\n this.beforeExitHandler = null;\n }\n await super.disconnect();\n }\n\n /**\n * Force a flush of the in-memory database to disk. No-op for ephemeral\n * databases or when no fs is available.\n */\n async flush(): Promise<void> {\n // Reach into the Knex pool and ask every live connection to flush.\n const knex = (this as any).knex;\n const client = knex?.client;\n const pool = client?.pool;\n if (!pool || typeof pool.numUsed !== 'function') return;\n\n const acquire = client.acquireConnection?.bind(client);\n const release = client.releaseConnection?.bind(client);\n if (!acquire || !release) return;\n\n const conn = await acquire();\n try {\n if (conn && typeof conn.flush === 'function') {\n await conn.flush();\n }\n } finally {\n await release(conn);\n }\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Custom Knex SQLite dialect backed by sql.js (WASM SQLite).\n *\n * Mimics the surface that `Client_BetterSQLite3` presents to Knex so the\n * upstream SQLite3 dialect's query compiler, schema builder, and column\n * compiler all keep working unchanged. Only the transport layer —\n * `_driver` / `acquireRawConnection` / `_query` — is swapped out.\n *\n * ## Why the dialect class is built lazily\n *\n * The class `Client_WasmSqlite extends Client_SQLite3` needs the upstream\n * SQLite3 dialect at class-definition time. Resolving it at module\n * top-level breaks when this file is re-bundled by another tsup/esbuild\n * pass (e.g. `packages/runtime`), because that pass rewrites our runtime\n * `createRequire(import.meta.url)` chain back into a static `__require2`\n * Proxy stub that throws `Dynamic require of \"X\" is not supported`.\n *\n * Building the class inside a lazy factory (`getClient_WasmSqlite()`)\n * keeps the `require` call out of module-init code, so the re-bundler\n * cannot intercept it.\n */\n\nimport { createRequire } from 'node:module';\n\nimport type { SqlJsStatic } from 'sql.js';\n\nimport {\n WasmSqliteConnection,\n type PersistMode,\n type WasmConnectionOptions,\n} from './wasm-connection.js';\n\n// Built lazily — `node:module` is a Node builtin and is left untouched\n// by esbuild/tsup, so the `createRequire` import survives downstream\n// re-bundling. We defer the actual `createRequire(...)` call so that the\n// CJS build (where `import.meta.url` is empty) doesn't blow up at module\n// init; the CJS path uses `globalThis.require` directly anyway.\nlet cachedEsmRequire: any = null;\nfunction getEsmRequire(): any {\n if (cachedEsmRequire) return cachedEsmRequire;\n // `import.meta.url` is replaced with an empty string in CJS output;\n // fall back to the current file/cwd in that case.\n const anchor =\n typeof import.meta !== 'undefined' && (import.meta as any).url\n ? (import.meta as any).url\n : typeof __filename !== 'undefined'\n ? __filename\n : process.cwd() + '/';\n cachedEsmRequire = createRequire(anchor);\n return cachedEsmRequire;\n}\n\n/** Connection settings recognised by the WASM SQLite dialect. */\nexport interface WasmSqliteConnectionSettings {\n filename: string;\n persist?: PersistMode;\n sqlJs?: SqlJsStatic;\n locateFile?: (file: string) => string;\n logger?: WasmConnectionOptions['logger'];\n}\n\n/**\n * Coerce JS values that sql.js cannot bind directly. Mirrors\n * `Client_BetterSQLite3._formatBindings`.\n *\n * `undefined` is mapped to `null`: sql.js's binder only accepts\n * string/number/bigint/boolean/null (and array/blob) and `throw`s a *raw\n * string* — `\"Wrong API use : tried to bind a value of an unknown type\n * (undefined).\"` — for anything else. Because it throws a string rather than\n * an `Error`, it logs as a garbled char-indexed object and aborts the whole\n * write. Mapping to `null` matches the `useNullAsDefault` semantics the\n * dialect is configured with, so a missing/undefined value persists as SQL\n * `NULL` exactly as it would through better-sqlite3.\n */\nfunction formatBindings(bindings: unknown[] | undefined): unknown[] {\n if (!bindings) return [];\n return bindings.map((b) => {\n if (b === undefined) return null;\n if (b instanceof Date) return b.valueOf();\n if (typeof b === 'boolean') return Number(b);\n return b;\n });\n}\n\n/**\n * Mirrors the dispatch in upstream `Client_SQLite3._query`: only\n * `insert/update/counter/del` go through the row-less write path (and even\n * those switch to the read path when a `RETURNING` clause is requested).\n * Everything else — `select`, `first`, `pluck`, `columnInfo`, raw PRAGMA,\n * DDL with no `method` — is read with `all`/row iteration so Knex sees the\n * same response shape it would from better-sqlite3.\n *\n * ⚠️ This answers \"how do I EXECUTE this statement\", never \"does this statement\n * change the database\" — an `INSERT … RETURNING *` is executed down the\n * row-returning branch and mutates. Persistence is classified separately by\n * {@link statementMutatesDatabase}; conflating the two is #4518.\n */\nfunction isRowReturningExecution(method?: string, returning?: unknown): boolean {\n if (method === 'insert' || method === 'update') return !!returning ? true : false;\n if (method === 'counter' || method === 'del') return false;\n return true;\n}\n\n/** Knex `method` values that always denote a mutation. */\nconst MUTATING_METHODS = new Set(['insert', 'update', 'del', 'counter']);\n\n/** Statement-control forms whose persistence is owned by the transaction lifecycle. */\nconst TRANSACTION_CONTROL_RE = /^\\s*(BEGIN|COMMIT|END|ROLLBACK|SAVEPOINT|RELEASE)\\b/i;\n\n/**\n * DDL / schema statements. `BEGIN…RELEASE` share this prefix set in SQLite's\n * grammar but are transaction control, so they are matched (and routed) first.\n */\nconst DDL_RE =\n /^\\s*(CREATE|ALTER|DROP|BEGIN|COMMIT|ROLLBACK|SAVEPOINT|RELEASE|REINDEX|VACUUM|ATTACH|DETACH|TRUNCATE)\\b/i;\n\n/** DML that changes rows, whatever execution branch it happens to run down. */\nconst MUTATING_DML_RE = /^\\s*(INSERT|UPDATE|DELETE|REPLACE|UPSERT)\\b/i;\n\n/**\n * PRAGMA forms that change bytes in the database file: any assignment\n * (`PRAGMA auto_vacuum = INCREMENTAL`, `PRAGMA user_version = 3` — both\n * persistent header state) and `incremental_vacuum`, which actually moves\n * pages. Introspection PRAGMAs (`table_info`, `index_list`, …) are reads.\n */\nconst MUTATING_PRAGMA_RE = /^\\s*PRAGMA\\b(?:[^;]*=|\\s+incremental_vacuum\\b)/i;\n\n/**\n * THE single answer to \"did this statement change the database, so that the\n * in-memory image must eventually be written back to disk?\"\n *\n * It is deliberately independent of which execution branch {@link\n * isRowReturningExecution} picks, because those are different questions and\n * answering them with one predicate is what broke persistence in #4518: the\n * ObjectQL engine writes through `INSERT … RETURNING *` / `UPDATE … RETURNING *`\n * (it needs the stored row back), those run down the row-returning branch, and\n * the dirty flag was only ever set on the other branch. The result was a\n * file-backed database that flushed its schema and then silently stopped\n * recording anything — a cold boot found every table present and every row\n * gone, and `on-disconnect` did not save it either, because the final flush\n * also keys off the same flag.\n *\n * Classifying by BOTH the Knex `method` and the SQL text means a mutation\n * cannot slip through by arriving without a method (`knex.raw('INSERT …')`,\n * seed/migration SQL) or by taking an unexpected branch.\n */\nexport function statementMutatesDatabase(sql: string, method?: string): boolean {\n if (TRANSACTION_CONTROL_RE.test(sql)) return false; // owned by noteTransactionControl\n if (method && MUTATING_METHODS.has(method)) return true;\n if (DDL_RE.test(sql)) return true;\n if (MUTATING_DML_RE.test(sql)) return true;\n return MUTATING_PRAGMA_RE.test(sql);\n}\n\n/**\n * Resolve the upstream `knex/lib/dialects/sqlite3` class at runtime.\n *\n * Tries every escape hatch we have so that this works in:\n * - Plain Node ESM (use `createRequire(import.meta.url)`).\n * - Plain Node CJS (use the ambient `require` on `globalThis`).\n * - Re-bundled ESM where esbuild/tsup has stubbed `__require` — we\n * fall back to `new Function('return require')()` which evades static\n * analysis and grabs the real Node `require` at runtime.\n *\n * Wrapped in a function so the bundler cannot execute it at module init.\n */\nfunction resolveKnexSqlite3Dialect(): any {\n const g = globalThis as any;\n if (typeof g.require === 'function') {\n try {\n return g.require('knex/lib/dialects/sqlite3');\n } catch {\n /* fall through */\n }\n }\n // ESM-safe path: `createRequire` was imported statically at the top of\n // this module from `node:module`. In a pure-ESM process there is no\n // ambient `require`, so this is the only reliable way to load a CJS\n // package like `knex/lib/dialects/sqlite3`.\n return getEsmRequire()('knex/lib/dialects/sqlite3');\n}\n\nlet cachedDialect: any = null;\n\n/**\n * Build (and cache) the `Client_WasmSqlite` class. Building lazily keeps\n * the `require('knex/lib/dialects/sqlite3')` call out of module-init\n * code so downstream re-bundlers (e.g. `packages/runtime`) cannot collapse\n * it into a Dynamic-require stub.\n */\nexport function getClient_WasmSqlite(): any {\n if (cachedDialect) return cachedDialect;\n const Client_SQLite3 = resolveKnexSqlite3Dialect();\n\n class Client_WasmSqlite extends Client_SQLite3 {\n // sql.js has no shared \"driver module\" the way better-sqlite3 does. Knex\n // only uses `this.driver` to construct connections, and we override\n // `acquireRawConnection`, so a sentinel object is enough.\n _driver(): { name: 'sql.js' } {\n return { name: 'sql.js' };\n }\n\n async acquireRawConnection(): Promise<WasmSqliteConnection> {\n const settings = (this as any)\n .connectionSettings as WasmSqliteConnectionSettings;\n\n const conn = new WasmSqliteConnection({\n filename: settings.filename,\n persist: settings.persist,\n sqlJs: settings.sqlJs,\n locateFile: settings.locateFile,\n logger: settings.logger,\n });\n await conn.open(settings.sqlJs, settings.locateFile);\n return conn;\n }\n\n async destroyRawConnection(connection: WasmSqliteConnection): Promise<void> {\n await connection.close();\n }\n\n async _query(\n connection: WasmSqliteConnection,\n obj: any,\n ): Promise<any> {\n if (!obj.sql) throw new Error('The query is empty');\n if (!connection) throw new Error('No connection provided');\n\n const db = connection.raw;\n const bindings = formatBindings(obj.bindings);\n\n // ── 1. EXECUTE ────────────────────────────────────────────────────────\n // Three execution shapes. None of them decides persistence: that is\n // settled once, below, so a statement cannot mutate the database on a\n // branch that forgot to say so (#4518).\n\n // DDL / transaction control have no Knex `method`. sql.js's\n // `prepare`+`step` silently no-ops on many of these (e.g. CREATE TABLE),\n // so route them through `run` which is implemented via `exec` and\n // actually mutates the database. PRAGMA is intentionally excluded — many\n // PRAGMA forms (e.g. `PRAGMA table_info(...)`, `foreign_key_list(...)`)\n // return rows used by Knex's schema introspection/columnInfo, and\n // `db.run` discards those rows.\n if (DDL_RE.test(obj.sql)) {\n db.run(obj.sql, bindings as any);\n obj.response = [];\n } else if (\n isRowReturningExecution(obj.method, obj.returning) ||\n /^\\s*PRAGMA\\b/i.test(obj.sql)\n ) {\n // Row-returning branch. NOTE this is also where `INSERT … RETURNING *`\n // and `UPDATE … RETURNING *` land — statements that very much write.\n const stmt = db.prepare(obj.sql);\n try {\n if (bindings.length) stmt.bind(bindings as any);\n const rows: Record<string, unknown>[] = [];\n while (stmt.step()) {\n rows.push(stmt.getAsObject());\n }\n obj.response = rows;\n } finally {\n stmt.free();\n }\n } else {\n // Row-less write path: execute via `run` and capture SQLite's\n // per-connection lastID / changes counters.\n db.run(obj.sql, bindings as any);\n const changes = db.getRowsModified();\n let lastID: number | bigint = 0;\n if (obj.method === 'insert') {\n const r = db.exec('SELECT last_insert_rowid() AS id');\n lastID = (r?.[0]?.values?.[0]?.[0] as number) ?? 0;\n }\n obj.response = [];\n obj.context = { lastID, changes };\n }\n\n // ── 2. PERSIST ────────────────────────────────────────────────────────\n // Exactly one place decides whether the on-disk image is now stale.\n //\n // Transaction-control statements are routed to `noteTransactionControl`,\n // which owns flushing across the transaction lifecycle: it suppresses\n // flushes while a transaction is open (sql.js `export()` closes+reopens\n // the db, which would abort the txn) and performs a single flush once the\n // transaction fully closes. Routing them away from `markDirty` avoids a\n // second, racing flush on COMMIT.\n if (TRANSACTION_CONTROL_RE.test(obj.sql)) {\n connection.noteTransactionControl(obj.sql);\n } else if (statementMutatesDatabase(obj.sql, obj.method)) {\n connection.markDirty();\n }\n return obj;\n }\n }\n\n Object.assign(Client_WasmSqlite.prototype, {\n dialect: 'sqlite3',\n driverName: 'wasm-sqlite',\n });\n\n cachedDialect = Client_WasmSqlite;\n return Client_WasmSqlite;\n}\n\n/**\n * Back-compat re-export. Prefer `getClient_WasmSqlite()` so the dialect\n * is resolved lazily; the named export triggers the factory on first\n * access of any static property.\n *\n * Note: importing this binding will execute the factory at import time\n * in some bundlers, which defeats the lazy pattern. New code should call\n * `getClient_WasmSqlite()` directly.\n */\nexport const Client_WasmSqlite: any = new Proxy(function () {} as any, {\n get(_t, prop) {\n return (getClient_WasmSqlite() as any)[prop];\n },\n construct(_t, args) {\n const Klass = getClient_WasmSqlite();\n return new Klass(...args);\n },\n apply(_t, thisArg, args) {\n const Klass = getClient_WasmSqlite();\n return Reflect.apply(Klass, thisArg, args);\n },\n});\n\nexport default Client_WasmSqlite;\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\n/**\n * Thin wrapper over sql.js {@link Database} that mimics the surface of\n * `better-sqlite3`'s `Database` (only the methods the Knex dialect uses).\n *\n * Persistence is handled here, not in the Knex dialect, so it can be\n * orchestrated per-connection without polluting the SQL execution path.\n */\n\nimport type { Database, SqlJsStatic } from 'sql.js';\n\n/** When to flush the in-memory WASM database to disk. */\nexport type PersistMode =\n | 'on-disconnect'\n | 'on-write'\n | `debounced:${number}`;\n\nexport interface WasmConnectionOptions {\n /**\n * On-disk file path. `:memory:` (or any value starting with `:`) skips\n * persistence entirely and the database lives only for the process.\n */\n filename: string;\n /** When to persist. Default: `on-disconnect`. */\n persist?: PersistMode;\n /** Pre-loaded sql.js module. If omitted, loaded lazily on first connect. */\n sqlJs?: SqlJsStatic;\n /**\n * Optional override for the `.wasm` locator passed to `initSqlJs()`.\n * Defaults to resolving the file from the `sql.js` package on disk\n * (works in Node and WebContainer).\n */\n locateFile?: (file: string) => string;\n /** Optional logger; defaults to `console`. */\n logger?: { warn: (msg: string, meta?: unknown) => void };\n}\n\n/**\n * Detect whether a Node-style `fs` module is available. WebContainer\n * (StackBlitz) provides Node `fs`; pure-browser environments do not.\n */\nasync function tryLoadFs(): Promise<typeof import('node:fs/promises') | null> {\n try {\n return await import('node:fs/promises');\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve a default sql.js WASM locator. We point sql.js at the `.wasm`\n * file shipped inside `sql.js`'s own `dist/` folder. This avoids requiring\n * the caller to host the WASM separately.\n */\nasync function defaultLocateFile(): Promise<((file: string) => string) | undefined> {\n try {\n const { createRequire } = await import('node:module');\n const require = createRequire(import.meta.url);\n const pkgJsonPath = require.resolve('sql.js/package.json');\n const { dirname, join } = await import('node:path');\n const dir = dirname(pkgJsonPath);\n return (file: string) => join(dir, 'dist', file);\n } catch {\n return undefined;\n }\n}\n\nlet cachedSqlJs: Promise<SqlJsStatic> | null = null;\n\nasync function loadSqlJs(\n locateFile?: (file: string) => string,\n): Promise<SqlJsStatic> {\n if (cachedSqlJs) return cachedSqlJs;\n cachedSqlJs = (async () => {\n const mod = await import('sql.js');\n const initSqlJs = (mod as any).default ?? (mod as any);\n const locator = locateFile ?? (await defaultLocateFile());\n const SQL = await initSqlJs(locator ? { locateFile: locator } : undefined);\n return SQL as SqlJsStatic;\n })();\n return cachedSqlJs;\n}\n\n/**\n * A sql.js-backed connection that exposes the `prepare`/`exec`/`close`\n * subset used by Knex's SQLite dialect. Mutations are queued through a\n * configurable persistence strategy so the on-disk file stays in sync.\n */\nexport class WasmSqliteConnection {\n /**\n * Process-wide counter making each atomic-write temp filename unique, so\n * concurrent connections (or overlapping flushes) never target the same\n * temp path. Combined with `process.pid` for cross-process uniqueness.\n */\n private static tmpSeq = 0;\n\n readonly filename: string;\n readonly persist: PersistMode;\n readonly isEphemeral: boolean;\n\n private db!: Database;\n private fs: typeof import('node:fs/promises') | null = null;\n private dirty = false;\n private debounceMs = 0;\n private debounceTimer: ReturnType<typeof setTimeout> | null = null;\n private flushChain: Promise<void> | null = null;\n private destroyed = false;\n private logger: { warn: (msg: string, meta?: unknown) => void };\n\n /**\n * Whether a `BEGIN…COMMIT/ROLLBACK` transaction is currently open. Tracked\n * because sql.js's {@link Database.export} closes and reopens the database\n * (it has no in-place serialize), and closing a connection rolls back any\n * open transaction. Flushing mid-transaction would therefore silently\n * abort it, leaving the eventual `COMMIT` to fail with\n * \"cannot commit - no transaction is active\". We defer the flush until the\n * transaction fully closes. See {@link noteTransactionControl}.\n */\n private rootTxActive = false;\n /** Open `SAVEPOINT` depth (nested transactions emitted by Knex). */\n private savepointDepth = 0;\n /** A flush was requested while a transaction was open; run it on close. */\n private flushDeferred = false;\n\n /** True while any transaction (root or savepoint) is in flight. */\n private get inTransaction(): boolean {\n return this.rootTxActive || this.savepointDepth > 0;\n }\n\n constructor(opts: WasmConnectionOptions) {\n this.filename = opts.filename;\n this.persist = opts.persist ?? 'on-disconnect';\n this.isEphemeral =\n this.filename === ':memory:' || this.filename.startsWith(':');\n this.logger = opts.logger ?? console;\n\n if (typeof this.persist === 'string' && this.persist.startsWith('debounced:')) {\n const ms = Number(this.persist.slice('debounced:'.length));\n this.debounceMs = Number.isFinite(ms) && ms > 0 ? ms : 250;\n }\n }\n\n /** Open the underlying sql.js database, loading bytes from disk if any. */\n async open(sqlJs?: SqlJsStatic, locateFile?: (file: string) => string): Promise<void> {\n const SQL = sqlJs ?? (await loadSqlJs(locateFile));\n\n if (this.isEphemeral) {\n this.db = new SQL.Database();\n return;\n }\n\n this.fs = await tryLoadFs();\n if (!this.fs) {\n this.logger.warn(\n '[driver-sqlite-wasm] No node:fs available — falling back to in-memory database. ' +\n 'Data will not be persisted across reloads.',\n );\n this.db = new SQL.Database();\n return;\n }\n\n // Ensure parent directory exists, then load bytes if the file exists.\n const { dirname } = await import('node:path');\n const dir = dirname(this.filename);\n if (dir && dir !== '.') {\n await this.fs.mkdir(dir, { recursive: true });\n }\n\n let bytes: Uint8Array | undefined;\n try {\n const buf = await this.fs.readFile(this.filename);\n bytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n } catch (e: any) {\n if (e?.code !== 'ENOENT') throw e;\n }\n\n if (!bytes) {\n this.db = new SQL.Database();\n return;\n }\n\n await this.quarantineOrphanedWal();\n\n // Open the on-disk bytes, but guard against a corrupt image. A torn write\n // (process killed mid-flush before atomic writes existed) or otherwise\n // damaged file makes `new SQL.Database(bytes)` either throw (\"file is not a\n // database\") or open a handle whose every query fails with \"database disk\n // image is malformed\" — which, for a background dispatcher on a tick loop,\n // means the same error spammed forever with no path to recovery. Detect it\n // once at open, quarantine the bad file, and start fresh so the dev server\n // becomes usable again instead of wedging.\n try {\n const candidate = new SQL.Database(bytes);\n this.assertReadable(candidate);\n this.db = candidate;\n } catch (err) {\n await this.quarantineCorruptFile(err);\n this.db = new SQL.Database();\n }\n }\n\n /**\n * Force sql.js to actually read a page so a malformed image surfaces now\n * rather than on the first business query. `PRAGMA quick_check` walks the\n * b-tree structure without the full-scan cost of `integrity_check`; a healthy\n * database returns a single `ok` row. Any thrown error (raw string or Error)\n * or a non-`ok` result is treated as corruption.\n */\n private assertReadable(db: Database): void {\n const res = db.exec('PRAGMA quick_check(1)');\n const first = res?.[0]?.values?.[0]?.[0];\n if (typeof first === 'string' && first.toLowerCase() !== 'ok') {\n throw new Error(`sqlite quick_check failed: ${first}`);\n }\n }\n\n /**\n * Move a corrupt database file aside so its bytes are preserved for\n * post-mortem while a fresh, empty database takes its place. Best-effort:\n * failures here must not prevent the server from booting on a clean DB.\n */\n private async quarantineCorruptFile(cause: unknown): Promise<void> {\n if (!this.fs) return;\n const reason =\n typeof cause === 'string' ? cause : (cause as Error)?.message ?? String(cause);\n const backup = `${this.filename}.corrupt-${Date.now()}`;\n try {\n await this.fs.rename(this.filename, backup);\n this.logger.warn(\n `[driver-sqlite-wasm] Database image at ${this.filename} is corrupt ` +\n `(${reason}). Quarantined to ${backup} and starting from an empty ` +\n `database so the server can boot.`,\n );\n } catch (renameErr) {\n // Could not move it aside (e.g. permissions) — overwrite is still better\n // than looping forever on a malformed image. Warn loudly and continue.\n this.logger.warn(\n `[driver-sqlite-wasm] Database image at ${this.filename} is corrupt ` +\n `(${reason}) and could not be quarantined (${String(renameErr)}). ` +\n `Starting from an empty database; the corrupt file will be overwritten ` +\n `on the next flush.`,\n );\n }\n }\n\n /**\n * Move a write-ahead log left behind by a *real* SQLite aside (#3941).\n *\n * The native driver keeps file-backed databases in WAL mode, and a clean close\n * checkpoints the log away — so a non-empty `<db>-wal` here means the last\n * process died without one. That log is a problem in both directions, and\n * neither is something wasm SQLite can fix: it cannot read the log (we load\n * only the main image, so any transaction still in there is invisible), and it\n * must not leave it in place either — the next {@link flush} rewrites the\n * image, and a real SQLite opening a fresh image beside a stale log would\n * replay frames that no longer belong to it.\n *\n * So rename it, which loses nothing recoverable (the bytes are preserved for a\n * real `sqlite3` to recover from) and disarms the mismatch. Best-effort: this\n * is a dev-only step-down path and must never prevent a boot.\n */\n private async quarantineOrphanedWal(): Promise<void> {\n if (!this.fs) return;\n const wal = `${this.filename}-wal`;\n let size: number;\n try {\n size = (await this.fs.stat(wal)).size;\n } catch {\n return; // no sidecar (the normal case) or an unreadable one\n }\n if (size <= 0) return; // checkpointed-and-truncated: nothing in it\n\n const parked = `${wal}.orphaned-${Date.now()}`;\n try {\n await this.fs.rename(wal, parked);\n this.logger.warn(\n `[driver-sqlite-wasm] ${wal} holds ${size} bytes of write-ahead log that wasm SQLite ` +\n `cannot read — this database was last used in WAL mode and closed uncleanly. Parked it ` +\n `at ${parked} and loaded the main image without it, so anything committed only to the ` +\n `log is NOT in this session. To recover it, rebuild better-sqlite3 (or use \\`sqlite3\\`), ` +\n `restore the log next to the database, and run \\`PRAGMA wal_checkpoint(TRUNCATE)\\`.`,\n );\n } catch (renameErr) {\n this.logger.warn(\n `[driver-sqlite-wasm] ${wal} holds ${size} bytes of write-ahead log that wasm SQLite ` +\n `cannot read, and it could not be moved aside (${String(renameErr)}). Data committed ` +\n `only to the log is missing from this session; checkpoint it with a real sqlite3 before ` +\n `writing further.`,\n );\n }\n }\n\n /**\n * Update transaction state from a transaction-control statement and, when a\n * transaction has just fully closed, run any flush that was deferred while\n * it was open. Called by the Knex dialect for every `BEGIN` / `COMMIT` /\n * `ROLLBACK` / `SAVEPOINT` / `RELEASE` statement.\n *\n * We bias toward \"in transaction\": an unrecognised form leaves the flag set,\n * which at worst delays a flush (safe) rather than exporting mid-transaction\n * (which would abort it).\n */\n noteTransactionControl(sql: string): void {\n const s = sql.trim().toUpperCase();\n if (/^BEGIN\\b/.test(s)) {\n this.rootTxActive = true;\n } else if (/^(COMMIT|END)\\b/.test(s)) {\n // A COMMIT/END ends the whole transaction regardless of savepoint nesting.\n this.rootTxActive = false;\n this.savepointDepth = 0;\n } else if (/^ROLLBACK\\s+TO\\b/.test(s)) {\n // Rolls back to a savepoint but keeps the (outer) transaction open.\n } else if (/^ROLLBACK\\b/.test(s)) {\n this.rootTxActive = false;\n this.savepointDepth = 0;\n } else if (/^SAVEPOINT\\b/.test(s)) {\n this.savepointDepth += 1;\n } else if (/^RELEASE\\b/.test(s)) {\n this.savepointDepth = Math.max(0, this.savepointDepth - 1);\n }\n // If the transaction just fully closed and a flush was deferred while it\n // was open, run it now. We key off `flushDeferred` (set only when\n // `markDirty` actually wanted to flush) rather than `dirty`, so persist\n // modes that don't flush per-write — e.g. `on-disconnect` — still defer to\n // close() instead of flushing on every COMMIT.\n if (!this.inTransaction && this.flushDeferred) {\n this.flushDeferred = false;\n void this.flush();\n }\n }\n\n /**\n * Record that the statement just executed CHANGED the database, and schedule\n * a flush according to {@link persist}.\n *\n * Deliberately takes no argument. It used to filter the caller's Knex\n * `method` against a local write-method allowlist, which made \"did this\n * mutate?\" a decision taken in TWO places — here and in the dialect's\n * execution-path branch — and the two disagreed: an `INSERT … RETURNING`\n * runs down the dialect's ROW-returning branch (it has rows to return), that\n * branch never called this method at all, and so a whole class of committed\n * writes was never marked dirty and never reached disk (#4518). One decision,\n * one owner: {@link statementMutatesDatabase} in the dialect classifies the\n * statement, and this method just does what it is told.\n */\n markDirty(): void {\n if (this.isEphemeral || !this.fs) return;\n this.dirty = true;\n\n if (this.persist === 'on-write') {\n void this.flush();\n return;\n }\n if (this.debounceMs > 0) {\n if (this.debounceTimer) clearTimeout(this.debounceTimer);\n this.debounceTimer = setTimeout(() => {\n this.debounceTimer = null;\n void this.flush();\n }, this.debounceMs);\n }\n // 'on-disconnect' → flush only at close()\n }\n\n /**\n * Force a write of the current database state to disk.\n *\n * Flushes are strictly serialized through a single promise chain: every call\n * appends an export+write step that runs after all previously-queued steps.\n * This matters because sql.js `export()` mutates the live connection (it\n * closes and reopens the database), so two exports must never overlap — and\n * because the returned promise must not resolve until the caller's own write\n * has hit disk (deterministic for tests and for `close()`). Each step\n * re-checks `dirty` at run time, so a no-op write collapses cheaply and a\n * write that arrived mid-flush is captured by the next queued step.\n */\n async flush(): Promise<void> {\n if (this.isEphemeral || !this.fs || this.destroyed) return;\n // Never export while a transaction is open: sql.js's `export()` closes and\n // reopens the database, which rolls back the in-flight transaction and\n // makes the subsequent COMMIT fail. Defer until the transaction closes\n // (handled in `noteTransactionControl`).\n if (this.inTransaction) {\n this.flushDeferred = true;\n return;\n }\n\n const prev = this.flushChain;\n const step = (prev ?? Promise.resolve()).then(async () => {\n if (!this.dirty || this.destroyed || this.inTransaction) return;\n // Snapshot dirty=false before export so a concurrent write re-marks us\n // and is picked up by the next queued step.\n this.dirty = false;\n try {\n const exported = this.db.export();\n // sql.js returns a Uint8Array; Buffer.from on it shares memory but\n // works fine for the atomic write below.\n await this.atomicWriteFile(Buffer.from(exported));\n } catch (err) {\n this.dirty = true; // let a later flush retry\n throw err;\n }\n });\n // Keep the chain tail alive but swallow its rejection there so one failed\n // flush doesn't poison every future flush; the awaited `step` still throws.\n this.flushChain = step.catch(() => {});\n await step;\n }\n\n /**\n * Write the database bytes to disk atomically: write to a sibling temp file,\n * fsync it, then `rename()` it over the target.\n *\n * A plain `writeFile(this.filename, …)` truncates the target and streams the\n * new bytes in place, so a process killed mid-write (a dev-server restart,\n * Ctrl-C, or crash — likely under `on-write`, where every dispatcher tick\n * flushes) leaves a half-written file. sql.js then rejects that file on the\n * next boot with \"database disk image is malformed\". `rename(2)` is atomic\n * within a filesystem, so a reader always sees either the complete old file\n * or the complete new one — never a torn image. The temp file lives in the\n * same directory as the target so the rename stays intra-filesystem.\n */\n private async atomicWriteFile(data: Buffer): Promise<void> {\n if (!this.fs) return;\n const tmp = `${this.filename}.tmp-${process.pid}-${(WasmSqliteConnection.tmpSeq += 1)}`;\n let handle: import('node:fs/promises').FileHandle | undefined;\n try {\n handle = await this.fs.open(tmp, 'w');\n await handle.writeFile(data);\n // Flush the bytes to the platter before the rename so a crash can't leave\n // a renamed-but-empty file behind on filesystems that reorder the two.\n await handle.sync();\n await handle.close();\n handle = undefined;\n await this.fs.rename(tmp, this.filename);\n } catch (err) {\n if (handle) {\n try {\n await handle.close();\n } catch {\n /* ignore */\n }\n }\n // Clean up the temp file so a failed flush doesn't litter the data dir.\n try {\n await this.fs.unlink(tmp);\n } catch {\n /* ignore */\n }\n throw err;\n }\n }\n\n /** Close the database, flushing any pending writes first. */\n async close(): Promise<void> {\n if (this.destroyed) return;\n if (this.debounceTimer) {\n clearTimeout(this.debounceTimer);\n this.debounceTimer = null;\n }\n // Any transaction still open at close is abandoned and will be rolled back\n // by `db.close()`; clear the flag so the final flush is not deferred and\n // already-committed data is persisted.\n this.rootTxActive = false;\n this.savepointDepth = 0;\n try {\n await this.flush();\n } finally {\n this.destroyed = true;\n try {\n this.db.close();\n } catch {\n /* ignore */\n }\n }\n }\n\n /** Access the raw sql.js database (for the Knex dialect). */\n get raw(): Database {\n return this.db;\n }\n}\n","// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.\n\nimport { SqliteWasmDriver } from './sqlite-wasm-driver.js';\n\nexport { SqliteWasmDriver };\nexport type { SqliteWasmDriverConfig } from './sqlite-wasm-driver.js';\nexport { Client_WasmSqlite } from './knex-wasm-dialect.js';\nexport type { WasmSqliteConnectionSettings } from './knex-wasm-dialect.js';\nexport { WasmSqliteConnection } from './wasm-connection.js';\nexport type { PersistMode, WasmConnectionOptions } from './wasm-connection.js';\n\nexport default {\n id: 'com.objectstack.driver.sqlite-wasm',\n version: '1.0.0',\n\n onEnable: async (context: any) => {\n const { logger, config, drivers } = context;\n logger?.info?.('[SQLite-WASM Driver] Initializing...');\n\n if (drivers) {\n const driver = new SqliteWasmDriver(config);\n drivers.register(driver);\n logger?.info?.(`[SQLite-WASM Driver] Registered driver: ${driver.name}`);\n } else {\n logger?.warn?.('[SQLite-WASM Driver] No driver registry found in context.');\n }\n },\n};\n"],"mappings":";AAaA,SAAS,iBAAuC;;;ACWhD,SAAS,qBAAqB;;;ACkB9B,eAAe,YAA+D;AAC5E,MAAI;AACF,WAAO,MAAM,OAAO,aAAkB;AAAA,EACxC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOA,eAAe,oBAAqE;AAClF,MAAI;AACF,UAAM,EAAE,eAAAA,eAAc,IAAI,MAAM,OAAO,QAAa;AACpD,UAAMC,WA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,sCAAsC;AAErD,QAAI,SAAS;AACX,YAAM,SAAS,IAAI,iBAAiB,MAAM;AAC1C,cAAQ,SAAS,MAAM;AACvB,cAAQ,OAAO,2CAA2C,OAAO,IAAI,EAAE;AAAA,IACzE,OAAO;AACL,cAAQ,OAAO,2DAA2D;AAAA,IAC5E;AAAA,EACF;AACF;","names":["createRequire","require","Client_WasmSqlite"]}
|
|
1
|
+
{"version":3,"sources":["../src/sqlite-wasm-driver.ts","../src/knex-wasm-dialect.ts","../src/wasm-connection.ts","../src/index.ts"],"mappings":";AAaA,SAAS,iBAAuC;;;ACWhD,SAAS,qBAAqB;;;ACkB9B,eAAe,YAA+D;AAC5E,MAAI;AACF,WAAO,MAAM,OAAO,aAAkB;AAAA,EACxC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAOA,eAAe,oBAAqE;AAClF,MAAI;AACF,UAAM,EAAE,eAAAA,eAAc,IAAI,MAAM,OAAO,QAAa;AACpD,UAAMC,WAAUD,eAAc,YAAY,GAAG;AAC7C,UAAM,cAAcC,SAAQ,QAAQ,qBAAqB;AACzD,UAAM,EAAE,SAAS,KAAK,IAAI,MAAM,OAAO,MAAW;AAClD,UAAM,MAAM,QAAQ,WAAW;AAC/B,WAAO,CAAC,SAAiB,KAAK,KAAK,QAAQ,IAAI;AAAA,EACjD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,IAAI,cAA2C;AAE/C,eAAe,UACb,YACsB;AACtB,MAAI,YAAa,QAAO;AACxB,iBAAe,YAAY;AACzB,UAAM,MAAM,MAAM,OAAO,QAAQ;AACjC,UAAM,YAAa,IAAY,WAAY;AAC3C,UAAM,UAAU,cAAe,MAAM,kBAAkB;AACvD,UAAM,MAAM,MAAM,UAAU,UAAU,EAAE,YAAY,QAAQ,IAAI,MAAS;AACzE,WAAO;AAAA,EACT,GAAG;AACH,SAAO;AACT;AAOO,IAAM,wBAAN,MAAM,sBAAqB;AAAA,EAyChC,YAAY,MAA6B;AA5BzC,SAAQ,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B;AAE3B,UAAM,OAAQ,KAAa;AAC3B,UAAM,SAAS,MAAM;AACrB,UAAM,OAAO,QAAQ;AACrB,QAAI,CAAC,QAAQ,OAAO,KAAK,YAAY,WAAY;AAEjD,UAAM,UAAU,OAAO,mBAAmB,KAAK,MAAM;AACrD,UAAM,UAAU,OAAO,mBAAmB,KAAK,MAAM;AACrD,QAAI,CAAC,WAAW,CAAC,QAAS;AAE1B,UAAM,OAAO,MAAM,QAAQ;AAC3B,QAAI;AACF,UAAI,QAAQ,OAAO,KAAK,UAAU,YAAY;AAC5C,cAAM,KAAK,MAAM;AAAA,MACnB;AAAA,IACF,UAAE;AACA,YAAM,QAAQ,IAAI;AAAA,IACpB;AAAA,EACF;AACF;;;AGpLA,IAAO,gBAAQ;AAAA,EACb,IAAI;AAAA,EACJ,SAAS;AAAA,EAET,UAAU,OAAO,YAAiB;AAChC,UAAM,EAAE,QAAQ,QAAQ,QAAQ,IAAI;AACpC,YAAQ,OAAO,sCAAsC;AAErD,QAAI,SAAS;AACX,YAAM,SAAS,IAAI,iBAAiB,MAAM;AAC1C,cAAQ,SAAS,MAAM;AACvB,cAAQ,OAAO,2CAA2C,OAAO,IAAI,EAAE;AAAA,IACzE,OAAO;AACL,cAAQ,OAAO,2DAA2D;AAAA,IAC5E;AAAA,EACF;AACF;","names":["createRequire","require","Client_WasmSqlite"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@objectstack/driver-sqlite-wasm",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.4.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "WASM SQLite Driver for ObjectStack — runs in browser/WebContainer (StackBlitz) without native bindings",
|
|
6
6
|
"keywords": [
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"knex": "^3.3.0",
|
|
27
27
|
"nanoid": "^6.0.1",
|
|
28
28
|
"sql.js": "^1.14.1",
|
|
29
|
-
"@objectstack/
|
|
30
|
-
"@objectstack/
|
|
31
|
-
"@objectstack/spec": "17.
|
|
29
|
+
"@objectstack/core": "17.4.0",
|
|
30
|
+
"@objectstack/driver-sql": "17.4.0",
|
|
31
|
+
"@objectstack/spec": "17.4.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^26.2.0",
|
|
35
35
|
"@types/sql.js": "^1.4.11",
|
|
36
36
|
"typescript": "^6.0.3",
|
|
37
37
|
"vitest": "^4.1.10",
|
|
38
|
-
"@objectstack/formula": "17.
|
|
38
|
+
"@objectstack/formula": "17.4.0"
|
|
39
39
|
},
|
|
40
40
|
"author": "ObjectStack",
|
|
41
41
|
"repository": {
|