indexeddbshim 17.3.0 → 17.3.2

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.
@@ -1,4 +1,4 @@
1
- /*! indexeddbshim - v17.3.0 - 8/24/2026 */
1
+ /*! indexeddbshim - v17.3.2 - 8/24/2026 */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -6602,22 +6602,22 @@
6602
6602
  sync: true
6603
6603
  }, this.options), s),
6604
6604
  c = i.sync,
6605
- y = {},
6606
- u = [],
6605
+ u = {},
6606
+ y = [],
6607
6607
  l = [],
6608
6608
  p = [],
6609
6609
  f = !("cyclic" in i) || i.cyclic,
6610
6610
  d = i.encapsulateObserver,
6611
6611
  m = i.encapsulateError,
6612
6612
  finish = function finish(e) {
6613
- var t = Object.values(y);
6613
+ var t = Object.values(u);
6614
6614
  if (i.iterateNone) return t.length ? t[0] : getJSONType(e);
6615
6615
  if (t.length) {
6616
6616
  if (i.returnTypeNames) return _toConsumableArray(new Set(t));
6617
- e && isPlainObject(e) && !n(e, "$types") ? e.$types = y : e = {
6617
+ e && isPlainObject(e) && !n(e, "$types") ? e.$types = u : e = {
6618
6618
  $: e,
6619
6619
  $types: {
6620
- $: y
6620
+ $: u
6621
6621
  }
6622
6622
  };
6623
6623
  } else isObject(e) && n(e, "$types") && (e = {
@@ -6641,18 +6641,18 @@
6641
6641
  _context2.n = 2;
6642
6642
  return Promise.all(r.map(/*#__PURE__*/function () {
6643
6643
  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;
6644
+ var n, _t$splice, _t$splice2, a, _a, o, s, i, c, u, y, l, p, _t, _t2, _t3, _t4;
6645
6645
  return _regenerator().w(function (_context) {
6646
6646
  while (1) switch (_context.n) {
6647
6647
  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);
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], u = _a[5], y = _a[6], l = _encapsulate2(o, r, s, i, n, true, y), p = hasConstructorOf(l, TypesonPromise);
6649
6649
  if (!(o && p)) {
6650
6650
  _context.n = 2;
6651
6651
  break;
6652
6652
  }
6653
6653
  _t2 = setOwnEnumerable;
6654
6654
  _t3 = c;
6655
- _t4 = y;
6655
+ _t4 = u;
6656
6656
  _context.n = 1;
6657
6657
  return l.p;
6658
6658
  case 1:
@@ -6661,7 +6661,7 @@
6661
6661
  _context.n = 3;
6662
6662
  break;
6663
6663
  case 2:
6664
- _t = (o ? setOwnEnumerable(c, y, l) : e = p ? l.p : l, _checkPromises(e, n));
6664
+ _t = (o ? setOwnEnumerable(c, u, l) : e = p ? l.p : l, _checkPromises(e, n));
6665
6665
  case 3:
6666
6666
  return _context.a(2, _t);
6667
6667
  }
@@ -6740,11 +6740,11 @@
6740
6740
  })) : h = t, b && b(), h;
6741
6741
  if (null === t) return b && b(), t;
6742
6742
  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({
6743
+ var _r2 = y.indexOf(t);
6744
+ if (-1 !== _r2) return u[e] = "#", b && b({
6745
6745
  cyclicKeypath: l[_r2]
6746
6746
  }), "#" + l[_r2];
6747
- true === o && (u.push(t), l.push(e));
6747
+ true === o && (y.push(t), l.push(e));
6748
6748
  }
6749
6749
  var v = isPlainObject(t),
6750
6750
  w = a(t),
@@ -6814,14 +6814,14 @@
6814
6814
  },
6815
6815
  replace = function replace(e, t, r, n, a, o, s) {
6816
6816
  var i = a ? _this2.plainObjectReplacers : _this2.nonplainObjectReplacers;
6817
- var u = i.length;
6818
- for (; u--;) {
6819
- var _a3 = i[u];
6817
+ var y = i.length;
6818
+ for (; y--;) {
6819
+ var _a3 = i[y];
6820
6820
  if (_a3.test(t, r)) {
6821
6821
  var _i2 = _a3.type;
6822
6822
  if (Object.hasOwn(_this2.revivers, _i2)) {
6823
- var _t5 = y[e];
6824
- y[e] = _t5 ? [_i2].concat(_t5) : _i2;
6823
+ var _t5 = u[e];
6824
+ u[e] = _t5 ? [_i2].concat(_t5) : _i2;
6825
6825
  }
6826
6826
  if (Object.assign(r, {
6827
6827
  type: _i2,
@@ -6829,14 +6829,14 @@
6829
6829
  }), (c || !_a3.replaceAsync) && !_a3.replace) return s && s({
6830
6830
  typeDetected: true
6831
6831
  }), _encapsulate2(e, t, f && "readonly", r, n, o, _i2);
6832
- var _u = void 0;
6832
+ var _y = void 0;
6833
6833
  if (s && s({
6834
6834
  replacing: true
6835
6835
  }), c || !_a3.replaceAsync) {
6836
6836
  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);
6837
+ _y = _a3.replace(t, r);
6838
+ } else _y = _a3.replaceAsync(t, r);
6839
+ return _encapsulate2(e, _y, f && "readonly", r, n, o, _i2);
6840
6840
  }
6841
6841
  }
6842
6842
  return t;
@@ -6884,8 +6884,8 @@
6884
6884
  if (true === i) return finishRevival(e.$);
6885
6885
  if (!i || "object" != _typeof(i) || Array.isArray(i)) return finishRevival(e);
6886
6886
  var c = [],
6887
- y = Object.create(null),
6888
- u = {};
6887
+ u = Object.create(null),
6888
+ y = {};
6889
6889
  var l = true;
6890
6890
  i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, l = false);
6891
6891
  var executeReviver = function executeReviver(e, t) {
@@ -6895,8 +6895,8 @@
6895
6895
  r = _ref5[0];
6896
6896
  if (!r) throw new Error("Unregistered type: " + e);
6897
6897
  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);
6898
+ if (!s && r.reviveAsync) return r.reviveAsync(t, y);
6899
+ if (r.revive) return r.revive(t, y);
6900
6900
  throw new Error("Missing reviver");
6901
6901
  },
6902
6902
  p = [];
@@ -6941,7 +6941,7 @@
6941
6941
  var d;
6942
6942
  return hasConstructorOf(f, TypesonPromise) ? d = f.then(function () {
6943
6943
  return e;
6944
- }) : (d = function _revive(e, t, o, u, f) {
6944
+ }) : (d = function _revive(e, t, o, y, f) {
6945
6945
  if (l && "$types" === e) return;
6946
6946
  var d = p.length,
6947
6947
  m = n(i, e) ? i[e] : void 0,
@@ -6962,18 +6962,18 @@
6962
6962
  _t6 = _c$[1],
6963
6963
  _r5 = _c$[2],
6964
6964
  _a5 = _c$[3],
6965
- _o2 = n(y, _t6),
6966
- _s = _o2 ? y[_t6] : getByKeyPath(_e2, _t6);
6965
+ _o2 = n(u, _t6),
6966
+ _s = _o2 ? u[_t6] : getByKeyPath(_e2, _t6);
6967
6967
  if (!_o2 && void 0 === _s) break;
6968
6968
  setOwnEnumerable(_r5, _a5, _s), c.shift();
6969
6969
  }
6970
6970
  }
6971
- if (!m) return y[e] = t, t;
6971
+ if (!m) return u[e] = t, t;
6972
6972
  if ("#" === m) {
6973
6973
  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;
6974
+ _r6 = n(u, _e3),
6975
+ _a6 = _r6 ? u[_e3] : getByKeyPath(o, _e3);
6976
+ return _r6 || void 0 !== _a6 || c.push([o, _e3, y, f]), _a6;
6977
6977
  }
6978
6978
  var applyType = function applyType(t) {
6979
6979
  var r = [].concat(m).reduce(function reducer(e, t) {
@@ -6984,8 +6984,8 @@
6984
6984
  return executeReviver(t, e);
6985
6985
  }, t);
6986
6986
  return hasConstructorOf(r, TypesonPromise) ? r.then(function (t) {
6987
- return y[e] = t, t;
6988
- }) : (y[e] = r, r);
6987
+ return u[e] = t, t;
6988
+ }) : (u[e] = r, r);
6989
6989
  };
6990
6990
  return !s && p.length > d ? TypesonPromise.all(p.slice(d)).then(function () {
6991
6991
  return applyType(t);
@@ -7090,8 +7090,8 @@
7090
7090
  });
7091
7091
  Undefined.__typeson__type__ = "TypesonUndefined";
7092
7092
  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) {
7093
+ for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), u = 0; u < 64; u++) c[i.codePointAt(u)] = u;
7094
+ var y = function encode(e, t, r) {
7095
7095
  null == r && (r = e.byteLength);
7096
7096
  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
7097
  return a % 3 == 2 ? o = o.slice(0, -1) + "=" : a % 3 == 1 && (o = o.slice(0, -2) + "=="), o;
@@ -7104,10 +7104,10 @@
7104
7104
  o,
7105
7105
  s,
7106
7106
  i = .75 * e.length,
7107
- y = 0;
7107
+ u = 0;
7108
7108
  "=" === 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;
7109
+ 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;
7110
+ return y;
7111
7111
  };
7112
7112
  var p = {
7113
7113
  arraybuffer: {
@@ -7120,7 +7120,7 @@
7120
7120
  return -1 !== r ? {
7121
7121
  index: r
7122
7122
  } : (t.buffers.push(e), {
7123
- s: u(e),
7123
+ s: y(e),
7124
7124
  maxByteLength: e.maxByteLength,
7125
7125
  resizable: e.resizable
7126
7126
  });
@@ -7154,13 +7154,13 @@
7154
7154
  });
7155
7155
  i.push(_r0), c += _r0;
7156
7156
  }
7157
- var y = new ArrayBuffer(c);
7158
- var u = 0;
7157
+ var u = new ArrayBuffer(c);
7158
+ var y = 0;
7159
7159
  for (var _t9 = 0; _t9 < s; _t9++) {
7160
- var _r1 = new Uint8Array(y, u, i[_t9]);
7160
+ var _r1 = new Uint8Array(u, y, i[_t9]);
7161
7161
  e.copyTo(_r1, {
7162
7162
  planeIndex: _t9
7163
- }), u += i[_t9];
7163
+ }), y += i[_t9];
7164
7164
  }
7165
7165
  return {
7166
7166
  format: t,
@@ -7168,7 +7168,7 @@
7168
7168
  numberOfFrames: n,
7169
7169
  numberOfChannels: a,
7170
7170
  timestamp: o,
7171
- data: y
7171
+ data: u
7172
7172
  };
7173
7173
  },
7174
7174
  revive: function revive(_ref11) {
@@ -7319,7 +7319,7 @@
7319
7319
  byteOffset: t,
7320
7320
  byteLength: r
7321
7321
  } : (n.buffers.push(e), {
7322
- encoded: u(e),
7322
+ encoded: y(e),
7323
7323
  maxByteLength: e.maxByteLength,
7324
7324
  resizable: e.resizable,
7325
7325
  byteOffset: t,
@@ -7951,7 +7951,7 @@
7951
7951
  } : (n.buffers.push(e), {
7952
7952
  maxByteLength: e.maxByteLength,
7953
7953
  resizable: e.resizable,
7954
- encoded: u(e),
7954
+ encoded: y(e),
7955
7955
  byteOffset: t,
7956
7956
  length: r
7957
7957
  });
@@ -7964,10 +7964,10 @@
7964
7964
  s = t.index,
7965
7965
  i = t.maxByteLength,
7966
7966
  c = t.resizable;
7967
- var y;
7968
- return "index" in t ? y = r.buffers[s] : (y = l(o, c ? {
7967
+ var u;
7968
+ return "index" in t ? u = r.buffers[s] : (u = l(o, c ? {
7969
7969
  maxByteLength: i
7970
- } : void 0), r.buffers.push(y)), new e(y, n, a);
7970
+ } : void 0), r.buffers.push(u)), new e(u, n, a);
7971
7971
  }
7972
7972
  };
7973
7973
  }(e);
@@ -8006,12 +8006,12 @@
8006
8006
  replaceAsync: function replaceAsync(e) {
8007
8007
  return new TypesonPromise(/*#__PURE__*/function () {
8008
8008
  var _ref29 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(t, r) {
8009
- var _r12, _n3, _a7, _o3, _s2, _i3, _c, _y, _u2, _l, _t14;
8009
+ var _r12, _n3, _a7, _o3, _s2, _i3, _c, _u, _y2, _l, _t14;
8010
8010
  return _regenerator().w(function (_context6) {
8011
8011
  while (1) switch (_context6.p = _context6.n) {
8012
8012
  case 0:
8013
8013
  _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());
8014
+ _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
8015
  _context6.n = 1;
8016
8016
  return e.copyTo(_l);
8017
8017
  case 1:
@@ -8028,12 +8028,12 @@
8028
8028
  height: _i3.height
8029
8029
  },
8030
8030
  displayWidth: _c,
8031
- displayHeight: _y,
8031
+ displayHeight: _u,
8032
8032
  colorSpace: {
8033
- primaries: _u2.primaries,
8034
- transfer: _u2.transfer,
8035
- matrix: _u2.matrix,
8036
- fullRange: _u2.fullRange
8033
+ primaries: _y2.primaries,
8034
+ transfer: _y2.transfer,
8035
+ matrix: _y2.matrix,
8036
+ fullRange: _y2.fullRange
8037
8037
  },
8038
8038
  data: _l
8039
8039
  });
@@ -8063,8 +8063,8 @@
8063
8063
  s = _ref30.displayWidth,
8064
8064
  i = _ref30.displayHeight,
8065
8065
  c = _ref30.colorSpace,
8066
- y = _ref30.data;
8067
- return new VideoFrame(new Uint8Array(y), {
8066
+ u = _ref30.data;
8067
+ return new VideoFrame(new Uint8Array(u), {
8068
8068
  format: e,
8069
8069
  codedWidth: t,
8070
8070
  codedHeight: r,
@@ -8136,11 +8136,11 @@
8136
8136
  }],
8137
8137
  ne = [D, M, L, F],
8138
8138
  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({
8139
+ var ue = ce.concat({
8140
8140
  checkDataCloneException: {
8141
8141
  test: function test(e) {
8142
8142
  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) {
8143
+ 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
8144
  if ("boolean" == typeof e.detached) return e.detached;
8145
8145
  if (0 !== e.byteLength) return false;
8146
8146
  try {
@@ -8156,7 +8156,7 @@
8156
8156
 
8157
8157
  // See: https://stackoverflow.com/questions/42170826/categories-for-rejection-by-the-structured-cloning-algorithm
8158
8158
 
8159
- var typeson = new Typeson().register(ye);
8159
+ var typeson = new Typeson().register(ue);
8160
8160
 
8161
8161
  /**
8162
8162
  * @param {(preset: import('typeson-registry').Preset) =>
@@ -8165,7 +8165,7 @@
8165
8165
  */
8166
8166
  function register(func) {
8167
8167
  // eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Should be one-time cache
8168
- typeson = new Typeson().register(func(ye));
8168
+ typeson = new Typeson().register(func(ue));
8169
8169
  }
8170
8170
 
8171
8171
  /**
@@ -9228,6 +9228,11 @@
9228
9228
  * success: (key: import('./Key.js').Key, cn?: Integer) => void,
9229
9229
  * failCb: import('./Key.js').SQLFailureCallback
9230
9230
  * ) => void,
9231
+ * __checkIndexConstraints: (
9232
+ * tx: WebSQLTransaction,
9233
+ * value: import('./Key.js').Value,
9234
+ * excludeKey: import('./Key.js').Key|Integer|undefined
9235
+ * ) => SyncPromise,
9231
9236
  * __insertData: (
9232
9237
  * tx: WebSQLTransaction,
9233
9238
  * encoded: string,
@@ -9646,6 +9651,69 @@
9646
9651
  }
9647
9652
  };
9648
9653
 
9654
+ /**
9655
+ * Validates `value`'s unique index entries against the table's *current*
9656
+ * state without mutating anything -- used by `__storingRecordObjectStore`
9657
+ * to check a `put()`'s constraints *before* `__overwrite` deletes the
9658
+ * existing row for that key, so a rejected `put()` can't end up losing
9659
+ * the record it was trying to replace (see
9660
+ * `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
9661
+ * `excludeKey`, when given, treats a conflicting record as a non-conflict
9662
+ * if it's the very record being overwritten (its own current entry would
9663
+ * otherwise self-conflict on every no-op `put()` of an unchanged value).
9664
+ * `__insertData` below still runs its own (now redundant, but harmless --
9665
+ * the old row is gone by then) equivalent check as its first step; this
9666
+ * isn't merged into it because `__insertData` also performs the actual
9667
+ * `INSERT`, which cannot safely run before `__overwrite`'s `DELETE` when
9668
+ * overwriting an existing key.
9669
+ * @param {WebSQLTransaction} tx
9670
+ * @param {import('./Key.js').Value} value
9671
+ * @param {import('./Key.js').Key|Integer|undefined} excludeKey
9672
+ * @this {IDBObjectStoreFull}
9673
+ * @returns {SyncPromise}
9674
+ */
9675
+ IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeKey) {
9676
+ var me = this;
9677
+ var indexPromises = Object.keys(me.__indexes).map(function (indexName) {
9678
+ return new SyncPromise(function (resolve, reject) {
9679
+ var index = me.__indexes[indexName];
9680
+ if (index.__pendingCreate || index.__deleted || !index.unique) {
9681
+ resolve(undefined);
9682
+ return;
9683
+ }
9684
+ /**
9685
+ * @type {import('./Key.js').KeyValueObject|
9686
+ * import('./Key.js').KeyPathEvaluateValue}
9687
+ */
9688
+ var indexKey;
9689
+ try {
9690
+ indexKey = extractKeyValueDecodedFromValueUsingKeyPath(value, index.keyPath, index.multiEntry);
9691
+ if ('invalid' in indexKey && indexKey.invalid || 'failure' in indexKey && indexKey.failure) {
9692
+ throw new Error('Go to catch');
9693
+ }
9694
+ } catch (err) {
9695
+ resolve(undefined);
9696
+ return;
9697
+ }
9698
+ indexKey = indexKey.value;
9699
+ if (indexKey === undefined) {
9700
+ resolve(undefined);
9701
+ return;
9702
+ }
9703
+ var multiCheck = index.multiEntry && Array.isArray(indexKey);
9704
+ var fetchArgs = buildFetchIndexDataSQL(true, index, indexKey, 'key', multiCheck);
9705
+ executeFetchIndexData.apply(void 0, [null].concat(_toConsumableArray(fetchArgs), [tx, null, function success(key) {
9706
+ if (key === undefined || excludeKey !== undefined && cmp(key, excludeKey) === 0) {
9707
+ resolve(undefined);
9708
+ return;
9709
+ }
9710
+ reject(createDOMException('ConstraintError', 'Index already contains a record equal to ' + (multiCheck ? 'one of the subkeys of' : '') + '`indexKey`'));
9711
+ }, reject]));
9712
+ });
9713
+ });
9714
+ return SyncPromise.all(indexPromises);
9715
+ };
9716
+
9649
9717
  /**
9650
9718
  *
9651
9719
  * @param {WebSQLTransaction} tx
@@ -9907,7 +9975,32 @@
9907
9975
  }, error);
9908
9976
  }
9909
9977
  if (!noOverwrite) {
9910
- store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
9978
+ // Validate unique index constraints *before* `__overwrite`
9979
+ // deletes the existing row at this key -- otherwise a
9980
+ // `put()` that ends up rejected still permanently loses
9981
+ // the record it was trying to replace (see
9982
+ // `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
9983
+ store.__checkIndexConstraints(tx, value, clonedKeyOrCurrentNumber).then(function () {
9984
+ store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
9985
+ return undefined;
9986
+ /**
9987
+ * @param {Error|DOMException} err
9988
+ * @returns {null}
9989
+ */
9990
+ }).catch(function (err) {
9991
+ /**
9992
+ * @returns {void}
9993
+ */
9994
+ function fail() {
9995
+ error(err);
9996
+ }
9997
+ if (typeof oldCn === 'number') {
9998
+ assignCurrentNumber(tx, store, oldCn, fail, fail);
9999
+ return null;
10000
+ }
10001
+ fail();
10002
+ return null;
10003
+ });
9911
10004
  return;
9912
10005
  }
9913
10006
  insert(tx);
@@ -11472,7 +11565,22 @@
11472
11565
  // open/close the transaction's active-handler window itself.
11473
11566
  req.transaction.__handlerActive = true;
11474
11567
  req.dispatchEvent(e);
11475
- req.transaction.__handlerActive = false;
11568
+ // Give any same-tick microtask scheduled from within the
11569
+ // `upgradeneeded` handler (e.g. a plain
11570
+ // `Promise.resolve().then(...)`) a chance to run -- and still
11571
+ // observe the transaction as active -- before we deactivate it
11572
+ // again, per https://github.com/w3c/IndexedDB/issues/87. Only
11573
+ // the flag reset itself is deferred here -- unlike
11574
+ // `IDBTransaction.js`'s `advanceAfterDispatch`, `finished()`
11575
+ // (this transaction's own queue-advancement/completion signal)
11576
+ // still runs synchronously, at exactly its previous timing: an
11577
+ // earlier attempt at deferring `finished()` too raced against
11578
+ // unrelated test setup that assumed a freshly deleted/created
11579
+ // database's upgrade transaction had already fully completed by
11580
+ // the time this function returns.
11581
+ queueMicrotask(function () {
11582
+ req.transaction.__handlerActive = false;
11583
+ });
11476
11584
  if (e.__legacyOutputDidListenersThrowError) {
11477
11585
  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
11478
11586
  req.transaction.__abortTransaction(createDOMException('AbortError', 'A request was aborted.'));
@@ -12043,6 +12151,14 @@
12043
12151
  // We must resort to this to get "get <name>" as the function `name` for
12044
12152
  // proper IDL.
12045
12153
  var o = _defineAccessor("get", {}, prop, function () {
12154
+ // This is defined on the *shared* prototype (see above), so,
12155
+ // unlike a per-instance getter, it's reachable by calling it
12156
+ // directly on `IDBRecord.prototype` itself (not a real
12157
+ // instance) -- WebIDL requires that to throw.
12158
+ if (!(this instanceof IDBRecordAlias)) {
12159
+ throw new TypeError('Illegal invocation');
12160
+ }
12161
+ // @ts-ignore `this` is a real instance past the check above (not an issue in TS7)
12046
12162
  return this['__' + prop];
12047
12163
  });
12048
12164
  var desc = /** @type {PropertyDescriptor} */
@@ -13546,8 +13662,24 @@
13546
13662
  Object.setPrototypeOf(IDBRequest, EventTarget);
13547
13663
  Object.setPrototypeOf(IDBTransaction, EventTarget);
13548
13664
  Object.setPrototypeOf(IDBVersionChangeEvent, ShimEvent);
13549
- Object.setPrototypeOf(ShimDOMException, Error);
13550
- Object.setPrototypeOf(ShimDOMException.prototype, Error.prototype);
13665
+ // `ShimDOMException` is the real native `DOMException` when one
13666
+ // is available (see `DOMException.js`'s `useNativeDOMException`)
13667
+ // -- which, unlike the shim classes above, is a single,
13668
+ // process-wide singleton shared by reference across every
13669
+ // sandbox this library gets installed into (see
13670
+ // `node-idb-test.js`'s `sandboxObj`). A native `DOMException`
13671
+ // already has the correct prototype chain out of the box
13672
+ // (`Object.getPrototypeOf(DOMException) === Function.prototype`,
13673
+ // not `Error`), so forcing it here isn't just unneeded but
13674
+ // actively wrong -- and, because it's shared, permanently
13675
+ // wrong for every later use of `DOMException` in the same
13676
+ // process (e.g. a later WPT test file's own idlharness-style
13677
+ // check that `DOMException` does *not* inherit from `Error`
13678
+ // on the class side), not just this one shim install.
13679
+ if (typeof DOMException === 'undefined' || ShimDOMException !== DOMException) {
13680
+ Object.setPrototypeOf(ShimDOMException, Error);
13681
+ Object.setPrototypeOf(ShimDOMException.prototype, Error.prototype);
13682
+ }
13551
13683
  }
13552
13684
  if (IDB.indexedDB && !IDB.indexedDB.toString().includes('[native code]')) {
13553
13685
  if (CFG.addNonIDBGlobals) {