indexeddbshim 17.2.1 → 17.3.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.
Files changed (92) hide show
  1. package/README.md +8 -5
  2. package/dist/CFG.d.ts +1 -1
  3. package/dist/CFG.d.ts.map +1 -1
  4. package/dist/DOMException.d.ts +21 -7
  5. package/dist/DOMException.d.ts.map +1 -1
  6. package/dist/DOMStringList.d.ts.map +1 -1
  7. package/dist/Event.d.ts +12 -6
  8. package/dist/Event.d.ts.map +1 -1
  9. package/dist/IDBCursor.d.ts +125 -7
  10. package/dist/IDBCursor.d.ts.map +1 -1
  11. package/dist/IDBDatabase.d.ts +17 -10
  12. package/dist/IDBDatabase.d.ts.map +1 -1
  13. package/dist/IDBFactory.d.ts +5 -0
  14. package/dist/IDBFactory.d.ts.map +1 -1
  15. package/dist/IDBIndex.d.ts +43 -13
  16. package/dist/IDBIndex.d.ts.map +1 -1
  17. package/dist/IDBKeyRange.d.ts +6 -2
  18. package/dist/IDBKeyRange.d.ts.map +1 -1
  19. package/dist/IDBObjectStore.d.ts +66 -17
  20. package/dist/IDBObjectStore.d.ts.map +1 -1
  21. package/dist/IDBRecord.d.ts +44 -0
  22. package/dist/IDBRecord.d.ts.map +1 -0
  23. package/dist/IDBRequest.d.ts +2 -2
  24. package/dist/IDBRequest.d.ts.map +1 -1
  25. package/dist/IDBTransaction.d.ts +43 -15
  26. package/dist/IDBTransaction.d.ts.map +1 -1
  27. package/dist/IDBVersionChangeEvent.d.ts +23 -12
  28. package/dist/IDBVersionChangeEvent.d.ts.map +1 -1
  29. package/dist/Key.d.ts +7 -6
  30. package/dist/Key.d.ts.map +1 -1
  31. package/dist/Sca.d.ts +15 -0
  32. package/dist/Sca.d.ts.map +1 -1
  33. package/dist/indexeddbshim-Key.js +59 -23
  34. package/dist/indexeddbshim-Key.js.map +1 -1
  35. package/dist/indexeddbshim-Key.min.js +2 -2
  36. package/dist/indexeddbshim-Key.min.js.map +1 -1
  37. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +3123 -1169
  38. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  39. package/dist/indexeddbshim-UnicodeIdentifiers.js +2683 -979
  40. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  41. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +4 -4
  42. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  43. package/dist/indexeddbshim-node.cjs +3123 -1169
  44. package/dist/indexeddbshim-node.cjs.map +1 -1
  45. package/dist/indexeddbshim-noninvasive.js +2683 -979
  46. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  47. package/dist/indexeddbshim-noninvasive.min.js +4 -4
  48. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  49. package/dist/indexeddbshim.js +2683 -979
  50. package/dist/indexeddbshim.js.map +1 -1
  51. package/dist/indexeddbshim.min.js +4 -4
  52. package/dist/indexeddbshim.min.js.map +1 -1
  53. package/dist/node-UnicodeIdentifiers.d.ts +2 -2
  54. package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
  55. package/dist/node.d.ts +2 -2
  56. package/dist/node.d.ts.map +1 -1
  57. package/dist/nodeSQLiteDatabase.d.ts +13 -14
  58. package/dist/nodeSQLiteDatabase.d.ts.map +1 -1
  59. package/dist/nodeWebSQL.d.ts +17 -1
  60. package/dist/nodeWebSQL.d.ts.map +1 -1
  61. package/dist/setGlobalVars.d.ts +2 -2
  62. package/dist/setGlobalVars.d.ts.map +1 -1
  63. package/dist/util.d.ts +15 -0
  64. package/dist/util.d.ts.map +1 -1
  65. package/examples/IDBKeyUtils.html +0 -1
  66. package/package.json +28 -21
  67. package/src/CFG.js +2 -1
  68. package/src/DOMException.js +38 -12
  69. package/src/DOMStringList.js +21 -2
  70. package/src/Event.js +9 -4
  71. package/src/IDBCursor.js +346 -18
  72. package/src/IDBDatabase.js +33 -16
  73. package/src/IDBFactory.js +162 -62
  74. package/src/IDBIndex.js +78 -45
  75. package/src/IDBKeyRange.js +8 -2
  76. package/src/IDBObjectStore.js +89 -65
  77. package/src/IDBRecord.js +96 -0
  78. package/src/IDBRequest.js +7 -7
  79. package/src/IDBTransaction.js +342 -61
  80. package/src/IDBVersionChangeEvent.js +37 -30
  81. package/src/Key.js +36 -18
  82. package/src/Sca.js +22 -1
  83. package/src/browser-UnicodeIdentifiers.js +3 -1
  84. package/src/browser-noninvasive.js +3 -1
  85. package/src/browser.js +3 -1
  86. package/src/node-UnicodeIdentifiers.js +1 -1
  87. package/src/node.js +1 -1
  88. package/src/nodeSQLiteDatabase.js +67 -2
  89. package/src/nodeWebSQL.js +22 -2
  90. package/src/setGlobalVars.js +5 -5
  91. package/src/util.js +29 -1
  92. package/typings/shimIndexedDB.d.ts +1 -1
package/src/IDBFactory.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable sonarjs/no-invariant-returns -- Convenient here */
2
2
  // eslint-disable-next-line no-restricted-imports -- Can be polyfilled
3
- import path from 'path';
3
+ import path from 'node:path';
4
4
  import SyncPromise from 'sync-promise-expanded';
5
5
 
6
6
  import {createEvent} from './Event.js';
@@ -18,6 +18,18 @@ import CFG from './CFG.js';
18
18
  * @typedef {number} Integer
19
19
  */
20
20
 
21
+ /**
22
+ * @typedef {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} WebSQLTransaction
23
+ */
24
+
25
+ /**
26
+ * @typedef {import('websql-configurable/lib/websql/WebSQLTransaction.js').SqlErrorCallback} SqlErrorCallback
27
+ */
28
+
29
+ /**
30
+ * @typedef {import('websql-configurable/lib/websql/WebSQLResultSet.js').default} WebSQLResultSet
31
+ */
32
+
21
33
  /**
22
34
  * @callback DatabaseDeleted
23
35
  * @returns {void}
@@ -52,7 +64,7 @@ const hasNullOrigin = () => CFG.checkOrigin !== false && (getOrigin() === 'null'
52
64
  * [key: string]: {
53
65
  * [key: string]: {
54
66
  * req: import('./IDBRequest.js').IDBOpenDBRequestFull,
55
- * cb: (req: import('./IDBRequest.js').IDBRequestFull) => void,
67
+ * cb: (req: import('./IDBRequest.js').IDBOpenDBRequestFull) => void,
56
68
  * }[]
57
69
  * }
58
70
  * }}
@@ -78,9 +90,13 @@ function processNextInConnectionQueue (name, origin = getOrigin()) {
78
90
  queueItems.shift();
79
91
  processNextInConnectionQueue(name, origin);
80
92
  }
93
+ // Only a terminal (`success`/`error`) event advances the queue --
94
+ // `blocked` means this request is still pending (waiting on other
95
+ // connections to close), so later requests for the same database must
96
+ // keep waiting behind it rather than starting concurrently, per
97
+ // https://w3c.github.io/IndexedDB/#request-connection-queue.
81
98
  req.addEventListener('success', removeFromQueue);
82
99
  req.addEventListener('error', removeFromQueue);
83
- req.addEventListener('blocked', removeFromQueue);
84
100
  cb(req);
85
101
  }
86
102
 
@@ -117,7 +133,7 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
117
133
  // auto-close if unloading
118
134
 
119
135
  /**
120
- * @param {IDBDatabase} connection
136
+ * @param {import('./IDBDatabase.js').IDBDatabaseFull} connection
121
137
  * @returns {boolean|undefined}
122
138
  */
123
139
  const connectionIsClosed = (connection) => connection.__closePending;
@@ -134,6 +150,7 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
134
150
  return undefined;
135
151
  }
136
152
  const e = /** @type {Event & IDBVersionChangeEvent} */ (
153
+ // @ts-ignore It's ok; needed under some TS versions
137
154
  new IDBVersionChangeEvent('versionchange', {oldVersion, newVersion})
138
155
  );
139
156
  return new SyncPromise(function (resolve) {
@@ -156,6 +173,7 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
156
173
  }
157
174
  };
158
175
  const e = /** @type {Event & IDBVersionChangeEvent} */ (
176
+ // @ts-ignore It's ok; needed under some TS versions
159
177
  new IDBVersionChangeEvent('blocked', {oldVersion, newVersion})
160
178
  );
161
179
  setTimeout(() => {
@@ -163,7 +181,10 @@ function triggerAnyVersionChangeAndBlockedEvents (openConnections, req, oldVersi
163
181
  if (!connectionsClosed()) {
164
182
  openConnections.forEach((connection) => {
165
183
  if (!connectionIsClosed(connection)) {
166
- connection.__unblocking = unblocking;
184
+ // Several concurrently-blocked requests can each be
185
+ // waiting on this same connection, so append
186
+ // rather than overwrite -- see `IDBDatabase.close`.
187
+ connection.__unblocking.push(unblocking);
167
188
  }
168
189
  });
169
190
  } else {
@@ -219,12 +240,63 @@ function getLatestCachedWebSQLDB (name) {
219
240
  ];
220
241
  }
221
242
 
243
+ /**
244
+ * A cached WebSQL connection (e.g., from a prior `open()`) can keep the
245
+ * underlying SQLite file handle open even after `IDBDatabase#close()`
246
+ * (which only flags the connection for closing without releasing the
247
+ * handle, to allow instance reuse). On Windows, deleting a file while a
248
+ * handle to it is still open fails with `EBUSY`, so any cached connections
249
+ * for `name` must be actually closed (and evicted, since they're no longer
250
+ * usable) before attempting to remove the file.
251
+ * @param {string} name
252
+ * @param {() => void} cb
253
+ * @returns {void}
254
+ */
255
+ function closeCachedWebSQLConnections (name, cb) {
256
+ if (!Object.hasOwn(websqlDBCache, name)) {
257
+ cb();
258
+ return;
259
+ }
260
+ const dbs = Object.values(websqlDBCache[name]);
261
+ delete websqlDBCache[name];
262
+ let remaining = dbs.length;
263
+ if (remaining === 0) {
264
+ cb();
265
+ return;
266
+ }
267
+ dbs.forEach((db) => {
268
+ const sqliteDB = db._db && db._db._db;
269
+ if (!sqliteDB || !sqliteDB.close) {
270
+ remaining--;
271
+ if (remaining === 0) {
272
+ cb();
273
+ }
274
+ return;
275
+ }
276
+ sqliteDB.close(
277
+ /**
278
+ * @param {Error} err
279
+ * @returns {void}
280
+ */
281
+ (err) => {
282
+ if (err) {
283
+ console.warn('Error closing database connection prior to file removal: ' + err);
284
+ }
285
+ remaining--;
286
+ if (remaining === 0) {
287
+ cb();
288
+ }
289
+ }
290
+ );
291
+ });
292
+ }
293
+
222
294
  /**
223
295
  * @param {OpenDatabase} __openDatabase
224
296
  * @param {string} name
225
297
  * @param {string} escapedDatabaseName
226
298
  * @param {DatabaseDeleted} databaseDeleted
227
- * @param {(tx: SQLTransaction|Error|SQLError, err?: SQLError) => boolean} dbError
299
+ * @param {(tx: WebSQLTransaction|Error|(Error & {code?: number}), err?: (Error & {code?: number})) => boolean} dbError
228
300
  * @returns {void}
229
301
  */
230
302
  function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, databaseDeleted, dbError) {
@@ -257,15 +329,18 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
257
329
  return;
258
330
  }
259
331
  if (fs && CFG.deleteDatabaseFiles !== false) {
260
- fs.unlink(path.join(CFG.databaseBasePath || '', escapedDatabaseName), (err) => {
261
- if (err && err.code !== 'ENOENT') { // Ignore if file is already deleted
262
- dbError({
263
- code: 0,
264
- message: 'Error removing database file: ' + escapedDatabaseName + ' ' + err
265
- });
266
- return;
267
- }
268
- databaseDeleted();
332
+ closeCachedWebSQLConnections(name, () => {
333
+ fs.unlink(path.join(CFG.databaseBasePath || '', escapedDatabaseName), (err) => {
334
+ if (err && err.code !== 'ENOENT') { // Ignore if file is already deleted
335
+ const removalError = /** @type {Error & {code?: number}} */ (
336
+ new Error('Error removing database file: ' + escapedDatabaseName + ' ' + err)
337
+ );
338
+ removalError.code = 0;
339
+ dbError(removalError);
340
+ return;
341
+ }
342
+ databaseDeleted();
343
+ });
269
344
  });
270
345
  return;
271
346
  }
@@ -289,7 +364,7 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
289
364
  // Delete all tables in this database, maintained in the sys table
290
365
  tx.executeSql('DROP TABLE ' + util.escapeStoreNameForSQL(
291
366
  util.unescapeSQLiteResponse( // Avoid double-escaping
292
- tables.item(i).name
367
+ /** @type {{name: string}} */ (tables.item(i)).name
293
368
  )
294
369
  ), [], function () {
295
370
  deleteTables(i + 1);
@@ -316,18 +391,18 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
316
391
  * Creates the sysDB to keep track of version numbers for databases.
317
392
  * @param {OpenDatabase} __openDatabase
318
393
  * @param {CreateSysDBSuccessCallback} success
319
- * @param {(tx: SQLTransaction|SQLError|Error, err?: SQLError) => void} failure
394
+ * @param {(tx: WebSQLTransaction|(Error & {code?: number})|Error, err?: (Error & {code?: number})) => void} failure
320
395
  * @returns {void}
321
396
  */
322
397
  function createSysDB (__openDatabase, success, failure) {
323
398
  /**
324
399
  *
325
- * @param {boolean|SQLTransaction|SQLError} tx
326
- * @param {SQLError} [err]
400
+ * @param {boolean|WebSQLTransaction|(Error & {code?: number})} tx
401
+ * @param {(Error & {code?: number})} [err]
327
402
  * @returns {void}
328
403
  */
329
404
  function sysDbCreateError (tx, err) {
330
- const er = webSQLErrback(/** @type {SQLError} */ (err) || tx);
405
+ const er = webSQLErrback(/** @type {(Error & {code?: number})} */ (err) || tx);
331
406
  if (CFG.DEBUG) { console.log('Error in sysdb transaction - when creating dbVersions', err); }
332
407
  failure(er);
333
408
  }
@@ -359,9 +434,9 @@ function createSysDB (__openDatabase, success, failure) {
359
434
  'CREATE INDEX IF NOT EXISTS dbvname ON dbVersions(name)',
360
435
  [],
361
436
  success,
362
- /** @type {SQLStatementErrorCallback} */ (sysDbCreateError)
437
+ /** @type {SqlErrorCallback} */ (sysDbCreateError)
363
438
  );
364
- }, /** @type {SQLStatementErrorCallback} */ (sysDbCreateError));
439
+ }, /** @type {SqlErrorCallback} */ (sysDbCreateError));
365
440
  }, sysDbCreateError);
366
441
  }
367
442
  }
@@ -387,7 +462,9 @@ function IDBFactory () {
387
462
  * __openDatabase: OpenDatabase,
388
463
  * __connections: {
389
464
  * [key: string]: import('./IDBDatabase.js').IDBDatabaseFull[]
390
- * }
465
+ * },
466
+ * __forceClose: (dbName: string, connIdx: Integer, msg: string) => void,
467
+ * __setConnectionQueueOrigin: (origin?: string) => void
391
468
  * }} IDBFactoryFull
392
469
  */
393
470
 
@@ -398,8 +475,10 @@ const IDBFactoryAlias = IDBFactory;
398
475
  IDBFactory.__createInstance = function () {
399
476
  /**
400
477
  * @class
478
+ * @this {IDBFactoryFull}
401
479
  */
402
480
  function IDBFactory () {
481
+ // @ts-expect-error It's ok
403
482
  this[Symbol.toStringTag] = 'IDBFactory';
404
483
  this.__connections = {};
405
484
  }
@@ -462,8 +541,8 @@ IDBFactory.prototype.open = function (name /* , version */) {
462
541
 
463
542
  /**
464
543
  *
465
- * @param {SQLTransaction|Error|SQLError} tx
466
- * @param {SQLError} [err]
544
+ * @param {WebSQLTransaction|Error|(Error & {code?: number})} tx
545
+ * @param {(Error & {code?: number})} [err]
467
546
  * @returns {boolean}
468
547
  */
469
548
  function dbCreateError (tx, err) {
@@ -483,7 +562,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
483
562
 
484
563
  /**
485
564
  *
486
- * @param {SQLTransaction} tx
565
+ * @param {WebSQLTransaction} tx
487
566
  * @param {DatabaseFull} db
488
567
  * @param {Integer} oldVersion
489
568
  * @returns {void}
@@ -509,9 +588,9 @@ IDBFactory.prototype.open = function (name /* , version */) {
509
588
  // DB Upgrade in progress
510
589
  /**
511
590
  *
512
- * @param {SQLTransaction} systx
513
- * @param {boolean|SQLError|DOMException|Error} err
514
- * @param {(tx?: SQLTransaction|SQLError, err?: SQLError|SQLResultSet) => boolean} cb
591
+ * @param {WebSQLTransaction} systx
592
+ * @param {boolean|(Error & {code?: number})|DOMException|Error} err
593
+ * @param {(tx?: WebSQLTransaction|(Error & {code?: number}), err?: (Error & {code?: number})|WebSQLResultSet) => boolean} cb
515
594
  * @returns {void}
516
595
  */
517
596
  let sysdbFinishedCb = function (systx, err, cb) {
@@ -569,37 +648,56 @@ IDBFactory.prototype.open = function (name /* , version */) {
569
648
  */
570
649
  function versionSet () {
571
650
  const e = /** @type {import('eventtargeter').EventWithProps & Event & IDBVersionChangeEvent} */ (
651
+ // @ts-ignore It's ok; needed under some TS versions
572
652
  new IDBVersionChangeEvent('upgradeneeded', {oldVersion, newVersion: version})
573
653
  );
574
654
  req.__result = connection;
575
655
  connection.__upgradeTransaction = req.__transaction = req.__result.__versionTransaction = IDBTransaction.__createInstance(req.__result, req.__result.objectStoreNames, 'versionchange');
576
656
  req.__done = true;
577
657
 
578
- req.transaction.__addNonRequestToTransactionQueue(function onupgradeneeded (tx, args, finished /* , error */) {
579
- req.dispatchEvent(e);
580
-
581
- if (e.__legacyOutputDidListenersThrowError) {
582
- logError('Error', 'An error occurred in an upgradeneeded handler attached to request chain', /** @type {Error} */ (e.__legacyOutputDidListenersThrowError)); // We do nothing else with this error as per spec
583
- req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
584
- return;
658
+ req.transaction.__addNonRequestToTransactionQueue(
659
+ /**
660
+ * @param {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} tx
661
+ * @param {ObjectArray} args
662
+ * @param {(result?: any, req?: import('./IDBRequest.js').IDBRequestFull) => void} finished
663
+ * @returns {void}
664
+ */
665
+ function onupgradeneeded (tx, args, finished /* , error */) {
666
+ // Unlike ordinary requests, this dispatch doesn't go through
667
+ // `IDBTransaction`'s own `success`/`error` closures, so it must
668
+ // open/close the transaction's active-handler window itself.
669
+ req.transaction.__handlerActive = true;
670
+ req.dispatchEvent(e);
671
+ req.transaction.__handlerActive = false;
672
+
673
+ if (e.__legacyOutputDidListenersThrowError) {
674
+ logError('Error', 'An error occurred in an upgradeneeded handler attached to request chain', /** @type {Error} */ (e.__legacyOutputDidListenersThrowError)); // We do nothing else with this error as per spec
675
+ req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
676
+ return;
677
+ }
678
+ finished();
585
679
  }
586
- finished();
587
- });
680
+ );
588
681
 
589
682
  // eslint-disable-next-line camelcase -- Clear API
590
- req.transaction.on__beforecomplete = function (ev) {
591
- connection.__upgradeTransaction = null;
592
- /** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
593
- req.__result
594
- ).__versionTransaction = null;
595
- sysdbFinishedCb(systx, false, function () {
596
- req.transaction.__callTransFinishedCb(false, function () {
597
- ev.complete();
598
- req.__transaction = null;
683
+ req.transaction.on__beforecomplete =
684
+ /**
685
+ * @param {Event & {complete: () => void}} ev
686
+ * @returns {void}
687
+ */
688
+ function (ev) {
689
+ connection.__upgradeTransaction = null;
690
+ /** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
691
+ req.__result
692
+ ).__versionTransaction = null;
693
+ sysdbFinishedCb(systx, false, function () {
694
+ req.transaction.__callTransFinishedCb(false, function () {
695
+ ev.complete();
696
+ req.__transaction = null;
697
+ });
698
+ return false;
599
699
  });
600
- return false;
601
- });
602
- };
700
+ };
603
701
 
604
702
  // eslint-disable-next-line camelcase -- Clear API
605
703
  req.transaction.on__preabort = function () {
@@ -726,12 +824,12 @@ IDBFactory.prototype.open = function (name /* , version */) {
726
824
  if ((useMemoryDatabase || useDatabaseCache) && Object.hasOwn(websqlDBCache, name) && Object.hasOwn(websqlDBCache[name], version)) {
727
825
  db = websqlDBCache[name][version];
728
826
  } else {
729
- db = me.__openDatabase(
827
+ db = /** @type {DatabaseFull} */ (me.__openDatabase(
730
828
  useMemoryDatabase ? CFG.memoryDatabase : path.join(CFG.databaseBasePath || '', escapedDatabaseName),
731
829
  '1',
732
830
  name,
733
831
  CFG.DEFAULT_DB_SIZE
734
- );
832
+ ));
735
833
  if (useDatabaseCache) {
736
834
  if (!(Object.hasOwn(websqlDBCache, name))) {
737
835
  websqlDBCache[name] = {};
@@ -765,7 +863,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
765
863
  return;
766
864
  }
767
865
  tx.executeSql('CREATE INDEX IF NOT EXISTS sysname ON __sys__(name)', [], setup, dbCreateError);
768
- }, /** @type {SQLStatementErrorCallback} */ (dbCreateError));
866
+ }, /** @type {SqlErrorCallback} */ (dbCreateError));
769
867
  }, dbCreateError);
770
868
  }
771
869
 
@@ -787,7 +885,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
787
885
  // Database with this name does not exist
788
886
  openDB(0);
789
887
  } else {
790
- openDB(data.rows.item(0).version);
888
+ openDB(/** @type {{version: Integer}} */ (data.rows.item(0)).version);
791
889
  }
792
890
  }, dbCreateError);
793
891
  }, dbCreateError);
@@ -851,8 +949,8 @@ IDBFactory.prototype.deleteDatabase = function (name) {
851
949
  // `UnknownError` as we may require upon a SQL deletion error
852
950
  /**
853
951
  *
854
- * @param {SQLTransaction|SQLError|Error} tx
855
- * @param {SQLError|boolean} [err]
952
+ * @param {WebSQLTransaction|(Error & {code?: number})|Error} tx
953
+ * @param {(Error & {code?: number})|boolean} [err]
856
954
  * @returns {boolean}
857
955
  */
858
956
  function dbError (tx, err) {
@@ -867,7 +965,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
867
965
  // transaction, corrupting that connection's task queue (see issue with unrelated `open()` calls
868
966
  // failing/crashing after a `deleteDatabase` file-removal error).
869
967
  calledDBError = true;
870
- const er = webSQLErrback(/** @type {SQLError} */ (err || tx));
968
+ const er = webSQLErrback(/** @type {(Error & {code?: number})} */ (err || tx));
871
969
  sysdbFinishedCbDelete(true, function () {
872
970
  req.__done = true;
873
971
  req.__error = er;
@@ -891,6 +989,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
891
989
  req.__result = undefined;
892
990
  req.__done = true;
893
991
  const e = /** @type {Event & IDBVersionChangeEvent} */ (
992
+ // @ts-ignore It's ok; needed under some TS versions
894
993
  new IDBVersionChangeEvent('success', {oldVersion: version, newVersion: null})
895
994
  );
896
995
  req.dispatchEvent(e);
@@ -913,7 +1012,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
913
1012
  completeDatabaseDelete();
914
1013
  return undefined;
915
1014
  }
916
- ({version} = data.rows.item(0));
1015
+ ({version} = /** @type {{version: Integer}} */ (data.rows.item(0)));
917
1016
 
918
1017
  const openConnections = me.__connections[name] || [];
919
1018
  triggerAnyVersionChangeAndBlockedEvents(openConnections, req, version, null).then(function () {
@@ -997,15 +1096,15 @@ IDBFactory.prototype.databases = function () {
997
1096
  }
998
1097
  /**
999
1098
  *
1000
- * @param {true|SQLTransaction|SQLError|DOMException|Error} tx
1001
- * @param {SQLError|DOMException|Error} [err]
1099
+ * @param {true|WebSQLTransaction|(Error & {code?: number})|DOMException|Error} tx
1100
+ * @param {(Error & {code?: number})|DOMException|Error} [err]
1002
1101
  * @returns {boolean}
1003
1102
  */
1004
1103
  function dbGetDatabaseNamesError (tx, err) {
1005
1104
  if (calledDbCreateError) {
1006
1105
  return false;
1007
1106
  }
1008
- const er = err ? webSQLErrback(/** @type {SQLError} */ (err)) : tx;
1107
+ const er = err ? webSQLErrback(/** @type {(Error & {code?: number})} */ (err)) : tx;
1009
1108
  calledDbCreateError = true;
1010
1109
  reject(er);
1011
1110
  return false;
@@ -1015,7 +1114,7 @@ IDBFactory.prototype.databases = function () {
1015
1114
  sysReadTx.executeSql('SELECT "name", "version" FROM dbVersions', [], function (sysReadTx, data) {
1016
1115
  const dbNames = [];
1017
1116
  for (let i = 0; i < data.rows.length; i++) {
1018
- const {name, version} = data.rows.item(i);
1117
+ const {name, version} = /** @type {{name: string, version: Integer}} */ (data.rows.item(i));
1019
1118
  dbNames.push({
1020
1119
  name: util.unescapeSQLiteResponse(name),
1021
1120
  version
@@ -1085,6 +1184,7 @@ IDBFactory.prototype.__setConnectionQueueOrigin = function (origin = getOrigin()
1085
1184
  IDBFactory.prototype[Symbol.toStringTag] = 'IDBFactoryPrototype';
1086
1185
 
1087
1186
  /* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
1187
+ util.setOperationNames(IDBFactory.prototype);
1088
1188
  Object.defineProperty(IDBFactory, 'prototype', {
1089
1189
  writable: false
1090
1190
  });