indexeddbshim 17.3.1 → 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.1 - 8/24/2026 */
1
+ /*! indexeddbshim - v17.3.2 - 8/24/2026 */
2
2
 
3
3
  (function (factory) {
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -6607,22 +6607,22 @@
6607
6607
  sync: true
6608
6608
  }, this.options), s),
6609
6609
  c = i.sync,
6610
- y = {},
6611
- u = [],
6610
+ u = {},
6611
+ y = [],
6612
6612
  l = [],
6613
6613
  p = [],
6614
6614
  f = !("cyclic" in i) || i.cyclic,
6615
6615
  d = i.encapsulateObserver,
6616
6616
  m = i.encapsulateError,
6617
6617
  finish = function finish(e) {
6618
- var t = Object.values(y);
6618
+ var t = Object.values(u);
6619
6619
  if (i.iterateNone) return t.length ? t[0] : getJSONType(e);
6620
6620
  if (t.length) {
6621
6621
  if (i.returnTypeNames) return _toConsumableArray(new Set(t));
6622
- e && isPlainObject(e) && !n(e, "$types") ? e.$types = y : e = {
6622
+ e && isPlainObject(e) && !n(e, "$types") ? e.$types = u : e = {
6623
6623
  $: e,
6624
6624
  $types: {
6625
- $: y
6625
+ $: u
6626
6626
  }
6627
6627
  };
6628
6628
  } else isObject(e) && n(e, "$types") && (e = {
@@ -6646,18 +6646,18 @@
6646
6646
  _context2.n = 2;
6647
6647
  return Promise.all(r.map(/*#__PURE__*/function () {
6648
6648
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(r) {
6649
- var n, _t$splice, _t$splice2, a, _a, o, s, i, c, y, u, l, p, _t, _t2, _t3, _t4;
6649
+ var n, _t$splice, _t$splice2, a, _a, o, s, i, c, u, y, l, p, _t, _t2, _t3, _t4;
6650
6650
  return _regenerator().w(function (_context) {
6651
6651
  while (1) switch (_context.n) {
6652
6652
  case 0:
6653
- 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);
6653
+ 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);
6654
6654
  if (!(o && p)) {
6655
6655
  _context.n = 2;
6656
6656
  break;
6657
6657
  }
6658
6658
  _t2 = setOwnEnumerable;
6659
6659
  _t3 = c;
6660
- _t4 = y;
6660
+ _t4 = u;
6661
6661
  _context.n = 1;
6662
6662
  return l.p;
6663
6663
  case 1:
@@ -6666,7 +6666,7 @@
6666
6666
  _context.n = 3;
6667
6667
  break;
6668
6668
  case 2:
6669
- _t = (o ? setOwnEnumerable(c, y, l) : e = p ? l.p : l, _checkPromises(e, n));
6669
+ _t = (o ? setOwnEnumerable(c, u, l) : e = p ? l.p : l, _checkPromises(e, n));
6670
6670
  case 3:
6671
6671
  return _context.a(2, _t);
6672
6672
  }
@@ -6745,11 +6745,11 @@
6745
6745
  })) : h = t, b && b(), h;
6746
6746
  if (null === t) return b && b(), t;
6747
6747
  if (o && t && "object" == _typeof(t) && !s.iterateIn && !s.iterateUnsetNumeric) {
6748
- var _r2 = u.indexOf(t);
6749
- if (-1 !== _r2) return y[e] = "#", b && b({
6748
+ var _r2 = y.indexOf(t);
6749
+ if (-1 !== _r2) return u[e] = "#", b && b({
6750
6750
  cyclicKeypath: l[_r2]
6751
6751
  }), "#" + l[_r2];
6752
- true === o && (u.push(t), l.push(e));
6752
+ true === o && (y.push(t), l.push(e));
6753
6753
  }
6754
6754
  var v = isPlainObject(t),
6755
6755
  w = a(t),
@@ -6819,14 +6819,14 @@
6819
6819
  },
6820
6820
  replace = function replace(e, t, r, n, a, o, s) {
6821
6821
  var i = a ? _this2.plainObjectReplacers : _this2.nonplainObjectReplacers;
6822
- var u = i.length;
6823
- for (; u--;) {
6824
- var _a3 = i[u];
6822
+ var y = i.length;
6823
+ for (; y--;) {
6824
+ var _a3 = i[y];
6825
6825
  if (_a3.test(t, r)) {
6826
6826
  var _i2 = _a3.type;
6827
6827
  if (Object.hasOwn(_this2.revivers, _i2)) {
6828
- var _t5 = y[e];
6829
- y[e] = _t5 ? [_i2].concat(_t5) : _i2;
6828
+ var _t5 = u[e];
6829
+ u[e] = _t5 ? [_i2].concat(_t5) : _i2;
6830
6830
  }
6831
6831
  if (Object.assign(r, {
6832
6832
  type: _i2,
@@ -6834,14 +6834,14 @@
6834
6834
  }), (c || !_a3.replaceAsync) && !_a3.replace) return s && s({
6835
6835
  typeDetected: true
6836
6836
  }), _encapsulate2(e, t, f && "readonly", r, n, o, _i2);
6837
- var _u = void 0;
6837
+ var _y = void 0;
6838
6838
  if (s && s({
6839
6839
  replacing: true
6840
6840
  }), c || !_a3.replaceAsync) {
6841
6841
  if (void 0 === _a3.replace) throw new TypeError("Missing replacer");
6842
- _u = _a3.replace(t, r);
6843
- } else _u = _a3.replaceAsync(t, r);
6844
- return _encapsulate2(e, _u, f && "readonly", r, n, o, _i2);
6842
+ _y = _a3.replace(t, r);
6843
+ } else _y = _a3.replaceAsync(t, r);
6844
+ return _encapsulate2(e, _y, f && "readonly", r, n, o, _i2);
6845
6845
  }
6846
6846
  }
6847
6847
  return t;
@@ -6889,8 +6889,8 @@
6889
6889
  if (true === i) return finishRevival(e.$);
6890
6890
  if (!i || "object" != _typeof(i) || Array.isArray(i)) return finishRevival(e);
6891
6891
  var c = [],
6892
- y = Object.create(null),
6893
- u = {};
6892
+ u = Object.create(null),
6893
+ y = {};
6894
6894
  var l = true;
6895
6895
  i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, l = false);
6896
6896
  var executeReviver = function executeReviver(e, t) {
@@ -6900,8 +6900,8 @@
6900
6900
  r = _ref5[0];
6901
6901
  if (!r) throw new Error("Unregistered type: " + e);
6902
6902
  if (s && !("revive" in r)) return t;
6903
- if (!s && r.reviveAsync) return r.reviveAsync(t, u);
6904
- if (r.revive) return r.revive(t, u);
6903
+ if (!s && r.reviveAsync) return r.reviveAsync(t, y);
6904
+ if (r.revive) return r.revive(t, y);
6905
6905
  throw new Error("Missing reviver");
6906
6906
  },
6907
6907
  p = [];
@@ -6946,7 +6946,7 @@
6946
6946
  var d;
6947
6947
  return hasConstructorOf(f, TypesonPromise) ? d = f.then(function () {
6948
6948
  return e;
6949
- }) : (d = function _revive(e, t, o, u, f) {
6949
+ }) : (d = function _revive(e, t, o, y, f) {
6950
6950
  if (l && "$types" === e) return;
6951
6951
  var d = p.length,
6952
6952
  m = n(i, e) ? i[e] : void 0,
@@ -6967,18 +6967,18 @@
6967
6967
  _t6 = _c$[1],
6968
6968
  _r5 = _c$[2],
6969
6969
  _a5 = _c$[3],
6970
- _o2 = n(y, _t6),
6971
- _s = _o2 ? y[_t6] : getByKeyPath(_e2, _t6);
6970
+ _o2 = n(u, _t6),
6971
+ _s = _o2 ? u[_t6] : getByKeyPath(_e2, _t6);
6972
6972
  if (!_o2 && void 0 === _s) break;
6973
6973
  setOwnEnumerable(_r5, _a5, _s), c.shift();
6974
6974
  }
6975
6975
  }
6976
- if (!m) return y[e] = t, t;
6976
+ if (!m) return u[e] = t, t;
6977
6977
  if ("#" === m) {
6978
6978
  var _e3 = t.slice(1),
6979
- _r6 = n(y, _e3),
6980
- _a6 = _r6 ? y[_e3] : getByKeyPath(o, _e3);
6981
- return _r6 || void 0 !== _a6 || c.push([o, _e3, u, f]), _a6;
6979
+ _r6 = n(u, _e3),
6980
+ _a6 = _r6 ? u[_e3] : getByKeyPath(o, _e3);
6981
+ return _r6 || void 0 !== _a6 || c.push([o, _e3, y, f]), _a6;
6982
6982
  }
6983
6983
  var applyType = function applyType(t) {
6984
6984
  var r = [].concat(m).reduce(function reducer(e, t) {
@@ -6989,8 +6989,8 @@
6989
6989
  return executeReviver(t, e);
6990
6990
  }, t);
6991
6991
  return hasConstructorOf(r, TypesonPromise) ? r.then(function (t) {
6992
- return y[e] = t, t;
6993
- }) : (y[e] = r, r);
6992
+ return u[e] = t, t;
6993
+ }) : (u[e] = r, r);
6994
6994
  };
6995
6995
  return !s && p.length > d ? TypesonPromise.all(p.slice(d)).then(function () {
6996
6996
  return applyType(t);
@@ -7095,8 +7095,8 @@
7095
7095
  });
7096
7096
  Undefined.__typeson__type__ = "TypesonUndefined";
7097
7097
  var s = ["null", "boolean", "number", "string", "array", "object"];
7098
- for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), y = 0; y < 64; y++) c[i.codePointAt(y)] = y;
7099
- var u = function encode(e, t, r) {
7098
+ for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), u = 0; u < 64; u++) c[i.codePointAt(u)] = u;
7099
+ var y = function encode(e, t, r) {
7100
7100
  null == r && (r = e.byteLength);
7101
7101
  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]];
7102
7102
  return a % 3 == 2 ? o = o.slice(0, -1) + "=" : a % 3 == 1 && (o = o.slice(0, -2) + "=="), o;
@@ -7109,10 +7109,10 @@
7109
7109
  o,
7110
7110
  s,
7111
7111
  i = .75 * e.length,
7112
- y = 0;
7112
+ u = 0;
7113
7113
  "=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
7114
- 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;
7115
- return u;
7114
+ 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;
7115
+ return y;
7116
7116
  };
7117
7117
  var p = {
7118
7118
  arraybuffer: {
@@ -7125,7 +7125,7 @@
7125
7125
  return -1 !== r ? {
7126
7126
  index: r
7127
7127
  } : (t.buffers.push(e), {
7128
- s: u(e),
7128
+ s: y(e),
7129
7129
  maxByteLength: e.maxByteLength,
7130
7130
  resizable: e.resizable
7131
7131
  });
@@ -7159,13 +7159,13 @@
7159
7159
  });
7160
7160
  i.push(_r0), c += _r0;
7161
7161
  }
7162
- var y = new ArrayBuffer(c);
7163
- var u = 0;
7162
+ var u = new ArrayBuffer(c);
7163
+ var y = 0;
7164
7164
  for (var _t9 = 0; _t9 < s; _t9++) {
7165
- var _r1 = new Uint8Array(y, u, i[_t9]);
7165
+ var _r1 = new Uint8Array(u, y, i[_t9]);
7166
7166
  e.copyTo(_r1, {
7167
7167
  planeIndex: _t9
7168
- }), u += i[_t9];
7168
+ }), y += i[_t9];
7169
7169
  }
7170
7170
  return {
7171
7171
  format: t,
@@ -7173,7 +7173,7 @@
7173
7173
  numberOfFrames: n,
7174
7174
  numberOfChannels: a,
7175
7175
  timestamp: o,
7176
- data: y
7176
+ data: u
7177
7177
  };
7178
7178
  },
7179
7179
  revive: function revive(_ref11) {
@@ -7324,7 +7324,7 @@
7324
7324
  byteOffset: t,
7325
7325
  byteLength: r
7326
7326
  } : (n.buffers.push(e), {
7327
- encoded: u(e),
7327
+ encoded: y(e),
7328
7328
  maxByteLength: e.maxByteLength,
7329
7329
  resizable: e.resizable,
7330
7330
  byteOffset: t,
@@ -7956,7 +7956,7 @@
7956
7956
  } : (n.buffers.push(e), {
7957
7957
  maxByteLength: e.maxByteLength,
7958
7958
  resizable: e.resizable,
7959
- encoded: u(e),
7959
+ encoded: y(e),
7960
7960
  byteOffset: t,
7961
7961
  length: r
7962
7962
  });
@@ -7969,10 +7969,10 @@
7969
7969
  s = t.index,
7970
7970
  i = t.maxByteLength,
7971
7971
  c = t.resizable;
7972
- var y;
7973
- return "index" in t ? y = r.buffers[s] : (y = l(o, c ? {
7972
+ var u;
7973
+ return "index" in t ? u = r.buffers[s] : (u = l(o, c ? {
7974
7974
  maxByteLength: i
7975
- } : void 0), r.buffers.push(y)), new e(y, n, a);
7975
+ } : void 0), r.buffers.push(u)), new e(u, n, a);
7976
7976
  }
7977
7977
  };
7978
7978
  }(e);
@@ -8011,12 +8011,12 @@
8011
8011
  replaceAsync: function replaceAsync(e) {
8012
8012
  return new TypesonPromise(/*#__PURE__*/function () {
8013
8013
  var _ref29 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(t, r) {
8014
- var _r12, _n3, _a7, _o3, _s2, _i3, _c, _y, _u2, _l, _t14;
8014
+ var _r12, _n3, _a7, _o3, _s2, _i3, _c, _u, _y2, _l, _t14;
8015
8015
  return _regenerator().w(function (_context6) {
8016
8016
  while (1) switch (_context6.p = _context6.n) {
8017
8017
  case 0:
8018
8018
  _context6.p = 0;
8019
- _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());
8019
+ _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());
8020
8020
  _context6.n = 1;
8021
8021
  return e.copyTo(_l);
8022
8022
  case 1:
@@ -8033,12 +8033,12 @@
8033
8033
  height: _i3.height
8034
8034
  },
8035
8035
  displayWidth: _c,
8036
- displayHeight: _y,
8036
+ displayHeight: _u,
8037
8037
  colorSpace: {
8038
- primaries: _u2.primaries,
8039
- transfer: _u2.transfer,
8040
- matrix: _u2.matrix,
8041
- fullRange: _u2.fullRange
8038
+ primaries: _y2.primaries,
8039
+ transfer: _y2.transfer,
8040
+ matrix: _y2.matrix,
8041
+ fullRange: _y2.fullRange
8042
8042
  },
8043
8043
  data: _l
8044
8044
  });
@@ -8068,8 +8068,8 @@
8068
8068
  s = _ref30.displayWidth,
8069
8069
  i = _ref30.displayHeight,
8070
8070
  c = _ref30.colorSpace,
8071
- y = _ref30.data;
8072
- return new VideoFrame(new Uint8Array(y), {
8071
+ u = _ref30.data;
8072
+ return new VideoFrame(new Uint8Array(u), {
8073
8073
  format: e,
8074
8074
  codedWidth: t,
8075
8075
  codedHeight: r,
@@ -8141,11 +8141,11 @@
8141
8141
  }],
8142
8142
  ne = [D, M, L, F],
8143
8143
  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 : []);
8144
- var ye = ce.concat({
8144
+ var ue = ce.concat({
8145
8145
  checkDataCloneException: {
8146
8146
  test: function test(e) {
8147
8147
  var t = {}.toString.call(e).slice(8, -1);
8148
- 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) {
8148
+ 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) {
8149
8149
  if ("boolean" == typeof e.detached) return e.detached;
8150
8150
  if (0 !== e.byteLength) return false;
8151
8151
  try {
@@ -8161,7 +8161,7 @@
8161
8161
 
8162
8162
  // See: https://stackoverflow.com/questions/42170826/categories-for-rejection-by-the-structured-cloning-algorithm
8163
8163
 
8164
- var typeson = new Typeson().register(ye);
8164
+ var typeson = new Typeson().register(ue);
8165
8165
 
8166
8166
  /**
8167
8167
  * @param {(preset: import('typeson-registry').Preset) =>
@@ -8170,7 +8170,7 @@
8170
8170
  */
8171
8171
  function register(func) {
8172
8172
  // eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Should be one-time cache
8173
- typeson = new Typeson().register(func(ye));
8173
+ typeson = new Typeson().register(func(ue));
8174
8174
  }
8175
8175
 
8176
8176
  /**
@@ -9233,6 +9233,11 @@
9233
9233
  * success: (key: import('./Key.js').Key, cn?: Integer) => void,
9234
9234
  * failCb: import('./Key.js').SQLFailureCallback
9235
9235
  * ) => void,
9236
+ * __checkIndexConstraints: (
9237
+ * tx: WebSQLTransaction,
9238
+ * value: import('./Key.js').Value,
9239
+ * excludeKey: import('./Key.js').Key|Integer|undefined
9240
+ * ) => SyncPromise,
9236
9241
  * __insertData: (
9237
9242
  * tx: WebSQLTransaction,
9238
9243
  * encoded: string,
@@ -9651,6 +9656,69 @@
9651
9656
  }
9652
9657
  };
9653
9658
 
9659
+ /**
9660
+ * Validates `value`'s unique index entries against the table's *current*
9661
+ * state without mutating anything -- used by `__storingRecordObjectStore`
9662
+ * to check a `put()`'s constraints *before* `__overwrite` deletes the
9663
+ * existing row for that key, so a rejected `put()` can't end up losing
9664
+ * the record it was trying to replace (see
9665
+ * `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
9666
+ * `excludeKey`, when given, treats a conflicting record as a non-conflict
9667
+ * if it's the very record being overwritten (its own current entry would
9668
+ * otherwise self-conflict on every no-op `put()` of an unchanged value).
9669
+ * `__insertData` below still runs its own (now redundant, but harmless --
9670
+ * the old row is gone by then) equivalent check as its first step; this
9671
+ * isn't merged into it because `__insertData` also performs the actual
9672
+ * `INSERT`, which cannot safely run before `__overwrite`'s `DELETE` when
9673
+ * overwriting an existing key.
9674
+ * @param {WebSQLTransaction} tx
9675
+ * @param {import('./Key.js').Value} value
9676
+ * @param {import('./Key.js').Key|Integer|undefined} excludeKey
9677
+ * @this {IDBObjectStoreFull}
9678
+ * @returns {SyncPromise}
9679
+ */
9680
+ IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeKey) {
9681
+ var me = this;
9682
+ var indexPromises = Object.keys(me.__indexes).map(function (indexName) {
9683
+ return new SyncPromise(function (resolve, reject) {
9684
+ var index = me.__indexes[indexName];
9685
+ if (index.__pendingCreate || index.__deleted || !index.unique) {
9686
+ resolve(undefined);
9687
+ return;
9688
+ }
9689
+ /**
9690
+ * @type {import('./Key.js').KeyValueObject|
9691
+ * import('./Key.js').KeyPathEvaluateValue}
9692
+ */
9693
+ var indexKey;
9694
+ try {
9695
+ indexKey = extractKeyValueDecodedFromValueUsingKeyPath(value, index.keyPath, index.multiEntry);
9696
+ if ('invalid' in indexKey && indexKey.invalid || 'failure' in indexKey && indexKey.failure) {
9697
+ throw new Error('Go to catch');
9698
+ }
9699
+ } catch (err) {
9700
+ resolve(undefined);
9701
+ return;
9702
+ }
9703
+ indexKey = indexKey.value;
9704
+ if (indexKey === undefined) {
9705
+ resolve(undefined);
9706
+ return;
9707
+ }
9708
+ var multiCheck = index.multiEntry && Array.isArray(indexKey);
9709
+ var fetchArgs = buildFetchIndexDataSQL(true, index, indexKey, 'key', multiCheck);
9710
+ executeFetchIndexData.apply(void 0, [null].concat(_toConsumableArray(fetchArgs), [tx, null, function success(key) {
9711
+ if (key === undefined || excludeKey !== undefined && cmp(key, excludeKey) === 0) {
9712
+ resolve(undefined);
9713
+ return;
9714
+ }
9715
+ reject(createDOMException('ConstraintError', 'Index already contains a record equal to ' + (multiCheck ? 'one of the subkeys of' : '') + '`indexKey`'));
9716
+ }, reject]));
9717
+ });
9718
+ });
9719
+ return SyncPromise.all(indexPromises);
9720
+ };
9721
+
9654
9722
  /**
9655
9723
  *
9656
9724
  * @param {WebSQLTransaction} tx
@@ -9912,7 +9980,32 @@
9912
9980
  }, error);
9913
9981
  }
9914
9982
  if (!noOverwrite) {
9915
- store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
9983
+ // Validate unique index constraints *before* `__overwrite`
9984
+ // deletes the existing row at this key -- otherwise a
9985
+ // `put()` that ends up rejected still permanently loses
9986
+ // the record it was trying to replace (see
9987
+ // `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
9988
+ store.__checkIndexConstraints(tx, value, clonedKeyOrCurrentNumber).then(function () {
9989
+ store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
9990
+ return undefined;
9991
+ /**
9992
+ * @param {Error|DOMException} err
9993
+ * @returns {null}
9994
+ */
9995
+ }).catch(function (err) {
9996
+ /**
9997
+ * @returns {void}
9998
+ */
9999
+ function fail() {
10000
+ error(err);
10001
+ }
10002
+ if (typeof oldCn === 'number') {
10003
+ assignCurrentNumber(tx, store, oldCn, fail, fail);
10004
+ return null;
10005
+ }
10006
+ fail();
10007
+ return null;
10008
+ });
9916
10009
  return;
9917
10010
  }
9918
10011
  insert(tx);
@@ -12063,6 +12156,14 @@
12063
12156
  // We must resort to this to get "get <name>" as the function `name` for
12064
12157
  // proper IDL.
12065
12158
  var o = _defineAccessor("get", {}, prop, function () {
12159
+ // This is defined on the *shared* prototype (see above), so,
12160
+ // unlike a per-instance getter, it's reachable by calling it
12161
+ // directly on `IDBRecord.prototype` itself (not a real
12162
+ // instance) -- WebIDL requires that to throw.
12163
+ if (!(this instanceof IDBRecordAlias)) {
12164
+ throw new TypeError('Illegal invocation');
12165
+ }
12166
+ // @ts-ignore `this` is a real instance past the check above (not an issue in TS7)
12066
12167
  return this['__' + prop];
12067
12168
  });
12068
12169
  var desc = /** @type {PropertyDescriptor} */