indexeddbshim 18.0.0 → 19.0.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 (68) hide show
  1. package/dist/DOMException.d.ts +3 -7
  2. package/dist/DOMException.d.ts.map +1 -1
  3. package/dist/DOMStringList.d.ts +1 -2
  4. package/dist/DOMStringList.d.ts.map +1 -1
  5. package/dist/IDBCursor.d.ts +100 -52
  6. package/dist/IDBCursor.d.ts.map +1 -1
  7. package/dist/IDBFactory.d.ts.map +1 -1
  8. package/dist/IDBIndex.d.ts +8 -7
  9. package/dist/IDBIndex.d.ts.map +1 -1
  10. package/dist/IDBKeyRange.d.ts +3 -3
  11. package/dist/IDBKeyRange.d.ts.map +1 -1
  12. package/dist/IDBObjectStore.d.ts +12 -12
  13. package/dist/IDBObjectStore.d.ts.map +1 -1
  14. package/dist/IDBRequest.d.ts +2 -2
  15. package/dist/IDBRequest.d.ts.map +1 -1
  16. package/dist/IDBTransaction.d.ts +13 -13
  17. package/dist/IDBTransaction.d.ts.map +1 -1
  18. package/dist/Key.d.ts +14 -15
  19. package/dist/Key.d.ts.map +1 -1
  20. package/dist/Sca.d.ts +2 -2
  21. package/dist/Sca.d.ts.map +1 -1
  22. package/dist/cmp.d.ts +3 -3
  23. package/dist/cmp.d.ts.map +1 -1
  24. package/dist/indexeddbshim-Key.js +36 -45
  25. package/dist/indexeddbshim-Key.js.map +1 -1
  26. package/dist/indexeddbshim-Key.min.js +2 -2
  27. package/dist/indexeddbshim-Key.min.js.map +1 -1
  28. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +224 -208
  29. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  30. package/dist/indexeddbshim-UnicodeIdentifiers.js +221 -235
  31. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  32. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +3 -3
  33. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  34. package/dist/indexeddbshim-node.cjs +224 -208
  35. package/dist/indexeddbshim-node.cjs.map +1 -1
  36. package/dist/indexeddbshim-noninvasive.js +221 -235
  37. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  38. package/dist/indexeddbshim-noninvasive.min.js +3 -3
  39. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  40. package/dist/indexeddbshim.js +221 -235
  41. package/dist/indexeddbshim.js.map +1 -1
  42. package/dist/indexeddbshim.min.js +3 -3
  43. package/dist/indexeddbshim.min.js.map +1 -1
  44. package/dist/nodeWebSQL.d.ts +2 -2
  45. package/dist/nodeWebSQL.d.ts.map +1 -1
  46. package/dist/setGlobalVars.d.ts +1 -2
  47. package/dist/setGlobalVars.d.ts.map +1 -1
  48. package/dist/util.d.ts +20 -22
  49. package/dist/util.d.ts.map +1 -1
  50. package/package.json +1 -1
  51. package/src/CFG.js +1 -1
  52. package/src/DOMException.js +8 -10
  53. package/src/DOMStringList.js +6 -11
  54. package/src/Event.js +1 -4
  55. package/src/IDBCursor.js +95 -47
  56. package/src/IDBFactory.js +8 -5
  57. package/src/IDBIndex.js +10 -12
  58. package/src/IDBKeyRange.js +6 -5
  59. package/src/IDBObjectStore.js +32 -27
  60. package/src/IDBRequest.js +1 -1
  61. package/src/IDBTransaction.js +11 -11
  62. package/src/IDBVersionChangeEvent.js +1 -4
  63. package/src/Key.js +32 -31
  64. package/src/Sca.js +1 -1
  65. package/src/cmp.js +2 -2
  66. package/src/nodeWebSQL.js +5 -2
  67. package/src/setGlobalVars.js +8 -19
  68. package/src/util.js +19 -16
package/src/IDBFactory.js CHANGED
@@ -645,7 +645,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
645
645
  let sysdbFinishedCb = function (systx, err, cb) {
646
646
  if (err) {
647
647
  /**
648
- * @param {any} [errorToShow]
648
+ * @param {unknown} [errorToShow]
649
649
  * @returns {void}
650
650
  */
651
651
  const manualRevert = function (errorToShow) {
@@ -679,7 +679,10 @@ IDBFactory.prototype.open = function (name /* , version */) {
679
679
  },
680
680
  function () {
681
681
  isRevertingSysdb = false;
682
- cb(errorToShow || reportError); // eslint-disable-line promise/no-callback-in-promise -- Convenient
682
+ // eslint-disable-next-line promise/no-callback-in-promise -- Convenient
683
+ cb(/** @type {(Error & {code?: number})|undefined} */ (
684
+ errorToShow || reportError
685
+ ));
683
686
  }
684
687
  );
685
688
  };
@@ -718,14 +721,14 @@ IDBFactory.prototype.open = function (name /* , version */) {
718
721
  new IDBVersionChangeEvent('upgradeneeded', {oldVersion, newVersion: version})
719
722
  );
720
723
  req.__result = connection;
721
- connection.__upgradeTransaction = req.__transaction = req.__result.__versionTransaction = IDBTransaction.__createInstance(req.__result, req.__result.objectStoreNames, 'versionchange');
724
+ connection.__upgradeTransaction = req.__transaction = connection.__versionTransaction = IDBTransaction.__createInstance(connection, connection.objectStoreNames, 'versionchange');
722
725
  req.__done = true;
723
726
 
724
727
  req.transaction.__addNonRequestToTransactionQueue(
725
728
  /**
726
729
  * @param {import('websql-configurable/lib/websql/WebSQLTransaction.js').default} tx
727
- * @param {any[]} args
728
- * @param {(result?: any, req?: import('./IDBRequest.js').IDBRequestFull) => void} finished
730
+ * @param {unknown[]} args
731
+ * @param {(result?: unknown, req?: import('./IDBRequest.js').IDBRequestFull) => void} finished
729
732
  * @returns {void}
730
733
  */
731
734
  function onupgradeneeded (tx, args, finished /* , error */) {
package/src/IDBIndex.js CHANGED
@@ -68,7 +68,7 @@ const IDBIndexAlias = IDBIndex;
68
68
  * __keyPath: import('./Key.js').KeyPath,
69
69
  * __recreated?: boolean,
70
70
  * __fetchIndexData: (
71
- * range: any,
71
+ * range: Query,
72
72
  * opType: "value"|"key"|"count",
73
73
  * nullDisallowed: boolean,
74
74
  * count?: number
@@ -497,7 +497,7 @@ IDBIndex.__updateIndexList = function (store, tx, success, failure) {
497
497
  };
498
498
 
499
499
  /**
500
- * @typedef {any|IDBKeyRange} Query
500
+ * @typedef {import('./Key.js').Value|IDBKeyRange} Query
501
501
  */
502
502
 
503
503
  /**
@@ -766,7 +766,7 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
766
766
  })
767
767
  );
768
768
  SyncPromise.all(indexCreations).then(finish).catch(
769
- /** @type {(reason: any) => PromiseLike<never>} */
769
+ /** @type {(reason: unknown) => PromiseLike<never>} */
770
770
  (error)
771
771
  ).catch((err) => {
772
772
  console.log('Index rename error');
@@ -779,14 +779,10 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
779
779
  });
780
780
  };
781
781
 
782
- /**
783
- * @typedef {any} AnyValue
784
- */
785
-
786
782
  /* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
787
783
  Object.defineProperty(IDBIndex, Symbol.hasInstance, {
788
784
  /**
789
- * @param {AnyValue} obj
785
+ * @param {unknown} obj
790
786
  * @returns {boolean}
791
787
  */
792
788
  value: (obj) => util.isObj(obj) &&
@@ -819,7 +815,9 @@ Object.defineProperty(IDBIndex, 'prototype', {
819
815
  * @param {string[]} sqlValues
820
816
  * @param {WebSQLTransaction} tx
821
817
  * @param {null|undefined} args
822
- * @param {(result: number|undefined|[]|AnyValue|AnyValue[]) => void} success
818
+ * @param {(
819
+ * result: number|undefined|[]|import('./Key.js').Value|import('./Key.js').Value[]
820
+ * ) => void} success
823
821
  * @param {(tx: WebSQLTransaction, err: (Error & {code?: number})) => void} error
824
822
  * @returns {void}
825
823
  */
@@ -859,7 +857,7 @@ function executeFetchIndexData (
859
857
  * @param {{
860
858
  * value: string
861
859
  * }} record
862
- * @returns {AnyValue}
860
+ * @returns {import('./Key.js').Value}
863
861
  */
864
862
  (record) => { // when opType is value
865
863
  return Sca.decode(util.unescapeSQLiteResponse(record.value));
@@ -874,9 +872,9 @@ function executeFetchIndexData (
874
872
  );
875
873
  let record;
876
874
  if (hasKey && (
877
- (multiChecks && range.some(
875
+ (multiChecks && /** @type {import('./Key.js').ValueType[]} */ (range).some(
878
876
  /**
879
- * @param {string} check
877
+ * @param {import('./Key.js').ValueType} check
880
878
  * @returns {boolean}
881
879
  */
882
880
  (check) => rowKey.includes(check)
@@ -27,8 +27,8 @@ function IDBKeyRange () {
27
27
  const IDBKeyRangeAlias = IDBKeyRange;
28
28
 
29
29
  /**
30
- * @param {import('./Key.js').Key|null} lower
31
- * @param {import('./Key.js').Key|null} upper
30
+ * @param {import('./Key.js').Value} lower
31
+ * @param {import('./Key.js').Value} upper
32
32
  * @param {boolean} lowerOpen
33
33
  * @param {boolean} upperOpen
34
34
  * @returns {import('./IDBKeyRange.js').IDBKeyRangeFull}
@@ -238,10 +238,11 @@ function setSQLForKeyRange (
238
238
  function convertValueToKeyRange (value, nullDisallowed) {
239
239
  if (util.instanceOf(value, IDBKeyRange)) {
240
240
  // We still need to validate IDBKeyRange-like objects (the above check is based on loose duck-typing)
241
- if (value.toString() !== '[object IDBKeyRange]') {
242
- return IDBKeyRange.__createInstance(value.lower, value.upper, value.lowerOpen, value.upperOpen);
241
+ const range = /** @type {IDBKeyRangeFull} */ (value);
242
+ if (range.toString() !== '[object IDBKeyRange]') {
243
+ return IDBKeyRange.__createInstance(range.lower, range.upper, range.lowerOpen, range.upperOpen);
243
244
  }
244
- return value;
245
+ return range;
245
246
  }
246
247
  if (util.isNullish(value)) {
247
248
  if (nullDisallowed) {
@@ -60,14 +60,14 @@ const IDBObjectStoreAlias = IDBObjectStore;
60
60
  * __idbdb: import('./IDBDatabase.js').IDBDatabaseFull,
61
61
  * __validateKeyAndValueAndCloneValue: (
62
62
  * value: import('./Key.js').Value,
63
- * key: import('./Key.js').Key,
63
+ * key: import('./Key.js').Key|undefined,
64
64
  * cursorUpdate: boolean
65
65
  * ) => KeyValueArray,
66
66
  * __deriveKey: (
67
67
  * tx: WebSQLTransaction,
68
68
  * value: import('./Key.js').Value,
69
- * key: import('./Key.js').Key,
70
- * success: (key: import('./Key.js').Key, cn?: Integer) => void,
69
+ * key: import('./Key.js').Key|undefined,
70
+ * success: (key: import('./Key.js').Value, cn?: Integer) => void,
71
71
  * failCb: import('./Key.js').SQLFailureCallback
72
72
  * ) => void,
73
73
  * __checkIndexConstraints: (
@@ -399,7 +399,7 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
399
399
  };
400
400
 
401
401
  /**
402
- * @typedef {[import('./Key.js').Key, import('./Key.js').Value]} KeyValueArray
402
+ * @typedef {[import('./Key.js').Key|undefined, import('./Key.js').Value]} KeyValueArray
403
403
  */
404
404
 
405
405
  // Todo: Although we may end up needing to do cloning genuinely asynchronously (for Blobs and FileLists),
@@ -414,7 +414,7 @@ IDBObjectStore.__deleteObjectStore = function (db, store) {
414
414
  * Determines whether the given inline or out-of-line key is valid,
415
415
  * according to the object store's schema.
416
416
  * @param {import('./Key.js').Value} value Used for inline keys
417
- * @param {import('./Key.js').Key} key Used for out-of-line keys
417
+ * @param {import('./Key.js').Key|undefined} key Used for out-of-line keys
418
418
  * @param {boolean} cursorUpdate
419
419
  * @throws {DOMException}
420
420
  * @this {IDBObjectStoreFull}
@@ -433,11 +433,11 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
433
433
  /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (me.transaction),
434
434
  value
435
435
  );
436
- key = Key.extractKeyValueDecodedFromValueUsingKeyPath(clonedValue, me.keyPath); // May throw so "rethrow"
437
- if (key.invalid) {
436
+ const extractedKey = Key.extractKeyValueDecodedFromValueUsingKeyPath(clonedValue, me.keyPath); // May throw so "rethrow"
437
+ if ('invalid' in extractedKey && extractedKey.invalid) {
438
438
  throw createDOMException('DataError', 'KeyPath was specified, but key was invalid.');
439
439
  }
440
- if (key.failure) {
440
+ if ('failure' in extractedKey && extractedKey.failure) {
441
441
  if (!cursorUpdate) {
442
442
  if (!me.autoIncrement) {
443
443
  throw createDOMException('DataError', 'Could not evaluate a key from keyPath and there is no key generator');
@@ -452,14 +452,13 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
452
452
  throw createDOMException('DataError', 'Could not evaluate a key from keyPath');
453
453
  }
454
454
  // An `IDBCursor.update` call will also throw if not equal to the cursor’s effective key
455
- return [key.value, clonedValue];
455
+ return [(/** @type {import('./Key.js').Key} */ (extractedKey.value)), clonedValue];
456
456
  }
457
457
  if (key === undefined) {
458
458
  if (!me.autoIncrement) {
459
459
  throw createDOMException('DataError', 'The object store uses out-of-line keys and has no key generator and the key parameter was not provided.');
460
460
  }
461
461
  // A key will be generated
462
- key = undefined;
463
462
  } else {
464
463
  Key.convertValueToKeyRethrowingAndIfInvalid(key);
465
464
  }
@@ -477,8 +476,8 @@ IDBObjectStore.prototype.__validateKeyAndValueAndCloneValue = function (value, k
477
476
  * a keyPath leading to a valid but non-numeric or < 1 key).
478
477
  * @param {WebSQLTransaction} tx
479
478
  * @param {import('./Key.js').Value} value
480
- * @param {import('./Key.js').Key} key
481
- * @param {(key: import('./Key.js').Key, cn?: Integer) => void} success
479
+ * @param {import('./Key.js').Key|undefined} key
480
+ * @param {(key: import('./Key.js').Value, cn?: Integer) => void} success
482
481
  * @param {import('./Key.js').SQLFailureCallback} failCb
483
482
  * @this {IDBObjectStoreFull}
484
483
  * @returns {void}
@@ -492,9 +491,8 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
492
491
  * @returns {void}
493
492
  */
494
493
  function keyCloneThenSuccess (oldCn) { // We want to return the original key, so we don't need to accept an argument here
495
- Sca.encode(key, function (key) {
496
- key = Sca.decode(key);
497
- success(key, oldCn);
494
+ Sca.encode(key, function (encodedKey) {
495
+ success(Sca.decode(encodedKey), oldCn);
498
496
  });
499
497
  }
500
498
 
@@ -510,7 +508,9 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
510
508
  // Should not throw now as checked earlier
511
509
  // Todo: Could this not be an array here?
512
510
  Key.injectKeyIntoValueUsingKeyPath(
513
- value, key, /** @type {string} */ (me.keyPath)
511
+ /** @type {{[key: string]: import('./Key.js').Value}} */ (value),
512
+ /** @type {import('./Key.js').Key} */ (key),
513
+ /** @type {string} */ (me.keyPath)
514
514
  );
515
515
  }
516
516
  success(key, oldCn);
@@ -571,15 +571,17 @@ IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeK
571
571
  resolve(undefined);
572
572
  return;
573
573
  }
574
- indexKey = indexKey.value;
575
- if (indexKey === undefined) {
574
+ const indexKeyValue = indexKey.value;
575
+ if (indexKeyValue === undefined) {
576
576
  resolve(undefined);
577
577
  return;
578
578
  }
579
- const multiCheck = index.multiEntry && Array.isArray(indexKey);
580
- const fetchArgs = buildFetchIndexDataSQL(true, index, indexKey, 'key', multiCheck);
579
+ const multiCheck = index.multiEntry && Array.isArray(indexKeyValue);
580
+ const fetchArgs = buildFetchIndexDataSQL(true, index, indexKeyValue, 'key', multiCheck);
581
581
  executeFetchIndexData(null, ...fetchArgs, tx, null, function success (key) {
582
- if (key === undefined || (excludeKey !== undefined && cmp(key, excludeKey) === 0)) {
582
+ if (key === undefined || (excludeKey !== undefined && cmp(
583
+ /** @type {import('./Key.js').Key} */ (key), excludeKey
584
+ ) === 0)) {
583
585
  resolve(undefined);
584
586
  return;
585
587
  }
@@ -662,22 +664,22 @@ IDBObjectStore.prototype.__insertData = function (tx, encoded, value, clonedKeyO
662
664
  resolve(undefined);
663
665
  return;
664
666
  }
665
- indexKey = indexKey.value;
667
+ const indexKeyValue = indexKey.value;
666
668
  /**
667
669
  * @param {import('./IDBIndex.js').IDBIndexFull} index
668
670
  * @returns {void}
669
671
  */
670
672
  function setIndexInfo (index) {
671
- if (indexKey === undefined) {
673
+ if (indexKeyValue === undefined) {
672
674
  return;
673
675
  }
674
676
  paramMap[index.__currentName] = /** @type {string} */ (
675
- Key.encode(indexKey, index.multiEntry)
677
+ Key.encode(indexKeyValue, index.multiEntry)
676
678
  );
677
679
  }
678
680
  if (index.unique) {
679
- const multiCheck = index.multiEntry && Array.isArray(indexKey);
680
- const fetchArgs = buildFetchIndexDataSQL(true, index, indexKey, 'key', multiCheck);
681
+ const multiCheck = index.multiEntry && Array.isArray(indexKeyValue);
682
+ const fetchArgs = buildFetchIndexDataSQL(true, index, indexKeyValue, 'key', multiCheck);
681
683
  executeFetchIndexData(null, ...fetchArgs, tx, null, function success (key) {
682
684
  if (key === undefined) {
683
685
  setIndexInfo(index);
@@ -854,7 +856,10 @@ IDBObjectStore.__storingRecordObjectStore = function (request, store, invalidate
854
856
  /** @type {import('./IDBTransaction.js').IDBTransactionFull} */ (
855
857
  store.transaction
856
858
  ).__pushToQueue(request, function (tx, args, success, error) {
857
- store.__deriveKey(tx, value, key, function (clonedKeyOrCurrentNumber, oldCn) {
859
+ store.__deriveKey(tx, value, key, function (clonedKeyOrCurrentNumberRaw, oldCn) {
860
+ const clonedKeyOrCurrentNumber = /** @type {import('./Key.js').Key|Integer} */ (
861
+ clonedKeyOrCurrentNumberRaw
862
+ );
858
863
  Sca.encode(value, function (encoded) {
859
864
  /**
860
865
  * @param {WebSQLTransaction} tx
package/src/IDBRequest.js CHANGED
@@ -20,7 +20,7 @@ function IDBRequest () {
20
20
  * @typedef {IDBRequest & EventTarget & import('eventtargeter').EventTargetInstance & {
21
21
  * transaction: import('./IDBTransaction.js').IDBTransactionFull,
22
22
  * __done: boolean,
23
- * __result: import('./IDBDatabase.js').IDBDatabaseFull|undefined,
23
+ * __result: unknown,
24
24
  * __error: null|DOMException|Error,
25
25
  * __source: null|import('./IDBDatabase.js').IDBDatabaseFull|
26
26
  * import('./IDBObjectStore.js').IDBObjectStoreFull|
@@ -19,7 +19,7 @@ const readonlyProperties = ['objectStoreNames', 'mode', 'durability', 'db', 'err
19
19
  /**
20
20
  * @typedef {{
21
21
  * op: SQLCallback,
22
- * args: any[],
22
+ * args: unknown[],
23
23
  * req: import('./IDBRequest.js').IDBRequestFull|null
24
24
  * }} RequestInfo
25
25
  */
@@ -71,17 +71,17 @@ const readonlyProperties = ['objectStoreNames', 'mode', 'durability', 'db', 'err
71
71
  * __pushToQueue: (
72
72
  * request: import('./IDBRequest.js').IDBRequestFull|null,
73
73
  * callback: SQLCallback,
74
- * args?: any[]
74
+ * args?: unknown[]
75
75
  * ) => void,
76
76
  * __assertActive: () => void,
77
77
  * commit: () => void,
78
78
  * __addNonRequestToTransactionQueue: (
79
79
  * callback: SQLCallback,
80
- * args?: any[]
80
+ * args?: unknown[]
81
81
  * ) => void
82
82
  * __addToTransactionQueue: (
83
83
  * callback: SQLCallback,
84
- * args: any[]|undefined,
84
+ * args: unknown[]|undefined,
85
85
  * source: import('./IDBDatabase.js').IDBDatabaseFull|
86
86
  * import('./IDBObjectStore.js').IDBObjectStoreFull|
87
87
  * import('./IDBIndex.js').IDBIndexFull|
@@ -281,7 +281,7 @@ IDBTransaction.prototype.__executeRequests = function () {
281
281
  i = -1;
282
282
 
283
283
  /**
284
- * @typedef {any} IDBRequestResult
284
+ * @typedef {unknown} IDBRequestResult
285
285
  */
286
286
 
287
287
  /**
@@ -710,8 +710,8 @@ IDBTransaction.prototype.__createRequest = function (source) {
710
710
  /**
711
711
  * @typedef {(
712
712
  * tx: import('websql-configurable/lib/websql/WebSQLTransaction.js').default,
713
- * args: any[],
714
- * success: (result?: any, req?: import('./IDBRequest.js').IDBRequestFull) => void,
713
+ * args: unknown[],
714
+ * success: (result?: unknown, req?: import('./IDBRequest.js').IDBRequestFull) => void,
715
715
  * error: (
716
716
  * tx: import('websql-configurable/lib/websql/WebSQLTransaction.js').default|Error|DOMException,
717
717
  * err?: Error & {code?: number}
@@ -723,7 +723,7 @@ IDBTransaction.prototype.__createRequest = function (source) {
723
723
  /**
724
724
  * Adds a callback function to the transaction queue.
725
725
  * @param {SQLCallback} callback
726
- * @param {any[]} args
726
+ * @param {unknown[]} args
727
727
  * @param {import('./IDBDatabase.js').IDBDatabaseFull|
728
728
  * import('./IDBObjectStore.js').IDBObjectStoreFull|
729
729
  * import('./IDBIndex.js').IDBIndexFull} source
@@ -740,7 +740,7 @@ IDBTransaction.prototype.__addToTransactionQueue = function (callback, args, sou
740
740
  * Adds a callback function to the transaction queue without generating a
741
741
  * request.
742
742
  * @param {SQLCallback} callback
743
- * @param {any[]} args
743
+ * @param {unknown[]} args
744
744
  * @this {IDBTransactionFull}
745
745
  * @returns {void}
746
746
  */
@@ -752,7 +752,7 @@ IDBTransaction.prototype.__addNonRequestToTransactionQueue = function (callback,
752
752
  * Adds an IDBRequest to the transaction queue.
753
753
  * @param {import('./IDBRequest.js').IDBRequestFull|null} request
754
754
  * @param {SQLCallback} callback
755
- * @param {any[]} args
755
+ * @param {unknown[]} args
756
756
  * @this {IDBTransactionFull}
757
757
  * @returns {void}
758
758
  */
@@ -923,7 +923,7 @@ IDBTransaction.prototype.__abortTransaction = function (err) {
923
923
  q.req.__error = createDOMException('AbortError', 'A request was aborted (an unfinished request).');
924
924
  const reqEvt = createEvent('error', q.req.__error, {bubbles: true, cancelable: true});
925
925
  return new SyncPromise(
926
- /** @type {(resolve: (value?: any) => void) => void} */
926
+ /** @type {(resolve: (value?: unknown) => void) => void} */
927
927
  (resolve) => {
928
928
  setTimeout(() => {
929
929
  if (!q.req) { // TS guard
@@ -66,12 +66,9 @@ readonlyProperties.forEach((prop) => {
66
66
  });
67
67
 
68
68
  Object.defineProperty(IDBVersionChangeEvent, Symbol.hasInstance, {
69
- /**
70
- * @typedef {any} AnyValue
71
- */
72
69
  value:
73
70
  /**
74
- * @param {AnyValue} obj
71
+ * @param {unknown} obj
75
72
  * @returns {boolean}
76
73
  */
77
74
  (obj) => util.isObj(obj) && 'oldVersion' in obj &&
package/src/Key.js CHANGED
@@ -39,12 +39,11 @@ import CFG from './CFG.js';
39
39
  */
40
40
 
41
41
  /**
42
- * @typedef {any} Value
42
+ * @typedef {unknown} Value
43
43
  */
44
44
 
45
45
  /**
46
- * @typedef {any} Key
47
- * @todo Specify possible value more precisely
46
+ * @typedef {IDBValidKey} Key
48
47
  */
49
48
 
50
49
  /**
@@ -113,15 +112,11 @@ const encodedCharToKeyType = keyTypes.reduce((o, k) => {
113
112
  */
114
113
  const signValues = ['negativeInfinity', 'bigNegative', 'smallNegative', 'smallPositive', 'bigPositive', 'positiveInfinity'];
115
114
 
116
- /**
117
- * @typedef {any} AnyValue
118
- */
119
-
120
115
  /**
121
116
  * @type {{
122
117
  * [key: string]: {
123
- * encode: (param: any, inArray?: boolean) => string,
124
- * decode: (param: string, inArray?: boolean) => any
118
+ * encode(param: unknown, inArray?: boolean): string,
119
+ * decode(param: string, inArray?: boolean): ValueType|undefined
125
120
  * }
126
121
  * }}
127
122
  */
@@ -473,7 +468,7 @@ function negate (s) {
473
468
  }
474
469
 
475
470
  /**
476
- * @param {Key} key
471
+ * @param {Value} key
477
472
  * @returns {KeyType|"invalid"}
478
473
  */
479
474
  function getKeyType (key) {
@@ -595,7 +590,7 @@ function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
595
590
  }
596
591
  return {type: 'binary', value: octets};
597
592
  } case 'array': { // May throw (from binary)
598
- const arr = /** @type {Array<any>} */ (input);
593
+ const arr = /** @type {unknown[]} */ (input);
599
594
  const len = arr.length;
600
595
  safePush(seen, input);
601
596
 
@@ -615,8 +610,12 @@ function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
615
610
  return {type, invalid: true, message: 'Bad array entry value-to-key conversion'};
616
611
  }
617
612
  if (!multiEntry ||
618
- (!fullKeys && keys.every((k) => cmp(k, key.value) !== 0)) ||
619
- (fullKeys && keys.every((k) => cmp(k, key) !== 0))
613
+ (!fullKeys && keys.every((k) => cmp(
614
+ /** @type {Key} */ (k), /** @type {Key} */ (key.value)
615
+ ) !== 0)) ||
616
+ (fullKeys && keys.every((k) => cmp(
617
+ /** @type {Key} */ (k), /** @type {Key} */ (/** @type {unknown} */ (key))
618
+ ) !== 0))
620
619
  ) {
621
620
  safePush(keys, fullKeys ? key : key.value);
622
621
  }
@@ -647,7 +646,7 @@ function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
647
646
 
648
647
  /**
649
648
  *
650
- * @param {Key} key
649
+ * @param {Value} key
651
650
  * @param {boolean} [fullKeys]
652
651
  * @returns {KeyValueObject}
653
652
  * @todo Document other allowable `key`?
@@ -759,7 +758,7 @@ function evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullK
759
758
  : {value: result};
760
759
  }
761
760
  if (keyPath === '') {
762
- return {value};
761
+ return {value: /** @type {KeyPathEvaluateValueValue} */ (value)};
763
762
  }
764
763
  const identifiers = keyPath.split('.');
765
764
  return identifiers.some((idntfr) => {
@@ -797,12 +796,12 @@ function evaluateKeyPathOnValueToDecodedValue (value, keyPath, multiEntry, fullK
797
796
  return false;
798
797
  })
799
798
  ? {failure: true}
800
- : {value};
799
+ : {value: /** @type {KeyPathEvaluateValueValue} */ (value)};
801
800
  }
802
801
 
803
802
  /**
804
803
  * Sets the inline key value.
805
- * @param {{[key: string]: AnyValue}} value
804
+ * @param {{[key: string]: Value}} value
806
805
  * @param {Key} key
807
806
  * @param {string} keyPath
808
807
  * @returns {void}
@@ -815,7 +814,7 @@ function injectKeyIntoValueUsingKeyPath (value, key, keyPath) {
815
814
  if (!hop) {
816
815
  Object.defineProperty(value, identifier, {value: {}, enumerable: true, writable: true, configurable: true});
817
816
  }
818
- value = value[identifier];
817
+ value = /** @type {{[key: string]: Value}} */ (value[identifier]);
819
818
  });
820
819
  Object.defineProperty(value, /** @type {string} */ (last), {value: key, enumerable: true, writable: true, configurable: true}); // key is already a `keyValue` in our processing so no need to convert
821
820
  }
@@ -903,7 +902,7 @@ function isMultiEntryMatch (encodedEntry, encodedKey) {
903
902
  * @returns {Key[]}
904
903
  */
905
904
  function findMultiEntryMatches (keyEntry, range) {
906
- /** @type {unknown[]} */
905
+ /** @type {Key[]} */
907
906
  const matches = [];
908
907
 
909
908
  if (Array.isArray(keyEntry)) {
@@ -935,7 +934,7 @@ function findMultiEntryMatches (keyEntry, range) {
935
934
 
936
935
  /**
937
936
  * Not currently in use but keeping for spec parity.
938
- * @param {Key} key
937
+ * @param {KeyValueObject} key
939
938
  * @throws {Error} Upon a "bad key"
940
939
  * @returns {ValueType}
941
940
  */
@@ -943,35 +942,37 @@ function convertKeyToValue (key) {
943
942
  const {type, value} = key;
944
943
  switch (type) {
945
944
  case 'number': case 'string': {
946
- return value;
945
+ return /** @type {number|string} */ (value);
947
946
  } case 'array': {
948
947
  /** @type {ValueType[]} */
949
948
  const array = [];
950
- const len = value.length;
949
+ const arrValue = /** @type {KeyValueObject[]} */ (value);
950
+ const len = arrValue.length;
951
951
  let index = 0;
952
952
  while (index < len) {
953
- const entry = convertKeyToValue(value[index]);
953
+ const entry = convertKeyToValue(arrValue[index]);
954
954
  setArrayValue(array, index, entry);
955
955
  index++;
956
956
  }
957
957
  return array;
958
958
  } case 'date': {
959
- return new Date(value);
959
+ return new Date(/** @type {number} */ (value));
960
960
  } case 'binary': {
961
- const len = value.length;
961
+ const binValue = /** @type {Uint8Array} */ (value);
962
+ const len = binValue.length;
962
963
  const buffer = new ArrayBuffer(len);
963
964
  // Set the entries in buffer's [[ArrayBufferData]] to those in `value`
964
- const uint8 = new Uint8Array(buffer, value.byteOffset || 0, value.byteLength);
965
- uint8.set(value);
965
+ const uint8 = new Uint8Array(buffer, binValue.byteOffset || 0, binValue.byteLength);
966
+ uint8.set(binValue);
966
967
  return buffer;
967
- } case 'invalid': default:
968
+ } default:
968
969
  throw new Error('Bad key');
969
970
  }
970
971
  }
971
972
 
972
973
  /**
973
974
  *
974
- * @param {Key} key
975
+ * @param {Value} key
975
976
  * @param {boolean} [inArray]
976
977
  * @returns {string|null}
977
978
  */
@@ -986,7 +987,7 @@ function encode (key, inArray) {
986
987
 
987
988
  /**
988
989
  *
989
- * @param {Key} key
990
+ * @param {string|null} key
990
991
  * @param {boolean} [inArray]
991
992
  * @throws {Error} Invalid number
992
993
  * @returns {undefined|ValueType}
@@ -1000,7 +1001,7 @@ function decode (key, inArray) {
1000
1001
 
1001
1002
  /**
1002
1003
  *
1003
- * @param {Key} key
1004
+ * @param {Value} key
1004
1005
  * @param {boolean} [inArray]
1005
1006
  * @returns {undefined|ValueType}
1006
1007
  */
package/src/Sca.js CHANGED
@@ -102,7 +102,7 @@ function encode (obj, func) {
102
102
  }
103
103
 
104
104
  /**
105
- * @typedef {any} AnyValue
105
+ * @typedef {import('./Key.js').Value} AnyValue
106
106
  */
107
107
 
108
108
  /**
package/src/cmp.js CHANGED
@@ -3,8 +3,8 @@ import {encode as keyEncode, decode as keyDecode} from './Key.js';
3
3
 
4
4
  /**
5
5
  * Compares two keys.
6
- * @param {import('./Key.js').Key} first
7
- * @param {import('./Key.js').Key} second
6
+ * @param {import('./Key.js').Key|null|undefined} first
7
+ * @param {import('./Key.js').Key|null|undefined} second
8
8
  * @returns {0|1|-1}
9
9
  */
10
10
  function cmp (first, second) {
package/src/nodeWebSQL.js CHANGED
@@ -4,7 +4,7 @@ import CFG from './CFG.js';
4
4
 
5
5
  /**
6
6
  * @typedef {{
7
- * _db: any,
7
+ * _db: unknown,
8
8
  * exec: typeof SQLiteDatabase['prototype']['exec']
9
9
  * }} SQLiteDatabaseInstance
10
10
  */
@@ -18,7 +18,10 @@ import CFG from './CFG.js';
18
18
  * object yields that object as the `new` expression's result, overriding
19
19
  * the default "return `this`" behavior), not something TypeScript can
20
20
  * verify structurally.
21
- * @typedef {new (name: string, opts?: any) => SQLiteDatabaseInstance} SQLiteDatabaseConstructor
21
+ * @typedef {new (
22
+ * name: string,
23
+ * opts?: import('websql-configurable/lib/sqlite/SQLiteDatabase.js').SQLiteDatabaseOptions
24
+ * ) => SQLiteDatabaseInstance} SQLiteDatabaseConstructor
22
25
  */
23
26
 
24
27
  /**