@birchill/nice-sqlite-wasm 0.0.2 → 0.1.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/README.md CHANGED
@@ -3,10 +3,11 @@
3
3
  This is a custom build of SQLite that only supports the "opfs-sahpool" VFS.
4
4
  It's "nice" because:
5
5
 
6
- - It remove the "opfs" VFS and worker parts of the JS bindings making for a
6
+ - It removes the "opfs" VFS and worker parts of the JS bindings making for a
7
7
  smaller bundle size.
8
- - It allows passing in a custom path for the WASM module in order to support
9
- cache-busting filenames / bundlers.
8
+ - It allows overriding the `locateFile` function so that you can provide a
9
+ custom path for the WASM module (e.g. in order to support cache-busting
10
+ filenames) or even a `Response` object (e.g. so you can abort the download).
10
11
  - It fixes some warnings that otherwise might occur at build or run-time
11
12
  (e.g. the COOP/COEP header warning which is only relevant to the "opfs" VFS
12
13
  and a warning about dependencies based on expressions).
@@ -85,6 +86,7 @@ Then update the table below.
85
86
  | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
86
87
  | `0001-locatefile-nullish-coalesce.patch` | Allow a user-provided `locateFile` function to be used (rather than clobbered). |
87
88
  | `0002-hardcode-locatefile-path.patch` | Hardcodes the path used in the default `locateFile` implementation so that bundlers don't complain about dependencies based on expressions. |
89
+ | `0003-locatefile-with-response.patch` | Allows a user-provided `locateFile` function to return a `Response` or a `Promise<Response>`. |
88
90
 
89
91
  ### Building the WASM module
90
92
 
package/dist/sqlite3.d.ts CHANGED
@@ -2241,7 +2241,10 @@ declare type Sqlite3Static = {
2241
2241
  };
2242
2242
 
2243
2243
  declare type InitOptions = {
2244
- locateFile?: (path: string, prefix: string) => string;
2244
+ locateFile?: (
2245
+ path: string,
2246
+ prefix: string,
2247
+ ) => string | Response | Promise<Response>;
2245
2248
  print?: (msg: string) => void;
2246
2249
  printErr?: (msg: string) => void;
2247
2250
  };
package/dist/sqlite3.js CHANGED
@@ -73,7 +73,10 @@ async function sqlite3InitModule(moduleArg = {}) {
73
73
  'undefined' === typeof scriptDirectory ? '' : scriptDirectory
74
74
  );
75
75
  sims.debugModule('instantiateWasm() uri =', uri, 'sIMS =', this);
76
- const wfetch = () => fetch(uri, { credentials: 'same-origin' });
76
+ const response =
77
+ uri instanceof Response || uri instanceof Promise
78
+ ? uri
79
+ : fetch(uri, { credentials: 'same-origin' });
77
80
  const finalThen = (arg) => {
78
81
  arg.imports = imports;
79
82
  sims.instantiateWasm = arg;
@@ -81,9 +84,9 @@ async function sqlite3InitModule(moduleArg = {}) {
81
84
  };
82
85
  const loadWasm = WebAssembly.instantiateStreaming
83
86
  ? async () =>
84
- WebAssembly.instantiateStreaming(wfetch(), imports).then(finalThen)
87
+ WebAssembly.instantiateStreaming(response, imports).then(finalThen)
85
88
  : async () =>
86
- wfetch()
89
+ Promise.resolve(response)
87
90
  .then((response) => response.arrayBuffer())
88
91
  .then((bytes) => WebAssembly.instantiate(bytes, imports))
89
92
  .then(finalThen);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@birchill/nice-sqlite-wasm",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,5 +23,5 @@
23
23
  "publishConfig": {
24
24
  "provenance": true
25
25
  },
26
- "publishedAt": "2026-01-14T04:43:12.688Z"
26
+ "publishedAt": "2026-01-14T05:14:37.216Z"
27
27
  }