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 (factory) {
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -58,7 +58,7 @@
58
58
  }
59
59
  }
60
60
  function _createClass(e, r, t) {
61
- return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
61
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
62
62
  writable: false
63
63
  }), e;
64
64
  }
@@ -301,6 +301,13 @@
301
301
  function _slicedToArray(r, e) {
302
302
  return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
303
303
  }
304
+ function _taggedTemplateLiteral(e, t) {
305
+ return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, {
306
+ raw: {
307
+ value: Object.freeze(t)
308
+ }
309
+ }));
310
+ }
304
311
  function _toConsumableArray(r) {
305
312
  return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
306
313
  }
@@ -1307,6 +1314,7 @@
1307
1314
  * sqlBusyTimeout: number,
1308
1315
  * sqlTrace: () => void,
1309
1316
  * sqlProfile: () => void,
1317
+ * escapeNULForSQLiteStatements: boolean,
1310
1318
  * createIndexes: boolean
1311
1319
  * }} ConfigValues
1312
1320
  */
@@ -1461,8 +1469,8 @@
1461
1469
  // Callback not used by default
1462
1470
  'sqlProfile',
1463
1471
  // Callback not used by default
1464
-
1465
- 'createIndexes'].forEach(function (prop) {
1472
+ // Defaults to true except in Node builds where we can preserve literal NUL with better-sqlite3
1473
+ 'escapeNULForSQLiteStatements', 'createIndexes'].forEach(function (prop) {
1466
1474
  /** @type {(val: any) => void} */
1467
1475
  var validator;
1468
1476
  if (Array.isArray(prop)) {
@@ -1543,7 +1551,8 @@
1543
1551
  * @returns {string}
1544
1552
  */
1545
1553
  function escapeSQLiteStatement(arg) {
1546
- return escapeUnmatchedSurrogates(arg.replaceAll('^', '^^').replaceAll('\0', '^0'));
1554
+ var escaped = arg.replaceAll('^', '^^');
1555
+ return escapeUnmatchedSurrogates(CFG.escapeNULForSQLiteStatements === false ? escaped : escaped.replaceAll('\0', '^0'));
1547
1556
  }
1548
1557
 
1549
1558
  /**
@@ -1551,7 +1560,11 @@
1551
1560
  * @returns {string}
1552
1561
  */
1553
1562
  function unescapeSQLiteResponse(arg) {
1554
- return unescapeUnmatchedSurrogates(arg).replaceAll(/(\^+)0/g, function (_, esc) {
1563
+ var unescaped = unescapeUnmatchedSurrogates(arg);
1564
+ if (CFG.escapeNULForSQLiteStatements === false) {
1565
+ return unescaped.replaceAll('^^', '^');
1566
+ }
1567
+ return unescaped.replaceAll(/(\^+)0/g, function (_, esc) {
1555
1568
  return esc.length % 2 ? esc.slice(1) + '\0' : _;
1556
1569
  }).replaceAll('^^', '^');
1557
1570
  }
@@ -1952,6 +1965,56 @@
1952
1965
  return v === null || v === undefined;
1953
1966
  }
1954
1967
 
1968
+ /**
1969
+ * Cursor/request continuation chains can call each other synchronously
1970
+ * (e.g. walking a large prefetched buffer, or advancing many interleaved
1971
+ * cursors in one transaction) which, for large enough record counts, can
1972
+ * exceed the JS engine's call stack ("Maximum call stack size exceeded").
1973
+ *
1974
+ * This can't be fixed by deferring continuations to a microtask/macrotask:
1975
+ * the transaction machinery synchronously checks (once the current call
1976
+ * stack unwinds) whether there are any pending requests left in order to
1977
+ * decide it's safe to commit; deferring a continuation opens a real gap in
1978
+ * which that check runs first and the transaction completes prematurely,
1979
+ * with the deferred continuation then acting on an already-finished
1980
+ * transaction (a hang, since it can never resolve).
1981
+ *
1982
+ * Instead, this implements a true trampoline: the first call starts a
1983
+ * synchronous work queue and drains it in a flat loop; any call made while
1984
+ * already draining (i.e. a continuation triggering another continuation)
1985
+ * is simply appended to that same queue and returns immediately instead of
1986
+ * recursing. This keeps everything synchronous (so no completion-check
1987
+ * race is introduced) while preventing the call stack from growing with
1988
+ * each successive continuation.
1989
+ */
1990
+ var continuationState = {
1991
+ /** @type {Array<() => void>|null} */
1992
+ queue: null
1993
+ };
1994
+
1995
+ /**
1996
+ * @param {() => void} fn
1997
+ * @returns {void}
1998
+ */
1999
+ function runContinuationSafely(fn) {
2000
+ if (continuationState.queue) {
2001
+ continuationState.queue.push(fn);
2002
+ return;
2003
+ }
2004
+ var queue = [fn];
2005
+ continuationState.queue = queue;
2006
+ try {
2007
+ while (queue.length) {
2008
+ var next = /** @type {() => void} */queue.shift();
2009
+ next();
2010
+ }
2011
+ } finally {
2012
+ // Ensure a thrown exception can't leave the queue permanently
2013
+ // stuck (which would silently swallow all future continuations).
2014
+ continuationState.queue = null;
2015
+ }
2016
+ }
2017
+
1955
2018
  /**
1956
2019
  * @typedef {Error} DebuggingError
1957
2020
  */
@@ -2422,11 +2485,11 @@
2422
2485
  // eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
2423
2486
  ?
2424
2487
  /**
2425
- * @param {string} name
2426
- * @param {string} message
2427
- * @param {ErrorLike} [error]
2428
- * @returns {DOMException}
2429
- */
2488
+ * @param {string} name
2489
+ * @param {string} message
2490
+ * @param {ErrorLike} [error]
2491
+ * @returns {DOMException}
2492
+ */
2430
2493
  function (name, message, error) {
2431
2494
  logError(name, message, error);
2432
2495
  return createNativeDOMException(name, message);
@@ -2434,11 +2497,11 @@
2434
2497
  // eslint-disable-next-line @stylistic/operator-linebreak -- Need JSDoc
2435
2498
  :
2436
2499
  /**
2437
- * @param {string} name
2438
- * @param {string} message
2439
- * @param {ErrorLike} [error]
2440
- * @returns {Error}
2441
- */
2500
+ * @param {string} name
2501
+ * @param {string} message
2502
+ * @param {ErrorLike} [error]
2503
+ * @returns {Error}
2504
+ */
2442
2505
  function (name, message, error) {
2443
2506
  logError(name, message, error);
2444
2507
  return createNonNativeDOMException(name, message);
@@ -2633,16 +2696,15 @@
2633
2696
  /* eslint-disable promise/prefer-await-to-callbacks -- Needed for API */
2634
2697
  /* eslint-disable promise/catch-or-return, n/callback-return,
2635
2698
  promise/always-return -- Not needed */
2636
- /* eslint-disable unicorn/no-this-assignment -- Clarity */
2637
2699
  // Since [immediate](https://github.com/calvinmetcalf/immediate) is
2638
2700
  // not doing the trick for our WebSQL transactions (at least in Node),
2639
2701
  // we are forced to make the promises run fully synchronously.
2640
2702
 
2641
- // Todo: Use ES6 classes
2642
-
2703
+ /* eslint-disable jsdoc/reject-any-type -- Truly arbitrary */
2643
2704
  /**
2644
2705
  * @typedef {any} ArbitraryValue
2645
2706
  */
2707
+ /* eslint-enable jsdoc/reject-any-type -- Truly arbitrary */
2646
2708
 
2647
2709
  /**
2648
2710
  * @callback Resolve
@@ -2702,209 +2764,235 @@
2702
2764
  REJECTED = 1;
2703
2765
 
2704
2766
  /**
2705
- * @class
2706
- * @param {(
2707
- * resolve: (value: ArbitraryValue | PromiseLike<ArbitraryValue>) => void,
2708
- * reject: (reason?: any) => void
2709
- * ) => void} fn
2710
- */
2711
- function SyncPromise(fn) {
2712
- var that = this;
2713
- // Value, this will be set to either a resolved value or rejected reason
2714
- that.v = 0;
2715
- // State of the promise
2716
- that.s = PENDING;
2717
- // Callbacks c[0] is fulfillment and c[1] contains rejection callbacks
2718
- /** @type {Callbacks|null} */
2719
- that.c = [[], []];
2767
+ *
2768
+ */
2769
+ var SyncPromise = /*#__PURE__*/function () {
2720
2770
  /**
2721
- *
2722
- * @param {ArbitraryValue} val
2723
- * @param {0|1} state
2724
- * @returns {void}
2771
+ * @param {(
2772
+ * resolve: (value: ArbitraryValue | PromiseLike<ArbitraryValue>) => void,
2773
+ * reject: (reason?: ArbitraryValue) => void
2774
+ * ) => void} fn
2725
2775
  */
2726
- function transist(val, state) {
2727
- that.v = val;
2728
- that.s = state;
2729
-
2730
- // console.log('state', state);
2731
- /** @type {Callbacks} */
2732
- that.c[state].forEach(function (func) {
2733
- func(val);
2734
- });
2735
- // Release memory, but if no handlers have been added, as we
2736
- // assume that we will resolve/reject (truly) synchronously
2737
- // and thus we avoid flagging checks about whether we've
2738
- // already resolved/rejected.
2739
- if (/** @type {Callbacks} */that.c[state].length) {
2740
- that.c = null;
2741
- }
2742
- }
2776
+ function SyncPromise(fn) {
2777
+ var _this = this;
2778
+ _classCallCheck(this, SyncPromise);
2779
+ // Value, this will be set to either a resolved value or rejected reason
2780
+ _defineProperty(this, "v", 0);
2781
+ // State of the promise
2782
+ this.s = PENDING;
2783
+ // Callbacks c[0] is fulfillment and c[1] contains rejection callbacks
2784
+ /** @type {Callbacks|null} */
2785
+ this.c = [[], []];
2786
+ /**
2787
+ *
2788
+ * @param {ArbitraryValue} val
2789
+ * @param {0|1} state
2790
+ * @returns {void}
2791
+ */
2792
+ var transist = function transist(val, state) {
2793
+ _this.v = val;
2794
+ _this.s = state;
2743
2795
 
2744
- /** @type {Resolve} */
2745
- function resolve(val) {
2746
- if (!that.c) ; else if (isPromise(val)) {
2747
- addReject(val.then(resolve), reject);
2748
- } else {
2749
- transist(val, FULFILLED);
2750
- }
2751
- }
2796
+ // console.log('state', state);
2797
+ /** @type {Callbacks} */
2798
+ _this.c[state].forEach(function (func) {
2799
+ func(val);
2800
+ });
2801
+ // Release memory, but if no handlers have been added, as we
2802
+ // assume that we will resolve/reject (truly) synchronously
2803
+ // and thus we avoid flagging checks about whether we've
2804
+ // already resolved/rejected.
2805
+ if (/** @type {Callbacks} */_this.c[state].length) {
2806
+ _this.c = null;
2807
+ }
2808
+ };
2752
2809
 
2753
- /** @type {Reject} */
2754
- function reject(reason) {
2755
- if (!that.c) ; else if (isPromise(reason)) {
2756
- addReject(reason.then(reject), reject);
2757
- } else {
2758
- transist(reason, REJECTED);
2810
+ /** @type {Resolve} */
2811
+ var _resolve = function resolve(val) {
2812
+ if (!_this.c) ; else if (isPromise(val)) {
2813
+ addReject(val.then(_resolve), _reject);
2814
+ } else {
2815
+ transist(val, FULFILLED);
2816
+ }
2817
+ };
2818
+
2819
+ /** @type {Reject} */
2820
+ var _reject = function reject(reason) {
2821
+ if (!_this.c) ; else if (isPromise(reason)) {
2822
+ addReject(reason.then(_reject), _reject);
2823
+ } else {
2824
+ transist(reason, REJECTED);
2825
+ }
2826
+ };
2827
+ try {
2828
+ fn(_resolve, _reject);
2829
+ } catch (err) {
2830
+ _reject(err);
2759
2831
  }
2760
2832
  }
2761
- try {
2762
- fn(resolve, reject);
2763
- } catch (err) {
2764
- reject(err);
2765
- }
2766
- }
2767
2833
 
2768
- /* eslint-disable unicorn/no-thenable -- Promise API */
2769
- /**
2770
- * @param {((value: ArbitraryValue) => ArbitraryValue)|null|undefined} [cb]
2771
- * @param {(reason: any) => PromiseLike<never>} [errBack]
2772
- * @returns {SyncPromise}
2773
- */
2774
- SyncPromise.prototype.then = function (cb, errBack) {
2775
- /* eslint-enable unicorn/no-thenable -- Promise API */
2776
- var that = this;
2777
- return new SyncPromise(/** @type {ResolveReject} */
2778
- function (resolve, reject) {
2779
- var rej = typeof errBack === 'function' ? errBack : reject;
2834
+ /* eslint-disable unicorn/no-thenable -- Promise API */
2835
+ /**
2836
+ * @param {((value: ArbitraryValue) => ArbitraryValue)|null|undefined} [cb]
2837
+ * @param {(reason: ArbitraryValue) => PromiseLike<never>} [errBack]
2838
+ * @returns {SyncPromise}
2839
+ */
2840
+ return _createClass(SyncPromise, [{
2841
+ key: "then",
2842
+ value: function then(cb, errBack) {
2843
+ var _this2 = this;
2844
+ /* eslint-enable unicorn/no-thenable -- Promise API */
2845
+ return new SyncPromise(/** @type {ResolveReject} */
2846
+ function (resolve, reject) {
2847
+ var rej = typeof errBack === 'function' ? errBack : reject;
2780
2848
 
2781
- /** @type {Settle} */
2782
- function settle() {
2783
- try {
2784
- resolve(cb ? cb(that.v) : that.v);
2785
- } catch (e) {
2786
- rej(e);
2787
- }
2788
- }
2789
- if (that.s === FULFILLED) {
2790
- settle();
2791
- } else if (that.s === REJECTED) {
2792
- rej(that.v);
2793
- } else {
2794
- /** @type {Callbacks} */that.c[FULFILLED].push(settle);
2795
- /** @type {Callbacks} */
2796
- that.c[REJECTED].push(rej);
2849
+ /** @type {Settle} */
2850
+ var settle = function settle() {
2851
+ try {
2852
+ resolve(cb ? cb(_this2.v) : _this2.v);
2853
+ } catch (e) {
2854
+ rej(e);
2855
+ }
2856
+ };
2857
+ if (_this2.s === FULFILLED) {
2858
+ settle();
2859
+ } else if (_this2.s === REJECTED) {
2860
+ rej(_this2.v);
2861
+ } else {
2862
+ /** @type {Callbacks} */_this2.c[FULFILLED].push(settle);
2863
+ /** @type {Callbacks} */
2864
+ _this2.c[REJECTED].push(rej);
2865
+ }
2866
+ });
2797
2867
  }
2798
- });
2799
- };
2800
2868
 
2801
- /**
2802
- * @param {(reason: any) => PromiseLike<never>|null|undefined} cb
2803
- * @returns {SyncPromise}
2804
- */
2805
- SyncPromise.prototype.catch = function (cb) {
2806
- var that = this;
2807
- return new SyncPromise(/** @type {ResolveReject} */
2808
- function (resolve, reject) {
2809
2869
  /**
2810
- * @returns {void}
2870
+ * @param {(reason: ArbitraryValue) => PromiseLike<never>|null|undefined} cb
2871
+ * @returns {SyncPromise}
2811
2872
  */
2812
- function settle() {
2813
- try {
2814
- resolve(cb(that.v));
2815
- } catch (e) {
2816
- reject(e);
2817
- }
2818
- }
2819
- if (that.s === REJECTED) {
2820
- settle();
2821
- } else if (that.s === FULFILLED) {
2822
- resolve(that.v);
2823
- } else {
2824
- /** @type {Callbacks} */that.c[REJECTED].push(settle);
2825
- /** @type {Callbacks} */
2826
- that.c[FULFILLED].push(resolve);
2873
+ }, {
2874
+ key: "catch",
2875
+ value: function _catch(cb) {
2876
+ var _this3 = this;
2877
+ return new SyncPromise(/** @type {ResolveReject} */
2878
+ function (resolve, reject) {
2879
+ /**
2880
+ * @returns {void}
2881
+ */
2882
+ var settle = function settle() {
2883
+ try {
2884
+ resolve(cb(_this3.v));
2885
+ } catch (e) {
2886
+ reject(e);
2887
+ }
2888
+ };
2889
+ if (_this3.s === REJECTED) {
2890
+ settle();
2891
+ } else if (_this3.s === FULFILLED) {
2892
+ resolve(_this3.v);
2893
+ } else {
2894
+ /** @type {Callbacks} */_this3.c[REJECTED].push(settle);
2895
+ /** @type {Callbacks} */
2896
+ _this3.c[FULFILLED].push(resolve);
2897
+ }
2898
+ });
2827
2899
  }
2828
- });
2829
- };
2830
-
2831
- /**
2832
- * @param {unknown[]|[]} promises
2833
- * @returns {SyncPromise}
2834
- */
2835
- SyncPromise.all = function (promises) {
2836
- return new SyncPromise(/** @type {ResolveReject} */
2837
- function (resolve, reject) {
2838
- var l = promises.length;
2839
- /** @type {ArbitraryValue[]} */
2840
- var newPromises = [];
2841
- if (!l) {
2842
- resolve(newPromises);
2843
- return;
2900
+ }], [{
2901
+ key: "all",
2902
+ value:
2903
+ /**
2904
+ * @param {unknown[]|[]} promises
2905
+ * @returns {SyncPromise}
2906
+ */
2907
+ function all(promises) {
2908
+ return new SyncPromise(/** @type {ResolveReject} */
2909
+ function (resolve, reject) {
2910
+ var l = promises.length;
2911
+ /** @type {ArbitraryValue[]} */
2912
+ var newPromises = [];
2913
+ if (!l) {
2914
+ resolve(newPromises);
2915
+ return;
2916
+ }
2917
+ promises.forEach(function (p, i) {
2918
+ if (isPromise(/** @type {PromiseLike<ArbitraryValue>} */p)) {
2919
+ addReject(/** @type {PromiseLike<ArbitraryValue>} */p.then(/** @type {OnFulfilled} */
2920
+ function (res) {
2921
+ newPromises[i] = res;
2922
+ --l;
2923
+ if (!l) {
2924
+ resolve(newPromises);
2925
+ }
2926
+ }), reject);
2927
+ } else {
2928
+ newPromises[i] = p;
2929
+ --l;
2930
+ if (!l) {
2931
+ resolve(promises);
2932
+ }
2933
+ }
2934
+ });
2935
+ });
2844
2936
  }
2845
- promises.forEach(function (p, i) {
2846
- if (isPromise(/** @type {PromiseLike<any>} */p)) {
2847
- addReject(/** @type {PromiseLike<any>} */p.then(/** @type {OnFulfilled} */
2848
- function (res) {
2849
- newPromises[i] = res;
2850
- --l || resolve(newPromises);
2851
- }), reject);
2852
- } else {
2853
- newPromises[i] = p;
2854
- --l || resolve(promises);
2855
- }
2856
- });
2857
- });
2858
- };
2859
2937
 
2860
- /**
2861
- * @param {unknown[]|[]} promises
2862
- * @returns {SyncPromise}
2863
- */
2864
- SyncPromise.race = function (promises) {
2865
- var resolved = false;
2866
- return new SyncPromise(/** @type {ResolveReject} */
2867
- function (resolve, reject) {
2868
- promises.some(function (p, i) {
2869
- if (isPromise(/** @type {PromiseLike<any>} */p)) {
2870
- addReject(/** @type {PromiseLike<any>} */p.then(/** @type {OnFulfilled} */
2871
- function (res) {
2872
- if (resolved) {
2873
- return;
2938
+ /**
2939
+ * @param {unknown[]|[]} promises
2940
+ * @returns {SyncPromise}
2941
+ */
2942
+ }, {
2943
+ key: "race",
2944
+ value: function race(promises) {
2945
+ var resolved = false;
2946
+ return new SyncPromise(/** @type {ResolveReject} */
2947
+ function (resolve, reject) {
2948
+ // eslint-disable-next-line @stylistic/max-len -- Long
2949
+ // eslint-disable-next-line unicorn/no-unused-array-method-return -- Shortcuts
2950
+ promises.some(function (p) {
2951
+ if (isPromise(/** @type {PromiseLike<ArbitraryValue>} */p)) {
2952
+ addReject(/** @type {PromiseLike<ArbitraryValue>} */p.then(/** @type {OnFulfilled} */
2953
+ function (res) {
2954
+ if (resolved) {
2955
+ return;
2956
+ }
2957
+ resolve(res);
2958
+ resolved = true;
2959
+ }), reject);
2960
+ return false;
2874
2961
  }
2875
- resolve(res);
2962
+ resolve(p);
2876
2963
  resolved = true;
2877
- }), reject);
2878
- return false;
2879
- }
2880
- resolve(p);
2881
- resolved = true;
2882
- return true;
2883
- });
2884
- });
2885
- };
2964
+ return true;
2965
+ });
2966
+ });
2967
+ }
2886
2968
 
2887
- /**
2888
- * @param {ArbitraryValue} val
2889
- * @returns {SyncPromise}
2890
- */
2891
- SyncPromise.resolve = function (val) {
2892
- return new SyncPromise(/** @type {ResolveReject} */
2893
- function (resolve, reject) {
2894
- resolve(val);
2895
- });
2896
- };
2969
+ /**
2970
+ * @param {ArbitraryValue} val
2971
+ * @returns {SyncPromise}
2972
+ */
2973
+ }, {
2974
+ key: "resolve",
2975
+ value: function resolve(val) {
2976
+ return new SyncPromise(/** @type {ResolveReject} */
2977
+ function (resolve) {
2978
+ resolve(val);
2979
+ });
2980
+ }
2897
2981
 
2898
- /**
2899
- * @param {ArbitraryValue} val
2900
- * @returns {SyncPromise}
2901
- */
2902
- SyncPromise.reject = function (val) {
2903
- return new SyncPromise(/** @type {ResolveReject} */
2904
- function (resolve, reject) {
2905
- reject(val);
2906
- });
2907
- };
2982
+ /**
2983
+ * @param {ArbitraryValue} val
2984
+ * @returns {SyncPromise}
2985
+ */
2986
+ }, {
2987
+ key: "reject",
2988
+ value: function reject(val) {
2989
+ return new SyncPromise(/** @type {ResolveReject} */
2990
+ function (resolve, reject) {
2991
+ reject(val);
2992
+ });
2993
+ }
2994
+ }]);
2995
+ }();
2908
2996
 
2909
2997
  /**
2910
2998
  * Compares two keys.
@@ -2941,6 +3029,8 @@
2941
3029
  return result;
2942
3030
  }
2943
3031
 
3032
+ var _templateObject, _templateObject2;
3033
+
2944
3034
  /**
2945
3035
  * @typedef {NodeJS.TypedArray|DataView} ArrayBufferView
2946
3036
  */
@@ -2970,14 +3060,14 @@
2970
3060
  */
2971
3061
 
2972
3062
  /**
2973
- * @typedef {object} KeyValueObject
2974
- * @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
2975
- * "function"|"bigint"} type If not `KeyType`, indicates invalid value
2976
- * @property {Value} [value]
2977
- * @property {boolean} [invalid]
2978
- * @property {string} [message]
2979
- * @todo Specify acceptable `value` more precisely
2980
- */
3063
+ * @typedef {object} KeyValueObject
3064
+ * @property {KeyType|"NaN"|"null"|"undefined"|"boolean"|"object"|"symbol"|
3065
+ * "function"|"bigint"} type If not `KeyType`, indicates invalid value
3066
+ * @property {Value} [value]
3067
+ * @property {boolean} [invalid]
3068
+ * @property {string} [message]
3069
+ * @todo Specify acceptable `value` more precisely
3070
+ */
2981
3071
 
2982
3072
  /**
2983
3073
  * @typedef {number|string|Date|ArrayBuffer} ValueTypePrimitive
@@ -3216,14 +3306,22 @@
3216
3306
  _iterator.f();
3217
3307
  }
3218
3308
  encoded.push(keyTypeToEncodedChar.invalid + '-'); // append an extra item, so empty arrays sort correctly
3219
- return keyTypeToEncodedChar.array + '-' + JSON.stringify(encoded);
3309
+ var encodedKey = JSON.stringify(encoded);
3310
+ if (CFG.escapeNULForSQLiteStatements === false) {
3311
+ encodedKey = encodedKey.replaceAll(String.raw(_templateObject || (_templateObject = _taggedTemplateLiteral(["\0"], ["\\u0000"]))), '\0');
3312
+ }
3313
+ return keyTypeToEncodedChar.array + '-' + encodedKey;
3220
3314
  },
3221
3315
  /**
3222
3316
  * @param {string} key
3223
3317
  * @returns {ValueTypeArray}
3224
3318
  */
3225
3319
  decode: function decode(key) {
3226
- var decoded = JSON.parse(key.slice(2));
3320
+ var decodedKey = key.slice(2);
3321
+ if (CFG.escapeNULForSQLiteStatements === false) {
3322
+ decodedKey = decodedKey.replaceAll('\0', String.raw(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\0"], ["\\u0000"]))));
3323
+ }
3324
+ var decoded = JSON.parse(decodedKey);
3227
3325
  decoded.pop(); // remove the extra item
3228
3326
  for (var i = 0; i < decoded.length; i++) {
3229
3327
  var item = decoded[i];
@@ -3409,10 +3507,10 @@
3409
3507
  }
3410
3508
 
3411
3509
  /**
3412
- * Currently not in use.
3413
- * @param {Value} input
3414
- * @returns {KeyValueObject}
3415
- */
3510
+ * Currently not in use.
3511
+ * @param {Value} input
3512
+ * @returns {KeyValueObject}
3513
+ */
3416
3514
  function convertValueToMultiEntryKey(input) {
3417
3515
  return convertValueToKeyValueDecoded(input, null, true, true);
3418
3516
  }
@@ -3447,17 +3545,17 @@
3447
3545
  }
3448
3546
 
3449
3547
  /**
3450
- * Shortcut utility to avoid returning full keys from `convertValueToKey`
3451
- * and subsequent need to process in calling code unless `fullKeys` is
3452
- * set; may throw.
3453
- * @param {Value} input
3454
- * @param {Value[]|null} [seen]
3455
- * @param {boolean} [multiEntry]
3456
- * @param {boolean} [fullKeys]
3457
- * @throws {TypeError} See `getCopyBytesHeldByBufferSource`
3458
- * @todo Document other allowable `input`
3459
- * @returns {KeyValueObject}
3460
- */
3548
+ * Shortcut utility to avoid returning full keys from `convertValueToKey`
3549
+ * and subsequent need to process in calling code unless `fullKeys` is
3550
+ * set; may throw.
3551
+ * @param {Value} input
3552
+ * @param {Value[]|null} [seen]
3553
+ * @param {boolean} [multiEntry]
3554
+ * @param {boolean} [fullKeys]
3555
+ * @throws {TypeError} See `getCopyBytesHeldByBufferSource`
3556
+ * @todo Document other allowable `input`
3557
+ * @returns {KeyValueObject}
3558
+ */
3461
3559
  function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
3462
3560
  seen || (seen = []);
3463
3561
  if (seen.includes(input)) {
@@ -3613,12 +3711,12 @@
3613
3711
  }
3614
3712
 
3615
3713
  /**
3616
- * An internal utility.
3617
- * @param {Value} input
3618
- * @param {Value[]|null|undefined} [seen]
3619
- * @throws {DOMException} `DataError`
3620
- * @returns {KeyValueObject}
3621
- */
3714
+ * An internal utility.
3715
+ * @param {Value} input
3716
+ * @param {Value[]|null|undefined} [seen]
3717
+ * @throws {DOMException} `DataError`
3718
+ * @returns {KeyValueObject}
3719
+ */
3622
3720
  function convertValueToKeyRethrowingAndIfInvalid(input, seen) {
3623
3721
  var key = convertValueToKey(input, seen);
3624
3722
  if (key.invalid) {
@@ -3639,26 +3737,26 @@
3639
3737
  return extractKeyValueDecodedFromValueUsingKeyPath(value, keyPath, multiEntry, true);
3640
3738
  }
3641
3739
  /**
3642
- * Not currently in use.
3643
- * @param {Value} value
3644
- * @param {KeyPath} keyPath
3645
- * @param {boolean} multiEntry
3646
- * @returns {KeyPathEvaluateValue}
3647
- */
3740
+ * Not currently in use.
3741
+ * @param {Value} value
3742
+ * @param {KeyPath} keyPath
3743
+ * @param {boolean} multiEntry
3744
+ * @returns {KeyPathEvaluateValue}
3745
+ */
3648
3746
  function evaluateKeyPathOnValue(value, keyPath, multiEntry) {
3649
3747
  return evaluateKeyPathOnValueToDecodedValue(value, keyPath);
3650
3748
  }
3651
3749
 
3652
3750
  /**
3653
- * May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
3654
- * or `{invalid: true}` (e.g., `NaN`).
3655
- * @param {Value} value
3656
- * @param {KeyPath} keyPath
3657
- * @param {boolean} [multiEntry]
3658
- * @param {boolean} [fullKeys]
3659
- * @returns {KeyValueObject|KeyPathEvaluateValue}
3660
- * @todo Document other possible return?
3661
- */
3751
+ * May throw, return `{failure: true}` (e.g., non-object on keyPath resolution)
3752
+ * or `{invalid: true}` (e.g., `NaN`).
3753
+ * @param {Value} value
3754
+ * @param {KeyPath} keyPath
3755
+ * @param {boolean} [multiEntry]
3756
+ * @param {boolean} [fullKeys]
3757
+ * @returns {KeyValueObject|KeyPathEvaluateValue}
3758
+ * @todo Document other possible return?
3759
+ */
3662
3760
  function extractKeyValueDecodedFromValueUsingKeyPath(value, keyPath, multiEntry, fullKeys) {
3663
3761
  var r = evaluateKeyPathOnValueToDecodedValue(value, keyPath);
3664
3762
  if (r.failure) {
@@ -3888,11 +3986,11 @@
3888
3986
  }
3889
3987
 
3890
3988
  /**
3891
- * Not currently in use but keeping for spec parity.
3892
- * @param {Key} key
3893
- * @throws {Error} Upon a "bad key"
3894
- * @returns {ValueType}
3895
- */
3989
+ * Not currently in use but keeping for spec parity.
3990
+ * @param {Key} key
3991
+ * @throws {Error} Upon a "bad key"
3992
+ * @returns {ValueType}
3993
+ */
3896
3994
  function convertKeyToValue(key) {
3897
3995
  var type = key.type,
3898
3996
  value = key.value;
@@ -3984,10 +4082,10 @@
3984
4082
  */
3985
4083
 
3986
4084
  /**
3987
- * @callback SQLFailureCallback
3988
- * @param {DOMException|Error} exception
3989
- * @returns {void}
3990
- */
4085
+ * @callback SQLFailureCallback
4086
+ * @param {DOMException|Error} exception
4087
+ * @returns {void}
4088
+ */
3991
4089
 
3992
4090
  /**
3993
4091
  *
@@ -4156,11 +4254,11 @@
4156
4254
 
4157
4255
  /**
4158
4256
  * @typedef {globalThis.IDBKeyRange & {
4159
- * __lowerCached: string|null|false,
4160
- * __upperCached: string|null|false,
4161
- * __lowerOpen: boolean,
4162
- * }} IDBKeyRangeFull
4163
- */
4257
+ * __lowerCached: string|null|false,
4258
+ * __upperCached: string|null|false,
4259
+ * __lowerOpen: boolean,
4260
+ * }} IDBKeyRangeFull
4261
+ */
4164
4262
 
4165
4263
  /**
4166
4264
  * The IndexedDB KeyRange object.
@@ -4687,6 +4785,7 @@
4687
4785
  * },
4688
4786
  * __requestsFinished: boolean,
4689
4787
  * __transFinishedCb: (err: boolean, cb: ((bool?: boolean) => void)) => void,
4788
+ * __callTransFinishedCb: (err: boolean, cb: ((bool?: boolean) => void)) => void,
4690
4789
  * __transactionEndCallback: () => void,
4691
4790
  * __transactionFinished: boolean,
4692
4791
  * __completed: boolean,
@@ -4796,6 +4895,35 @@
4796
4895
  IDBTransaction.prototype.__transFinishedCb = function (err, cb) {
4797
4896
  cb(Boolean(err));
4798
4897
  };
4898
+
4899
+ /**
4900
+ * In Node, the real (SQL-commit-capable) `__transFinishedCb` is only
4901
+ * installed once the underlying WebSQL driver's own SQL-queue-idle check
4902
+ * has fired at least once for this transaction (asynchronously, via the
4903
+ * `nonstandardTransCb` passed to `db.transaction`/`.readTransaction`).
4904
+ * Since our own request processing can now finish synchronously (e.g., a
4905
+ * trivial upgrade using a synchronous SQL driver), it is possible to reach
4906
+ * transaction completion here before that has happened, in which case
4907
+ * `__transFinishedCb` is still the non-committing default above. Calling
4908
+ * that default directly would silently skip the actual SQL commit and
4909
+ * leave the underlying WebSQL transaction "running" forever, hanging any
4910
+ * later transaction on that same database connection. So, if the real
4911
+ * callback isn't installed yet, defer and retry until it is.
4912
+ * @this {IDBTransactionFull}
4913
+ * @param {boolean} err
4914
+ * @param {(bool?: boolean) => void} cb
4915
+ * @returns {void}
4916
+ */
4917
+ IDBTransaction.prototype.__callTransFinishedCb = function (err, cb) {
4918
+ var me = this;
4919
+ if (me.__transFinishedCb === IDBTransaction.prototype.__transFinishedCb) {
4920
+ setTimeout(function () {
4921
+ me.__callTransFinishedCb(err, cb);
4922
+ }, 0);
4923
+ return;
4924
+ }
4925
+ me.__transFinishedCb(err, cb);
4926
+ };
4799
4927
  /**
4800
4928
  * @this {IDBTransactionFull}
4801
4929
  * @returns {void}
@@ -4855,7 +4983,7 @@
4855
4983
  me.__abortTransaction(createDOMException('AbortError', 'A request was aborted (in user handler after success).'));
4856
4984
  return;
4857
4985
  }
4858
- executeNextRequest();
4986
+ runContinuationSafely(executeNextRequest);
4859
4987
  }
4860
4988
 
4861
4989
  /**
@@ -4930,7 +5058,9 @@
4930
5058
  try {
4931
5059
  q = me.__requests[i];
4932
5060
  if (!q.req) {
4933
- q.op(tx, q.args, executeNextRequest, error);
5061
+ q.op(tx, q.args, function () {
5062
+ return runContinuationSafely(executeNextRequest);
5063
+ }, error);
4934
5064
  return;
4935
5065
  }
4936
5066
  if (q.req.__done) {
@@ -5396,10 +5526,10 @@
5396
5526
  };
5397
5527
 
5398
5528
  /**
5399
- * Used by our `EventTarget.prototype` library to implement bubbling/capturing.
5529
+ * Used by our `EventTarget.prototype` library to implement bubbling/capturing.
5400
5530
  * @this {IDBTransactionFull}
5401
- * @returns {import('./IDBDatabase.js').IDBDatabaseFull}
5402
- */
5531
+ * @returns {import('./IDBDatabase.js').IDBDatabaseFull}
5532
+ */
5403
5533
  IDBTransaction.prototype.__getParent = function () {
5404
5534
  return this.db;
5405
5535
  };
@@ -5435,7 +5565,7 @@
5435
5565
  }).then(r, n);
5436
5566
  });
5437
5567
  }, TypesonPromise.prototype.catch = function (e) {
5438
- return this.then(function () {}, e);
5568
+ return this.then(void 0, e);
5439
5569
  }, TypesonPromise.resolve = function (e) {
5440
5570
  return new TypesonPromise(function (t) {
5441
5571
  t(e);
@@ -5495,26 +5625,31 @@
5495
5625
  function unescapeKeyPathComponent(e) {
5496
5626
  return e.replaceAll("~1", ".").replaceAll("~0", "~").replace(/^''$/, "").replaceAll("''''", "''");
5497
5627
  }
5498
- function getByKeyPath(e, t) {
5499
- if ("" === t) return e;
5500
- if (null === e || "object" != _typeof$1(e)) throw new TypeError("Unexpected non-object type");
5501
- var r = t.indexOf(".");
5502
- if (-1 !== r) {
5503
- var _n = e[unescapeKeyPathComponent(t.slice(0, r))];
5504
- return void 0 === _n ? void 0 : getByKeyPath(_n, t.slice(r + 1));
5628
+ function getByKeyPath(t, r, n) {
5629
+ if ("" === r) return t;
5630
+ if (null === t || "object" != _typeof$1(t)) throw new TypeError("Unexpected non-object type");
5631
+ var o = r.indexOf("."),
5632
+ s = unescapeKeyPathComponent(-1 === o ? r : r.slice(0, o));
5633
+ if (e(t, s)) {
5634
+ if (-1 !== o) {
5635
+ var _e = t[s];
5636
+ return void 0 === _e ? void 0 : getByKeyPath(_e, r.slice(o + 1));
5637
+ }
5638
+ return t[s];
5505
5639
  }
5506
- return e[unescapeKeyPathComponent(t)];
5507
5640
  }
5508
- function setAtKeyPath(e, t, r) {
5509
- if ("" === t) return r;
5510
- var n = e,
5511
- o = t;
5641
+ function setAtKeyPath(t, r, n, o) {
5642
+ if ("" === r) return n;
5643
+ var s = t,
5644
+ a = r;
5512
5645
  for (;;) {
5513
- if (!n || "object" != _typeof$1(n)) throw new TypeError("Unexpected non-object type");
5514
- if ("__proto__" === o) throw new TypeError("Invalid property");
5515
- var _t = o.indexOf(".");
5516
- if (-1 === _t) return n[unescapeKeyPathComponent(o)] = r, e;
5517
- n = n[unescapeKeyPathComponent(o.slice(0, _t))], o = o.slice(_t + 1);
5646
+ if (!s || "object" != _typeof$1(s)) throw new TypeError("Unexpected non-object type");
5647
+ var _r = a.indexOf("."),
5648
+ _i = unescapeKeyPathComponent(-1 === _r ? a : a.slice(0, _r));
5649
+ if ("__proto__" === _i) throw new TypeError("Invalid property");
5650
+ if (-1 === _r) return s[_i] = n, t;
5651
+ if (!e(s, _i)) throw new TypeError("Invalid property");
5652
+ s = s[_i], a = a.slice(_r + 1);
5518
5653
  }
5519
5654
  }
5520
5655
  function getJSONType(e) {
@@ -5524,11 +5659,19 @@
5524
5659
  * @file Typeson - JSON with types.
5525
5660
  * @license The MIT License (MIT)
5526
5661
  * @copyright (c) 2016-2018 David Fahlander, Brett Zamir
5527
- */
5662
+ */
5528
5663
  var r = Object.keys,
5529
5664
  n = Object.hasOwn,
5530
5665
  o = Array.isArray,
5531
5666
  s = ["type", "replaced", "iterateIn", "iterateUnsetNumeric", "addLength"];
5667
+ function setOwnEnumerable(e, t, r) {
5668
+ Object.defineProperty(e, t, {
5669
+ configurable: true,
5670
+ enumerable: true,
5671
+ value: r,
5672
+ writable: true
5673
+ });
5674
+ }
5532
5675
  function nestedPathsFirst(e, t) {
5533
5676
  var _e$keypath$match, _t$keypath$match;
5534
5677
  if ("" === e.keypath) return -1;
@@ -5599,13 +5742,17 @@
5599
5742
  key: "specialTypeNames",
5600
5743
  value: function specialTypeNames(e, t) {
5601
5744
  var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5602
- return r.returnTypeNames = true, this.encapsulate(e, t, r);
5745
+ return this.encapsulate(e, t, _objectSpread2(_objectSpread2({}, r), {}, {
5746
+ returnTypeNames: true
5747
+ }));
5603
5748
  }
5604
5749
  }, {
5605
5750
  key: "rootTypeName",
5606
5751
  value: function rootTypeName(e, t) {
5607
5752
  var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5608
- return r.iterateNone = true, this.encapsulate(e, t, r);
5753
+ return this.encapsulate(e, t, _objectSpread2(_objectSpread2({}, r), {}, {
5754
+ iterateNone: true
5755
+ }));
5609
5756
  }
5610
5757
  }, {
5611
5758
  key: "encapsulate",
@@ -5616,11 +5763,12 @@
5616
5763
  }, this.options), a),
5617
5764
  c = i.sync,
5618
5765
  y = {},
5619
- l = [],
5620
5766
  u = [],
5767
+ l = [],
5621
5768
  p = [],
5622
5769
  f = !("cyclic" in i) || i.cyclic,
5623
5770
  d = i.encapsulateObserver,
5771
+ m = i.encapsulateError,
5624
5772
  finish = function finish(e) {
5625
5773
  var t = Object.values(y);
5626
5774
  if (i.iterateNone) return t.length ? t[0] : getJSONType(e);
@@ -5653,22 +5801,29 @@
5653
5801
  _context2.n = 2;
5654
5802
  return Promise.all(r.map(/*#__PURE__*/function () {
5655
5803
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(r) {
5656
- var n, _t$splice, _t$splice2, o, _o, s, a, i, c, y, l, u, p, _t2;
5804
+ var n, _t$splice, _t$splice2, o, _o, s, a, i, c, y, u, l, p, _t, _t2, _t3, _t4;
5657
5805
  return _regenerator().w(function (_context) {
5658
5806
  while (1) switch (_context.n) {
5659
5807
  case 0:
5660
- n = [], _t$splice = t.splice(0, 1), _t$splice2 = _slicedToArray(_t$splice, 1), o = _t$splice2[0], _o = _slicedToArray(o, 7), s = _o[0], a = _o[2], i = _o[3], c = _o[4], y = _o[5], l = _o[6], u = _encapsulate2(s, r, a, i, n, true, l), p = hasConstructorOf(u, TypesonPromise);
5808
+ n = [], _t$splice = t.splice(0, 1), _t$splice2 = _slicedToArray(_t$splice, 1), o = _t$splice2[0], _o = _slicedToArray(o, 7), s = _o[0], a = _o[2], i = _o[3], c = _o[4], y = _o[5], u = _o[6], l = _encapsulate2(s, r, a, i, n, true, u), p = hasConstructorOf(l, TypesonPromise);
5661
5809
  if (!(s && p)) {
5662
5810
  _context.n = 2;
5663
5811
  break;
5664
5812
  }
5813
+ _t2 = setOwnEnumerable;
5814
+ _t3 = c;
5815
+ _t4 = y;
5665
5816
  _context.n = 1;
5666
- return u.p;
5817
+ return l.p;
5667
5818
  case 1:
5668
- _t2 = _context.v;
5669
- return _context.a(2, (c[y] = _t2, _checkPromises(e, n)));
5819
+ _t2(_t3, _t4, _context.v);
5820
+ _t = _checkPromises(e, n);
5821
+ _context.n = 3;
5822
+ break;
5670
5823
  case 2:
5671
- return _context.a(2, (s ? c[y] = u : e = p ? u.p : u, _checkPromises(e, n)));
5824
+ _t = (s ? setOwnEnumerable(c, y, l) : e = p ? l.p : l, _checkPromises(e, n));
5825
+ case 3:
5826
+ return _context.a(2, _t);
5672
5827
  }
5673
5828
  }, _callee);
5674
5829
  }));
@@ -5697,61 +5852,88 @@
5697
5852
  });
5698
5853
  },
5699
5854
  _encapsulate2 = function _encapsulate(e, t, s, a, c, p, f) {
5700
- var m,
5701
- h = {};
5702
- var g = d ? function (r) {
5703
- var _ref2;
5704
- var n = (_ref2 = f !== null && f !== void 0 ? f : a.type) !== null && _ref2 !== void 0 ? _ref2 : getJSONType(t);
5705
- d(Object.assign(r !== null && r !== void 0 ? r : h, {
5706
- keypath: e,
5707
- value: t,
5708
- cyclic: s,
5709
- stateObj: a,
5710
- promisesData: c,
5711
- resolvingTypesonPromise: p,
5712
- awaitingTypesonPromise: hasConstructorOf(t, TypesonPromise)
5713
- }, {
5714
- type: n
5715
- }));
5716
- } : null;
5717
- if (["string", "boolean", "number", "undefined"].includes(_typeof$1(t))) return void 0 === t || t === 1 / 0 || 0 === t || t === -1 / 0 || Number.isNaN(t) ? (m = a.replaced ? t : replace(e, t, a, c, false, p, g), m !== t && (h = {
5718
- replaced: m
5719
- })) : m = t, g && g(), m;
5720
- if (null === t) return g && g(), t;
5855
+ var h,
5856
+ g = {};
5857
+ var b = d ? function (r) {
5858
+ var _ref2;
5859
+ var n = (_ref2 = f !== null && f !== void 0 ? f : a.type) !== null && _ref2 !== void 0 ? _ref2 : getJSONType(t);
5860
+ d(Object.assign(r !== null && r !== void 0 ? r : g, {
5861
+ keypath: e,
5862
+ value: t,
5863
+ cyclic: s,
5864
+ stateObj: a,
5865
+ promisesData: c,
5866
+ resolvingTypesonPromise: p,
5867
+ awaitingTypesonPromise: hasConstructorOf(t, TypesonPromise)
5868
+ }, {
5869
+ type: n
5870
+ }));
5871
+ } : null,
5872
+ getEncapsulatedValue = function getEncapsulatedValue(e, t, r) {
5873
+ try {
5874
+ return {
5875
+ value: _encapsulate2(e, t[r], Boolean(s), a, c, p)
5876
+ };
5877
+ } catch (n) {
5878
+ var _ref3;
5879
+ if (!m) throw n;
5880
+ var _o2 = (_ref3 = f !== null && f !== void 0 ? f : a.type) !== null && _ref3 !== void 0 ? _ref3 : getJSONType(t),
5881
+ _s = m({
5882
+ keypath: e,
5883
+ error: n,
5884
+ parent: t,
5885
+ key: r,
5886
+ stateObj: a,
5887
+ type: _o2
5888
+ });
5889
+ if (!_s) throw n;
5890
+ if ("substitute" in _s) return {
5891
+ value: _s.substitute,
5892
+ substitute: true
5893
+ };
5894
+ if (_s.ignore) return;
5895
+ throw n;
5896
+ }
5897
+ };
5898
+ if (["string", "boolean", "number", "undefined"].includes(_typeof$1(t))) return void 0 === t || t === 1 / 0 || 0 === t || t === -1 / 0 || Number.isNaN(t) ? (h = a.replaced ? t : replace(e, t, a, c, false, p, b), h !== t && (g = {
5899
+ replaced: h
5900
+ })) : h = t, b && b(), h;
5901
+ if (null === t) return b && b(), t;
5721
5902
  if (s && t && "object" == _typeof$1(t) && !a.iterateIn && !a.iterateUnsetNumeric) {
5722
- var _r = l.indexOf(t);
5723
- if (-1 !== _r) return y[e] = "#", g && g({
5724
- cyclicKeypath: u[_r]
5725
- }), "#" + u[_r];
5726
- true === s && (l.push(t), u.push(e));
5903
+ var _r2 = u.indexOf(t);
5904
+ if (-1 !== _r2) return y[e] = "#", b && b({
5905
+ cyclicKeypath: l[_r2]
5906
+ }), "#" + l[_r2];
5907
+ true === s && (u.push(t), l.push(e));
5727
5908
  }
5728
- var b = isPlainObject(t),
5729
- v = o(t),
5730
- O = (b || v) && (!_this2.plainObjectReplacers.length || a.replaced) || a.iterateIn ? t : replace(e, t, a, c, b || v, null, g);
5731
- var w;
5732
- if (O !== t ? (m = O, h = {
5733
- replaced: O
5734
- }) : "" === e && hasConstructorOf(t, TypesonPromise) ? (c.push([e, t, s, a, void 0, void 0, a.type]), m = t) : v && "object" !== a.iterateIn || "array" === a.iterateIn ? (w = new Array(t.length), h = {
5735
- clone: w
5736
- }) : !b && (["function", "symbol"].includes(_typeof$1(t)) || "toJSON" in t || hasConstructorOf(t, TypesonPromise) || hasConstructorOf(t, Promise) || hasConstructorOf(t, ArrayBuffer)) && "object" !== a.iterateIn ? m = t : (w = {}, a.addLength && (w.length = t.length), h = {
5737
- clone: w
5738
- }), g && g(), i.iterateNone) return w !== null && w !== void 0 ? w : m;
5739
- if (!w) return m;
5909
+ var v = isPlainObject(t),
5910
+ O = o(t),
5911
+ w = (v || O) && (!_this2.plainObjectReplacers.length || a.replaced) || a.iterateIn ? t : replace(e, t, a, c, v || O, null, b);
5912
+ var T;
5913
+ if (w !== t ? (h = w, g = {
5914
+ replaced: w
5915
+ }) : "" === e && hasConstructorOf(t, TypesonPromise) ? (c.push([e, t, s, a, void 0, void 0, a.type]), h = t) : O && "object" !== a.iterateIn || "array" === a.iterateIn ? (T = new Array(t.length), g = {
5916
+ clone: T
5917
+ }) : !v && ("object" != _typeof$1(t) || "toJSON" in t || hasConstructorOf(t, TypesonPromise) || hasConstructorOf(t, Promise) || hasConstructorOf(t, ArrayBuffer)) && "object" !== a.iterateIn ? h = t : (T = {}, a.addLength && (T.length = t.length), g = {
5918
+ clone: T
5919
+ }), b && b(), i.iterateNone) return T !== null && T !== void 0 ? T : h;
5920
+ if (!T) return h;
5740
5921
  if (a.iterateIn) {
5741
- var _loop = function _loop(_r2) {
5922
+ var _loop = function _loop(_r3) {
5742
5923
  var o = {
5743
- ownKeys: n(t, _r2)
5924
+ ownKeys: n(t, _r3)
5744
5925
  };
5745
5926
  _adaptBuiltinStateObjectProperties(a, o, function () {
5746
- var n = e + (e ? "." : "") + escapeKeyPathComponent(_r2),
5747
- o = _encapsulate2(n, t[_r2], Boolean(s), a, c, p);
5748
- hasConstructorOf(o, TypesonPromise) ? c.push([n, o, Boolean(s), a, w, _r2, a.type]) : void 0 !== o && (w[_r2] = o);
5927
+ var n = e + (e ? "." : "") + escapeKeyPathComponent(_r3),
5928
+ o = getEncapsulatedValue(n, t, _r3),
5929
+ i = o && o.value;
5930
+ hasConstructorOf(i, TypesonPromise) ? c.push([n, i, Boolean(s), a, T, _r3, a.type]) : o && (void 0 !== i || "substitute" in o) && setOwnEnumerable(T, _r3, i);
5749
5931
  });
5750
5932
  };
5751
- for (var _r2 in t) {
5752
- _loop(_r2);
5933
+ for (var _r3 in t) {
5934
+ _loop(_r3);
5753
5935
  }
5754
- g && g({
5936
+ b && b({
5755
5937
  endIterateIn: true,
5756
5938
  end: true
5757
5939
  });
@@ -5760,70 +5942,71 @@
5760
5942
  _adaptBuiltinStateObjectProperties(a, {
5761
5943
  ownKeys: true
5762
5944
  }, function () {
5763
- var e = _encapsulate2(n, t[r], Boolean(s), a, c, p);
5764
- hasConstructorOf(e, TypesonPromise) ? c.push([n, e, Boolean(s), a, w, r, a.type]) : void 0 !== e && (w[r] = e);
5945
+ var e = getEncapsulatedValue(n, t, r),
5946
+ o = e && e.value;
5947
+ hasConstructorOf(o, TypesonPromise) ? c.push([n, o, Boolean(s), a, T, r, a.type]) : e && (void 0 !== o || "substitute" in e) && setOwnEnumerable(T, r, o);
5765
5948
  });
5766
- }), g && g({
5949
+ }), b && b({
5767
5950
  endIterateOwn: true,
5768
5951
  end: true
5769
5952
  });
5770
5953
  if (a.iterateUnsetNumeric) {
5771
- var _r3 = t.length;
5772
- var _loop2 = function _loop2(_n2) {
5773
- if (_n2 in t) return 1; // continue
5774
- var r = "".concat(e).concat(e ? "." : "").concat(String(_n2));
5954
+ var _r4 = t.length;
5955
+ var _loop2 = function _loop2(_n) {
5956
+ if (_n in t) return 1; // continue
5957
+ var r = "".concat(e).concat(e ? "." : "").concat(String(_n));
5775
5958
  _adaptBuiltinStateObjectProperties(a, {
5776
5959
  ownKeys: false
5777
5960
  }, function () {
5778
5961
  var e = _encapsulate2(r, void 0, Boolean(s), a, c, p);
5779
- hasConstructorOf(e, TypesonPromise) ? c.push([r, e, Boolean(s), a, w, _n2, a.type]) : void 0 !== e && (w[_n2] = e);
5962
+ hasConstructorOf(e, TypesonPromise) ? c.push([r, e, Boolean(s), a, T, _n, a.type]) : void 0 !== e && setOwnEnumerable(T, _n, e);
5780
5963
  });
5781
5964
  };
5782
- for (var _n2 = 0; _n2 < _r3; _n2++) {
5783
- if (_loop2(_n2)) continue;
5965
+ for (var _n = 0; _n < _r4; _n++) {
5966
+ if (_loop2(_n)) continue;
5784
5967
  }
5785
- g && g({
5968
+ b && b({
5786
5969
  endIterateUnsetNumeric: true,
5787
5970
  end: true
5788
5971
  });
5789
5972
  }
5790
- return w;
5973
+ return T;
5791
5974
  },
5792
5975
  replace = function replace(e, t, r, n, o, s, a) {
5793
5976
  var i = o ? _this2.plainObjectReplacers : _this2.nonplainObjectReplacers;
5794
- var l = i.length;
5795
- for (; l--;) {
5796
- var _o2 = i[l];
5797
- if (_o2.test(t, r)) {
5798
- var _i = _o2.type;
5799
- if (Object.hasOwn(_this2.revivers, _i)) {
5800
- var _t3 = y[e];
5801
- y[e] = _t3 ? [_i].concat(_t3) : _i;
5977
+ var u = i.length;
5978
+ for (; u--;) {
5979
+ var _o3 = i[u];
5980
+ if (_o3.test(t, r)) {
5981
+ var _i2 = _o3.type;
5982
+ if (Object.hasOwn(_this2.revivers, _i2)) {
5983
+ var _t5 = y[e];
5984
+ y[e] = _t5 ? [_i2].concat(_t5) : _i2;
5802
5985
  }
5803
5986
  if (Object.assign(r, {
5804
- type: _i,
5987
+ type: _i2,
5805
5988
  replaced: true
5806
- }), (c || !_o2.replaceAsync) && !_o2.replace) return a && a({
5989
+ }), (c || !_o3.replaceAsync) && !_o3.replace) return a && a({
5807
5990
  typeDetected: true
5808
- }), _encapsulate2(e, t, f && "readonly", r, n, s, _i);
5809
- var _l = void 0;
5991
+ }), _encapsulate2(e, t, f && "readonly", r, n, s, _i2);
5992
+ var _u = void 0;
5810
5993
  if (a && a({
5811
5994
  replacing: true
5812
- }), c || !_o2.replaceAsync) {
5813
- if (void 0 === _o2.replace) throw new TypeError("Missing replacer");
5814
- _l = _o2.replace(t, r);
5815
- } else _l = _o2.replaceAsync(t, r);
5816
- return _encapsulate2(e, _l, f && "readonly", r, n, s, _i);
5995
+ }), c || !_o3.replaceAsync) {
5996
+ if (void 0 === _o3.replace) throw new TypeError("Missing replacer");
5997
+ _u = _o3.replace(t, r);
5998
+ } else _u = _o3.replaceAsync(t, r);
5999
+ return _encapsulate2(e, _u, f && "readonly", r, n, s, _i2);
5817
6000
  }
5818
6001
  }
5819
6002
  return t;
5820
6003
  },
5821
- m = _encapsulate2("", e, f, t !== null && t !== void 0 ? t : {}, p);
6004
+ h = _encapsulate2("", e, f, t !== null && t !== void 0 ? t : {}, p);
5822
6005
  if (p.length) return c && i.throwOnBadSyncType ? function () {
5823
6006
  throw new TypeError("Sync method requested but async result obtained");
5824
- }() : Promise.resolve(_checkPromises(m, p)).then(finish);
6007
+ }() : Promise.resolve(_checkPromises(h, p)).then(finish);
5825
6008
  if (!c && i.throwOnBadSyncType) throw new TypeError("Async method requested but sync result obtained");
5826
- return c && i.stringification ? [finish(m)] : c ? finish(m) : Promise.resolve(finish(m));
6009
+ return c && i.stringification ? [finish(h)] : c ? finish(h) : Promise.resolve(finish(h));
5827
6010
  }
5828
6011
  }, {
5829
6012
  key: "encapsulateSync",
@@ -5862,18 +6045,18 @@
5862
6045
  if (!i || "object" != _typeof$1(i) || Array.isArray(i)) return finishRevival(e);
5863
6046
  var c = [],
5864
6047
  y = Object.create(null),
5865
- l = {};
5866
- var u = true;
5867
- i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, u = false);
6048
+ u = {};
6049
+ var l = true;
6050
+ i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, l = false);
5868
6051
  var executeReviver = function executeReviver(e, t) {
5869
6052
  var _this3$revivers$e;
5870
- var _ref3 = (_this3$revivers$e = _this3.revivers[e]) !== null && _this3$revivers$e !== void 0 ? _this3$revivers$e : [],
5871
- _ref4 = _slicedToArray(_ref3, 1),
5872
- r = _ref4[0];
6053
+ var _ref4 = (_this3$revivers$e = _this3.revivers[e]) !== null && _this3$revivers$e !== void 0 ? _this3$revivers$e : [],
6054
+ _ref5 = _slicedToArray(_ref4, 1),
6055
+ r = _ref5[0];
5873
6056
  if (!r) throw new Error("Unregistered type: " + e);
5874
6057
  if (a && !("revive" in r)) return t;
5875
- if (!a && r.reviveAsync) return r.reviveAsync(t, l);
5876
- if (r.revive) return r.revive(t, l);
6058
+ if (!a && r.reviveAsync) return r.reviveAsync(t, u);
6059
+ if (r.revive) return r.revive(t, u);
5877
6060
  throw new Error("Missing reviver");
5878
6061
  },
5879
6062
  p = [];
@@ -5883,23 +6066,23 @@
5883
6066
  var f = function () {
5884
6067
  if (!i) throw new Error("Found bad `types`");
5885
6068
  var t = [];
5886
- if (Object.entries(i).forEach(function (_ref5) {
5887
- var _ref6 = _slicedToArray(_ref5, 2),
5888
- e = _ref6[0],
5889
- r = _ref6[1];
6069
+ if (Object.entries(i).forEach(function (_ref6) {
6070
+ var _ref7 = _slicedToArray(_ref6, 2),
6071
+ e = _ref7[0],
6072
+ r = _ref7[1];
5890
6073
  "#" !== r && [].concat(r).forEach(function (r) {
5891
6074
  var _this3$revivers$r;
5892
- var _ref7 = (_this3$revivers$r = _this3.revivers[r]) !== null && _this3$revivers$r !== void 0 ? _this3$revivers$r : [null, {}],
5893
- _ref8 = _slicedToArray(_ref7, 2),
5894
- n = _ref8[1].plain;
6075
+ var _ref8 = (_this3$revivers$r = _this3.revivers[r]) !== null && _this3$revivers$r !== void 0 ? _this3$revivers$r : [null, {}],
6076
+ _ref9 = _slicedToArray(_ref8, 2),
6077
+ n = _ref9[1].plain;
5895
6078
  n && (t.push({
5896
6079
  keypath: e,
5897
6080
  type: r
5898
6081
  }), delete i[e]);
5899
6082
  });
5900
- }), t.length) return t.sort(nestedPathsFirst), t.reduce(function reducer(t, _ref9) {
5901
- var r = _ref9.keypath,
5902
- n = _ref9.type;
6083
+ }), t.length) return t.sort(nestedPathsFirst), t.reduce(function reducer(t, _ref0) {
6084
+ var r = _ref0.keypath,
6085
+ n = _ref0.type;
5903
6086
  if (isThenable(t)) return t.then(function (e) {
5904
6087
  return reducer(e, {
5905
6088
  keypath: r,
@@ -5918,39 +6101,39 @@
5918
6101
  var d;
5919
6102
  return hasConstructorOf(f, TypesonPromise) ? d = f.then(function () {
5920
6103
  return e;
5921
- }) : (d = function _revive(e, t, s, l, f) {
5922
- if (u && "$types" === e) return;
6104
+ }) : (d = function _revive(e, t, s, u, f) {
6105
+ if (l && "$types" === e) return;
5923
6106
  var d = p.length,
5924
- m = i[e],
6107
+ m = n(i, e) ? i[e] : void 0,
5925
6108
  h = o(t);
5926
6109
  if (h || isPlainObject(t)) {
5927
- var _o3 = h ? new Array(t.length) : {};
6110
+ var _o4 = h ? new Array(t.length) : {};
5928
6111
  for (r(t).forEach(function (r) {
5929
- var n = _revive(e + (e ? "." : "") + escapeKeyPathComponent(r), t[r], s !== null && s !== void 0 ? s : _o3, _o3, r),
6112
+ var n = _revive(e + (e ? "." : "") + escapeKeyPathComponent(r), t[r], s !== null && s !== void 0 ? s : _o4, _o4, r),
5930
6113
  set = function set(e) {
5931
- return hasConstructorOf(e, Undefined) ? _o3[r] = void 0 : void 0 !== e && (_o3[r] = e), e;
6114
+ return hasConstructorOf(e, Undefined) ? setOwnEnumerable(_o4, r, void 0) : void 0 !== e && setOwnEnumerable(_o4, r, e), e;
5932
6115
  };
5933
6116
  hasConstructorOf(n, TypesonPromise) ? p.push(n.then(function (e) {
5934
6117
  return set(e);
5935
6118
  })) : set(n);
5936
- }), t = _o3; c.length;) {
6119
+ }), t = _o4; c.length;) {
5937
6120
  var _c$ = _slicedToArray(c[0], 4),
5938
- _e = _c$[0],
5939
- _t4 = _c$[1],
5940
- _r4 = _c$[2],
5941
- _o4 = _c$[3],
5942
- _s = n(y, _t4),
5943
- _a = _s ? y[_t4] : getByKeyPath(_e, _t4);
5944
- if (!_s && void 0 === _a) break;
5945
- _r4[_o4] = _a, c.shift();
6121
+ _e2 = _c$[0],
6122
+ _t6 = _c$[1],
6123
+ _r5 = _c$[2],
6124
+ _o5 = _c$[3],
6125
+ _s2 = n(y, _t6),
6126
+ _a = _s2 ? y[_t6] : getByKeyPath(_e2, _t6);
6127
+ if (!_s2 && void 0 === _a) break;
6128
+ setOwnEnumerable(_r5, _o5, _a), c.shift();
5946
6129
  }
5947
6130
  }
5948
6131
  if (!m) return y[e] = t, t;
5949
6132
  if ("#" === m) {
5950
- var _e2 = t.slice(1),
5951
- _r5 = n(y, _e2),
5952
- _o5 = _r5 ? y[_e2] : getByKeyPath(s, _e2);
5953
- return _r5 || void 0 !== _o5 || c.push([s, _e2, l, f]), _o5;
6133
+ var _e3 = t.slice(1),
6134
+ _r6 = n(y, _e3),
6135
+ _o6 = _r6 ? y[_e3] : getByKeyPath(s, _e3);
6136
+ return _r6 || void 0 !== _o6 || c.push([s, _e3, u, f]), _o6;
5954
6137
  }
5955
6138
  var applyType = function applyType(t) {
5956
6139
  var r = [].concat(m).reduce(function reducer(e, t) {
@@ -5969,9 +6152,9 @@
5969
6152
  }) : applyType(t);
5970
6153
  }("", e, null), p.length && (d = TypesonPromise.resolve(d).then(function (e) {
5971
6154
  return TypesonPromise.all([e].concat(p));
5972
- }).then(function (_ref0) {
5973
- var _ref1 = _slicedToArray(_ref0, 1),
5974
- e = _ref1[0];
6155
+ }).then(function (_ref1) {
6156
+ var _ref10 = _slicedToArray(_ref1, 1),
6157
+ e = _ref10[0];
5975
6158
  return e;
5976
6159
  }))), isThenable(d) ? a && s.throwOnBadSyncType ? function () {
5977
6160
  throw new TypeError("Sync method requested but async result obtained");
@@ -6006,49 +6189,50 @@
6006
6189
  o(e) ? e.forEach(function (e) {
6007
6190
  _reg(e);
6008
6191
  }) : r(e).forEach(function (t) {
6009
- var _r8;
6192
+ var _r9;
6010
6193
  if ("#" === t) throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");
6011
6194
  if (a.includes(t)) throw new TypeError("Plain JSON object types are reserved as type names");
6012
6195
  var r = e[t];
6013
- var s = r && "function" != typeof r && !Array.isArray(r) && r.testPlainObjects ? _this4.plainObjectReplacers : _this4.nonplainObjectReplacers,
6014
- i = s.filter(function (e) {
6196
+ if ([_this4.plainObjectReplacers, _this4.nonplainObjectReplacers].forEach(function (e) {
6197
+ var r = e.findIndex(function (e) {
6015
6198
  return e.type === t;
6016
6199
  });
6017
- if (i.length && (s.splice(s.indexOf(i[0]), 1), delete _this4.revivers[t], delete _this4.types[t]), "function" == typeof r) {
6018
- var _e3 = r;
6200
+ -1 !== r && e.splice(r, 1);
6201
+ }), delete _this4.revivers[t], delete _this4.types[t], "function" == typeof r) {
6202
+ var _e4 = r;
6019
6203
  r = {
6020
6204
  test: function test(t) {
6021
- return t && t.constructor === _e3;
6205
+ return t && t.constructor === _e4;
6022
6206
  },
6023
6207
  replace: function replace(e) {
6024
6208
  return _objectSpread2({}, e);
6025
6209
  },
6026
6210
  revive: function revive(t) {
6027
- return Object.assign(Object.create(_e3.prototype), t);
6211
+ return Object.assign(Object.create(_e4.prototype), t);
6028
6212
  }
6029
6213
  };
6030
6214
  } else if (o(r)) {
6031
- var _r6 = r,
6032
- _r7 = _slicedToArray(_r6, 3),
6033
- _e4 = _r7[0],
6034
- _t5 = _r7[1],
6035
- _n3 = _r7[2];
6215
+ var _r7 = r,
6216
+ _r8 = _slicedToArray(_r7, 3),
6217
+ _e5 = _r8[0],
6218
+ _t7 = _r8[1],
6219
+ _n2 = _r8[2];
6036
6220
  r = {
6037
- test: _e4,
6038
- replace: _t5,
6039
- revive: _n3
6221
+ test: _e5,
6222
+ replace: _t7,
6223
+ revive: _n2
6040
6224
  };
6041
6225
  }
6042
- if (!((_r8 = r) !== null && _r8 !== void 0 && _r8.test)) return;
6043
- var c = {
6226
+ if (!((_r9 = r) !== null && _r9 !== void 0 && _r9.test)) return;
6227
+ var s = {
6044
6228
  type: t,
6045
6229
  test: r.test.bind(r)
6046
6230
  };
6047
- r.replace && (c.replace = r.replace.bind(r)), r.replaceAsync && (c.replaceAsync = r.replaceAsync.bind(r));
6048
- var y = "number" == typeof n.fallback ? n.fallback : n.fallback ? 0 : 1 / 0;
6049
- if (r.testPlainObjects ? _this4.plainObjectReplacers.splice(y, 0, c) : _this4.nonplainObjectReplacers.splice(y, 0, c), r.revive || r.reviveAsync) {
6050
- var _e5 = {};
6051
- r.revive && (_e5.revive = r.revive.bind(r)), r.reviveAsync && (_e5.reviveAsync = r.reviveAsync.bind(r)), _this4.revivers[t] = [_e5, {
6231
+ r.replace && (s.replace = r.replace.bind(r)), r.replaceAsync && (s.replaceAsync = r.replaceAsync.bind(r));
6232
+ var i = "number" == typeof n.fallback ? n.fallback : n.fallback ? 0 : 1 / 0;
6233
+ if (r.testPlainObjects ? _this4.plainObjectReplacers.splice(i, 0, s) : _this4.nonplainObjectReplacers.splice(i, 0, s), r.revive || r.reviveAsync) {
6234
+ var _e6 = {};
6235
+ r.revive && (_e6.revive = r.revive.bind(r)), r.reviveAsync && (_e6.reviveAsync = r.reviveAsync.bind(r)), _this4.revivers[t] = [_e6, {
6052
6236
  plain: r.testPlainObjects
6053
6237
  }];
6054
6238
  }
@@ -6067,12 +6251,12 @@
6067
6251
  Undefined.__typeson__type__ = "TypesonUndefined";
6068
6252
  var a = ["null", "boolean", "number", "string", "array", "object"];
6069
6253
  for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), y = 0; y < 64; y++) c[i.codePointAt(y)] = y;
6070
- var l = function encode(e, t, r) {
6254
+ var u = function encode(e, t, r) {
6071
6255
  null == r && (r = e.byteLength);
6072
6256
  for (var n = new Uint8Array(e, 0, r), o = n.length, s = "", a = 0; a < o; a += 3) s += i[n[a] >> 2], s += i[(3 & n[a]) << 4 | n[a + 1] >> 4], s += i[(15 & n[a + 1]) << 2 | n[a + 2] >> 6], s += i[63 & n[a + 2]];
6073
6257
  return o % 3 == 2 ? s = s.slice(0, -1) + "=" : o % 3 == 1 && (s = s.slice(0, -2) + "=="), s;
6074
6258
  },
6075
- u = function decode(e, t) {
6259
+ l = function decode(e, t) {
6076
6260
  var r = e.length;
6077
6261
  if (r % 4) throw new Error("Bad base64 length: not divisible by four");
6078
6262
  var n,
@@ -6082,8 +6266,8 @@
6082
6266
  i = .75 * e.length,
6083
6267
  y = 0;
6084
6268
  "=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
6085
- for (var l = new ArrayBuffer(i, t), u = new Uint8Array(l), p = 0; p < r; p += 4) n = c[e.codePointAt(p)], o = c[e.codePointAt(p + 1)], s = c[e.codePointAt(p + 2)], a = c[e.codePointAt(p + 3)], u[y++] = n << 2 | o >> 4, u[y++] = (15 & o) << 4 | s >> 2, u[y++] = (3 & s) << 6 | 63 & a;
6086
- return l;
6269
+ for (var u = new ArrayBuffer(i, t), l = new Uint8Array(u), p = 0; p < r; p += 4) n = c[e.codePointAt(p)], o = c[e.codePointAt(p + 1)], s = c[e.codePointAt(p + 2)], a = c[e.codePointAt(p + 3)], l[y++] = n << 2 | o >> 4, l[y++] = (15 & o) << 4 | s >> 2, l[y++] = (3 & s) << 6 | 63 & a;
6270
+ return u;
6087
6271
  };
6088
6272
  var p = {
6089
6273
  arraybuffer: {
@@ -6096,14 +6280,14 @@
6096
6280
  return -1 !== r ? {
6097
6281
  index: r
6098
6282
  } : (t.buffers.push(e), {
6099
- s: l(e),
6283
+ s: u(e),
6100
6284
  maxByteLength: e.maxByteLength,
6101
6285
  resizable: e.resizable
6102
6286
  });
6103
6287
  },
6104
6288
  revive: function revive(e, t) {
6105
6289
  if (t.buffers || (t.buffers = []), Object.hasOwn(e, "index")) return t.buffers[e.index];
6106
- var r = u(e.s, e.resizable ? {
6290
+ var r = l(e.s, e.resizable ? {
6107
6291
  maxByteLength: e.maxByteLength
6108
6292
  } : void 0);
6109
6293
  return t.buffers.push(r), r;
@@ -6139,7 +6323,7 @@
6139
6323
  }
6140
6324
  function string2arraybuffer(e) {
6141
6325
  var t = new Uint8Array(e.length);
6142
- for (var _r9 = 0; _r9 < e.length; _r9++) t[_r9] = e.charCodeAt(_r9);
6326
+ for (var _r0 = 0; _r0 < e.length; _r0++) t[_r0] = e.charCodeAt(_r0);
6143
6327
  return t.buffer;
6144
6328
  }
6145
6329
  var m = {
@@ -6184,8 +6368,8 @@
6184
6368
  },
6185
6369
  replaceAsync: function replaceAsync(e) {
6186
6370
  return new TypesonPromise(/*#__PURE__*/function () {
6187
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(t, r) {
6188
- var n, _t6;
6371
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(t, r) {
6372
+ var n, _t8;
6189
6373
  return _regenerator().w(function (_context3) {
6190
6374
  while (1) switch (_context3.p = _context3.n) {
6191
6375
  case 0:
@@ -6198,8 +6382,8 @@
6198
6382
  break;
6199
6383
  case 2:
6200
6384
  _context3.p = 2;
6201
- _t6 = _context3.v;
6202
- return _context3.a(2, void r(_t6));
6385
+ _t8 = _context3.v;
6386
+ return _context3.a(2, void r(_t8));
6203
6387
  case 3:
6204
6388
  t({
6205
6389
  jwk: n,
@@ -6212,7 +6396,7 @@
6212
6396
  }, _callee3, null, [[0, 2]]);
6213
6397
  }));
6214
6398
  return function (_x4, _x5) {
6215
- return _ref10.apply(this, arguments);
6399
+ return _ref11.apply(this, arguments);
6216
6400
  };
6217
6401
  }());
6218
6402
  },
@@ -6229,10 +6413,10 @@
6229
6413
  test: function test(e) {
6230
6414
  return "DataView" === toStringTag(e);
6231
6415
  },
6232
- replace: function replace(_ref11, n) {
6233
- var e = _ref11.buffer,
6234
- t = _ref11.byteOffset,
6235
- r = _ref11.byteLength;
6416
+ replace: function replace(_ref12, n) {
6417
+ var e = _ref12.buffer,
6418
+ t = _ref12.byteOffset,
6419
+ r = _ref12.byteLength;
6236
6420
  n.buffers || (n.buffers = []);
6237
6421
  var o = n.buffers.indexOf(e);
6238
6422
  return -1 !== o ? {
@@ -6240,7 +6424,7 @@
6240
6424
  byteOffset: t,
6241
6425
  byteLength: r
6242
6426
  } : (n.buffers.push(e), {
6243
- encoded: l(e),
6427
+ encoded: u(e),
6244
6428
  maxByteLength: e.maxByteLength,
6245
6429
  resizable: e.resizable,
6246
6430
  byteOffset: t,
@@ -6256,7 +6440,7 @@
6256
6440
  a = e.maxByteLength,
6257
6441
  i = e.resizable;
6258
6442
  var c;
6259
- return "index" in e ? c = t.buffers[s] : (c = u(o, i ? {
6443
+ return "index" in e ? c = t.buffers[s] : (c = l(o, i ? {
6260
6444
  maxByteLength: a
6261
6445
  } : a), t.buffers.push(c)), new DataView(c, r, n);
6262
6446
  }
@@ -6287,9 +6471,9 @@
6287
6471
  message: e.message
6288
6472
  };
6289
6473
  },
6290
- revive: function revive(_ref12) {
6291
- var e = _ref12.message,
6292
- t = _ref12.name;
6474
+ revive: function revive(_ref13) {
6475
+ var e = _ref13.message,
6476
+ t = _ref13.name;
6293
6477
  return new DOMException(e, t);
6294
6478
  }
6295
6479
  }
@@ -6347,11 +6531,11 @@
6347
6531
  w: e.w
6348
6532
  };
6349
6533
  },
6350
- revive: function revive(_ref13) {
6351
- var t = _ref13.x,
6352
- r = _ref13.y,
6353
- n = _ref13.z,
6354
- o = _ref13.w;
6534
+ revive: function revive(_ref14) {
6535
+ var t = _ref14.x,
6536
+ r = _ref14.y,
6537
+ n = _ref14.z,
6538
+ o = _ref14.w;
6355
6539
  return new e(t, r, n, o);
6356
6540
  }
6357
6541
  };
@@ -6370,11 +6554,11 @@
6370
6554
  p4: e.p4
6371
6555
  };
6372
6556
  },
6373
- revive: function revive(_ref14) {
6374
- var e = _ref14.p1,
6375
- t = _ref14.p2,
6376
- r = _ref14.p3,
6377
- n = _ref14.p4;
6557
+ revive: function revive(_ref15) {
6558
+ var e = _ref15.p1,
6559
+ t = _ref15.p2,
6560
+ r = _ref15.p3,
6561
+ n = _ref15.p4;
6378
6562
  return new DOMQuad(e, t, r, n);
6379
6563
  }
6380
6564
  }
@@ -6393,11 +6577,11 @@
6393
6577
  height: e.height
6394
6578
  };
6395
6579
  },
6396
- revive: function revive(_ref15) {
6397
- var t = _ref15.x,
6398
- r = _ref15.y,
6399
- n = _ref15.width,
6400
- o = _ref15.height;
6580
+ revive: function revive(_ref16) {
6581
+ var t = _ref16.x,
6582
+ r = _ref16.y,
6583
+ n = _ref16.width,
6584
+ o = _ref16.height;
6401
6585
  return new e(t, r, n, o);
6402
6586
  }
6403
6587
  };
@@ -6408,14 +6592,14 @@
6408
6592
  test: function test(e) {
6409
6593
  return "Error" === toStringTag(e);
6410
6594
  },
6411
- replace: function replace(_ref16) {
6412
- var e = _ref16.name,
6413
- t = _ref16.message,
6414
- r = _ref16.cause,
6415
- n = _ref16.stack,
6416
- o = _ref16.fileName,
6417
- s = _ref16.lineNumber,
6418
- a = _ref16.columnNumber;
6595
+ replace: function replace(_ref17) {
6596
+ var e = _ref17.name,
6597
+ t = _ref17.message,
6598
+ r = _ref17.cause,
6599
+ n = _ref17.stack,
6600
+ o = _ref17.fileName,
6601
+ s = _ref17.lineNumber,
6602
+ a = _ref17.columnNumber;
6419
6603
  return {
6420
6604
  name: e,
6421
6605
  message: t,
@@ -6438,15 +6622,15 @@
6438
6622
  test: function test(t) {
6439
6623
  return hasConstructorOf(t, e);
6440
6624
  },
6441
- replace: function replace(_ref17) {
6442
- var e = _ref17.name,
6443
- t = _ref17.message,
6444
- r = _ref17.cause,
6445
- n = _ref17.stack,
6446
- o = _ref17.fileName,
6447
- s = _ref17.lineNumber,
6448
- a = _ref17.columnNumber,
6449
- i = _ref17.errors;
6625
+ replace: function replace(_ref18) {
6626
+ var e = _ref18.name,
6627
+ t = _ref18.message,
6628
+ r = _ref18.cause,
6629
+ n = _ref18.stack,
6630
+ o = _ref18.fileName,
6631
+ s = _ref18.lineNumber,
6632
+ a = _ref18.columnNumber,
6633
+ i = _ref18.errors;
6450
6634
  return {
6451
6635
  name: e,
6452
6636
  message: t,
@@ -6467,7 +6651,7 @@
6467
6651
  [TypeError, RangeError, SyntaxError, ReferenceError, EvalError, URIError].forEach(function (e) {
6468
6652
  return create$2(e);
6469
6653
  }), "undefined" != typeof AggregateError && create$2(AggregateError), "function" == typeof InternalError && create$2(InternalError);
6470
- var N = {
6654
+ var E = {
6471
6655
  file: {
6472
6656
  test: function test(e) {
6473
6657
  return "File" === toStringTag(e);
@@ -6482,11 +6666,11 @@
6482
6666
  lastModified: e.lastModified
6483
6667
  };
6484
6668
  },
6485
- revive: function revive(_ref18) {
6486
- var e = _ref18.name,
6487
- t = _ref18.type,
6488
- r = _ref18.stringContents,
6489
- n = _ref18.lastModified;
6669
+ revive: function revive(_ref19) {
6670
+ var e = _ref19.name,
6671
+ t = _ref19.type,
6672
+ r = _ref19.stringContents,
6673
+ n = _ref19.lastModified;
6490
6674
  return new File([string2arraybuffer(r)], e, {
6491
6675
  type: t,
6492
6676
  lastModified: n
@@ -6509,15 +6693,15 @@
6509
6693
  }
6510
6694
  }
6511
6695
  },
6512
- _ = {
6513
- file: N.file,
6696
+ N = {
6697
+ file: E.file,
6514
6698
  filelist: {
6515
6699
  test: function test(e) {
6516
6700
  return "FileList" === toStringTag(e);
6517
6701
  },
6518
6702
  replace: function replace(e) {
6519
6703
  var t = [];
6520
- for (var _r0 = 0; _r0 < e.length; _r0++) t[_r0] = e.item(_r0);
6704
+ for (var _r1 = 0; _r1 < e.length; _r1++) t[_r1] = e.item(_r1);
6521
6705
  return t;
6522
6706
  },
6523
6707
  revive: function revive(e) {
@@ -6542,7 +6726,7 @@
6542
6726
  }
6543
6727
  }
6544
6728
  },
6545
- B = {
6729
+ _ = {
6546
6730
  imagebitmap: {
6547
6731
  test: function test(e) {
6548
6732
  return "ImageBitmap" === toStringTag(e) || e && e.dataset && "ImageBitmap" === e.dataset.toStringTag;
@@ -6570,36 +6754,36 @@
6570
6754
  return n.addEventListener("load", function () {
6571
6755
  r.drawImage(n, 0, 0);
6572
6756
  }), n.src = e.dataURL, new TypesonPromise(/*#__PURE__*/function () {
6573
- var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(e, r) {
6574
- var _t7, _t8;
6757
+ var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(e, r) {
6758
+ var _t9, _t0;
6575
6759
  return _regenerator().w(function (_context4) {
6576
6760
  while (1) switch (_context4.p = _context4.n) {
6577
6761
  case 0:
6578
6762
  _context4.p = 0;
6579
- _t7 = e;
6763
+ _t9 = e;
6580
6764
  _context4.n = 1;
6581
6765
  return createImageBitmap(t);
6582
6766
  case 1:
6583
- _t7(_context4.v);
6767
+ _t9(_context4.v);
6584
6768
  _context4.n = 3;
6585
6769
  break;
6586
6770
  case 2:
6587
6771
  _context4.p = 2;
6588
- _t8 = _context4.v;
6589
- r(_t8);
6772
+ _t0 = _context4.v;
6773
+ r(_t0);
6590
6774
  case 3:
6591
6775
  return _context4.a(2);
6592
6776
  }
6593
6777
  }, _callee4, null, [[0, 2]]);
6594
6778
  }));
6595
6779
  return function (_x6, _x7) {
6596
- return _ref19.apply(this, arguments);
6780
+ return _ref20.apply(this, arguments);
6597
6781
  };
6598
6782
  }());
6599
6783
  }
6600
6784
  }
6601
6785
  },
6602
- E = {
6786
+ B = {
6603
6787
  imagedata: {
6604
6788
  test: function test(e) {
6605
6789
  return "ImageData" === toStringTag(e);
@@ -6616,7 +6800,7 @@
6616
6800
  }
6617
6801
  }
6618
6802
  },
6619
- C = {
6803
+ I = {
6620
6804
  infinity: {
6621
6805
  test: function test(e) {
6622
6806
  return e === 1 / 0;
@@ -6681,7 +6865,7 @@
6681
6865
  }
6682
6866
  }
6683
6867
  },
6684
- k = {
6868
+ R = {
6685
6869
  StringObject: {
6686
6870
  test: function test(e) {
6687
6871
  return "String" === toStringTag(e) && "object" == _typeof$1(e);
@@ -6712,7 +6896,7 @@
6712
6896
  }
6713
6897
  }
6714
6898
  },
6715
- $ = {
6899
+ K = {
6716
6900
  regexp: {
6717
6901
  test: function test(e) {
6718
6902
  return "RegExp" === toStringTag(e);
@@ -6723,14 +6907,14 @@
6723
6907
  flags: (e.global ? "g" : "") + (e.ignoreCase ? "i" : "") + (e.multiline ? "m" : "") + (e.sticky ? "y" : "") + (e.unicode ? "u" : "") + (e.unicodeSets ? "v" : "") + (e.hasIndices ? "d" : "") + (e.dotAll ? "s" : "")
6724
6908
  };
6725
6909
  },
6726
- revive: function revive(_ref21) {
6727
- var e = _ref21.source,
6728
- t = _ref21.flags;
6910
+ revive: function revive(_ref22) {
6911
+ var e = _ref22.source,
6912
+ t = _ref22.flags;
6729
6913
  return new RegExp(e, t);
6730
6914
  }
6731
6915
  }
6732
6916
  },
6733
- J = {
6917
+ z = {
6734
6918
  set: {
6735
6919
  test: function test(e) {
6736
6920
  return "Set" === toStringTag(e);
@@ -6768,10 +6952,10 @@
6768
6952
  test: function test(e) {
6769
6953
  return toStringTag(e) === t;
6770
6954
  },
6771
- replace: function replace(_ref22, n) {
6772
- var e = _ref22.buffer,
6773
- t = _ref22.byteOffset,
6774
- r = _ref22.length;
6955
+ replace: function replace(_ref23, n) {
6956
+ var e = _ref23.buffer,
6957
+ t = _ref23.byteOffset,
6958
+ r = _ref23.length;
6775
6959
  n.buffers || (n.buffers = []);
6776
6960
  var o = n.buffers.indexOf(e);
6777
6961
  return -1 !== o ? {
@@ -6781,7 +6965,7 @@
6781
6965
  } : (n.buffers.push(e), {
6782
6966
  maxByteLength: e.maxByteLength,
6783
6967
  resizable: e.resizable,
6784
- encoded: l(e),
6968
+ encoded: u(e),
6785
6969
  byteOffset: t,
6786
6970
  length: r
6787
6971
  });
@@ -6795,7 +6979,7 @@
6795
6979
  i = t.maxByteLength,
6796
6980
  c = t.resizable;
6797
6981
  var y;
6798
- return "index" in t ? y = r.buffers[a] : (y = u(s, c ? {
6982
+ return "index" in t ? y = r.buffers[a] : (y = l(s, c ? {
6799
6983
  maxByteLength: i
6800
6984
  } : void 0), r.buffers.push(y)), new e(y, n, o);
6801
6985
  }
@@ -6842,10 +7026,10 @@
6842
7026
  revive: function revive(e) {
6843
7027
  if (Array.isArray(e)) return e;
6844
7028
  var t = [];
6845
- return Object.entries(e).forEach(function (_ref23) {
6846
- var _ref24 = _slicedToArray(_ref23, 2),
6847
- e = _ref24[0],
6848
- r = _ref24[1];
7029
+ return Object.entries(e).forEach(function (_ref24) {
7030
+ var _ref25 = _slicedToArray(_ref24, 2),
7031
+ e = _ref25[0],
7032
+ r = _ref25[1];
6849
7033
  t[e] = r;
6850
7034
  }), t;
6851
7035
  }
@@ -6861,8 +7045,8 @@
6861
7045
  revive: function revive() {}
6862
7046
  }
6863
7047
  }],
6864
- X = [M, C, L, D],
6865
- re = [G, Q, H, k, X, O, $, E, B, N, _, m, x, j].concat("function" == typeof Map ? U : [], "function" == typeof Set ? J : [], "function" == typeof ArrayBuffer ? p : [], "function" == typeof Uint8Array ? W : [], "function" == typeof DataView ? v : [], "undefined" != typeof crypto ? b : [], "undefined" != typeof BigInt ? [d, f] : [], "undefined" != typeof DOMException ? w : [], "undefined" != typeof DOMRect ? S : [], "undefined" != typeof DOMPoint ? A : [], "undefined" != typeof DOMQuad ? P : [], "undefined" != typeof DOMMatrix ? T : []),
7048
+ X = [M, I, L, D],
7049
+ re = [G, Q, H, R, X, O, K, B, _, E, N, m, x, j].concat("function" == typeof Map ? U : [], "function" == typeof Set ? z : [], "function" == typeof ArrayBuffer ? p : [], "function" == typeof Uint8Array ? W : [], "function" == typeof DataView ? v : [], "undefined" != typeof crypto ? b : [], "undefined" != typeof BigInt ? [d, f] : [], "undefined" != typeof DOMException ? w : [], "undefined" != typeof DOMRect ? S : [], "undefined" != typeof DOMPoint ? A : [], "undefined" != typeof DOMQuad ? P : [], "undefined" != typeof DOMMatrix ? T : []),
6866
7050
  ne = re.concat({
6867
7051
  checkDataCloneException: {
6868
7052
  test: function test(e) {
@@ -7626,7 +7810,7 @@
7626
7810
  reject(err);
7627
7811
  });
7628
7812
  }));
7629
- SyncPromise.all(indexCreations).then(finish, /** @type {(reason: any) => PromiseLike<never>} */
7813
+ SyncPromise.all(indexCreations).then(finish).catch(/** @type {(reason: any) => PromiseLike<never>} */
7630
7814
  error).catch(function (err) {
7631
7815
  console.log('Index rename error');
7632
7816
  throw err;
@@ -9819,7 +10003,7 @@
9819
10003
  * __connections: {
9820
10004
  * [key: string]: import('./IDBDatabase.js').IDBDatabaseFull[]
9821
10005
  * }
9822
- * }} IDBFactoryFull
10006
+ * }} IDBFactoryFull
9823
10007
  */
9824
10008
 
9825
10009
  var IDBFactoryAlias = IDBFactory;
@@ -10010,7 +10194,7 @@
10010
10194
  /** @type {import('./IDBDatabase.js').IDBDatabaseFull} */
10011
10195
  req.__result.__versionTransaction = null;
10012
10196
  sysdbFinishedCb(systx, false, function () {
10013
- req.transaction.__transFinishedCb(false, function () {
10197
+ req.transaction.__callTransFinishedCb(false, function () {
10014
10198
  ev.complete();
10015
10199
  req.__transaction = null;
10016
10200
  });
@@ -10121,6 +10305,13 @@
10121
10305
  function openDB(oldVersion) {
10122
10306
  /** @type {DatabaseFull} */
10123
10307
  var db;
10308
+ if (version === undefined) {
10309
+ // Resolve before use as a cache key below, or a `open(name)` call
10310
+ // (no explicit version) would cache/look up under `undefined`
10311
+ // instead of the actual version, causing a second, separate
10312
+ // connection to be opened for the same database on reopen.
10313
+ version = oldVersion || 1;
10314
+ }
10124
10315
  if ((useMemoryDatabase || useDatabaseCache) && Object.hasOwn(websqlDBCache, name) && Object.hasOwn(websqlDBCache[name], version)) {
10125
10316
  db = websqlDBCache[name][version];
10126
10317
  } else {
@@ -10132,9 +10323,6 @@
10132
10323
  websqlDBCache[name][version] = db;
10133
10324
  }
10134
10325
  }
10135
- if (version === undefined) {
10136
- version = oldVersion || 1;
10137
- }
10138
10326
  if (oldVersion > version) {
10139
10327
  var err = createDOMException('VersionError', 'An attempt was made to open a database using a lower version than the existing version.', version);
10140
10328
  if (useDatabaseCache) {
@@ -10302,7 +10490,6 @@
10302
10490
  version = _data$rows$item.version;
10303
10491
  var openConnections = me.__connections[name] || [];
10304
10492
  triggerAnyVersionChangeAndBlockedEvents(openConnections, req, version, null).then(function () {
10305
- // eslint-disable-line promise/catch-or-return -- Sync promise
10306
10493
  // Since we need two databases which can't be in a single transaction, we
10307
10494
  // do this deleting from `dbVersions` first since the `__sys__` deleting
10308
10495
  // only impacts file memory whereas this one is critical for avoiding it
@@ -10331,7 +10518,7 @@
10331
10518
  });
10332
10519
  return undefined;
10333
10520
  // @ts-expect-error It's ok
10334
- }, dbError);
10521
+ }).catch(dbError);
10335
10522
  return undefined;
10336
10523
  }, dbError);
10337
10524
  });
@@ -10362,14 +10549,14 @@
10362
10549
  };
10363
10550
 
10364
10551
  /**
10365
- * May return outdated information if a database has since been deleted.
10366
- * @see https://github.com/w3c/IndexedDB/pull/240/files
10367
- * @this {IDBFactoryFull}
10368
- * @returns {Promise<{
10369
- * name: string,
10370
- * version: Integer
10371
- * }[]>}
10372
- */
10552
+ * May return outdated information if a database has since been deleted.
10553
+ * @see https://github.com/w3c/IndexedDB/pull/240/files
10554
+ * @this {IDBFactoryFull}
10555
+ * @returns {Promise<{
10556
+ * name: string,
10557
+ * version: Integer
10558
+ * }[]>}
10559
+ */
10373
10560
  IDBFactory.prototype.databases = function () {
10374
10561
  var me = this;
10375
10562
  var calledDbCreateError = false;
@@ -10417,17 +10604,17 @@
10417
10604
  };
10418
10605
 
10419
10606
  /**
10420
- * @todo forceClose: Test
10421
- * This is provided to facilitate unit-testing of the
10422
- * closing of a database connection with a forced flag:
10423
- * <https://w3c.github.io/IndexedDB/#steps-for-closing-a-database-connection>
10424
- * @param {string} dbName
10425
- * @param {Integer} connIdx
10426
- * @param {string} msg
10427
- * @throws {TypeError}
10428
- * @this {IDBFactoryFull}
10429
- * @returns {void}
10430
- */
10607
+ * @todo forceClose: Test
10608
+ * This is provided to facilitate unit-testing of the
10609
+ * closing of a database connection with a forced flag:
10610
+ * <https://w3c.github.io/IndexedDB/#steps-for-closing-a-database-connection>
10611
+ * @param {string} dbName
10612
+ * @param {Integer} connIdx
10613
+ * @param {string} msg
10614
+ * @throws {TypeError}
10615
+ * @this {IDBFactoryFull}
10616
+ * @returns {void}
10617
+ */
10431
10618
  IDBFactory.prototype.__forceClose = function (dbName, connIdx, msg) {
10432
10619
  var me = this;
10433
10620
  /**
@@ -10513,6 +10700,9 @@
10513
10700
  * __unique: boolean,
10514
10701
  * __sqlDirection: "DESC"|"ASC",
10515
10702
  * __matchedKeys: {[key: string]: true},
10703
+ * __continuationKey: import('./Key.js').Key|undefined,
10704
+ * __continuationPrimaryKey: import('./Key.js').Key|undefined,
10705
+ * __multiEntryExhausted: boolean,
10516
10706
  * __invalidateCache: () => void
10517
10707
  * }} IDBCursorFull
10518
10708
  */
@@ -10586,6 +10776,9 @@
10586
10776
  this.__valueDecoder = this.__keyOnly ? Key : Sca;
10587
10777
  this.__count = count;
10588
10778
  this.__prefetchedIndex = -1;
10779
+ this.__continuationKey = undefined;
10780
+ this.__continuationPrimaryKey = undefined;
10781
+ this.__multiEntryExhausted = false;
10589
10782
  this.__multiEntryIndex = this.__indexSource ? 'multiEntry' in source && source.multiEntry : false;
10590
10783
  this.__unique = this.direction.includes('unique');
10591
10784
  this.__sqlDirection = ['prev', 'prevunique'].includes(this.direction) ? 'DESC' : 'ASC';
@@ -10749,73 +10942,97 @@
10749
10942
  * @param {SQLTransaction} tx
10750
10943
  * @param {KeySuccess} success
10751
10944
  * @param {FindError} error
10752
- * @param {Integer|undefined} recordsToLoad
10945
+ * @param {Integer} [recordsToLoad]
10753
10946
  * @this {IDBCursorFull}
10754
10947
  * @returns {void}
10755
10948
  */
10756
- IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, error, recordsToLoad) {
10949
+ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, error) {
10950
+ var recordsToLoad = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
10757
10951
  var me = this;
10758
- if (me.__prefetchedData && me.__prefetchedData.length === me.__prefetchedIndex) {
10952
+ if (me.__multiEntryExhausted) {
10759
10953
  if (CFG.DEBUG) {
10760
- console.log('Reached end of multiEntry cursor');
10954
+ console.log('[multiEntry] Reached end of multiEntry cursor (already exhausted)');
10761
10955
  }
10762
10956
  success(undefined, undefined, undefined);
10763
10957
  return;
10764
10958
  }
10765
10959
  var quotedKeyColumnName = sqlQuote(me.__keyColumnName);
10766
- var sql = ['SELECT * FROM', escapeStoreNameForSQL(me.__store.__currentName)];
10767
- /** @type {string[]} */
10768
- var sqlValues = [];
10769
- sql.push('WHERE', quotedKeyColumnName, 'NOT NULL');
10770
- if (me.__range && me.__range.lower !== undefined && Array.isArray(me.__range.upper)) {
10771
- if (me.__range.upper.indexOf(me.__range.lower) === 0) {
10772
- sql.push('AND', quotedKeyColumnName, "LIKE ? ESCAPE '^'");
10773
- sqlValues.push('%' + sqlLIKEEscape(/** @type {string} */me.__range.__lowerCached.slice(0, -1)) + '%');
10774
- }
10775
- }
10960
+ var quotedKey = sqlQuote('key');
10776
10961
 
10777
10962
  // Determine the ORDER BY direction based on the cursor.
10778
10963
  var direction = me.__sqlDirection;
10779
10964
  var op = direction === 'ASC' ? '>' : '<';
10780
- var quotedKey = sqlQuote('key');
10781
- if (primaryKey !== undefined) {
10782
- sql.push('AND', quotedKey, op + '= ?');
10783
- // Key.convertValueToKey(primaryKey); // Already checked by `continuePrimaryKey`
10784
- sqlValues.push(/** @type {string} */_encode(primaryKey));
10785
- }
10786
- if (key !== undefined) {
10787
- sql.push('AND', quotedKeyColumnName, op + '= ?');
10788
- // Key.convertValueToKey(key); // Already checked by `continue` or `continuePrimaryKey`
10789
- sqlValues.push(/** @type {string} */_encode(key));
10790
- } else if (me.__key !== undefined) {
10791
- sql.push('AND', quotedKeyColumnName, op + ' ?');
10792
- // Key.convertValueToKey(me.__key); // Already checked when entered
10793
- sqlValues.push(/** @type {string} */_encode(me.__key));
10794
- }
10795
- if (!me.__count) {
10796
- // 1. Sort by key
10797
- sql.push('ORDER BY', quotedKeyColumnName, direction);
10798
10965
 
10799
- // 2. Sort by primaryKey (if defined and not unique)
10800
- if (!me.__unique && me.__keyColumnName !== 'key') {
10801
- // Avoid adding 'key' twice
10802
- sql.push(',', sqlQuote('key'), direction);
10966
+ /**
10967
+ * Runs (and, if a batch of underlying rows produces no matching
10968
+ * multi-entry values, repeatedly re-runs) the query for the next batch
10969
+ * of underlying rows, advancing `me.__continuationKey`/
10970
+ * `me.__continuationPrimaryKey` (tracking the last *physical* row
10971
+ * scanned) each time, until either some matches are found or the
10972
+ * underlying table is exhausted.
10973
+ * @returns {void}
10974
+ */
10975
+ function runQuery() {
10976
+ var sql = ['SELECT * FROM', escapeStoreNameForSQL(me.__store.__currentName)];
10977
+ /** @type {string[]} */
10978
+ var sqlValues = [];
10979
+ sql.push('WHERE', quotedKeyColumnName, 'NOT NULL');
10980
+ if (me.__range && me.__range.lower !== undefined && Array.isArray(me.__range.upper)) {
10981
+ if (me.__range.upper.indexOf(me.__range.lower) === 0) {
10982
+ sql.push('AND', quotedKeyColumnName, "LIKE ? ESCAPE '^'");
10983
+ sqlValues.push('%' + sqlLIKEEscape(/** @type {string} */me.__range.__lowerCached.slice(0, -1)) + '%');
10984
+ }
10985
+ }
10986
+ if (primaryKey !== undefined) {
10987
+ sql.push('AND', quotedKey, op + '= ?');
10988
+ // Key.convertValueToKey(primaryKey); // Already checked by `continuePrimaryKey`
10989
+ sqlValues.push(/** @type {string} */_encode(primaryKey));
10803
10990
  }
10804
-
10805
- // 3. Sort by position (if defined)
10806
-
10807
- if (!me.__unique && me.__indexSource) {
10808
- // 4. Sort by object store position (if defined and not unique)
10809
- sql.push(',', sqlQuote(me.__valueColumnName), direction);
10991
+ if (key !== undefined) {
10992
+ sql.push('AND', quotedKeyColumnName, op + '= ?');
10993
+ // Key.convertValueToKey(key); // Already checked by `continue` or `continuePrimaryKey`
10994
+ sqlValues.push(/** @type {string} */_encode(key));
10995
+ } else if (me.__continuationKey !== undefined) {
10996
+ // Resume from the last underlying (physical) row we scanned, not
10997
+ // from the last *matching* multi-entry value (which lives in a
10998
+ // different key-space than the raw index column and cannot be
10999
+ // reliably compared against it, e.g. for array index keys).
11000
+ sql.push('AND (', quotedKeyColumnName, op, '?', 'OR (', quotedKeyColumnName, '= ?', 'AND', quotedKey, op, '?))');
11001
+ var encodedContinuationKey = /** @type {string} */
11002
+ _encode(me.__continuationKey, true);
11003
+ sqlValues.push(encodedContinuationKey, encodedContinuationKey, /** @type {string} */_encode(me.__continuationPrimaryKey));
11004
+ }
11005
+ if (!me.__count) {
11006
+ // 1. Sort by key
11007
+ sql.push('ORDER BY', quotedKeyColumnName, direction);
11008
+
11009
+ // 2. Sort by primaryKey (if defined and not unique)
11010
+ if (!me.__unique && me.__keyColumnName !== 'key') {
11011
+ // Avoid adding 'key' twice
11012
+ sql.push(',', sqlQuote('key'), direction);
11013
+ }
11014
+
11015
+ // 3. Sort by position (if defined)
11016
+
11017
+ if (!me.__unique && me.__indexSource) {
11018
+ // 4. Sort by object store position (if defined and not unique)
11019
+ sql.push(',', sqlQuote(me.__valueColumnName), direction);
11020
+ }
11021
+ sql.push('LIMIT', String(recordsToLoad));
11022
+ }
11023
+ var sqlStr = sql.join(' ');
11024
+ if (CFG.DEBUG) {
11025
+ console.log('[multiEntry] query', sqlStr, sqlValues);
10810
11026
  }
10811
- sql.push('LIMIT', String(recordsToLoad));
10812
- }
10813
- var sqlStr = sql.join(' ');
10814
- if (CFG.DEBUG) {
10815
- console.log(sqlStr, sqlValues);
10816
- }
10817
- tx.executeSql(sqlStr, sqlValues, function (tx, data) {
10818
- if (data.rows.length > 0) {
11027
+ tx.executeSql(sqlStr, sqlValues, function (tx, data) {
11028
+ if (data.rows.length === 0) {
11029
+ me.__multiEntryExhausted = true;
11030
+ if (CFG.DEBUG) {
11031
+ console.log('[multiEntry] Reached end of multiEntry cursor (no more rows)');
11032
+ }
11033
+ success(undefined, undefined, undefined);
11034
+ return;
11035
+ }
10819
11036
  if (me.__count) {
10820
11037
  // Avoid caching and other processing below
10821
11038
  var ct = 0;
@@ -10828,6 +11045,16 @@
10828
11045
  success(undefined, ct, undefined);
10829
11046
  return;
10830
11047
  }
11048
+
11049
+ // Track how far we've physically scanned, regardless of whether
11050
+ // this batch produced any matches, so the next batch (if any)
11051
+ // resumes after this one instead of re-scanning or stopping early.
11052
+ var lastRawRow = data.rows.item(data.rows.length - 1);
11053
+ me.__continuationKey = _decode(lastRawRow[me.__keyColumnName], true);
11054
+ me.__continuationPrimaryKey = _decode(lastRawRow.key);
11055
+ if (data.rows.length < recordsToLoad) {
11056
+ me.__multiEntryExhausted = true;
11057
+ }
10831
11058
  var rows = [];
10832
11059
  for (var _i = 0; _i < data.rows.length; _i++) {
10833
11060
  var _rowItem = data.rows.item(_i);
@@ -10854,6 +11081,20 @@
10854
11081
  _iterator.f();
10855
11082
  }
10856
11083
  }
11084
+ if (rows.length === 0) {
11085
+ if (me.__multiEntryExhausted) {
11086
+ if (CFG.DEBUG) {
11087
+ console.log('[multiEntry] Reached end of multiEntry cursor (last batch had no matches)');
11088
+ }
11089
+ success(undefined, undefined, undefined);
11090
+ return;
11091
+ }
11092
+ if (CFG.DEBUG) {
11093
+ console.log('[multiEntry] batch had no matches; fetching next batch');
11094
+ }
11095
+ runQuery();
11096
+ return;
11097
+ }
10857
11098
  var reverse = me.direction.indexOf('prev') === 0;
10858
11099
  rows.sort(function (a, b) {
10859
11100
  if (a.matchingKey.replaceAll(leftBracketRegex, 'z') < b.matchingKey.replaceAll(leftBracketRegex, 'z')) {
@@ -10870,47 +11111,31 @@
10870
11111
  }
10871
11112
  return 0;
10872
11113
  });
10873
- if (rows.length > 1) {
10874
- me.__prefetchedIndex = 0;
10875
- me.__prefetchedData = {
10876
- data: rows,
10877
- length: rows.length,
10878
- /**
10879
- * @param {Integer} index
10880
- * @returns {RowItemNonNull}
10881
- */
10882
- item: function item(index) {
10883
- return this.data[index];
10884
- }
10885
- };
10886
- if (CFG.DEBUG) {
10887
- console.log('Preloaded ' + me.__prefetchedData.length + ' records for multiEntry cursor');
10888
- }
10889
- me.__decode(rows[0], success);
10890
- } else if (rows.length === 1) {
10891
- if (CFG.DEBUG) {
10892
- console.log('Reached end of multiEntry cursor');
10893
- }
10894
- me.__decode(rows[0], success);
10895
- } else {
10896
- if (CFG.DEBUG) {
10897
- console.log('Reached end of multiEntry cursor');
11114
+ me.__prefetchedIndex = 0;
11115
+ me.__prefetchedData = {
11116
+ data: rows,
11117
+ length: rows.length,
11118
+ /**
11119
+ * @param {Integer} index
11120
+ * @returns {RowItemNonNull}
11121
+ */
11122
+ item: function item(index) {
11123
+ return this.data[index];
10898
11124
  }
10899
- success(undefined, undefined, undefined);
11125
+ };
11126
+ if (CFG.DEBUG) {
11127
+ console.log('[multiEntry] Preloaded ' + me.__prefetchedData.length + ' records for multiEntry cursor');
10900
11128
  }
10901
- } else {
11129
+ me.__decode(rows[0], success);
11130
+ }, function (tx, err) {
10902
11131
  if (CFG.DEBUG) {
10903
- console.log('Reached end of multiEntry cursor');
11132
+ console.log('[multiEntry] Could not execute Cursor.continue', sqlStr, sqlValues);
10904
11133
  }
10905
- success(undefined, undefined, undefined);
10906
- }
10907
- }, function (tx, err) {
10908
- if (CFG.DEBUG) {
10909
- console.log('Could not execute Cursor.continue', sqlStr, sqlValues);
10910
- }
10911
- error(err);
10912
- return false;
10913
- });
11134
+ error(err);
11135
+ return false;
11136
+ });
11137
+ }
11138
+ runQuery();
10914
11139
  };
10915
11140
 
10916
11141
  /**
@@ -10922,19 +11147,19 @@
10922
11147
  */
10923
11148
 
10924
11149
  /**
10925
- * @callback SuccessArg
10926
- * @param {StructuredCloneValue} value
10927
- * @param {import('./IDBRequest.js').IDBRequestFull} req
10928
- * @returns {void}
10929
- */
11150
+ * @callback SuccessArg
11151
+ * @param {StructuredCloneValue} value
11152
+ * @param {import('./IDBRequest.js').IDBRequestFull} req
11153
+ * @returns {void}
11154
+ */
10930
11155
 
10931
11156
  /**
10932
- * @callback SuccessCallback
10933
- * @param {IndexedDBKey} key
10934
- * @param {StructuredCloneValue} value
10935
- * @param {IndexedDBKey} primaryKey
10936
- * @returns {void}
10937
- */
11157
+ * @callback SuccessCallback
11158
+ * @param {IndexedDBKey} key
11159
+ * @param {StructuredCloneValue} value
11160
+ * @param {IndexedDBKey} primaryKey
11161
+ * @returns {void}
11162
+ */
10938
11163
 
10939
11164
  /**
10940
11165
  * Creates an "onsuccess" callback.
@@ -10962,11 +11187,11 @@
10962
11187
 
10963
11188
  /**
10964
11189
  * @typedef {{
10965
- * matchingKey: string,
10966
- * key: string,
10967
- * [k: string]: string
10968
- * }} RowItemNonNull
10969
- */
11190
+ * matchingKey: string,
11191
+ * key: string,
11192
+ * [k: string]: string
11193
+ * }} RowItemNonNull
11194
+ */
10970
11195
 
10971
11196
  /**
10972
11197
  *
@@ -11019,6 +11244,7 @@
11019
11244
  IDBCursor.prototype.__invalidateCache = function () {
11020
11245
  // @ts-expect-error Why is this not being found?
11021
11246
  this.__prefetchedData = null;
11247
+ this.__multiEntryExhausted = false;
11022
11248
  };
11023
11249
 
11024
11250
  /**
@@ -11074,8 +11300,8 @@
11074
11300
  me.__advanceCount--;
11075
11301
  me.__key = k;
11076
11302
  me.__continue(undefined, true);
11077
- /** @type {() => void} */
11078
- executeNextRequest(); // We don't call success yet but do need to advance the transaction queue
11303
+ // We don't call success yet but do need to advance the transaction queue
11304
+ runContinuationSafely(/** @type {() => void} */executeNextRequest);
11079
11305
  return;
11080
11306
  }
11081
11307
  me.__advanceCount = undefined;
@@ -11097,11 +11323,15 @@
11097
11323
  return;
11098
11324
  }
11099
11325
  // @ts-expect-error Todo: Our bug to fix
11100
- cursorContinue(tx, args, success, error);
11326
+ runContinuationSafely(function () {
11327
+ return cursorContinue(tx, args, success, error);
11328
+ });
11101
11329
  }
11102
11330
  if (me.__unique && !me.__multiEntryIndex && encKey === _encode(me.key, me.__multiEntryIndex)) {
11103
11331
  // @ts-expect-error Todo: Our bug to fix
11104
- cursorContinue(tx, args, success, error);
11332
+ runContinuationSafely(function () {
11333
+ return cursorContinue(tx, args, success, error);
11334
+ });
11105
11335
  return;
11106
11336
  }
11107
11337
  checkKey();