indexeddbshim 17.1.0 → 17.2.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 (38) hide show
  1. package/dist/DOMException.d.ts.map +1 -1
  2. package/dist/IDBCursor.d.ts +16 -16
  3. package/dist/IDBCursor.d.ts.map +1 -1
  4. package/dist/IDBFactory.d.ts +19 -19
  5. package/dist/IDBFactory.d.ts.map +1 -1
  6. package/dist/IDBKeyRange.d.ts +5 -5
  7. package/dist/IDBKeyRange.d.ts.map +1 -1
  8. package/dist/IDBTransaction.d.ts +3 -3
  9. package/dist/IDBTransaction.d.ts.map +1 -1
  10. package/dist/Key.d.ts +41 -41
  11. package/dist/Key.d.ts.map +1 -1
  12. package/dist/indexeddbshim-Key.js +64 -64
  13. package/dist/indexeddbshim-Key.js.map +1 -1
  14. package/dist/indexeddbshim-Key.min.js +1 -1
  15. package/dist/indexeddbshim-Key.min.js.map +1 -1
  16. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +287 -238
  17. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  18. package/dist/indexeddbshim-UnicodeIdentifiers.js +429 -368
  19. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  20. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +3 -3
  21. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  22. package/dist/indexeddbshim-node.cjs +287 -238
  23. package/dist/indexeddbshim-node.cjs.map +1 -1
  24. package/dist/indexeddbshim-noninvasive.js +429 -368
  25. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  26. package/dist/indexeddbshim-noninvasive.min.js +3 -3
  27. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  28. package/dist/indexeddbshim.js +429 -368
  29. package/dist/indexeddbshim.js.map +1 -1
  30. package/dist/indexeddbshim.min.js +3 -3
  31. package/dist/indexeddbshim.min.js.map +1 -1
  32. package/package.json +11 -12
  33. package/src/DOMException.js +10 -10
  34. package/src/IDBCursor.js +16 -16
  35. package/src/IDBFactory.js +29 -22
  36. package/src/IDBKeyRange.js +5 -5
  37. package/src/IDBTransaction.js +3 -3
  38. package/src/Key.js +53 -53
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indexeddbshim",
3
- "version": "17.1.0",
3
+ "version": "17.2.1",
4
4
  "type": "module",
5
5
  "author": "Parashuram <code@nparashuram.com>",
6
6
  "contributors": [
@@ -21,8 +21,8 @@
21
21
  "web-platform-tests/**",
22
22
  "coverage",
23
23
  "ignore",
24
- ".eslintrc.js",
25
- ".mocharc.cjs",
24
+ "eslint.config.js",
25
+ ".mocharc.js",
26
26
  "tests-mocha/**",
27
27
  "tests-polyfill/**",
28
28
  "test-support/**"
@@ -161,8 +161,8 @@
161
161
  "canvas": "^3.2.3",
162
162
  "eventtargeter": "0.9.0",
163
163
  "sync-promise-expanded": "^2.0.0",
164
- "typeson": "10.0.0",
165
- "typeson-registry": "13.0.0",
164
+ "typeson": "10.2.0",
165
+ "typeson-registry": "13.1.0",
166
166
  "websql-configurable": "^3.0.3"
167
167
  },
168
168
  "devDependencies": {
@@ -176,11 +176,11 @@
176
176
  "@rollup/plugin-node-resolve": "^16.0.3",
177
177
  "@rollup/plugin-terser": "^1.0.0",
178
178
  "@types/better-sqlite3": "^9.6.0",
179
- "@types/node": "^26.1.2",
179
+ "@types/node": "^26.2.0",
180
180
  "@types/websql": "^0.0.30",
181
181
  "@unicode/unicode-17.0.0": "^1.6.17",
182
182
  "babel-plugin-add-module-exports": "1.0.4",
183
- "bson": "^7.3.1",
183
+ "bson": "^7.3.2",
184
184
  "builtin-modules": "^5.3.0",
185
185
  "c8": "^12.0.0",
186
186
  "chai": "6.2.2",
@@ -191,9 +191,9 @@
191
191
  "coveradge": "^0.8.2",
192
192
  "cyclonejs": "1.1.4",
193
193
  "delay-cli": "^3.0.0",
194
- "eslint": "^10.8.0",
195
- "eslint-config-ash-nazg": "^42.1.1",
196
- "globals": "^17.9.0",
194
+ "eslint": "^10.8.1",
195
+ "eslint-config-ash-nazg": "^42.5.0",
196
+ "globals": "^17.11.0",
197
197
  "is-date-object": "1.1.0",
198
198
  "isomorphic-fetch": "^3.0.0",
199
199
  "jsdom": "^30.0.1",
@@ -210,10 +210,9 @@
210
210
  "rollup-plugin-node-polyfills": "^0.2.1",
211
211
  "sinon": "^22.1.0",
212
212
  "source-map-support": "0.5.21",
213
- "sourcemap-transformer": "git+https://github.com/brettz9/sourcemap-transformer.git",
214
213
  "typescript": "^6.0.3",
215
214
  "w3c-blob": "0.0.1",
216
- "ws": "^8.21.2"
215
+ "ws": "^8.21.3"
217
216
  },
218
217
  "allowScripts": {
219
218
  "es5-ext@0.10.64": true,
@@ -368,22 +368,22 @@ try {
368
368
  const createDOMException = useNativeDOMException
369
369
  // eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
370
370
  ? /**
371
- * @param {string} name
372
- * @param {string} message
373
- * @param {ErrorLike} [error]
374
- * @returns {DOMException}
375
- */
371
+ * @param {string} name
372
+ * @param {string} message
373
+ * @param {ErrorLike} [error]
374
+ * @returns {DOMException}
375
+ */
376
376
  function (name, message, error) {
377
377
  logError(name, message, error);
378
378
  return createNativeDOMException(name, message);
379
379
  }
380
380
  // eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
381
381
  : /**
382
- * @param {string} name
383
- * @param {string} message
384
- * @param {ErrorLike} [error]
385
- * @returns {Error}
386
- */
382
+ * @param {string} name
383
+ * @param {string} message
384
+ * @param {ErrorLike} [error]
385
+ * @returns {Error}
386
+ */
387
387
  function (name, message, error) {
388
388
  logError(name, message, error);
389
389
  return createNonNativeDOMException(name, message);
package/src/IDBCursor.js CHANGED
@@ -482,19 +482,19 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
482
482
  */
483
483
 
484
484
  /**
485
- * @callback SuccessArg
486
- * @param {StructuredCloneValue} value
487
- * @param {import('./IDBRequest.js').IDBRequestFull} req
488
- * @returns {void}
489
- */
485
+ * @callback SuccessArg
486
+ * @param {StructuredCloneValue} value
487
+ * @param {import('./IDBRequest.js').IDBRequestFull} req
488
+ * @returns {void}
489
+ */
490
490
 
491
491
  /**
492
- * @callback SuccessCallback
493
- * @param {IndexedDBKey} key
494
- * @param {StructuredCloneValue} value
495
- * @param {IndexedDBKey} primaryKey
496
- * @returns {void}
497
- */
492
+ * @callback SuccessCallback
493
+ * @param {IndexedDBKey} key
494
+ * @param {StructuredCloneValue} value
495
+ * @param {IndexedDBKey} primaryKey
496
+ * @returns {void}
497
+ */
498
498
 
499
499
  /**
500
500
  * Creates an "onsuccess" callback.
@@ -522,11 +522,11 @@ IDBCursor.prototype.__onsuccess = function (success) {
522
522
 
523
523
  /**
524
524
  * @typedef {{
525
- * matchingKey: string,
526
- * key: string,
527
- * [k: string]: string
528
- * }} RowItemNonNull
529
- */
525
+ * matchingKey: string,
526
+ * key: string,
527
+ * [k: string]: string
528
+ * }} RowItemNonNull
529
+ */
530
530
 
531
531
  /**
532
532
  *
package/src/IDBFactory.js CHANGED
@@ -388,7 +388,7 @@ function IDBFactory () {
388
388
  * __connections: {
389
389
  * [key: string]: import('./IDBDatabase.js').IDBDatabaseFull[]
390
390
  * }
391
- * }} IDBFactoryFull
391
+ * }} IDBFactoryFull
392
392
  */
393
393
 
394
394
  const IDBFactoryAlias = IDBFactory;
@@ -856,9 +856,17 @@ IDBFactory.prototype.deleteDatabase = function (name) {
856
856
  * @returns {boolean}
857
857
  */
858
858
  function dbError (tx, err) {
859
- if (calledDBError || err === true) {
859
+ if (calledDBError) {
860
860
  return false;
861
861
  }
862
+ // Must be set synchronously (not inside the `sysdbFinishedCbDelete` callback below) to
863
+ // guard against reentrancy: `sysdbFinishedCbDelete` -> `rollback`/`commit` -> websql-configurable's
864
+ // `done()` -> `currentTask.errorCallback(er)`, which is this very `dbError`, calling back into
865
+ // us before the first invocation has finished. Without this, a second rollback/commit gets
866
+ // issued on the shared `sysdb` connection after it has already moved on to the next queued
867
+ // transaction, corrupting that connection's task queue (see issue with unrelated `open()` calls
868
+ // failing/crashing after a `deleteDatabase` file-removal error).
869
+ calledDBError = true;
862
870
  const er = webSQLErrback(/** @type {SQLError} */ (err || tx));
863
871
  sysdbFinishedCbDelete(true, function () {
864
872
  req.__done = true;
@@ -867,7 +875,6 @@ IDBFactory.prototype.deleteDatabase = function (name) {
867
875
  // Re: why bubbling here (and how cancelable is only really relevant for `window.onerror`) see: https://github.com/w3c/IndexedDB/issues/86
868
876
  const e = createEvent('error', er, {bubbles: true, cancelable: true});
869
877
  req.dispatchEvent(e);
870
- calledDBError = true;
871
878
  });
872
879
  return false;
873
880
  }
@@ -970,14 +977,14 @@ IDBFactory.prototype.cmp = function (key1, key2) {
970
977
  };
971
978
 
972
979
  /**
973
- * May return outdated information if a database has since been deleted.
974
- * @see https://github.com/w3c/IndexedDB/pull/240/files
975
- * @this {IDBFactoryFull}
976
- * @returns {Promise<{
977
- * name: string,
978
- * version: Integer
979
- * }[]>}
980
- */
980
+ * May return outdated information if a database has since been deleted.
981
+ * @see https://github.com/w3c/IndexedDB/pull/240/files
982
+ * @this {IDBFactoryFull}
983
+ * @returns {Promise<{
984
+ * name: string,
985
+ * version: Integer
986
+ * }[]>}
987
+ */
981
988
  IDBFactory.prototype.databases = function () {
982
989
  const me = this;
983
990
  let calledDbCreateError = false;
@@ -1022,17 +1029,17 @@ IDBFactory.prototype.databases = function () {
1022
1029
  };
1023
1030
 
1024
1031
  /**
1025
- * @todo forceClose: Test
1026
- * This is provided to facilitate unit-testing of the
1027
- * closing of a database connection with a forced flag:
1028
- * <https://w3c.github.io/IndexedDB/#steps-for-closing-a-database-connection>
1029
- * @param {string} dbName
1030
- * @param {Integer} connIdx
1031
- * @param {string} msg
1032
- * @throws {TypeError}
1033
- * @this {IDBFactoryFull}
1034
- * @returns {void}
1035
- */
1032
+ * @todo forceClose: Test
1033
+ * This is provided to facilitate unit-testing of the
1034
+ * closing of a database connection with a forced flag:
1035
+ * <https://w3c.github.io/IndexedDB/#steps-for-closing-a-database-connection>
1036
+ * @param {string} dbName
1037
+ * @param {Integer} connIdx
1038
+ * @param {string} msg
1039
+ * @throws {TypeError}
1040
+ * @this {IDBFactoryFull}
1041
+ * @returns {void}
1042
+ */
1036
1043
  IDBFactory.prototype.__forceClose = function (dbName, connIdx, msg) {
1037
1044
  const me = this;
1038
1045
  /**
@@ -6,11 +6,11 @@ const readonlyProperties = /** @type {const} */ (['lower', 'upper', 'lowerOpen',
6
6
 
7
7
  /**
8
8
  * @typedef {globalThis.IDBKeyRange & {
9
- * __lowerCached: string|null|false,
10
- * __upperCached: string|null|false,
11
- * __lowerOpen: boolean,
12
- * }} IDBKeyRangeFull
13
- */
9
+ * __lowerCached: string|null|false,
10
+ * __upperCached: string|null|false,
11
+ * __lowerOpen: boolean,
12
+ * }} IDBKeyRangeFull
13
+ */
14
14
 
15
15
  /**
16
16
  * The IndexedDB KeyRange object.
@@ -776,10 +776,10 @@ IDBTransaction.__assertActive = function (tx) {
776
776
  };
777
777
 
778
778
  /**
779
- * Used by our `EventTarget.prototype` library to implement bubbling/capturing.
779
+ * Used by our `EventTarget.prototype` library to implement bubbling/capturing.
780
780
  * @this {IDBTransactionFull}
781
- * @returns {import('./IDBDatabase.js').IDBDatabaseFull}
782
- */
781
+ * @returns {import('./IDBDatabase.js').IDBDatabaseFull}
782
+ */
783
783
  IDBTransaction.prototype.__getParent = function () {
784
784
  return this.db;
785
785
  };
package/src/Key.js CHANGED
@@ -32,14 +32,14 @@ import CFG from './CFG.js';
32
32
  */
33
33
 
34
34
  /**
35
- * @typedef {object} KeyValueObject
36
- * @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
37
- * "function"|"bigint"} type If not `KeyType`, indicates invalid value
38
- * @property {Value} [value]
39
- * @property {boolean} [invalid]
40
- * @property {string} [message]
41
- * @todo Specify acceptable `value` more precisely
42
- */
35
+ * @typedef {object} KeyValueObject
36
+ * @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
37
+ * "function"|"bigint"} type If not `KeyType`, indicates invalid value
38
+ * @property {Value} [value]
39
+ * @property {boolean} [invalid]
40
+ * @property {string} [message]
41
+ * @todo Specify acceptable `value` more precisely
42
+ */
43
43
 
44
44
  /**
45
45
  * @typedef {number|string|Date|ArrayBuffer} ValueTypePrimitive
@@ -474,10 +474,10 @@ function convertValueToKey (input, seen) {
474
474
  }
475
475
 
476
476
  /**
477
- * Currently not in use.
478
- * @param {Value} input
479
- * @returns {KeyValueObject}
480
- */
477
+ * Currently not in use.
478
+ * @param {Value} input
479
+ * @returns {KeyValueObject}
480
+ */
481
481
  function convertValueToMultiEntryKey (input) {
482
482
  return convertValueToKeyValueDecoded(input, null, true, true);
483
483
  }
@@ -516,17 +516,17 @@ function getCopyBytesHeldByBufferSource (O) {
516
516
  }
517
517
 
518
518
  /**
519
- * Shortcut utility to avoid returning full keys from `convertValueToKey`
520
- * and subsequent need to process in calling code unless `fullKeys` is
521
- * set; may throw.
522
- * @param {Value} input
523
- * @param {Value[]|null} [seen]
524
- * @param {boolean} [multiEntry]
525
- * @param {boolean} [fullKeys]
526
- * @throws {TypeError} See `getCopyBytesHeldByBufferSource`
527
- * @todo Document other allowable `input`
528
- * @returns {KeyValueObject}
529
- */
519
+ * Shortcut utility to avoid returning full keys from `convertValueToKey`
520
+ * and subsequent need to process in calling code unless `fullKeys` is
521
+ * set; may throw.
522
+ * @param {Value} input
523
+ * @param {Value[]|null} [seen]
524
+ * @param {boolean} [multiEntry]
525
+ * @param {boolean} [fullKeys]
526
+ * @throws {TypeError} See `getCopyBytesHeldByBufferSource`
527
+ * @todo Document other allowable `input`
528
+ * @returns {KeyValueObject}
529
+ */
530
530
  function convertValueToKeyValueDecoded (input, seen, multiEntry, fullKeys) {
531
531
  seen ||= [];
532
532
  if (seen.includes(input)) {
@@ -623,12 +623,12 @@ function convertValueToMultiEntryKeyDecoded (key, fullKeys) {
623
623
  }
624
624
 
625
625
  /**
626
- * An internal utility.
627
- * @param {Value} input
628
- * @param {Value[]|null|undefined} [seen]
629
- * @throws {DOMException} `DataError`
630
- * @returns {KeyValueObject}
631
- */
626
+ * An internal utility.
627
+ * @param {Value} input
628
+ * @param {Value[]|null|undefined} [seen]
629
+ * @throws {DOMException} `DataError`
630
+ * @returns {KeyValueObject}
631
+ */
632
632
  function convertValueToKeyRethrowingAndIfInvalid (input, seen) {
633
633
  const key = convertValueToKey(input, seen);
634
634
  if (key.invalid) {
@@ -649,26 +649,26 @@ function extractKeyFromValueUsingKeyPath (value, keyPath, multiEntry) {
649
649
  return extractKeyValueDecodedFromValueUsingKeyPath(value, keyPath, multiEntry, true);
650
650
  }
651
651
  /**
652
- * Not currently in use.
653
- * @param {Value} value
654
- * @param {KeyPath} keyPath
655
- * @param {boolean} multiEntry
656
- * @returns {KeyPathEvaluateValue}
657
- */
652
+ * Not currently in use.
653
+ * @param {Value} value
654
+ * @param {KeyPath} keyPath
655
+ * @param {boolean} multiEntry
656
+ * @returns {KeyPathEvaluateValue}
657
+ */
658
658
  function evaluateKeyPathOnValue (value, keyPath, multiEntry) {
659
659
  return evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, true);
660
660
  }
661
661
 
662
662
  /**
663
- * May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
664
- * or `{invalid: true}` (e.g., `NaN`).
665
- * @param {Value} value
666
- * @param {KeyPath} keyPath
667
- * @param {boolean} [multiEntry]
668
- * @param {boolean} [fullKeys]
669
- * @returns {KeyValueObject|KeyPathEvaluateValue}
670
- * @todo Document other possible return?
671
- */
663
+ * May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
664
+ * or `{invalid: true}` (e.g., `NaN`).
665
+ * @param {Value} value
666
+ * @param {KeyPath} keyPath
667
+ * @param {boolean} [multiEntry]
668
+ * @param {boolean} [fullKeys]
669
+ * @returns {KeyValueObject|KeyPathEvaluateValue}
670
+ * @todo Document other possible return?
671
+ */
672
672
  function extractKeyValueDecodedFromValueUsingKeyPath (value, keyPath, multiEntry, fullKeys) {
673
673
  const r = evaluateKeyPathOnValueToDecodedValue(value, keyPath, multiEntry, fullKeys);
674
674
  if (r.failure) {
@@ -899,11 +899,11 @@ function findMultiEntryMatches (keyEntry, range) {
899
899
  }
900
900
 
901
901
  /**
902
- * Not currently in use but keeping for spec parity.
903
- * @param {Key} key
904
- * @throws {Error} Upon a "bad key"
905
- * @returns {ValueType}
906
- */
902
+ * Not currently in use but keeping for spec parity.
903
+ * @param {Key} key
904
+ * @throws {Error} Upon a "bad key"
905
+ * @returns {ValueType}
906
+ */
907
907
  function convertKeyToValue (key) {
908
908
  const {type, value} = key;
909
909
  switch (type) {
@@ -985,10 +985,10 @@ const MAX_ALLOWED_CURRENT_NUMBER = 9007199254740992; // 2 ^ 53 (Also equal to `N
985
985
  */
986
986
 
987
987
  /**
988
- * @callback SQLFailureCallback
989
- * @param {DOMException|Error} exception
990
- * @returns {void}
991
- */
988
+ * @callback SQLFailureCallback
989
+ * @param {DOMException|Error} exception
990
+ * @returns {void}
991
+ */
992
992
 
993
993
  /**
994
994
  *