indexeddbshim 17.2.2 → 17.3.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.
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 +3090 -1168
  38. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  39. package/dist/indexeddbshim-UnicodeIdentifiers.js +2660 -988
  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 +3090 -1168
  44. package/dist/indexeddbshim-node.cjs.map +1 -1
  45. package/dist/indexeddbshim-noninvasive.js +2660 -988
  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 +2660 -988
  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 +27 -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 +118 -56
  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 +335 -67
  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 +23 -7
  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 {
@@ -275,7 +296,7 @@ function closeCachedWebSQLConnections (name, cb) {
275
296
  * @param {string} name
276
297
  * @param {string} escapedDatabaseName
277
298
  * @param {DatabaseDeleted} databaseDeleted
278
- * @param {(tx: SQLTransaction|Error|SQLError, err?: SQLError) => boolean} dbError
299
+ * @param {(tx: WebSQLTransaction|Error|(Error & {code?: number}), err?: (Error & {code?: number})) => boolean} dbError
279
300
  * @returns {void}
280
301
  */
281
302
  function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, databaseDeleted, dbError) {
@@ -311,10 +332,11 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
311
332
  closeCachedWebSQLConnections(name, () => {
312
333
  fs.unlink(path.join(CFG.databaseBasePath || '', escapedDatabaseName), (err) => {
313
334
  if (err && err.code !== 'ENOENT') { // Ignore if file is already deleted
314
- dbError({
315
- code: 0,
316
- message: 'Error removing database file: ' + escapedDatabaseName + ' ' + err
317
- });
335
+ const removalError = /** @type {Error & {code?: number}} */ (
336
+ new Error('Error removing database file: ' + escapedDatabaseName + ' ' + err)
337
+ );
338
+ removalError.code = 0;
339
+ dbError(removalError);
318
340
  return;
319
341
  }
320
342
  databaseDeleted();
@@ -342,7 +364,7 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
342
364
  // Delete all tables in this database, maintained in the sys table
343
365
  tx.executeSql('DROP TABLE ' + util.escapeStoreNameForSQL(
344
366
  util.unescapeSQLiteResponse( // Avoid double-escaping
345
- tables.item(i).name
367
+ /** @type {{name: string}} */ (tables.item(i)).name
346
368
  )
347
369
  ), [], function () {
348
370
  deleteTables(i + 1);
@@ -369,18 +391,18 @@ function cleanupDatabaseResources (__openDatabase, name, escapedDatabaseName, da
369
391
  * Creates the sysDB to keep track of version numbers for databases.
370
392
  * @param {OpenDatabase} __openDatabase
371
393
  * @param {CreateSysDBSuccessCallback} success
372
- * @param {(tx: SQLTransaction|SQLError|Error, err?: SQLError) => void} failure
394
+ * @param {(tx: WebSQLTransaction|(Error & {code?: number})|Error, err?: (Error & {code?: number})) => void} failure
373
395
  * @returns {void}
374
396
  */
375
397
  function createSysDB (__openDatabase, success, failure) {
376
398
  /**
377
399
  *
378
- * @param {boolean|SQLTransaction|SQLError} tx
379
- * @param {SQLError} [err]
400
+ * @param {boolean|WebSQLTransaction|(Error & {code?: number})} tx
401
+ * @param {(Error & {code?: number})} [err]
380
402
  * @returns {void}
381
403
  */
382
404
  function sysDbCreateError (tx, err) {
383
- const er = webSQLErrback(/** @type {SQLError} */ (err) || tx);
405
+ const er = webSQLErrback(/** @type {(Error & {code?: number})} */ (err) || tx);
384
406
  if (CFG.DEBUG) { console.log('Error in sysdb transaction - when creating dbVersions', err); }
385
407
  failure(er);
386
408
  }
@@ -412,9 +434,9 @@ function createSysDB (__openDatabase, success, failure) {
412
434
  'CREATE INDEX IF NOT EXISTS dbvname ON dbVersions(name)',
413
435
  [],
414
436
  success,
415
- /** @type {SQLStatementErrorCallback} */ (sysDbCreateError)
437
+ /** @type {SqlErrorCallback} */ (sysDbCreateError)
416
438
  );
417
- }, /** @type {SQLStatementErrorCallback} */ (sysDbCreateError));
439
+ }, /** @type {SqlErrorCallback} */ (sysDbCreateError));
418
440
  }, sysDbCreateError);
419
441
  }
420
442
  }
@@ -440,7 +462,9 @@ function IDBFactory () {
440
462
  * __openDatabase: OpenDatabase,
441
463
  * __connections: {
442
464
  * [key: string]: import('./IDBDatabase.js').IDBDatabaseFull[]
443
- * }
465
+ * },
466
+ * __forceClose: (dbName: string, connIdx: Integer, msg: string) => void,
467
+ * __setConnectionQueueOrigin: (origin?: string) => void
444
468
  * }} IDBFactoryFull
445
469
  */
446
470
 
@@ -451,8 +475,10 @@ const IDBFactoryAlias = IDBFactory;
451
475
  IDBFactory.__createInstance = function () {
452
476
  /**
453
477
  * @class
478
+ * @this {IDBFactoryFull}
454
479
  */
455
480
  function IDBFactory () {
481
+ // @ts-expect-error It's ok
456
482
  this[Symbol.toStringTag] = 'IDBFactory';
457
483
  this.__connections = {};
458
484
  }
@@ -515,8 +541,8 @@ IDBFactory.prototype.open = function (name /* , version */) {
515
541
 
516
542
  /**
517
543
  *
518
- * @param {SQLTransaction|Error|SQLError} tx
519
- * @param {SQLError} [err]
544
+ * @param {WebSQLTransaction|Error|(Error & {code?: number})} tx
545
+ * @param {(Error & {code?: number})} [err]
520
546
  * @returns {boolean}
521
547
  */
522
548
  function dbCreateError (tx, err) {
@@ -536,7 +562,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
536
562
 
537
563
  /**
538
564
  *
539
- * @param {SQLTransaction} tx
565
+ * @param {WebSQLTransaction} tx
540
566
  * @param {DatabaseFull} db
541
567
  * @param {Integer} oldVersion
542
568
  * @returns {void}
@@ -562,9 +588,9 @@ IDBFactory.prototype.open = function (name /* , version */) {
562
588
  // DB Upgrade in progress
563
589
  /**
564
590
  *
565
- * @param {SQLTransaction} systx
566
- * @param {boolean|SQLError|DOMException|Error} err
567
- * @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
568
594
  * @returns {void}
569
595
  */
570
596
  let sysdbFinishedCb = function (systx, err, cb) {
@@ -622,37 +648,71 @@ IDBFactory.prototype.open = function (name /* , version */) {
622
648
  */
623
649
  function versionSet () {
624
650
  const e = /** @type {import('eventtargeter').EventWithProps & Event & IDBVersionChangeEvent} */ (
651
+ // @ts-ignore It's ok; needed under some TS versions
625
652
  new IDBVersionChangeEvent('upgradeneeded', {oldVersion, newVersion: version})
626
653
  );
627
654
  req.__result = connection;
628
655
  connection.__upgradeTransaction = req.__transaction = req.__result.__versionTransaction = IDBTransaction.__createInstance(req.__result, req.__result.objectStoreNames, 'versionchange');
629
656
  req.__done = true;
630
657
 
631
- req.transaction.__addNonRequestToTransactionQueue(function onupgradeneeded (tx, args, finished /* , error */) {
632
- req.dispatchEvent(e);
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
+ // Give any same-tick microtask scheduled from within the
672
+ // `upgradeneeded` handler (e.g. a plain
673
+ // `Promise.resolve().then(...)`) a chance to run -- and still
674
+ // observe the transaction as active -- before we deactivate it
675
+ // again, per https://github.com/w3c/IndexedDB/issues/87. Only
676
+ // the flag reset itself is deferred here -- unlike
677
+ // `IDBTransaction.js`'s `advanceAfterDispatch`, `finished()`
678
+ // (this transaction's own queue-advancement/completion signal)
679
+ // still runs synchronously, at exactly its previous timing: an
680
+ // earlier attempt at deferring `finished()` too raced against
681
+ // unrelated test setup that assumed a freshly deleted/created
682
+ // database's upgrade transaction had already fully completed by
683
+ // the time this function returns.
684
+ queueMicrotask(() => {
685
+ req.transaction.__handlerActive = false;
686
+ });
633
687
 
634
- if (e.__legacyOutputDidListenersThrowError) {
635
- 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
636
- req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
637
- return;
688
+ if (e.__legacyOutputDidListenersThrowError) {
689
+ 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
690
+ req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
691
+ return;
692
+ }
693
+ finished();
638
694
  }
639
- finished();
640
- });
695
+ );
641
696
 
642
697
  // eslint-disable-next-line camelcase -- Clear API
643
- req.transaction.on__beforecomplete = function (ev) {
644
- connection.__upgradeTransaction = null;
645
- /** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
646
- req.__result
647
- ).__versionTransaction = null;
648
- sysdbFinishedCb(systx, false, function () {
649
- req.transaction.__callTransFinishedCb(false, function () {
650
- ev.complete();
651
- req.__transaction = null;
698
+ req.transaction.on__beforecomplete =
699
+ /**
700
+ * @param {Event & {complete: () => void}} ev
701
+ * @returns {void}
702
+ */
703
+ function (ev) {
704
+ connection.__upgradeTransaction = null;
705
+ /** @type {import('./IDBDatabase.js').IDBDatabaseFull} */ (
706
+ req.__result
707
+ ).__versionTransaction = null;
708
+ sysdbFinishedCb(systx, false, function () {
709
+ req.transaction.__callTransFinishedCb(false, function () {
710
+ ev.complete();
711
+ req.__transaction = null;
712
+ });
713
+ return false;
652
714
  });
653
- return false;
654
- });
655
- };
715
+ };
656
716
 
657
717
  // eslint-disable-next-line camelcase -- Clear API
658
718
  req.transaction.on__preabort = function () {
@@ -779,12 +839,12 @@ IDBFactory.prototype.open = function (name /* , version */) {
779
839
  if ((useMemoryDatabase || useDatabaseCache) && Object.hasOwn(websqlDBCache, name) && Object.hasOwn(websqlDBCache[name], version)) {
780
840
  db = websqlDBCache[name][version];
781
841
  } else {
782
- db = me.__openDatabase(
842
+ db = /** @type {DatabaseFull} */ (me.__openDatabase(
783
843
  useMemoryDatabase ? CFG.memoryDatabase : path.join(CFG.databaseBasePath || '', escapedDatabaseName),
784
844
  '1',
785
845
  name,
786
846
  CFG.DEFAULT_DB_SIZE
787
- );
847
+ ));
788
848
  if (useDatabaseCache) {
789
849
  if (!(Object.hasOwn(websqlDBCache, name))) {
790
850
  websqlDBCache[name] = {};
@@ -818,7 +878,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
818
878
  return;
819
879
  }
820
880
  tx.executeSql('CREATE INDEX IF NOT EXISTS sysname ON __sys__(name)', [], setup, dbCreateError);
821
- }, /** @type {SQLStatementErrorCallback} */ (dbCreateError));
881
+ }, /** @type {SqlErrorCallback} */ (dbCreateError));
822
882
  }, dbCreateError);
823
883
  }
824
884
 
@@ -840,7 +900,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
840
900
  // Database with this name does not exist
841
901
  openDB(0);
842
902
  } else {
843
- openDB(data.rows.item(0).version);
903
+ openDB(/** @type {{version: Integer}} */ (data.rows.item(0)).version);
844
904
  }
845
905
  }, dbCreateError);
846
906
  }, dbCreateError);
@@ -904,8 +964,8 @@ IDBFactory.prototype.deleteDatabase = function (name) {
904
964
  // `UnknownError` as we may require upon a SQL deletion error
905
965
  /**
906
966
  *
907
- * @param {SQLTransaction|SQLError|Error} tx
908
- * @param {SQLError|boolean} [err]
967
+ * @param {WebSQLTransaction|(Error & {code?: number})|Error} tx
968
+ * @param {(Error & {code?: number})|boolean} [err]
909
969
  * @returns {boolean}
910
970
  */
911
971
  function dbError (tx, err) {
@@ -920,7 +980,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
920
980
  // transaction, corrupting that connection's task queue (see issue with unrelated `open()` calls
921
981
  // failing/crashing after a `deleteDatabase` file-removal error).
922
982
  calledDBError = true;
923
- const er = webSQLErrback(/** @type {SQLError} */ (err || tx));
983
+ const er = webSQLErrback(/** @type {(Error & {code?: number})} */ (err || tx));
924
984
  sysdbFinishedCbDelete(true, function () {
925
985
  req.__done = true;
926
986
  req.__error = er;
@@ -944,6 +1004,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
944
1004
  req.__result = undefined;
945
1005
  req.__done = true;
946
1006
  const e = /** @type {Event & IDBVersionChangeEvent} */ (
1007
+ // @ts-ignore It's ok; needed under some TS versions
947
1008
  new IDBVersionChangeEvent('success', {oldVersion: version, newVersion: null})
948
1009
  );
949
1010
  req.dispatchEvent(e);
@@ -966,7 +1027,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
966
1027
  completeDatabaseDelete();
967
1028
  return undefined;
968
1029
  }
969
- ({version} = data.rows.item(0));
1030
+ ({version} = /** @type {{version: Integer}} */ (data.rows.item(0)));
970
1031
 
971
1032
  const openConnections = me.__connections[name] || [];
972
1033
  triggerAnyVersionChangeAndBlockedEvents(openConnections, req, version, null).then(function () {
@@ -1050,15 +1111,15 @@ IDBFactory.prototype.databases = function () {
1050
1111
  }
1051
1112
  /**
1052
1113
  *
1053
- * @param {true|SQLTransaction|SQLError|DOMException|Error} tx
1054
- * @param {SQLError|DOMException|Error} [err]
1114
+ * @param {true|WebSQLTransaction|(Error & {code?: number})|DOMException|Error} tx
1115
+ * @param {(Error & {code?: number})|DOMException|Error} [err]
1055
1116
  * @returns {boolean}
1056
1117
  */
1057
1118
  function dbGetDatabaseNamesError (tx, err) {
1058
1119
  if (calledDbCreateError) {
1059
1120
  return false;
1060
1121
  }
1061
- const er = err ? webSQLErrback(/** @type {SQLError} */ (err)) : tx;
1122
+ const er = err ? webSQLErrback(/** @type {(Error & {code?: number})} */ (err)) : tx;
1062
1123
  calledDbCreateError = true;
1063
1124
  reject(er);
1064
1125
  return false;
@@ -1068,7 +1129,7 @@ IDBFactory.prototype.databases = function () {
1068
1129
  sysReadTx.executeSql('SELECT "name", "version" FROM dbVersions', [], function (sysReadTx, data) {
1069
1130
  const dbNames = [];
1070
1131
  for (let i = 0; i < data.rows.length; i++) {
1071
- const {name, version} = data.rows.item(i);
1132
+ const {name, version} = /** @type {{name: string, version: Integer}} */ (data.rows.item(i));
1072
1133
  dbNames.push({
1073
1134
  name: util.unescapeSQLiteResponse(name),
1074
1135
  version
@@ -1138,6 +1199,7 @@ IDBFactory.prototype.__setConnectionQueueOrigin = function (origin = getOrigin()
1138
1199
  IDBFactory.prototype[Symbol.toStringTag] = 'IDBFactoryPrototype';
1139
1200
 
1140
1201
  /* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
1202
+ util.setOperationNames(IDBFactory.prototype);
1141
1203
  Object.defineProperty(IDBFactory, 'prototype', {
1142
1204
  writable: false
1143
1205
  });