indexeddbshim 17.0.0 → 17.2.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 (58) hide show
  1. package/README.md +62 -0
  2. package/badges/licenses-badge-dev.svg +1 -1
  3. package/badges/licenses-badge.svg +1 -1
  4. package/dist/CFG.d.ts +1 -0
  5. package/dist/CFG.d.ts.map +1 -1
  6. package/dist/DOMException.d.ts.map +1 -1
  7. package/dist/IDBCursor.d.ts +25 -18
  8. package/dist/IDBCursor.d.ts.map +1 -1
  9. package/dist/IDBFactory.d.ts +19 -19
  10. package/dist/IDBFactory.d.ts.map +1 -1
  11. package/dist/IDBIndex.d.ts.map +1 -1
  12. package/dist/IDBKeyRange.d.ts +5 -5
  13. package/dist/IDBKeyRange.d.ts.map +1 -1
  14. package/dist/IDBTransaction.d.ts +24 -3
  15. package/dist/IDBTransaction.d.ts.map +1 -1
  16. package/dist/Key.d.ts +41 -41
  17. package/dist/Key.d.ts.map +1 -1
  18. package/dist/indexeddbshim-Key.js +88 -69
  19. package/dist/indexeddbshim-Key.js.map +1 -1
  20. package/dist/indexeddbshim-Key.min.js +2 -2
  21. package/dist/indexeddbshim-Key.min.js.map +1 -1
  22. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +1682 -1056
  23. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  24. package/dist/indexeddbshim-UnicodeIdentifiers.js +886 -663
  25. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  26. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +4 -4
  27. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  28. package/dist/indexeddbshim-node.cjs +1682 -1056
  29. package/dist/indexeddbshim-node.cjs.map +1 -1
  30. package/dist/indexeddbshim-noninvasive.js +886 -663
  31. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  32. package/dist/indexeddbshim-noninvasive.min.js +4 -4
  33. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  34. package/dist/indexeddbshim.js +890 -660
  35. package/dist/indexeddbshim.js.map +1 -1
  36. package/dist/indexeddbshim.min.js +4 -4
  37. package/dist/indexeddbshim.min.js.map +1 -1
  38. package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
  39. package/dist/node.d.ts.map +1 -1
  40. package/dist/nodeSQLiteDatabase.d.ts +65 -0
  41. package/dist/nodeSQLiteDatabase.d.ts.map +1 -0
  42. package/dist/nodeWebSQL.d.ts.map +1 -1
  43. package/dist/util.d.ts +5 -0
  44. package/dist/util.d.ts.map +1 -1
  45. package/package.json +22 -18
  46. package/src/CFG.js +3 -0
  47. package/src/DOMException.js +10 -10
  48. package/src/IDBCursor.js +152 -102
  49. package/src/IDBFactory.js +30 -26
  50. package/src/IDBIndex.js +1 -2
  51. package/src/IDBKeyRange.js +5 -5
  52. package/src/IDBTransaction.js +35 -5
  53. package/src/Key.js +63 -55
  54. package/src/node-UnicodeIdentifiers.js +5 -1
  55. package/src/node.js +5 -1
  56. package/src/nodeSQLiteDatabase.js +174 -0
  57. package/src/nodeWebSQL.js +1 -3
  58. package/src/util.js +62 -3
@@ -1,4 +1,4 @@
1
- /*! indexeddbshim - v17.0.0 - 7/28/2026 */
1
+ /*! indexeddbshim - v17.2.0 - 8/18/2026 */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -101,6 +101,13 @@
101
101
  function _slicedToArray(r, e) {
102
102
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
103
103
  }
104
+ function _taggedTemplateLiteral(e, t) {
105
+ return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
106
+ raw: {
107
+ value: Object.freeze(t)
108
+ }
109
+ }));
110
+ }
104
111
  function _toConsumableArray(r) {
105
112
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
106
113
  }
@@ -165,6 +172,7 @@
165
172
  * sqlBusyTimeout: number,
166
173
  * sqlTrace: () => void,
167
174
  * sqlProfile: () => void,
175
+ * escapeNULForSQLiteStatements: boolean,
168
176
  * createIndexes: boolean
169
177
  * }} ConfigValues
170
178
  */
@@ -319,8 +327,8 @@
319
327
  // Callback not used by default
320
328
  'sqlProfile',
321
329
  // Callback not used by default
322
-
323
- 'createIndexes'].forEach(function (prop) {
330
+ // Defaults to true except in Node builds where we can preserve literal NUL with better-sqlite3
331
+ 'escapeNULForSQLiteStatements', 'createIndexes'].forEach(function (prop) {
324
332
  /** @type {(val: any) => void} */
325
333
  var validator;
326
334
  if (Array.isArray(prop)) {
@@ -630,11 +638,11 @@
630
638
  // eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
631
639
  ?
632
640
  /**
633
- * @param {string} name
634
- * @param {string} message
635
- * @param {ErrorLike} [error]
636
- * @returns {DOMException}
637
- */
641
+ * @param {string} name
642
+ * @param {string} message
643
+ * @param {ErrorLike} [error]
644
+ * @returns {DOMException}
645
+ */
638
646
  function (name, message, error) {
639
647
  logError(name, message, error);
640
648
  return createNativeDOMException(name, message);
@@ -642,11 +650,11 @@
642
650
  // eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
643
651
  :
644
652
  /**
645
- * @param {string} name
646
- * @param {string} message
647
- * @param {ErrorLike} [error]
648
- * @returns {Error}
649
- */
653
+ * @param {string} name
654
+ * @param {string} message
655
+ * @param {ErrorLike} [error]
656
+ * @returns {Error}
657
+ */
650
658
  function (name, message, error) {
651
659
  logError(name, message, error);
652
660
  return createNonNativeDOMException(name, message);
@@ -678,7 +686,8 @@
678
686
  * @returns {string}
679
687
  */
680
688
  function escapeSQLiteStatement(arg) {
681
- return escapeUnmatchedSurrogates(arg.replaceAll('^', '^^').replaceAll('\0', '^0'));
689
+ var escaped = arg.replaceAll('^', '^^');
690
+ return escapeUnmatchedSurrogates(CFG.escapeNULForSQLiteStatements === false ? escaped : escaped.replaceAll('\0', '^0'));
682
691
  }
683
692
 
684
693
  /**
@@ -772,6 +781,8 @@
772
781
  return result;
773
782
  }
774
783
 
784
+ var _templateObject, _templateObject2;
785
+
775
786
  /**
776
787
  * @typedef {NodeJS.TypedArray|DataView} ArrayBufferView
777
788
  */
@@ -801,14 +812,14 @@
801
812
  */
802
813
 
803
814
  /**
804
- * @typedef {object} KeyValueObject
805
- * @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
806
- * "function"|"bigint"} type If not `KeyType`, indicates invalid value
807
- * @property {Value} [value]
808
- * @property {boolean} [invalid]
809
- * @property {string} [message]
810
- * @todo Specify acceptable `value` more precisely
811
- */
815
+ * @typedef {object} KeyValueObject
816
+ * @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
817
+ * "function"|"bigint"} type If not `KeyType`, indicates invalid value
818
+ * @property {Value} [value]
819
+ * @property {boolean} [invalid]
820
+ * @property {string} [message]
821
+ * @todo Specify acceptable `value` more precisely
822
+ */
812
823
 
813
824
  /**
814
825
  * @typedef {number|string|Date|ArrayBuffer} ValueTypePrimitive
@@ -1047,14 +1058,22 @@
1047
1058
  _iterator.f();
1048
1059
  }
1049
1060
  encoded.push(keyTypeToEncodedChar.invalid + '-'); // append an extra item, so empty arrays sort correctly
1050
- return keyTypeToEncodedChar.array + '-' + JSON.stringify(encoded);
1061
+ var encodedKey = JSON.stringify(encoded);
1062
+ if (CFG.escapeNULForSQLiteStatements === false) {
1063
+ encodedKey = encodedKey.replaceAll(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["\0"], ["\\u0000"]))), '\0');
1064
+ }
1065
+ return keyTypeToEncodedChar.array + '-' + encodedKey;
1051
1066
  },
1052
1067
  /**
1053
1068
  * @param {string} key
1054
1069
  * @returns {ValueTypeArray}
1055
1070
  */
1056
1071
  decode: function decode(key) {
1057
- var decoded = JSON.parse(key.slice(2));
1072
+ var decodedKey = key.slice(2);
1073
+ if (CFG.escapeNULForSQLiteStatements === false) {
1074
+ decodedKey = decodedKey.replaceAll('\0', String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\0"], ["\\u0000"]))));
1075
+ }
1076
+ var decoded = JSON.parse(decodedKey);
1058
1077
  decoded.pop(); // remove the extra item
1059
1078
  for (var i = 0; i < decoded.length; i++) {
1060
1079
  var item = decoded[i];
@@ -1240,10 +1259,10 @@
1240
1259
  }
1241
1260
 
1242
1261
  /**
1243
- * Currently not in use.
1244
- * @param {Value} input
1245
- * @returns {KeyValueObject}
1246
- */
1262
+ * Currently not in use.
1263
+ * @param {Value} input
1264
+ * @returns {KeyValueObject}
1265
+ */
1247
1266
  function convertValueToMultiEntryKey(input) {
1248
1267
  return convertValueToKeyValueDecoded(input, null, true, true);
1249
1268
  }
@@ -1278,17 +1297,17 @@
1278
1297
  }
1279
1298
 
1280
1299
  /**
1281
- * Shortcut utility to avoid returning full keys from `convertValueToKey`
1282
- * and subsequent need to process in calling code unless `fullKeys` is
1283
- * set; may throw.
1284
- * @param {Value} input
1285
- * @param {Value[]|null} [seen]
1286
- * @param {boolean} [multiEntry]
1287
- * @param {boolean} [fullKeys]
1288
- * @throws {TypeError} See `getCopyBytesHeldByBufferSource`
1289
- * @todo Document other allowable `input`
1290
- * @returns {KeyValueObject}
1291
- */
1300
+ * Shortcut utility to avoid returning full keys from `convertValueToKey`
1301
+ * and subsequent need to process in calling code unless `fullKeys` is
1302
+ * set; may throw.
1303
+ * @param {Value} input
1304
+ * @param {Value[]|null} [seen]
1305
+ * @param {boolean} [multiEntry]
1306
+ * @param {boolean} [fullKeys]
1307
+ * @throws {TypeError} See `getCopyBytesHeldByBufferSource`
1308
+ * @todo Document other allowable `input`
1309
+ * @returns {KeyValueObject}
1310
+ */
1292
1311
  function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
1293
1312
  seen || (seen = []);
1294
1313
  if (seen.includes(input)) {
@@ -1444,12 +1463,12 @@
1444
1463
  }
1445
1464
 
1446
1465
  /**
1447
- * An internal utility.
1448
- * @param {Value} input
1449
- * @param {Value[]|null|undefined} [seen]
1450
- * @throws {DOMException} `DataError`
1451
- * @returns {KeyValueObject}
1452
- */
1466
+ * An internal utility.
1467
+ * @param {Value} input
1468
+ * @param {Value[]|null|undefined} [seen]
1469
+ * @throws {DOMException} `DataError`
1470
+ * @returns {KeyValueObject}
1471
+ */
1453
1472
  function convertValueToKeyRethrowingAndIfInvalid(input, seen) {
1454
1473
  var key = convertValueToKey(input, seen);
1455
1474
  if (key.invalid) {
@@ -1470,26 +1489,26 @@
1470
1489
  return extractKeyValueDecodedFromValueUsingKeyPath(value, keyPath, multiEntry, true);
1471
1490
  }
1472
1491
  /**
1473
- * Not currently in use.
1474
- * @param {Value} value
1475
- * @param {KeyPath} keyPath
1476
- * @param {boolean} multiEntry
1477
- * @returns {KeyPathEvaluateValue}
1478
- */
1492
+ * Not currently in use.
1493
+ * @param {Value} value
1494
+ * @param {KeyPath} keyPath
1495
+ * @param {boolean} multiEntry
1496
+ * @returns {KeyPathEvaluateValue}
1497
+ */
1479
1498
  function evaluateKeyPathOnValue(value, keyPath, multiEntry) {
1480
1499
  return evaluateKeyPathOnValueToDecodedValue(value, keyPath);
1481
1500
  }
1482
1501
 
1483
1502
  /**
1484
- * May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
1485
- * or `{invalid: true}` (e.g., `NaN`).
1486
- * @param {Value} value
1487
- * @param {KeyPath} keyPath
1488
- * @param {boolean} [multiEntry]
1489
- * @param {boolean} [fullKeys]
1490
- * @returns {KeyValueObject|KeyPathEvaluateValue}
1491
- * @todo Document other possible return?
1492
- */
1503
+ * May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
1504
+ * or `{invalid: true}` (e.g., `NaN`).
1505
+ * @param {Value} value
1506
+ * @param {KeyPath} keyPath
1507
+ * @param {boolean} [multiEntry]
1508
+ * @param {boolean} [fullKeys]
1509
+ * @returns {KeyValueObject|KeyPathEvaluateValue}
1510
+ * @todo Document other possible return?
1511
+ */
1493
1512
  function extractKeyValueDecodedFromValueUsingKeyPath(value, keyPath, multiEntry, fullKeys) {
1494
1513
  var r = evaluateKeyPathOnValueToDecodedValue(value, keyPath);
1495
1514
  if (r.failure) {
@@ -1719,11 +1738,11 @@
1719
1738
  }
1720
1739
 
1721
1740
  /**
1722
- * Not currently in use but keeping for spec parity.
1723
- * @param {Key} key
1724
- * @throws {Error} Upon a "bad key"
1725
- * @returns {ValueType}
1726
- */
1741
+ * Not currently in use but keeping for spec parity.
1742
+ * @param {Key} key
1743
+ * @throws {Error} Upon a "bad key"
1744
+ * @returns {ValueType}
1745
+ */
1727
1746
  function convertKeyToValue(key) {
1728
1747
  var type = key.type,
1729
1748
  value = key.value;
@@ -1815,10 +1834,10 @@
1815
1834
  */
1816
1835
 
1817
1836
  /**
1818
- * @callback SQLFailureCallback
1819
- * @param {DOMException|Error} exception
1820
- * @returns {void}
1821
- */
1837
+ * @callback SQLFailureCallback
1838
+ * @param {DOMException|Error} exception
1839
+ * @returns {void}
1840
+ */
1822
1841
 
1823
1842
  /**
1824
1843
  *