@sqliteai/sqlite-wasm 3.49.2-sync.0.8.29-vector.0.9.21 → 3.50.4-sync.0.8.29-vector.0.9.21

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/index.d.ts CHANGED
@@ -1412,6 +1412,21 @@ type SAHPoolUtil = {
1412
1412
  * currently in use, e.g. by an sqlite3 db.
1413
1413
  */
1414
1414
  wipeFiles: () => Promise<void>;
1415
+
1416
+ /**
1417
+ * Unregister this VFS and release file access handles, without clearing
1418
+ * files. The database must be closed before calling this.
1419
+ */
1420
+ pauseVfs: () => SAHPoolUtil;
1421
+
1422
+ /** Returns `true` if this VFS pool is paused */
1423
+ isPaused: () => boolean;
1424
+
1425
+ /**
1426
+ * Re-register this VFS and re-acquire file access handles. Any previously
1427
+ * open databases will have to be re-opened after calling this.
1428
+ */
1429
+ unpauseVfs: () => Promise<SAHPoolUtil>;
1415
1430
  };
1416
1431
 
1417
1432
  /** Exception class for reporting WASM-side allocation errors. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqliteai/sqlite-wasm",
3
- "version": "3.49.2-sync.0.8.29-vector.0.9.21",
3
+ "version": "3.50.4-sync.0.8.29-vector.0.9.21",
4
4
  "description": "SQLite Wasm compiled with automatically initialized sqlite-sync and sqlite-vector extensions. Conveniently packaged as an ES Module for effortless integration.",
5
5
  "keywords": [
6
6
  "sqlite",
@@ -26,9 +26,9 @@
26
26
  /*
27
27
  ** This code was built from sqlite3 version...
28
28
  **
29
- ** SQLITE_VERSION "3.49.2"
30
- ** SQLITE_VERSION_NUMBER 3049002
31
- ** SQLITE_SOURCE_ID "2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1"
29
+ ** SQLITE_VERSION "3.50.4"
30
+ ** SQLITE_VERSION_NUMBER 3050004
31
+ ** SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1"
32
32
  **
33
33
  ** Using the Emscripten SDK version 4.0.13.
34
34
  */
@@ -133,16 +133,16 @@ async function sqlite3InitModule(moduleArg = {}) {
133
133
 
134
134
  function updateMemoryViews() {
135
135
  var b = wasmMemory.buffer;
136
- HEAP8 = new Int8Array(b);
137
- HEAP16 = new Int16Array(b);
138
- HEAPU8 = new Uint8Array(b);
139
- HEAPU16 = new Uint16Array(b);
140
- HEAP32 = new Int32Array(b);
141
- HEAPU32 = new Uint32Array(b);
136
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
137
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
138
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
139
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
140
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
141
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
142
142
  HEAPF32 = new Float32Array(b);
143
143
  HEAPF64 = new Float64Array(b);
144
- HEAP64 = new BigInt64Array(b);
145
- HEAPU64 = new BigUint64Array(b);
144
+ Module['HEAP64'] = HEAP64 = new BigInt64Array(b);
145
+ Module['HEAPU64'] = HEAPU64 = new BigUint64Array(b);
146
146
  }
147
147
 
148
148
  function initMemory() {
@@ -9956,7 +9956,7 @@ async function sqlite3InitModule(moduleArg = {}) {
9956
9956
  if (!(tgt instanceof StructBinder.StructType)) {
9957
9957
  toss('Usage error: target object is-not-a StructType.');
9958
9958
  } else if (!(func instanceof Function) && !wasm.isPtr(func)) {
9959
- toss('Usage errror: expecting a Function or WASM pointer to one.');
9959
+ toss('Usage error: expecting a Function or WASM pointer to one.');
9960
9960
  }
9961
9961
  if (1 === arguments.length) {
9962
9962
  return (n, f) => callee(tgt, n, f, applyArgcCheck);
@@ -10070,11 +10070,11 @@ async function sqlite3InitModule(moduleArg = {}) {
10070
10070
 
10071
10071
  globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
10072
10072
  sqlite3.version = {
10073
- libVersion: '3.49.2',
10074
- libVersionNumber: 3049002,
10073
+ libVersion: '3.50.4',
10074
+ libVersionNumber: 3050004,
10075
10075
  sourceId:
10076
- '2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1',
10077
- downloadVersion: 3490200,
10076
+ '2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1',
10077
+ downloadVersion: 3500400,
10078
10078
  };
10079
10079
  });
10080
10080
 
@@ -11423,6 +11423,12 @@ async function sqlite3InitModule(moduleArg = {}) {
11423
11423
  rc.changeCount =
11424
11424
  db.changes(true, 64 === rc.countChanges) - changeCount;
11425
11425
  }
11426
+ const lastInsertRowId = !!rc.lastInsertRowId
11427
+ ? sqlite3.capi.sqlite3_last_insert_rowid(db)
11428
+ : undefined;
11429
+ if (undefined !== lastInsertRowId) {
11430
+ rc.lastInsertRowId = lastInsertRowId;
11431
+ }
11426
11432
  if (rc.callback instanceof Function) {
11427
11433
  rc.callback = theCallback;
11428
11434
 
@@ -12870,7 +12876,7 @@ async function sqlite3InitModule(moduleArg = {}) {
12870
12876
  capi.SQLITE_OPEN_MAIN_JOURNAL |
12871
12877
  capi.SQLITE_OPEN_SUPER_JOURNAL |
12872
12878
  capi.SQLITE_OPEN_WAL;
12873
-
12879
+ const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
12874
12880
  const OPAQUE_DIR_NAME = '.opaque';
12875
12881
 
12876
12882
  const getRandomName = () => Math.random().toString(36).slice(2);
@@ -13100,6 +13106,7 @@ async function sqlite3InitModule(moduleArg = {}) {
13100
13106
  xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
13101
13107
  const pool = getPoolForVfs(pVfs);
13102
13108
  try {
13109
+ flags &= ~FLAG_COMPUTE_DIGEST_V2;
13103
13110
  pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
13104
13111
 
13105
13112
  const path =
@@ -13248,8 +13255,7 @@ async function sqlite3InitModule(moduleArg = {}) {
13248
13255
 
13249
13256
  getFileNames() {
13250
13257
  const rc = [];
13251
- const iter = this.#mapFilenameToSAH.keys();
13252
- for (const n of iter) rc.push(n);
13258
+ for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
13253
13259
  return rc;
13254
13260
  }
13255
13261
 
@@ -13290,7 +13296,7 @@ async function sqlite3InitModule(moduleArg = {}) {
13290
13296
  this.#availableSAH.clear();
13291
13297
  }
13292
13298
 
13293
- async acquireAccessHandles(clearFiles) {
13299
+ async acquireAccessHandles(clearFiles = false) {
13294
13300
  const files = [];
13295
13301
  for await (const [name, h] of this.#dhOpaque) {
13296
13302
  if ('file' === h.kind) {
@@ -13341,12 +13347,14 @@ async function sqlite3InitModule(moduleArg = {}) {
13341
13347
 
13342
13348
  const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
13343
13349
  sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
13344
- const compDigest = this.computeDigest(this.#apBody);
13350
+ const compDigest = this.computeDigest(this.#apBody, flags);
13351
+
13345
13352
  if (fileDigest.every((v, i) => v === compDigest[i])) {
13346
13353
  const pathBytes = this.#apBody.findIndex((v) => 0 === v);
13347
13354
  if (0 === pathBytes) {
13348
13355
  sah.truncate(HEADER_OFFSET_DATA);
13349
13356
  }
13357
+
13350
13358
  return pathBytes
13351
13359
  ? textDecoder.decode(this.#apBody.subarray(0, pathBytes))
13352
13360
  : '';
@@ -13362,10 +13370,13 @@ async function sqlite3InitModule(moduleArg = {}) {
13362
13370
  if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
13363
13371
  toss('Path too long:', path);
13364
13372
  }
13373
+ if (path && flags) {
13374
+ flags |= FLAG_COMPUTE_DIGEST_V2;
13375
+ }
13365
13376
  this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
13366
13377
  this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
13378
+ const digest = this.computeDigest(this.#apBody, flags);
13367
13379
 
13368
- const digest = this.computeDigest(this.#apBody);
13369
13380
  sah.write(this.#apBody, { at: 0 });
13370
13381
  sah.write(digest, { at: HEADER_OFFSET_DIGEST });
13371
13382
  sah.flush();
@@ -13379,14 +13390,18 @@ async function sqlite3InitModule(moduleArg = {}) {
13379
13390
  }
13380
13391
  }
13381
13392
 
13382
- computeDigest(byteArray) {
13383
- let h1 = 0xdeadbeef;
13384
- let h2 = 0x41c6ce57;
13385
- for (const v of byteArray) {
13386
- h1 = 31 * h1 + v * 307;
13387
- h2 = 31 * h2 + v * 307;
13393
+ computeDigest(byteArray, fileFlags) {
13394
+ if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
13395
+ let h1 = 0xdeadbeef;
13396
+ let h2 = 0x41c6ce57;
13397
+ for (const v of byteArray) {
13398
+ h1 = Math.imul(h1 ^ v, 2654435761);
13399
+ h2 = Math.imul(h2 ^ v, 104729);
13400
+ }
13401
+ return new Uint32Array([h1 >>> 0, h2 >>> 0]);
13402
+ } else {
13403
+ return new Uint32Array([0, 0]);
13388
13404
  }
13389
- return new Uint32Array([h1 >>> 0, h2 >>> 0]);
13390
13405
  }
13391
13406
 
13392
13407
  async reset(clearFiles) {
@@ -13482,11 +13497,45 @@ async function sqlite3InitModule(moduleArg = {}) {
13482
13497
  });
13483
13498
  this.#dhVfsRoot = this.#dhVfsParent = undefined;
13484
13499
  } catch (e) {
13485
- sqlite3.config.error(this.vfsName, 'removeVfs() failed:', e);
13500
+ sqlite3.config.error(
13501
+ this.vfsName,
13502
+ 'removeVfs() failed with no recovery strategy:',
13503
+ e,
13504
+ );
13486
13505
  }
13487
13506
  return true;
13488
13507
  }
13489
13508
 
13509
+ pauseVfs() {
13510
+ if (this.#mapS3FileToOFile_.size > 0) {
13511
+ sqlite3.SQLite3Error.toss(
13512
+ capi.SQLITE_MISUSE,
13513
+ 'Cannot pause VFS',
13514
+ this.vfsName,
13515
+ 'because it has opened files.',
13516
+ );
13517
+ }
13518
+ if (this.#mapSAHToName.size > 0) {
13519
+ capi.sqlite3_vfs_unregister(this.vfsName);
13520
+ this.releaseAccessHandles();
13521
+ }
13522
+ return this;
13523
+ }
13524
+
13525
+ isPaused() {
13526
+ return 0 === this.#mapSAHToName.size;
13527
+ }
13528
+
13529
+ async unpauseVfs() {
13530
+ if (0 === this.#mapSAHToName.size) {
13531
+ return this.acquireAccessHandles(false).then(
13532
+ () => capi.sqlite3_vfs_register(this.#cVfs, 0),
13533
+ this,
13534
+ );
13535
+ }
13536
+ return this;
13537
+ }
13538
+
13490
13539
  exportFile(name) {
13491
13540
  const sah =
13492
13541
  this.#mapFilenameToSAH.get(name) || toss('File not found:', name);
@@ -13625,6 +13674,17 @@ async function sqlite3InitModule(moduleArg = {}) {
13625
13674
  async removeVfs() {
13626
13675
  return this.#p.removeVfs();
13627
13676
  }
13677
+
13678
+ pauseVfs() {
13679
+ this.#p.pauseVfs();
13680
+ return this;
13681
+ }
13682
+ async unpauseVfs() {
13683
+ return this.#p.unpauseVfs().then(() => this);
13684
+ }
13685
+ isPaused() {
13686
+ return this.#p.isPaused();
13687
+ }
13628
13688
  }
13629
13689
 
13630
13690
  const apiVersionCheck = async () => {
@@ -26,9 +26,9 @@
26
26
  /*
27
27
  ** This code was built from sqlite3 version...
28
28
  **
29
- ** SQLITE_VERSION "3.49.2"
30
- ** SQLITE_VERSION_NUMBER 3049002
31
- ** SQLITE_SOURCE_ID "2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1"
29
+ ** SQLITE_VERSION "3.50.4"
30
+ ** SQLITE_VERSION_NUMBER 3050004
31
+ ** SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1"
32
32
  **
33
33
  ** Using the Emscripten SDK version 4.0.13.
34
34
  */
@@ -141,16 +141,16 @@ async function sqlite3InitModule(moduleArg = {}) {
141
141
 
142
142
  function updateMemoryViews() {
143
143
  var b = wasmMemory.buffer;
144
- HEAP8 = new Int8Array(b);
145
- HEAP16 = new Int16Array(b);
146
- HEAPU8 = new Uint8Array(b);
147
- HEAPU16 = new Uint16Array(b);
148
- HEAP32 = new Int32Array(b);
149
- HEAPU32 = new Uint32Array(b);
144
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
145
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
146
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
147
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
148
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
149
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
150
150
  HEAPF32 = new Float32Array(b);
151
151
  HEAPF64 = new Float64Array(b);
152
- HEAP64 = new BigInt64Array(b);
153
- HEAPU64 = new BigUint64Array(b);
152
+ Module['HEAP64'] = HEAP64 = new BigInt64Array(b);
153
+ Module['HEAPU64'] = HEAPU64 = new BigUint64Array(b);
154
154
  }
155
155
 
156
156
  function initMemory() {
@@ -9981,7 +9981,7 @@ async function sqlite3InitModule(moduleArg = {}) {
9981
9981
  if (!(tgt instanceof StructBinder.StructType)) {
9982
9982
  toss('Usage error: target object is-not-a StructType.');
9983
9983
  } else if (!(func instanceof Function) && !wasm.isPtr(func)) {
9984
- toss('Usage errror: expecting a Function or WASM pointer to one.');
9984
+ toss('Usage error: expecting a Function or WASM pointer to one.');
9985
9985
  }
9986
9986
  if (1 === arguments.length) {
9987
9987
  return (n, f) => callee(tgt, n, f, applyArgcCheck);
@@ -10095,11 +10095,11 @@ async function sqlite3InitModule(moduleArg = {}) {
10095
10095
 
10096
10096
  globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
10097
10097
  sqlite3.version = {
10098
- libVersion: '3.49.2',
10099
- libVersionNumber: 3049002,
10098
+ libVersion: '3.50.4',
10099
+ libVersionNumber: 3050004,
10100
10100
  sourceId:
10101
- '2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1',
10102
- downloadVersion: 3490200,
10101
+ '2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1',
10102
+ downloadVersion: 3500400,
10103
10103
  };
10104
10104
  });
10105
10105
 
@@ -11448,6 +11448,12 @@ async function sqlite3InitModule(moduleArg = {}) {
11448
11448
  rc.changeCount =
11449
11449
  db.changes(true, 64 === rc.countChanges) - changeCount;
11450
11450
  }
11451
+ const lastInsertRowId = !!rc.lastInsertRowId
11452
+ ? sqlite3.capi.sqlite3_last_insert_rowid(db)
11453
+ : undefined;
11454
+ if (undefined !== lastInsertRowId) {
11455
+ rc.lastInsertRowId = lastInsertRowId;
11456
+ }
11451
11457
  if (rc.callback instanceof Function) {
11452
11458
  rc.callback = theCallback;
11453
11459
 
@@ -26,9 +26,9 @@
26
26
  /*
27
27
  ** This code was built from sqlite3 version...
28
28
  **
29
- ** SQLITE_VERSION "3.49.2"
30
- ** SQLITE_VERSION_NUMBER 3049002
31
- ** SQLITE_SOURCE_ID "2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1"
29
+ ** SQLITE_VERSION "3.50.4"
30
+ ** SQLITE_VERSION_NUMBER 3050004
31
+ ** SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1"
32
32
  **
33
33
  ** Using the Emscripten SDK version 4.0.13.
34
34
  */
@@ -167,16 +167,16 @@ var sqlite3InitModule = (() => {
167
167
 
168
168
  function updateMemoryViews() {
169
169
  var b = wasmMemory.buffer;
170
- HEAP8 = new Int8Array(b);
171
- HEAP16 = new Int16Array(b);
172
- HEAPU8 = new Uint8Array(b);
173
- HEAPU16 = new Uint16Array(b);
174
- HEAP32 = new Int32Array(b);
175
- HEAPU32 = new Uint32Array(b);
170
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
171
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
172
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
173
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
174
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
175
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
176
176
  HEAPF32 = new Float32Array(b);
177
177
  HEAPF64 = new Float64Array(b);
178
- HEAP64 = new BigInt64Array(b);
179
- HEAPU64 = new BigUint64Array(b);
178
+ Module['HEAP64'] = HEAP64 = new BigInt64Array(b);
179
+ Module['HEAPU64'] = HEAPU64 = new BigUint64Array(b);
180
180
  }
181
181
 
182
182
  function initMemory() {
@@ -10123,7 +10123,7 @@ var sqlite3InitModule = (() => {
10123
10123
  if (!(tgt instanceof StructBinder.StructType)) {
10124
10124
  toss('Usage error: target object is-not-a StructType.');
10125
10125
  } else if (!(func instanceof Function) && !wasm.isPtr(func)) {
10126
- toss('Usage errror: expecting a Function or WASM pointer to one.');
10126
+ toss('Usage error: expecting a Function or WASM pointer to one.');
10127
10127
  }
10128
10128
  if (1 === arguments.length) {
10129
10129
  return (n, f) => callee(tgt, n, f, applyArgcCheck);
@@ -10237,11 +10237,11 @@ var sqlite3InitModule = (() => {
10237
10237
 
10238
10238
  globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
10239
10239
  sqlite3.version = {
10240
- libVersion: '3.49.2',
10241
- libVersionNumber: 3049002,
10240
+ libVersion: '3.50.4',
10241
+ libVersionNumber: 3050004,
10242
10242
  sourceId:
10243
- '2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1',
10244
- downloadVersion: 3490200,
10243
+ '2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1',
10244
+ downloadVersion: 3500400,
10245
10245
  };
10246
10246
  });
10247
10247
 
@@ -11608,6 +11608,12 @@ var sqlite3InitModule = (() => {
11608
11608
  rc.changeCount =
11609
11609
  db.changes(true, 64 === rc.countChanges) - changeCount;
11610
11610
  }
11611
+ const lastInsertRowId = !!rc.lastInsertRowId
11612
+ ? sqlite3.capi.sqlite3_last_insert_rowid(db)
11613
+ : undefined;
11614
+ if (undefined !== lastInsertRowId) {
11615
+ rc.lastInsertRowId = lastInsertRowId;
11616
+ }
11611
11617
  if (rc.callback instanceof Function) {
11612
11618
  rc.callback = theCallback;
11613
11619
 
@@ -13077,7 +13083,7 @@ var sqlite3InitModule = (() => {
13077
13083
  capi.SQLITE_OPEN_MAIN_JOURNAL |
13078
13084
  capi.SQLITE_OPEN_SUPER_JOURNAL |
13079
13085
  capi.SQLITE_OPEN_WAL;
13080
-
13086
+ const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
13081
13087
  const OPAQUE_DIR_NAME = '.opaque';
13082
13088
 
13083
13089
  const getRandomName = () => Math.random().toString(36).slice(2);
@@ -13307,6 +13313,7 @@ var sqlite3InitModule = (() => {
13307
13313
  xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
13308
13314
  const pool = getPoolForVfs(pVfs);
13309
13315
  try {
13316
+ flags &= ~FLAG_COMPUTE_DIGEST_V2;
13310
13317
  pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
13311
13318
 
13312
13319
  const path =
@@ -13455,8 +13462,7 @@ var sqlite3InitModule = (() => {
13455
13462
 
13456
13463
  getFileNames() {
13457
13464
  const rc = [];
13458
- const iter = this.#mapFilenameToSAH.keys();
13459
- for (const n of iter) rc.push(n);
13465
+ for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
13460
13466
  return rc;
13461
13467
  }
13462
13468
 
@@ -13497,7 +13503,7 @@ var sqlite3InitModule = (() => {
13497
13503
  this.#availableSAH.clear();
13498
13504
  }
13499
13505
 
13500
- async acquireAccessHandles(clearFiles) {
13506
+ async acquireAccessHandles(clearFiles = false) {
13501
13507
  const files = [];
13502
13508
  for await (const [name, h] of this.#dhOpaque) {
13503
13509
  if ('file' === h.kind) {
@@ -13548,12 +13554,14 @@ var sqlite3InitModule = (() => {
13548
13554
 
13549
13555
  const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
13550
13556
  sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
13551
- const compDigest = this.computeDigest(this.#apBody);
13557
+ const compDigest = this.computeDigest(this.#apBody, flags);
13558
+
13552
13559
  if (fileDigest.every((v, i) => v === compDigest[i])) {
13553
13560
  const pathBytes = this.#apBody.findIndex((v) => 0 === v);
13554
13561
  if (0 === pathBytes) {
13555
13562
  sah.truncate(HEADER_OFFSET_DATA);
13556
13563
  }
13564
+
13557
13565
  return pathBytes
13558
13566
  ? textDecoder.decode(this.#apBody.subarray(0, pathBytes))
13559
13567
  : '';
@@ -13569,10 +13577,13 @@ var sqlite3InitModule = (() => {
13569
13577
  if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
13570
13578
  toss('Path too long:', path);
13571
13579
  }
13580
+ if (path && flags) {
13581
+ flags |= FLAG_COMPUTE_DIGEST_V2;
13582
+ }
13572
13583
  this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
13573
13584
  this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
13585
+ const digest = this.computeDigest(this.#apBody, flags);
13574
13586
 
13575
- const digest = this.computeDigest(this.#apBody);
13576
13587
  sah.write(this.#apBody, { at: 0 });
13577
13588
  sah.write(digest, { at: HEADER_OFFSET_DIGEST });
13578
13589
  sah.flush();
@@ -13586,14 +13597,18 @@ var sqlite3InitModule = (() => {
13586
13597
  }
13587
13598
  }
13588
13599
 
13589
- computeDigest(byteArray) {
13590
- let h1 = 0xdeadbeef;
13591
- let h2 = 0x41c6ce57;
13592
- for (const v of byteArray) {
13593
- h1 = 31 * h1 + v * 307;
13594
- h2 = 31 * h2 + v * 307;
13600
+ computeDigest(byteArray, fileFlags) {
13601
+ if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
13602
+ let h1 = 0xdeadbeef;
13603
+ let h2 = 0x41c6ce57;
13604
+ for (const v of byteArray) {
13605
+ h1 = Math.imul(h1 ^ v, 2654435761);
13606
+ h2 = Math.imul(h2 ^ v, 104729);
13607
+ }
13608
+ return new Uint32Array([h1 >>> 0, h2 >>> 0]);
13609
+ } else {
13610
+ return new Uint32Array([0, 0]);
13595
13611
  }
13596
- return new Uint32Array([h1 >>> 0, h2 >>> 0]);
13597
13612
  }
13598
13613
 
13599
13614
  async reset(clearFiles) {
@@ -13690,11 +13705,45 @@ var sqlite3InitModule = (() => {
13690
13705
  });
13691
13706
  this.#dhVfsRoot = this.#dhVfsParent = undefined;
13692
13707
  } catch (e) {
13693
- sqlite3.config.error(this.vfsName, 'removeVfs() failed:', e);
13708
+ sqlite3.config.error(
13709
+ this.vfsName,
13710
+ 'removeVfs() failed with no recovery strategy:',
13711
+ e,
13712
+ );
13694
13713
  }
13695
13714
  return true;
13696
13715
  }
13697
13716
 
13717
+ pauseVfs() {
13718
+ if (this.#mapS3FileToOFile_.size > 0) {
13719
+ sqlite3.SQLite3Error.toss(
13720
+ capi.SQLITE_MISUSE,
13721
+ 'Cannot pause VFS',
13722
+ this.vfsName,
13723
+ 'because it has opened files.',
13724
+ );
13725
+ }
13726
+ if (this.#mapSAHToName.size > 0) {
13727
+ capi.sqlite3_vfs_unregister(this.vfsName);
13728
+ this.releaseAccessHandles();
13729
+ }
13730
+ return this;
13731
+ }
13732
+
13733
+ isPaused() {
13734
+ return 0 === this.#mapSAHToName.size;
13735
+ }
13736
+
13737
+ async unpauseVfs() {
13738
+ if (0 === this.#mapSAHToName.size) {
13739
+ return this.acquireAccessHandles(false).then(
13740
+ () => capi.sqlite3_vfs_register(this.#cVfs, 0),
13741
+ this,
13742
+ );
13743
+ }
13744
+ return this;
13745
+ }
13746
+
13698
13747
  exportFile(name) {
13699
13748
  const sah =
13700
13749
  this.#mapFilenameToSAH.get(name) || toss('File not found:', name);
@@ -13839,6 +13888,17 @@ var sqlite3InitModule = (() => {
13839
13888
  async removeVfs() {
13840
13889
  return this.#p.removeVfs();
13841
13890
  }
13891
+
13892
+ pauseVfs() {
13893
+ this.#p.pauseVfs();
13894
+ return this;
13895
+ }
13896
+ async unpauseVfs() {
13897
+ return this.#p.unpauseVfs().then(() => this);
13898
+ }
13899
+ isPaused() {
13900
+ return this.#p.isPaused();
13901
+ }
13842
13902
  }
13843
13903
 
13844
13904
  const apiVersionCheck = async () => {
@@ -26,9 +26,9 @@
26
26
  /*
27
27
  ** This code was built from sqlite3 version...
28
28
  **
29
- ** SQLITE_VERSION "3.49.2"
30
- ** SQLITE_VERSION_NUMBER 3049002
31
- ** SQLITE_SOURCE_ID "2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1"
29
+ ** SQLITE_VERSION "3.50.4"
30
+ ** SQLITE_VERSION_NUMBER 3050004
31
+ ** SQLITE_SOURCE_ID "2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1"
32
32
  **
33
33
  ** Using the Emscripten SDK version 4.0.13.
34
34
  */
@@ -137,16 +137,16 @@ async function sqlite3InitModule(moduleArg = {}) {
137
137
 
138
138
  function updateMemoryViews() {
139
139
  var b = wasmMemory.buffer;
140
- HEAP8 = new Int8Array(b);
141
- HEAP16 = new Int16Array(b);
142
- HEAPU8 = new Uint8Array(b);
143
- HEAPU16 = new Uint16Array(b);
144
- HEAP32 = new Int32Array(b);
145
- HEAPU32 = new Uint32Array(b);
140
+ Module['HEAP8'] = HEAP8 = new Int8Array(b);
141
+ Module['HEAP16'] = HEAP16 = new Int16Array(b);
142
+ Module['HEAPU8'] = HEAPU8 = new Uint8Array(b);
143
+ Module['HEAPU16'] = HEAPU16 = new Uint16Array(b);
144
+ Module['HEAP32'] = HEAP32 = new Int32Array(b);
145
+ Module['HEAPU32'] = HEAPU32 = new Uint32Array(b);
146
146
  HEAPF32 = new Float32Array(b);
147
147
  HEAPF64 = new Float64Array(b);
148
- HEAP64 = new BigInt64Array(b);
149
- HEAPU64 = new BigUint64Array(b);
148
+ Module['HEAP64'] = HEAP64 = new BigInt64Array(b);
149
+ Module['HEAPU64'] = HEAPU64 = new BigUint64Array(b);
150
150
  }
151
151
 
152
152
  function initMemory() {
@@ -9960,7 +9960,7 @@ async function sqlite3InitModule(moduleArg = {}) {
9960
9960
  if (!(tgt instanceof StructBinder.StructType)) {
9961
9961
  toss('Usage error: target object is-not-a StructType.');
9962
9962
  } else if (!(func instanceof Function) && !wasm.isPtr(func)) {
9963
- toss('Usage errror: expecting a Function or WASM pointer to one.');
9963
+ toss('Usage error: expecting a Function or WASM pointer to one.');
9964
9964
  }
9965
9965
  if (1 === arguments.length) {
9966
9966
  return (n, f) => callee(tgt, n, f, applyArgcCheck);
@@ -10074,11 +10074,11 @@ async function sqlite3InitModule(moduleArg = {}) {
10074
10074
 
10075
10075
  globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
10076
10076
  sqlite3.version = {
10077
- libVersion: '3.49.2',
10078
- libVersionNumber: 3049002,
10077
+ libVersion: '3.50.4',
10078
+ libVersionNumber: 3050004,
10079
10079
  sourceId:
10080
- '2025-05-07 10:39:52 17144570b0d96ae63cd6f3edca39e27ebd74925252bbaf6723bcb2f6b486alt1',
10081
- downloadVersion: 3490200,
10080
+ '2025-07-30 19:33:53 4d8adfb30e03f9cf27f800a2c1ba3c48fb4ca1b08b0f5ed59a4d5ecbf45ealt1',
10081
+ downloadVersion: 3500400,
10082
10082
  };
10083
10083
  });
10084
10084
 
@@ -11427,6 +11427,12 @@ async function sqlite3InitModule(moduleArg = {}) {
11427
11427
  rc.changeCount =
11428
11428
  db.changes(true, 64 === rc.countChanges) - changeCount;
11429
11429
  }
11430
+ const lastInsertRowId = !!rc.lastInsertRowId
11431
+ ? sqlite3.capi.sqlite3_last_insert_rowid(db)
11432
+ : undefined;
11433
+ if (undefined !== lastInsertRowId) {
11434
+ rc.lastInsertRowId = lastInsertRowId;
11435
+ }
11430
11436
  if (rc.callback instanceof Function) {
11431
11437
  rc.callback = theCallback;
11432
11438
 
@@ -12872,7 +12878,7 @@ async function sqlite3InitModule(moduleArg = {}) {
12872
12878
  capi.SQLITE_OPEN_MAIN_JOURNAL |
12873
12879
  capi.SQLITE_OPEN_SUPER_JOURNAL |
12874
12880
  capi.SQLITE_OPEN_WAL;
12875
-
12881
+ const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
12876
12882
  const OPAQUE_DIR_NAME = '.opaque';
12877
12883
 
12878
12884
  const getRandomName = () => Math.random().toString(36).slice(2);
@@ -13102,6 +13108,7 @@ async function sqlite3InitModule(moduleArg = {}) {
13102
13108
  xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
13103
13109
  const pool = getPoolForVfs(pVfs);
13104
13110
  try {
13111
+ flags &= ~FLAG_COMPUTE_DIGEST_V2;
13105
13112
  pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
13106
13113
 
13107
13114
  const path =
@@ -13250,8 +13257,7 @@ async function sqlite3InitModule(moduleArg = {}) {
13250
13257
 
13251
13258
  getFileNames() {
13252
13259
  const rc = [];
13253
- const iter = this.#mapFilenameToSAH.keys();
13254
- for (const n of iter) rc.push(n);
13260
+ for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
13255
13261
  return rc;
13256
13262
  }
13257
13263
 
@@ -13292,7 +13298,7 @@ async function sqlite3InitModule(moduleArg = {}) {
13292
13298
  this.#availableSAH.clear();
13293
13299
  }
13294
13300
 
13295
- async acquireAccessHandles(clearFiles) {
13301
+ async acquireAccessHandles(clearFiles = false) {
13296
13302
  const files = [];
13297
13303
  for await (const [name, h] of this.#dhOpaque) {
13298
13304
  if ('file' === h.kind) {
@@ -13343,12 +13349,14 @@ async function sqlite3InitModule(moduleArg = {}) {
13343
13349
 
13344
13350
  const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
13345
13351
  sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
13346
- const compDigest = this.computeDigest(this.#apBody);
13352
+ const compDigest = this.computeDigest(this.#apBody, flags);
13353
+
13347
13354
  if (fileDigest.every((v, i) => v === compDigest[i])) {
13348
13355
  const pathBytes = this.#apBody.findIndex((v) => 0 === v);
13349
13356
  if (0 === pathBytes) {
13350
13357
  sah.truncate(HEADER_OFFSET_DATA);
13351
13358
  }
13359
+
13352
13360
  return pathBytes
13353
13361
  ? textDecoder.decode(this.#apBody.subarray(0, pathBytes))
13354
13362
  : '';
@@ -13364,10 +13372,13 @@ async function sqlite3InitModule(moduleArg = {}) {
13364
13372
  if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
13365
13373
  toss('Path too long:', path);
13366
13374
  }
13375
+ if (path && flags) {
13376
+ flags |= FLAG_COMPUTE_DIGEST_V2;
13377
+ }
13367
13378
  this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
13368
13379
  this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
13380
+ const digest = this.computeDigest(this.#apBody, flags);
13369
13381
 
13370
- const digest = this.computeDigest(this.#apBody);
13371
13382
  sah.write(this.#apBody, { at: 0 });
13372
13383
  sah.write(digest, { at: HEADER_OFFSET_DIGEST });
13373
13384
  sah.flush();
@@ -13381,14 +13392,18 @@ async function sqlite3InitModule(moduleArg = {}) {
13381
13392
  }
13382
13393
  }
13383
13394
 
13384
- computeDigest(byteArray) {
13385
- let h1 = 0xdeadbeef;
13386
- let h2 = 0x41c6ce57;
13387
- for (const v of byteArray) {
13388
- h1 = 31 * h1 + v * 307;
13389
- h2 = 31 * h2 + v * 307;
13395
+ computeDigest(byteArray, fileFlags) {
13396
+ if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
13397
+ let h1 = 0xdeadbeef;
13398
+ let h2 = 0x41c6ce57;
13399
+ for (const v of byteArray) {
13400
+ h1 = Math.imul(h1 ^ v, 2654435761);
13401
+ h2 = Math.imul(h2 ^ v, 104729);
13402
+ }
13403
+ return new Uint32Array([h1 >>> 0, h2 >>> 0]);
13404
+ } else {
13405
+ return new Uint32Array([0, 0]);
13390
13406
  }
13391
- return new Uint32Array([h1 >>> 0, h2 >>> 0]);
13392
13407
  }
13393
13408
 
13394
13409
  async reset(clearFiles) {
@@ -13484,11 +13499,45 @@ async function sqlite3InitModule(moduleArg = {}) {
13484
13499
  });
13485
13500
  this.#dhVfsRoot = this.#dhVfsParent = undefined;
13486
13501
  } catch (e) {
13487
- sqlite3.config.error(this.vfsName, 'removeVfs() failed:', e);
13502
+ sqlite3.config.error(
13503
+ this.vfsName,
13504
+ 'removeVfs() failed with no recovery strategy:',
13505
+ e,
13506
+ );
13488
13507
  }
13489
13508
  return true;
13490
13509
  }
13491
13510
 
13511
+ pauseVfs() {
13512
+ if (this.#mapS3FileToOFile_.size > 0) {
13513
+ sqlite3.SQLite3Error.toss(
13514
+ capi.SQLITE_MISUSE,
13515
+ 'Cannot pause VFS',
13516
+ this.vfsName,
13517
+ 'because it has opened files.',
13518
+ );
13519
+ }
13520
+ if (this.#mapSAHToName.size > 0) {
13521
+ capi.sqlite3_vfs_unregister(this.vfsName);
13522
+ this.releaseAccessHandles();
13523
+ }
13524
+ return this;
13525
+ }
13526
+
13527
+ isPaused() {
13528
+ return 0 === this.#mapSAHToName.size;
13529
+ }
13530
+
13531
+ async unpauseVfs() {
13532
+ if (0 === this.#mapSAHToName.size) {
13533
+ return this.acquireAccessHandles(false).then(
13534
+ () => capi.sqlite3_vfs_register(this.#cVfs, 0),
13535
+ this,
13536
+ );
13537
+ }
13538
+ return this;
13539
+ }
13540
+
13492
13541
  exportFile(name) {
13493
13542
  const sah =
13494
13543
  this.#mapFilenameToSAH.get(name) || toss('File not found:', name);
@@ -13627,6 +13676,17 @@ async function sqlite3InitModule(moduleArg = {}) {
13627
13676
  async removeVfs() {
13628
13677
  return this.#p.removeVfs();
13629
13678
  }
13679
+
13680
+ pauseVfs() {
13681
+ this.#p.pauseVfs();
13682
+ return this;
13683
+ }
13684
+ async unpauseVfs() {
13685
+ return this.#p.unpauseVfs().then(() => this);
13686
+ }
13687
+ isPaused() {
13688
+ return this.#p.isPaused();
13689
+ }
13630
13690
  }
13631
13691
 
13632
13692
  const apiVersionCheck = async () => {
Binary file