indexeddbshim 17.3.1 → 17.3.3

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 (33) hide show
  1. package/dist/IDBCursor.d.ts.map +1 -1
  2. package/dist/IDBFactory.d.ts.map +1 -1
  3. package/dist/IDBObjectStore.d.ts +28 -0
  4. package/dist/IDBObjectStore.d.ts.map +1 -1
  5. package/dist/IDBTransaction.d.ts.map +1 -1
  6. package/dist/indexeddbshim-Key.js +1 -1
  7. package/dist/indexeddbshim-Key.min.js +1 -1
  8. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +507 -150
  9. package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
  10. package/dist/indexeddbshim-UnicodeIdentifiers.js +334 -89
  11. package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
  12. package/dist/indexeddbshim-UnicodeIdentifiers.min.js +3 -3
  13. package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
  14. package/dist/indexeddbshim-node.cjs +507 -150
  15. package/dist/indexeddbshim-node.cjs.map +1 -1
  16. package/dist/indexeddbshim-noninvasive.js +334 -89
  17. package/dist/indexeddbshim-noninvasive.js.map +1 -1
  18. package/dist/indexeddbshim-noninvasive.min.js +3 -3
  19. package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
  20. package/dist/indexeddbshim.js +334 -89
  21. package/dist/indexeddbshim.js.map +1 -1
  22. package/dist/indexeddbshim.min.js +3 -3
  23. package/dist/indexeddbshim.min.js.map +1 -1
  24. package/dist/nodeSQLiteDatabase.d.ts.map +1 -1
  25. package/dist/nodeWebSQL.d.ts.map +1 -1
  26. package/package.json +4 -3
  27. package/src/IDBCursor.js +34 -4
  28. package/src/IDBFactory.js +119 -21
  29. package/src/IDBObjectStore.js +103 -1
  30. package/src/IDBRecord.js +8 -0
  31. package/src/IDBTransaction.js +16 -2
  32. package/src/nodeSQLiteDatabase.js +92 -26
  33. package/src/nodeWebSQL.js +8 -1
@@ -1,4 +1,4 @@
1
- /*! indexeddbshim - v17.3.1 - 8/24/2026 */
1
+ /*! indexeddbshim - v17.3.3 - 8/25/2026 */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -6156,9 +6156,15 @@
6156
6156
  if (err !== null) {
6157
6157
  me.__error = err;
6158
6158
  }
6159
- if (me.__requestsFinished) {
6159
+ if (me.__requestsFinished && err !== null) {
6160
6160
  // The transaction has already completed, so we can't call "onerror" or "onabort".
6161
- // So throw the error instead.
6161
+ // So throw the error instead. `err` is only ever `null` here via
6162
+ // `IDBTransaction.prototype.abort`'s own `__abortTransaction(null)`
6163
+ // call, which now checks `__requestsFinished` itself first and
6164
+ // throws `InvalidStateError` synchronously before ever reaching
6165
+ // this point -- so this guard is just defense in depth against
6166
+ // `err` somehow being `null` some other way, not something this
6167
+ // path should see in practice.
6162
6168
  setTimeout(function () {
6163
6169
  throw err;
6164
6170
  }, 0);
@@ -6278,6 +6284,14 @@
6278
6284
  if (me.__committed) {
6279
6285
  throw createDOMException('InvalidStateError', 'The transaction has already been committed');
6280
6286
  }
6287
+ if (me.__requestsFinished) {
6288
+ // All requests have already finished and the transaction is
6289
+ // auto-committing (the async SQL commit round trip just hasn't
6290
+ // resolved yet) -- too late to abort per spec, even though
6291
+ // `__committed` itself isn't set until that round trip actually
6292
+ // finishes.
6293
+ throw createDOMException('InvalidStateError', 'The transaction is already committing');
6294
+ }
6281
6295
  me.__abortTransaction(null);
6282
6296
  };
6283
6297
 
@@ -6602,22 +6616,22 @@
6602
6616
  sync: true
6603
6617
  }, this.options), s),
6604
6618
  c = i.sync,
6605
- y = {},
6606
- u = [],
6619
+ u = {},
6620
+ y = [],
6607
6621
  l = [],
6608
6622
  p = [],
6609
6623
  f = !("cyclic" in i) || i.cyclic,
6610
6624
  d = i.encapsulateObserver,
6611
6625
  m = i.encapsulateError,
6612
6626
  finish = function finish(e) {
6613
- var t = Object.values(y);
6627
+ var t = Object.values(u);
6614
6628
  if (i.iterateNone) return t.length ? t[0] : getJSONType(e);
6615
6629
  if (t.length) {
6616
6630
  if (i.returnTypeNames) return _toConsumableArray(new Set(t));
6617
- e && isPlainObject(e) && !n(e, "$types") ? e.$types = y : e = {
6631
+ e && isPlainObject(e) && !n(e, "$types") ? e.$types = u : e = {
6618
6632
  $: e,
6619
6633
  $types: {
6620
- $: y
6634
+ $: u
6621
6635
  }
6622
6636
  };
6623
6637
  } else isObject(e) && n(e, "$types") && (e = {
@@ -6641,18 +6655,18 @@
6641
6655
  _context2.n = 2;
6642
6656
  return Promise.all(r.map(/*#__PURE__*/function () {
6643
6657
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(r) {
6644
- var n, _t$splice, _t$splice2, a, _a, o, s, i, c, y, u, l, p, _t, _t2, _t3, _t4;
6658
+ var n, _t$splice, _t$splice2, a, _a, o, s, i, c, u, y, l, p, _t, _t2, _t3, _t4;
6645
6659
  return _regenerator().w(function (_context) {
6646
6660
  while (1) switch (_context.n) {
6647
6661
  case 0:
6648
- n = [], _t$splice = t.splice(0, 1), _t$splice2 = _slicedToArray(_t$splice, 1), a = _t$splice2[0], _a = _slicedToArray(a, 7), o = _a[0], s = _a[2], i = _a[3], c = _a[4], y = _a[5], u = _a[6], l = _encapsulate2(o, r, s, i, n, true, u), p = hasConstructorOf(l, TypesonPromise);
6662
+ n = [], _t$splice = t.splice(0, 1), _t$splice2 = _slicedToArray(_t$splice, 1), a = _t$splice2[0], _a = _slicedToArray(a, 7), o = _a[0], s = _a[2], i = _a[3], c = _a[4], u = _a[5], y = _a[6], l = _encapsulate2(o, r, s, i, n, true, y), p = hasConstructorOf(l, TypesonPromise);
6649
6663
  if (!(o && p)) {
6650
6664
  _context.n = 2;
6651
6665
  break;
6652
6666
  }
6653
6667
  _t2 = setOwnEnumerable;
6654
6668
  _t3 = c;
6655
- _t4 = y;
6669
+ _t4 = u;
6656
6670
  _context.n = 1;
6657
6671
  return l.p;
6658
6672
  case 1:
@@ -6661,7 +6675,7 @@
6661
6675
  _context.n = 3;
6662
6676
  break;
6663
6677
  case 2:
6664
- _t = (o ? setOwnEnumerable(c, y, l) : e = p ? l.p : l, _checkPromises(e, n));
6678
+ _t = (o ? setOwnEnumerable(c, u, l) : e = p ? l.p : l, _checkPromises(e, n));
6665
6679
  case 3:
6666
6680
  return _context.a(2, _t);
6667
6681
  }
@@ -6740,11 +6754,11 @@
6740
6754
  })) : h = t, b && b(), h;
6741
6755
  if (null === t) return b && b(), t;
6742
6756
  if (o && t && "object" == _typeof(t) && !s.iterateIn && !s.iterateUnsetNumeric) {
6743
- var _r2 = u.indexOf(t);
6744
- if (-1 !== _r2) return y[e] = "#", b && b({
6757
+ var _r2 = y.indexOf(t);
6758
+ if (-1 !== _r2) return u[e] = "#", b && b({
6745
6759
  cyclicKeypath: l[_r2]
6746
6760
  }), "#" + l[_r2];
6747
- true === o && (u.push(t), l.push(e));
6761
+ true === o && (y.push(t), l.push(e));
6748
6762
  }
6749
6763
  var v = isPlainObject(t),
6750
6764
  w = a(t),
@@ -6814,14 +6828,14 @@
6814
6828
  },
6815
6829
  replace = function replace(e, t, r, n, a, o, s) {
6816
6830
  var i = a ? _this2.plainObjectReplacers : _this2.nonplainObjectReplacers;
6817
- var u = i.length;
6818
- for (; u--;) {
6819
- var _a3 = i[u];
6831
+ var y = i.length;
6832
+ for (; y--;) {
6833
+ var _a3 = i[y];
6820
6834
  if (_a3.test(t, r)) {
6821
6835
  var _i2 = _a3.type;
6822
6836
  if (Object.hasOwn(_this2.revivers, _i2)) {
6823
- var _t5 = y[e];
6824
- y[e] = _t5 ? [_i2].concat(_t5) : _i2;
6837
+ var _t5 = u[e];
6838
+ u[e] = _t5 ? [_i2].concat(_t5) : _i2;
6825
6839
  }
6826
6840
  if (Object.assign(r, {
6827
6841
  type: _i2,
@@ -6829,14 +6843,14 @@
6829
6843
  }), (c || !_a3.replaceAsync) && !_a3.replace) return s && s({
6830
6844
  typeDetected: true
6831
6845
  }), _encapsulate2(e, t, f && "readonly", r, n, o, _i2);
6832
- var _u = void 0;
6846
+ var _y = void 0;
6833
6847
  if (s && s({
6834
6848
  replacing: true
6835
6849
  }), c || !_a3.replaceAsync) {
6836
6850
  if (void 0 === _a3.replace) throw new TypeError("Missing replacer");
6837
- _u = _a3.replace(t, r);
6838
- } else _u = _a3.replaceAsync(t, r);
6839
- return _encapsulate2(e, _u, f && "readonly", r, n, o, _i2);
6851
+ _y = _a3.replace(t, r);
6852
+ } else _y = _a3.replaceAsync(t, r);
6853
+ return _encapsulate2(e, _y, f && "readonly", r, n, o, _i2);
6840
6854
  }
6841
6855
  }
6842
6856
  return t;
@@ -6884,8 +6898,8 @@
6884
6898
  if (true === i) return finishRevival(e.$);
6885
6899
  if (!i || "object" != _typeof(i) || Array.isArray(i)) return finishRevival(e);
6886
6900
  var c = [],
6887
- y = Object.create(null),
6888
- u = {};
6901
+ u = Object.create(null),
6902
+ y = {};
6889
6903
  var l = true;
6890
6904
  i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, l = false);
6891
6905
  var executeReviver = function executeReviver(e, t) {
@@ -6895,8 +6909,8 @@
6895
6909
  r = _ref5[0];
6896
6910
  if (!r) throw new Error("Unregistered type: " + e);
6897
6911
  if (s && !("revive" in r)) return t;
6898
- if (!s && r.reviveAsync) return r.reviveAsync(t, u);
6899
- if (r.revive) return r.revive(t, u);
6912
+ if (!s && r.reviveAsync) return r.reviveAsync(t, y);
6913
+ if (r.revive) return r.revive(t, y);
6900
6914
  throw new Error("Missing reviver");
6901
6915
  },
6902
6916
  p = [];
@@ -6941,7 +6955,7 @@
6941
6955
  var d;
6942
6956
  return hasConstructorOf(f, TypesonPromise) ? d = f.then(function () {
6943
6957
  return e;
6944
- }) : (d = function _revive(e, t, o, u, f) {
6958
+ }) : (d = function _revive(e, t, o, y, f) {
6945
6959
  if (l && "$types" === e) return;
6946
6960
  var d = p.length,
6947
6961
  m = n(i, e) ? i[e] : void 0,
@@ -6962,18 +6976,18 @@
6962
6976
  _t6 = _c$[1],
6963
6977
  _r5 = _c$[2],
6964
6978
  _a5 = _c$[3],
6965
- _o2 = n(y, _t6),
6966
- _s = _o2 ? y[_t6] : getByKeyPath(_e2, _t6);
6979
+ _o2 = n(u, _t6),
6980
+ _s = _o2 ? u[_t6] : getByKeyPath(_e2, _t6);
6967
6981
  if (!_o2 && void 0 === _s) break;
6968
6982
  setOwnEnumerable(_r5, _a5, _s), c.shift();
6969
6983
  }
6970
6984
  }
6971
- if (!m) return y[e] = t, t;
6985
+ if (!m) return u[e] = t, t;
6972
6986
  if ("#" === m) {
6973
6987
  var _e3 = t.slice(1),
6974
- _r6 = n(y, _e3),
6975
- _a6 = _r6 ? y[_e3] : getByKeyPath(o, _e3);
6976
- return _r6 || void 0 !== _a6 || c.push([o, _e3, u, f]), _a6;
6988
+ _r6 = n(u, _e3),
6989
+ _a6 = _r6 ? u[_e3] : getByKeyPath(o, _e3);
6990
+ return _r6 || void 0 !== _a6 || c.push([o, _e3, y, f]), _a6;
6977
6991
  }
6978
6992
  var applyType = function applyType(t) {
6979
6993
  var r = [].concat(m).reduce(function reducer(e, t) {
@@ -6984,8 +6998,8 @@
6984
6998
  return executeReviver(t, e);
6985
6999
  }, t);
6986
7000
  return hasConstructorOf(r, TypesonPromise) ? r.then(function (t) {
6987
- return y[e] = t, t;
6988
- }) : (y[e] = r, r);
7001
+ return u[e] = t, t;
7002
+ }) : (u[e] = r, r);
6989
7003
  };
6990
7004
  return !s && p.length > d ? TypesonPromise.all(p.slice(d)).then(function () {
6991
7005
  return applyType(t);
@@ -7090,8 +7104,8 @@
7090
7104
  });
7091
7105
  Undefined.__typeson__type__ = "TypesonUndefined";
7092
7106
  var s = ["null", "boolean", "number", "string", "array", "object"];
7093
- for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), y = 0; y < 64; y++) c[i.codePointAt(y)] = y;
7094
- var u = function encode(e, t, r) {
7107
+ for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), u = 0; u < 64; u++) c[i.codePointAt(u)] = u;
7108
+ var y = function encode(e, t, r) {
7095
7109
  null == r && (r = e.byteLength);
7096
7110
  for (var n = new Uint8Array(e, 0, r), a = n.length, o = "", s = 0; s < a; s += 3) o += i[n[s] >> 2], o += i[(3 & n[s]) << 4 | n[s + 1] >> 4], o += i[(15 & n[s + 1]) << 2 | n[s + 2] >> 6], o += i[63 & n[s + 2]];
7097
7111
  return a % 3 == 2 ? o = o.slice(0, -1) + "=" : a % 3 == 1 && (o = o.slice(0, -2) + "=="), o;
@@ -7104,10 +7118,10 @@
7104
7118
  o,
7105
7119
  s,
7106
7120
  i = .75 * e.length,
7107
- y = 0;
7121
+ u = 0;
7108
7122
  "=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
7109
- for (var u = new ArrayBuffer(i, t), l = new Uint8Array(u), p = 0; p < r; p += 4) n = c[e.codePointAt(p)], a = c[e.codePointAt(p + 1)], o = c[e.codePointAt(p + 2)], s = c[e.codePointAt(p + 3)], l[y++] = n << 2 | a >> 4, l[y++] = (15 & a) << 4 | o >> 2, l[y++] = (3 & o) << 6 | 63 & s;
7110
- return u;
7123
+ for (var y = new ArrayBuffer(i, t), l = new Uint8Array(y), p = 0; p < r; p += 4) n = c[e.codePointAt(p)], a = c[e.codePointAt(p + 1)], o = c[e.codePointAt(p + 2)], s = c[e.codePointAt(p + 3)], l[u++] = n << 2 | a >> 4, l[u++] = (15 & a) << 4 | o >> 2, l[u++] = (3 & o) << 6 | 63 & s;
7124
+ return y;
7111
7125
  };
7112
7126
  var p = {
7113
7127
  arraybuffer: {
@@ -7120,7 +7134,7 @@
7120
7134
  return -1 !== r ? {
7121
7135
  index: r
7122
7136
  } : (t.buffers.push(e), {
7123
- s: u(e),
7137
+ s: y(e),
7124
7138
  maxByteLength: e.maxByteLength,
7125
7139
  resizable: e.resizable
7126
7140
  });
@@ -7154,13 +7168,13 @@
7154
7168
  });
7155
7169
  i.push(_r0), c += _r0;
7156
7170
  }
7157
- var y = new ArrayBuffer(c);
7158
- var u = 0;
7171
+ var u = new ArrayBuffer(c);
7172
+ var y = 0;
7159
7173
  for (var _t9 = 0; _t9 < s; _t9++) {
7160
- var _r1 = new Uint8Array(y, u, i[_t9]);
7174
+ var _r1 = new Uint8Array(u, y, i[_t9]);
7161
7175
  e.copyTo(_r1, {
7162
7176
  planeIndex: _t9
7163
- }), u += i[_t9];
7177
+ }), y += i[_t9];
7164
7178
  }
7165
7179
  return {
7166
7180
  format: t,
@@ -7168,7 +7182,7 @@
7168
7182
  numberOfFrames: n,
7169
7183
  numberOfChannels: a,
7170
7184
  timestamp: o,
7171
- data: y
7185
+ data: u
7172
7186
  };
7173
7187
  },
7174
7188
  revive: function revive(_ref11) {
@@ -7319,7 +7333,7 @@
7319
7333
  byteOffset: t,
7320
7334
  byteLength: r
7321
7335
  } : (n.buffers.push(e), {
7322
- encoded: u(e),
7336
+ encoded: y(e),
7323
7337
  maxByteLength: e.maxByteLength,
7324
7338
  resizable: e.resizable,
7325
7339
  byteOffset: t,
@@ -7951,7 +7965,7 @@
7951
7965
  } : (n.buffers.push(e), {
7952
7966
  maxByteLength: e.maxByteLength,
7953
7967
  resizable: e.resizable,
7954
- encoded: u(e),
7968
+ encoded: y(e),
7955
7969
  byteOffset: t,
7956
7970
  length: r
7957
7971
  });
@@ -7964,10 +7978,10 @@
7964
7978
  s = t.index,
7965
7979
  i = t.maxByteLength,
7966
7980
  c = t.resizable;
7967
- var y;
7968
- return "index" in t ? y = r.buffers[s] : (y = l(o, c ? {
7981
+ var u;
7982
+ return "index" in t ? u = r.buffers[s] : (u = l(o, c ? {
7969
7983
  maxByteLength: i
7970
- } : void 0), r.buffers.push(y)), new e(y, n, a);
7984
+ } : void 0), r.buffers.push(u)), new e(u, n, a);
7971
7985
  }
7972
7986
  };
7973
7987
  }(e);
@@ -8006,12 +8020,12 @@
8006
8020
  replaceAsync: function replaceAsync(e) {
8007
8021
  return new TypesonPromise(/*#__PURE__*/function () {
8008
8022
  var _ref29 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(t, r) {
8009
- var _r12, _n3, _a7, _o3, _s2, _i3, _c, _y, _u2, _l, _t14;
8023
+ var _r12, _n3, _a7, _o3, _s2, _i3, _c, _u, _y2, _l, _t14;
8010
8024
  return _regenerator().w(function (_context6) {
8011
8025
  while (1) switch (_context6.p = _context6.n) {
8012
8026
  case 0:
8013
8027
  _context6.p = 0;
8014
- _r12 = e.format, _n3 = e.codedWidth, _a7 = e.codedHeight, _o3 = e.timestamp, _s2 = e.duration, _i3 = e.visibleRect, _c = e.displayWidth, _y = e.displayHeight, _u2 = e.colorSpace, _l = new ArrayBuffer(e.allocationSize());
8028
+ _r12 = e.format, _n3 = e.codedWidth, _a7 = e.codedHeight, _o3 = e.timestamp, _s2 = e.duration, _i3 = e.visibleRect, _c = e.displayWidth, _u = e.displayHeight, _y2 = e.colorSpace, _l = new ArrayBuffer(e.allocationSize());
8015
8029
  _context6.n = 1;
8016
8030
  return e.copyTo(_l);
8017
8031
  case 1:
@@ -8028,12 +8042,12 @@
8028
8042
  height: _i3.height
8029
8043
  },
8030
8044
  displayWidth: _c,
8031
- displayHeight: _y,
8045
+ displayHeight: _u,
8032
8046
  colorSpace: {
8033
- primaries: _u2.primaries,
8034
- transfer: _u2.transfer,
8035
- matrix: _u2.matrix,
8036
- fullRange: _u2.fullRange
8047
+ primaries: _y2.primaries,
8048
+ transfer: _y2.transfer,
8049
+ matrix: _y2.matrix,
8050
+ fullRange: _y2.fullRange
8037
8051
  },
8038
8052
  data: _l
8039
8053
  });
@@ -8063,8 +8077,8 @@
8063
8077
  s = _ref30.displayWidth,
8064
8078
  i = _ref30.displayHeight,
8065
8079
  c = _ref30.colorSpace,
8066
- y = _ref30.data;
8067
- return new VideoFrame(new Uint8Array(y), {
8080
+ u = _ref30.data;
8081
+ return new VideoFrame(new Uint8Array(u), {
8068
8082
  format: e,
8069
8083
  codedWidth: t,
8070
8084
  codedHeight: r,
@@ -8136,11 +8150,11 @@
8136
8150
  }],
8137
8151
  ne = [D, M, L, F],
8138
8152
  ce = [Z, Y, re, K, ne, O, z, U, _, B, I, h, N, C].concat("function" == typeof Map ? k : [], "function" == typeof Set ? H : [], "function" == typeof ArrayBuffer ? p : [], "function" == typeof Uint8Array ? X : [], "function" == typeof DataView ? w : [], "undefined" != typeof crypto ? v : [], "undefined" != typeof BigInt ? [m, d] : [], "undefined" != typeof DOMException ? A : [], "undefined" != typeof QuotaExceededError ? W : [], "undefined" != typeof WebTransportError ? te : [], "undefined" != typeof DOMRect ? x : [], "undefined" != typeof DOMPoint ? S : [], "undefined" != typeof DOMQuad ? P : [], "undefined" != typeof DOMMatrix ? T : [], "undefined" != typeof AudioData ? f : [], "undefined" != typeof EncodedAudioChunk ? E : [], "undefined" != typeof EncodedVideoChunk ? j : [], "undefined" != typeof VideoFrame ? ee : []);
8139
- var ye = ce.concat({
8153
+ var ue = ce.concat({
8140
8154
  checkDataCloneException: {
8141
8155
  test: function test(e) {
8142
8156
  var t = {}.toString.call(e).slice(8, -1);
8143
- if (["symbol", "function"].includes(_typeof(e)) || ["Arguments", "Module", "Promise", "WeakMap", "WeakSet", "Event", "MessageChannel"].includes(t) || ["ArrayBuffer", "DataView", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array"].includes(t) && function isBufferDetached(e) {
8157
+ if (["symbol", "function"].includes(_typeof(e)) || ["Arguments", "Module", "Promise", "WeakMap", "WeakSet", "Event", "MessageChannel", "MessagePort"].includes(t) || e && e.constructor && ["MessageChannel", "MessagePort"].includes(e.constructor.name) || ["ArrayBuffer", "DataView", "Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array", "BigInt64Array", "BigUint64Array"].includes(t) && function isBufferDetached(e) {
8144
8158
  if ("boolean" == typeof e.detached) return e.detached;
8145
8159
  if (0 !== e.byteLength) return false;
8146
8160
  try {
@@ -8156,7 +8170,7 @@
8156
8170
 
8157
8171
  // See: https://stackoverflow.com/questions/42170826/categories-for-rejection-by-the-structured-cloning-algorithm
8158
8172
 
8159
- var typeson = new Typeson().register(ye);
8173
+ var typeson = new Typeson().register(ue);
8160
8174
 
8161
8175
  /**
8162
8176
  * @param {(preset: import('typeson-registry').Preset) =>
@@ -8165,7 +8179,7 @@
8165
8179
  */
8166
8180
  function register(func) {
8167
8181
  // eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Should be one-time cache
8168
- typeson = new Typeson().register(func(ye));
8182
+ typeson = new Typeson().register(func(ue));
8169
8183
  }
8170
8184
 
8171
8185
  /**
@@ -9228,6 +9242,11 @@
9228
9242
  * success: (key: import('./Key.js').Key, cn?: Integer) => void,
9229
9243
  * failCb: import('./Key.js').SQLFailureCallback
9230
9244
  * ) => void,
9245
+ * __checkIndexConstraints: (
9246
+ * tx: WebSQLTransaction,
9247
+ * value: import('./Key.js').Value,
9248
+ * excludeKey: import('./Key.js').Key|Integer|undefined
9249
+ * ) => SyncPromise,
9231
9250
  * __insertData: (
9232
9251
  * tx: WebSQLTransaction,
9233
9252
  * encoded: string,
@@ -9646,6 +9665,69 @@
9646
9665
  }
9647
9666
  };
9648
9667
 
9668
+ /**
9669
+ * Validates `value`'s unique index entries against the table's *current*
9670
+ * state without mutating anything -- used by `__storingRecordObjectStore`
9671
+ * to check a `put()`'s constraints *before* `__overwrite` deletes the
9672
+ * existing row for that key, so a rejected `put()` can't end up losing
9673
+ * the record it was trying to replace (see
9674
+ * `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
9675
+ * `excludeKey`, when given, treats a conflicting record as a non-conflict
9676
+ * if it's the very record being overwritten (its own current entry would
9677
+ * otherwise self-conflict on every no-op `put()` of an unchanged value).
9678
+ * `__insertData` below still runs its own (now redundant, but harmless --
9679
+ * the old row is gone by then) equivalent check as its first step; this
9680
+ * isn't merged into it because `__insertData` also performs the actual
9681
+ * `INSERT`, which cannot safely run before `__overwrite`'s `DELETE` when
9682
+ * overwriting an existing key.
9683
+ * @param {WebSQLTransaction} tx
9684
+ * @param {import('./Key.js').Value} value
9685
+ * @param {import('./Key.js').Key|Integer|undefined} excludeKey
9686
+ * @this {IDBObjectStoreFull}
9687
+ * @returns {SyncPromise}
9688
+ */
9689
+ IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeKey) {
9690
+ var me = this;
9691
+ var indexPromises = Object.keys(me.__indexes).map(function (indexName) {
9692
+ return new SyncPromise(function (resolve, reject) {
9693
+ var index = me.__indexes[indexName];
9694
+ if (index.__pendingCreate || index.__deleted || !index.unique) {
9695
+ resolve(undefined);
9696
+ return;
9697
+ }
9698
+ /**
9699
+ * @type {import('./Key.js').KeyValueObject|
9700
+ * import('./Key.js').KeyPathEvaluateValue}
9701
+ */
9702
+ var indexKey;
9703
+ try {
9704
+ indexKey = extractKeyValueDecodedFromValueUsingKeyPath(value, index.keyPath, index.multiEntry);
9705
+ if ('invalid' in indexKey && indexKey.invalid || 'failure' in indexKey && indexKey.failure) {
9706
+ throw new Error('Go to catch');
9707
+ }
9708
+ } catch (err) {
9709
+ resolve(undefined);
9710
+ return;
9711
+ }
9712
+ indexKey = indexKey.value;
9713
+ if (indexKey === undefined) {
9714
+ resolve(undefined);
9715
+ return;
9716
+ }
9717
+ var multiCheck = index.multiEntry && Array.isArray(indexKey);
9718
+ var fetchArgs = buildFetchIndexDataSQL(true, index, indexKey, 'key', multiCheck);
9719
+ executeFetchIndexData.apply(void 0, [null].concat(_toConsumableArray(fetchArgs), [tx, null, function success(key) {
9720
+ if (key === undefined || excludeKey !== undefined && cmp(key, excludeKey) === 0) {
9721
+ resolve(undefined);
9722
+ return;
9723
+ }
9724
+ reject(createDOMException('ConstraintError', 'Index already contains a record equal to ' + (multiCheck ? 'one of the subkeys of' : '') + '`indexKey`'));
9725
+ }, reject]));
9726
+ });
9727
+ });
9728
+ return SyncPromise.all(indexPromises);
9729
+ };
9730
+
9649
9731
  /**
9650
9732
  *
9651
9733
  * @param {WebSQLTransaction} tx
@@ -9907,7 +9989,32 @@
9907
9989
  }, error);
9908
9990
  }
9909
9991
  if (!noOverwrite) {
9910
- store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
9992
+ // Validate unique index constraints *before* `__overwrite`
9993
+ // deletes the existing row at this key -- otherwise a
9994
+ // `put()` that ends up rejected still permanently loses
9995
+ // the record it was trying to replace (see
9996
+ // `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
9997
+ store.__checkIndexConstraints(tx, value, clonedKeyOrCurrentNumber).then(function () {
9998
+ store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
9999
+ return undefined;
10000
+ /**
10001
+ * @param {Error|DOMException} err
10002
+ * @returns {null}
10003
+ */
10004
+ }).catch(function (err) {
10005
+ /**
10006
+ * @returns {void}
10007
+ */
10008
+ function fail() {
10009
+ error(err);
10010
+ }
10011
+ if (typeof oldCn === 'number') {
10012
+ assignCurrentNumber(tx, store, oldCn, fail, fail);
10013
+ return null;
10014
+ }
10015
+ fail();
10016
+ return null;
10017
+ });
9911
10018
  return;
9912
10019
  }
9913
10020
  insert(tx);
@@ -10999,7 +11106,29 @@
10999
11106
  return new SyncPromise(function (resolve) {
11000
11107
  setTimeout(function () {
11001
11108
  entry.dispatchEvent(e); // No need to catch errors
11002
- resolve(undefined);
11109
+ // Unlike a native `Promise`, `SyncPromise#then` chains
11110
+ // synchronously off `resolve()` (verified directly:
11111
+ // `SyncPromise.resolve().then(cb)` runs `cb` before
11112
+ // even the calling code below it finishes) -- so
11113
+ // resolving immediately here would let the
11114
+ // `connectionsClosed()` check below run before a
11115
+ // same-task-but-microtask-later continuation of a
11116
+ // `versionchange` listener above (e.g. an `await`-
11117
+ // based one that then calls `db.close()`, as in
11118
+ // `transaction-lifetime.any.js`) ever gets a turn,
11119
+ // incorrectly firing `blocked` even though the
11120
+ // connection was about to close in time. Give real
11121
+ // microtask-deferred continuations a small, bounded
11122
+ // number of turns first -- same pattern as
11123
+ // `IDBTransaction.js`'s `checkQueueEntry`.
11124
+ var attemptsLeft = 10;
11125
+ (function wait() {
11126
+ if (attemptsLeft-- <= 0) {
11127
+ resolve(undefined);
11128
+ return;
11129
+ }
11130
+ queueMicrotask(wait);
11131
+ })();
11003
11132
  }, 0);
11004
11133
  });
11005
11134
  });
@@ -11059,6 +11188,23 @@
11059
11188
  */
11060
11189
  var websqlDBCache = {};
11061
11190
 
11191
+ /**
11192
+ * Tracks databases with a creation/upgrade currently in flight but not yet
11193
+ * committed or aborted -- keyed by (unescaped) database name. The
11194
+ * `dbVersions` row in `sysdb` these entries shadow is written *before*
11195
+ * `upgradeneeded` is even dispatched to user code (as the success
11196
+ * callback of that very `INSERT`/`UPDATE`), on the same shared `sysdb`
11197
+ * connection `databases()` itself reads from -- so, absent this, a
11198
+ * `databases()` call made while an upgrade is still pending would see
11199
+ * the new row (or new version) immediately, rather than only once the
11200
+ * corresponding `versionchange` transaction has genuinely committed, as
11201
+ * required by `get-databases.any.js`'s "doesn't pick up changes that
11202
+ * haven't committed" test. `IDBFactory.prototype.databases` filters
11203
+ * its SQL results against this map.
11204
+ * @type {Map<string, {oldVersion: Integer, newVersion: Integer}>}
11205
+ */
11206
+ var pendingVersionChanges = new Map();
11207
+
11062
11208
  /** @type {import('websql-configurable/lib/websql/WebSQLDatabase.js').default} */
11063
11209
  var sysdb;
11064
11210
  var nameCounter = 0;
@@ -11361,6 +11507,19 @@
11361
11507
  if (calledDbCreateError) {
11362
11508
  return false;
11363
11509
  }
11510
+ // Defensive cleanup: `pendingVersionChanges.set(name, ...)` (see
11511
+ // below) runs *before* the `dbVersions` `INSERT`/`UPDATE` it
11512
+ // guards is even attempted, but only `versionSet`'s own
11513
+ // `on__beforecomplete`/`on__preabort` handlers ever clear it --
11514
+ // and `versionSet` never runs at all if that `INSERT`/`UPDATE`,
11515
+ // or an earlier step in this same `open()` flow, fails first.
11516
+ // Without this, such a failure would leave the entry orphaned
11517
+ // forever, silently corrupting `databases()` for any *other*,
11518
+ // unrelated later `open()` call that happens to reuse the same
11519
+ // database name (common in WPT tests, e.g. generic names like
11520
+ // "DB1"/"TestDatabase" reused across different test files in
11521
+ // the same process). A no-op if no entry was ever set.
11522
+ pendingVersionChanges.delete(name);
11364
11523
  var er = err ? webSQLErrback(err) : (/** @type {Error} */tx);
11365
11524
  calledDbCreateError = true;
11366
11525
  // Re: why bubbling here (and how cancelable is only really relevant for `window.onerror`) see: https://github.com/w3c/IndexedDB/issues/86
@@ -11472,22 +11631,43 @@
11472
11631
  // open/close the transaction's active-handler window itself.
11473
11632
  req.transaction.__handlerActive = true;
11474
11633
  req.dispatchEvent(e);
11475
- // Give any same-tick microtask scheduled from within the
11634
+ // Give any microtask-scheduled continuation of the
11476
11635
  // `upgradeneeded` handler (e.g. a plain
11477
- // `Promise.resolve().then(...)`) a chance to run -- and still
11478
- // observe the transaction as active -- before we deactivate it
11479
- // again, per https://github.com/w3c/IndexedDB/issues/87. Only
11480
- // the flag reset itself is deferred here -- unlike
11481
- // `IDBTransaction.js`'s `advanceAfterDispatch`, `finished()`
11482
- // (this transaction's own queue-advancement/completion signal)
11483
- // still runs synchronously, at exactly its previous timing: an
11484
- // earlier attempt at deferring `finished()` too raced against
11485
- // unrelated test setup that assumed a freshly deleted/created
11486
- // database's upgrade transaction had already fully completed by
11487
- // the time this function returns.
11488
- queueMicrotask(function () {
11489
- req.transaction.__handlerActive = false;
11490
- });
11636
+ // `Promise.resolve().then(...)`, or an `await`-based
11637
+ // continuation of a promise resolved from within the handler,
11638
+ // such as testharness.js's own `EventWatcher`) a chance to
11639
+ // run -- and still observe the transaction as active -- before
11640
+ // we deactivate it again, per
11641
+ // https://github.com/w3c/IndexedDB/issues/87. A single deferred
11642
+ // tick isn't always enough: an `await`-based continuation can
11643
+ // take more than one microtask turn to resume (e.g.
11644
+ // `transaction-lifetime.any.js`'s `EventWatcher`-based
11645
+ // `await eventWatcher.wait_for('upgradeneeded')`), so retry a
11646
+ // small, bounded number of times first -- same pattern as
11647
+ // `IDBTransaction.js`'s `checkQueueEntry` -- rather than
11648
+ // resetting after only one. Only the flag reset itself is
11649
+ // deferred here -- unlike `IDBTransaction.js`'s
11650
+ // `advanceAfterDispatch`, `finished()` (this transaction's own
11651
+ // queue-advancement/completion signal) still runs
11652
+ // synchronously, at exactly its previous timing: an earlier
11653
+ // attempt at deferring `finished()` too raced against unrelated
11654
+ // test setup that assumed a freshly deleted/created database's
11655
+ // upgrade transaction had already fully completed by the time
11656
+ // this function returns.
11657
+ /**
11658
+ * @param {Integer} attemptsLeft
11659
+ * @returns {void}
11660
+ */
11661
+ function deferHandlerActiveReset(attemptsLeft) {
11662
+ if (attemptsLeft <= 0) {
11663
+ req.transaction.__handlerActive = false;
11664
+ return;
11665
+ }
11666
+ queueMicrotask(function () {
11667
+ deferHandlerActiveReset(attemptsLeft - 1);
11668
+ });
11669
+ }
11670
+ deferHandlerActiveReset(10);
11491
11671
  if (e.__legacyOutputDidListenersThrowError) {
11492
11672
  logError('Error', 'An error occurred in an upgradeneeded handler attached to request chain', /** @type {Error} */e.__legacyOutputDidListenersThrowError); // We do nothing else with this error as per spec
11493
11673
  req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
@@ -11503,6 +11683,7 @@
11503
11683
  * @returns {void}
11504
11684
  */
11505
11685
  function (ev) {
11686
+ pendingVersionChanges.delete(name);
11506
11687
  connection.__upgradeTransaction = null;
11507
11688
  /** @type {import('./IDBDatabase.js').IDBDatabaseFull} */
11508
11689
  req.__result.__versionTransaction = null;
@@ -11517,6 +11698,7 @@
11517
11698
 
11518
11699
  // eslint-disable-next-line camelcase -- Clear API
11519
11700
  req.transaction.on__preabort = function () {
11701
+ pendingVersionChanges.delete(name);
11520
11702
  connection.__upgradeTransaction = null;
11521
11703
  // We ensure any cache is deleted before any request error events fire and try to reopen
11522
11704
  if (useDatabaseCache) {
@@ -11579,6 +11761,10 @@
11579
11761
  // });
11580
11762
  };
11581
11763
  }
11764
+ pendingVersionChanges.set(name, {
11765
+ oldVersion: oldVersion,
11766
+ newVersion: version
11767
+ });
11582
11768
  if (oldVersion === 0) {
11583
11769
  systx.executeSql('INSERT INTO dbVersions VALUES (?,?)', [sqlSafeName, version], versionSet, dbCreateError);
11584
11770
  } else {
@@ -11881,6 +12067,15 @@
11881
12067
  IDBFactory.prototype.databases = function () {
11882
12068
  var me = this;
11883
12069
  var calledDbCreateError = false;
12070
+ // Snapshotted *now*, synchronously, at call time -- not read later
12071
+ // from inside the SQL query's callback below, which runs on a
12072
+ // deferred macrotask (see `nodeSQLiteDatabase.js`'s `exec`) and so
12073
+ // could otherwise race against (and lose to) an in-flight upgrade's
12074
+ // own commit/abort handler clearing its `pendingVersionChanges`
12075
+ // entry in the meantime -- which would make this method incorrectly
12076
+ // reflect a since-committed change that hadn't committed yet when
12077
+ // it was actually called.
12078
+ var pendingVersionChangesSnapshot = new Map(pendingVersionChanges);
11884
12079
  return new Promise(function (resolve, reject) {
11885
12080
  // eslint-disable-line promise/avoid-new -- Own polyfill
11886
12081
  if (!(me instanceof IDBFactory)) {
@@ -11910,10 +12105,29 @@
11910
12105
  var dbNames = [];
11911
12106
  for (var i = 0; i < data.rows.length; i++) {
11912
12107
  var _data$rows$item2 = /** @type {{name: string, version: Integer}} */data.rows.item(i),
11913
- name = _data$rows$item2.name,
12108
+ encodedName = _data$rows$item2.name,
11914
12109
  version = _data$rows$item2.version;
12110
+ var name = unescapeSQLiteResponse(encodedName);
12111
+ // A row for a database whose creation/upgrade hasn't
12112
+ // committed yet (see `pendingVersionChanges`) must
12113
+ // not reflect that in-flight change: a brand new
12114
+ // database (`oldVersion === 0`) isn't reported at
12115
+ // all until its creation commits, and an existing
12116
+ // database being upgraded is still reported, but
12117
+ // with its pre-upgrade version.
12118
+ var pending = pendingVersionChangesSnapshot.get(name);
12119
+ if (pending) {
12120
+ if (pending.oldVersion === 0) {
12121
+ continue;
12122
+ }
12123
+ dbNames.push({
12124
+ name: name,
12125
+ version: pending.oldVersion
12126
+ });
12127
+ continue;
12128
+ }
11915
12129
  dbNames.push({
11916
- name: unescapeSQLiteResponse(name),
12130
+ name: name,
11917
12131
  version: version
11918
12132
  });
11919
12133
  }
@@ -12058,6 +12272,14 @@
12058
12272
  // We must resort to this to get "get <name>" as the function `name` for
12059
12273
  // proper IDL.
12060
12274
  var o = _defineAccessor("get", {}, prop, function () {
12275
+ // This is defined on the *shared* prototype (see above), so,
12276
+ // unlike a per-instance getter, it's reachable by calling it
12277
+ // directly on `IDBRecord.prototype` itself (not a real
12278
+ // instance) -- WebIDL requires that to throw.
12279
+ if (!(this instanceof IDBRecordAlias)) {
12280
+ throw new TypeError('Illegal invocation');
12281
+ }
12282
+ // @ts-ignore `this` is a real instance past the check above (not an issue in TS7)
12061
12283
  return this['__' + prop];
12062
12284
  });
12063
12285
  var desc = /** @type {PropertyDescriptor} */
@@ -12325,9 +12547,26 @@
12325
12547
  // Key.convertValueToKey(key); // Already checked by `continue` or `continuePrimaryKey`
12326
12548
  sqlValues.push(/** @type {string} */_encode(key));
12327
12549
  } else if (continueCall && me.__key !== undefined) {
12328
- sql.push('AND', quotedKeyColumnName, op + ' ?');
12329
12550
  // Key.convertValueToKey(me.__key); // Already checked when stored
12330
- sqlValues.push(/** @type {string} */_encode(me.__key));
12551
+ if (!me.__unique && me.__keyColumnName !== 'key' && me.__primaryKey !== undefined) {
12552
+ // A plain `continue()` on a non-unique index cursor must find
12553
+ // the next record strictly after the (key, primaryKey) pair
12554
+ // this cursor last returned -- a scalar `key > lastKey` alone
12555
+ // would wrongly exclude a *different*, not-yet-visited record
12556
+ // that's still tied on key with the last one (e.g. another
12557
+ // record that always had that same indexed value), and would
12558
+ // also wrongly re-admit the *same* record forever if a
12559
+ // same-transaction `update()` bumped its own key back above
12560
+ // the threshold, since a scalar comparison can't distinguish
12561
+ // "some other record newly tied" from "this record moved
12562
+ // past its own last position." Comparing the full tuple (via
12563
+ // this OR) against both key and primary key resolves both.
12564
+ sql.push('AND (', quotedKeyColumnName, op, '?', 'OR (', quotedKeyColumnName, '= ?', 'AND', quotedKey, op, '?))');
12565
+ sqlValues.push(/** @type {string} */_encode(me.__key), /** @type {string} */_encode(me.__key), /** @type {string} */_encode(me.__primaryKey));
12566
+ } else {
12567
+ sql.push('AND', quotedKeyColumnName, op + ' ?');
12568
+ sqlValues.push(/** @type {string} */_encode(me.__key));
12569
+ }
12331
12570
  }
12332
12571
  if (!me.__count) {
12333
12572
  // 1. Sort by key
@@ -12957,9 +13196,15 @@
12957
13196
  * @returns {void}
12958
13197
  */
12959
13198
  function addToQueue(clonedValue) {
12960
- // We set the `invalidateCache` argument to `false` since the old value shouldn't be accessed
13199
+ // `invalidateCache: true` so any cursor on this store (including
13200
+ // this one) drops its prefetched row batch, forcing its next
13201
+ // `continue()` to re-query live rather than serve rows snapshotted
13202
+ // before this update -- needed for the compound-tuple
13203
+ // continuation logic in `__findBasic` to see this update's
13204
+ // effect on ordering (see "Modify records during cursor
13205
+ // iteration" in idbcursor_update_index.any.js).
12961
13206
  // @ts-ignore -- API (not erring in TS 6)
12962
- IDBObjectStore.__storingRecordObjectStore(request, me.__store, false, clonedValue, false, key);
13207
+ IDBObjectStore.__storingRecordObjectStore(request, me.__store, true, clonedValue, false, key);
12963
13208
  }
12964
13209
  if (me.__store.keyPath !== null) {
12965
13210
  var _me$__store$__validat = me.__store.__validateKeyAndValueAndCloneValue(valueToUpdate, undefined, true),