@aztec/sqlite3mc-wasm 5.0.0-rc.2 → 5.0.1

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/dest/index.js CHANGED
@@ -2,4 +2,27 @@
2
2
  * Re-exports sqlite3mc's ES module default (sqlite3InitModule) and the TypeScript types expected by downstream
3
3
  * consumers. Mirrors the `@sqlite.org/sqlite-wasm` package default export — sqlite3mc is a strict API-compatible
4
4
  * superset, so upstream types apply unchanged.
5
- */ export { default } from '../vendor/jswasm/sqlite3.mjs';
5
+ *
6
+ * BUNDLER COMPATIBILITY: SQLite3MultipleCiphers 2.3.5 stopped shipping the `-bundler-friendly` build variant, so
7
+ * this entry re-exports the plain `sqlite3.mjs`. That loader always resolves `sqlite3.wasm` through its
8
+ * `Module['locateFile']` hook, which computes `new URL(path, import.meta.url)` with a *dynamic* `path` — invisible
9
+ * to bundlers, so bundled consumers request an unhashed `sqlite3.wasm` relative to the emitted chunk and 404 at
10
+ * runtime (pre-2.3.5, the bundler-friendly variant carried a statically-analyzable reference instead). To stay
11
+ * bundler-friendly we wrap the init and inject `emscriptenLocateFile` — the vendored loader's supported escape
12
+ * hatch (`Module['locateFile']` defers to it when present on the init-module state) — resolving the wasm via a
13
+ * static `new URL('…/sqlite3.wasm', import.meta.url)` that bundlers detect, emit, and rewrite. Unbundled usage is
14
+ * unaffected: the static URL resolves to the real vendored path.
15
+ */ import sqlite3InitModuleUnwrapped from '../vendor/jswasm/sqlite3.mjs';
16
+ /** Statically analyzable wasm reference: bundlers emit the asset and rewrite this URL to its final location. */ const SQLITE3_WASM_URL = new URL('../vendor/jswasm/sqlite3.wasm', import.meta.url);
17
+ const sqlite3InitModule = (...args)=>{
18
+ // `sqlite3.mjs` creates `globalThis.sqlite3InitModuleState` at import time and the inner Emscripten factory
19
+ // captures it (and deletes the global) on init, binding it as `this` of `Module['locateFile']`. Mutate the live
20
+ // object; recreate it if a previous init already consumed it (`debugModule` must exist — the factory calls it).
21
+ const g = globalThis;
22
+ const state = g.sqlite3InitModuleState ??= Object.assign(Object.create(null), {
23
+ debugModule: ()=>{}
24
+ });
25
+ state.emscriptenLocateFile = (path, prefix)=>path === 'sqlite3.wasm' ? SQLITE3_WASM_URL.href : new URL(path, prefix || import.meta.url).href;
26
+ return sqlite3InitModuleUnwrapped(...args);
27
+ };
28
+ export default sqlite3InitModule;
@@ -2,7 +2,19 @@
2
2
  * Re-exports sqlite3mc's ES module default (sqlite3InitModule) and the TypeScript types expected by downstream
3
3
  * consumers. Mirrors the `@sqlite.org/sqlite-wasm` package default export — sqlite3mc is a strict API-compatible
4
4
  * superset, so upstream types apply unchanged.
5
+ *
6
+ * BUNDLER COMPATIBILITY: SQLite3MultipleCiphers 2.3.5 stopped shipping the `-bundler-friendly` build variant, so
7
+ * this entry re-exports the plain `sqlite3.mjs`. That loader always resolves `sqlite3.wasm` through its
8
+ * `Module['locateFile']` hook, which computes `new URL(path, import.meta.url)` with a *dynamic* `path` — invisible
9
+ * to bundlers, so bundled consumers request an unhashed `sqlite3.wasm` relative to the emitted chunk and 404 at
10
+ * runtime (pre-2.3.5, the bundler-friendly variant carried a statically-analyzable reference instead). To stay
11
+ * bundler-friendly we wrap the init and inject `emscriptenLocateFile` — the vendored loader's supported escape
12
+ * hatch (`Module['locateFile']` defers to it when present on the init-module state) — resolving the wasm via a
13
+ * static `new URL('…/sqlite3.wasm', import.meta.url)` that bundlers detect, emit, and rewrite. Unbundled usage is
14
+ * unaffected: the static URL resolves to the real vendored path.
5
15
  */
6
- export { default } from '../vendor/jswasm/sqlite3.mjs';
16
+ import sqlite3InitModuleUnwrapped from '../vendor/jswasm/sqlite3.mjs';
17
+ declare const sqlite3InitModule: typeof sqlite3InitModuleUnwrapped;
18
+ export default sqlite3InitModule;
7
19
  export type { Database, SAHPoolUtil, Sqlite3Static } from '@sqlite.org/sqlite-wasm';
8
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7OztHQUlHO0FBQ0gsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ3ZELFlBQVksRUFBRSxRQUFRLEVBQUUsV0FBVyxFQUFFLGFBQWEsRUFBRSxNQUFNLHlCQUF5QixDQUFDIn0=
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7Ozs7Ozs7R0FjRztBQUNILE9BQU8sMEJBQTBCLE1BQU0sOEJBQThCLENBQUM7QUFVdEUsUUFBQSxNQUFNLGlCQUFpQixFQUFFLE9BQU8sMEJBVy9CLENBQUM7QUFFRixlQUFlLGlCQUFpQixDQUFDO0FBQ2pDLFlBQVksRUFBRSxRQUFRLEVBQUUsV0FBVyxFQUFFLGFBQWEsRUFBRSxNQUFNLHlCQUF5QixDQUFDIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,0BAA0B,MAAM,8BAA8B,CAAC;AAUtE,QAAA,MAAM,iBAAiB,EAAE,OAAO,0BAW/B,CAAC;AAEF,eAAe,iBAAiB,CAAC;AACjC,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/sqlite3mc-wasm",
3
- "version": "5.0.0-rc.2",
3
+ "version": "5.0.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/index.ts CHANGED
@@ -2,6 +2,39 @@
2
2
  * Re-exports sqlite3mc's ES module default (sqlite3InitModule) and the TypeScript types expected by downstream
3
3
  * consumers. Mirrors the `@sqlite.org/sqlite-wasm` package default export — sqlite3mc is a strict API-compatible
4
4
  * superset, so upstream types apply unchanged.
5
+ *
6
+ * BUNDLER COMPATIBILITY: SQLite3MultipleCiphers 2.3.5 stopped shipping the `-bundler-friendly` build variant, so
7
+ * this entry re-exports the plain `sqlite3.mjs`. That loader always resolves `sqlite3.wasm` through its
8
+ * `Module['locateFile']` hook, which computes `new URL(path, import.meta.url)` with a *dynamic* `path` — invisible
9
+ * to bundlers, so bundled consumers request an unhashed `sqlite3.wasm` relative to the emitted chunk and 404 at
10
+ * runtime (pre-2.3.5, the bundler-friendly variant carried a statically-analyzable reference instead). To stay
11
+ * bundler-friendly we wrap the init and inject `emscriptenLocateFile` — the vendored loader's supported escape
12
+ * hatch (`Module['locateFile']` defers to it when present on the init-module state) — resolving the wasm via a
13
+ * static `new URL('…/sqlite3.wasm', import.meta.url)` that bundlers detect, emit, and rewrite. Unbundled usage is
14
+ * unaffected: the static URL resolves to the real vendored path.
5
15
  */
6
- export { default } from '../vendor/jswasm/sqlite3.mjs';
16
+ import sqlite3InitModuleUnwrapped from '../vendor/jswasm/sqlite3.mjs';
17
+
18
+ /** Statically analyzable wasm reference: bundlers emit the asset and rewrite this URL to its final location. */
19
+ const SQLITE3_WASM_URL = new URL('../vendor/jswasm/sqlite3.wasm', import.meta.url);
20
+
21
+ type SqliteInitModuleState = {
22
+ emscriptenLocateFile?: (path: string, prefix: string) => string;
23
+ debugModule?: (...args: unknown[]) => void;
24
+ };
25
+
26
+ const sqlite3InitModule: typeof sqlite3InitModuleUnwrapped = (...args) => {
27
+ // `sqlite3.mjs` creates `globalThis.sqlite3InitModuleState` at import time and the inner Emscripten factory
28
+ // captures it (and deletes the global) on init, binding it as `this` of `Module['locateFile']`. Mutate the live
29
+ // object; recreate it if a previous init already consumed it (`debugModule` must exist — the factory calls it).
30
+ const g = globalThis as { sqlite3InitModuleState?: SqliteInitModuleState };
31
+ const state = (g.sqlite3InitModuleState ??= Object.assign(Object.create(null), {
32
+ debugModule: () => {},
33
+ }));
34
+ state.emscriptenLocateFile = (path: string, prefix: string) =>
35
+ path === 'sqlite3.wasm' ? SQLITE3_WASM_URL.href : new URL(path, prefix || import.meta.url).href;
36
+ return sqlite3InitModuleUnwrapped(...args);
37
+ };
38
+
39
+ export default sqlite3InitModule;
7
40
  export type { Database, SAHPoolUtil, Sqlite3Static } from '@sqlite.org/sqlite-wasm';