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.
- package/dist/IDBObjectStore.d.ts +28 -0
- package/dist/IDBObjectStore.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +1 -1
- package/dist/indexeddbshim-Key.min.js +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +164 -63
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +166 -65
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +2 -2
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +164 -63
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +166 -65
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +2 -2
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +166 -65
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +2 -2
- package/dist/indexeddbshim.min.js.map +1 -1
- package/package.json +3 -2
- package/src/IDBObjectStore.js +103 -1
- package/src/IDBRecord.js +8 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! indexeddbshim - v17.3.
|
|
1
|
+
/*! indexeddbshim - v17.3.2 - 8/24/2026 */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -6135,8 +6135,8 @@ class Typeson {
|
|
|
6135
6135
|
{
|
|
6136
6136
|
sync: c
|
|
6137
6137
|
} = i,
|
|
6138
|
-
|
|
6139
|
-
|
|
6138
|
+
u = {},
|
|
6139
|
+
y = [],
|
|
6140
6140
|
l = [],
|
|
6141
6141
|
p = [],
|
|
6142
6142
|
f = !("cyclic" in i) || i.cyclic,
|
|
@@ -6145,14 +6145,14 @@ class Typeson {
|
|
|
6145
6145
|
encapsulateError: m
|
|
6146
6146
|
} = i,
|
|
6147
6147
|
finish = e => {
|
|
6148
|
-
const t = Object.values(
|
|
6148
|
+
const t = Object.values(u);
|
|
6149
6149
|
if (i.iterateNone) return t.length ? t[0] : getJSONType(e);
|
|
6150
6150
|
if (t.length) {
|
|
6151
6151
|
if (i.returnTypeNames) return [...new Set(t)];
|
|
6152
|
-
e && isPlainObject(e) && !n(e, "$types") ? e.$types =
|
|
6152
|
+
e && isPlainObject(e) && !n(e, "$types") ? e.$types = u : e = {
|
|
6153
6153
|
$: e,
|
|
6154
6154
|
$types: {
|
|
6155
|
-
$:
|
|
6155
|
+
$: u
|
|
6156
6156
|
}
|
|
6157
6157
|
};
|
|
6158
6158
|
} else isObject(e) && n(e, "$types") && (e = {
|
|
@@ -6166,10 +6166,10 @@ class Typeson {
|
|
|
6166
6166
|
return await Promise.all(r.map(async function (r) {
|
|
6167
6167
|
const n = [],
|
|
6168
6168
|
[a] = t.splice(0, 1),
|
|
6169
|
-
[o,, s, i, c,
|
|
6170
|
-
l = _encapsulate(o, r, s, i, n, true,
|
|
6169
|
+
[o,, s, i, c, u, y] = a,
|
|
6170
|
+
l = _encapsulate(o, r, s, i, n, true, y),
|
|
6171
6171
|
p = hasConstructorOf(l, TypesonPromise);
|
|
6172
|
-
return o && p ? (setOwnEnumerable(c,
|
|
6172
|
+
return o && p ? (setOwnEnumerable(c, u, await l.p), checkPromises(e, n)) : (o ? setOwnEnumerable(c, u, l) : e = p ? l.p : l, checkPromises(e, n));
|
|
6173
6173
|
})), e;
|
|
6174
6174
|
},
|
|
6175
6175
|
_adaptBuiltinStateObjectProperties = (e, t, r) => {
|
|
@@ -6229,11 +6229,11 @@ class Typeson {
|
|
|
6229
6229
|
})) : h = t, b && b(), h;
|
|
6230
6230
|
if (null === t) return b && b(), t;
|
|
6231
6231
|
if (o && t && "object" == typeof t && !s.iterateIn && !s.iterateUnsetNumeric) {
|
|
6232
|
-
const r =
|
|
6233
|
-
if (-1 !== r) return
|
|
6232
|
+
const r = y.indexOf(t);
|
|
6233
|
+
if (-1 !== r) return u[e] = "#", b && b({
|
|
6234
6234
|
cyclicKeypath: l[r]
|
|
6235
6235
|
}), "#" + l[r];
|
|
6236
|
-
true === o && (
|
|
6236
|
+
true === o && (y.push(t), l.push(e));
|
|
6237
6237
|
}
|
|
6238
6238
|
const v = isPlainObject(t),
|
|
6239
6239
|
w = a(t),
|
|
@@ -6297,16 +6297,16 @@ class Typeson {
|
|
|
6297
6297
|
},
|
|
6298
6298
|
replace = (e, t, r, n, a, o, s) => {
|
|
6299
6299
|
const i = a ? this.plainObjectReplacers : this.nonplainObjectReplacers;
|
|
6300
|
-
let
|
|
6301
|
-
for (;
|
|
6302
|
-
const a = i[
|
|
6300
|
+
let y = i.length;
|
|
6301
|
+
for (; y--;) {
|
|
6302
|
+
const a = i[y];
|
|
6303
6303
|
if (a.test(t, r)) {
|
|
6304
6304
|
const {
|
|
6305
6305
|
type: i
|
|
6306
6306
|
} = a;
|
|
6307
6307
|
if (Object.hasOwn(this.revivers, i)) {
|
|
6308
|
-
const t =
|
|
6309
|
-
|
|
6308
|
+
const t = u[e];
|
|
6309
|
+
u[e] = t ? [i].concat(t) : i;
|
|
6310
6310
|
}
|
|
6311
6311
|
if (Object.assign(r, {
|
|
6312
6312
|
type: i,
|
|
@@ -6314,14 +6314,14 @@ class Typeson {
|
|
|
6314
6314
|
}), (c || !a.replaceAsync) && !a.replace) return s && s({
|
|
6315
6315
|
typeDetected: true
|
|
6316
6316
|
}), _encapsulate(e, t, f && "readonly", r, n, o, i);
|
|
6317
|
-
let
|
|
6317
|
+
let y;
|
|
6318
6318
|
if (s && s({
|
|
6319
6319
|
replacing: true
|
|
6320
6320
|
}), c || !a.replaceAsync) {
|
|
6321
6321
|
if (void 0 === a.replace) throw new TypeError("Missing replacer");
|
|
6322
|
-
|
|
6323
|
-
} else
|
|
6324
|
-
return _encapsulate(e,
|
|
6322
|
+
y = a.replace(t, r);
|
|
6323
|
+
} else y = a.replaceAsync(t, r);
|
|
6324
|
+
return _encapsulate(e, y, f && "readonly", r, n, o, i);
|
|
6325
6325
|
}
|
|
6326
6326
|
}
|
|
6327
6327
|
return t;
|
|
@@ -6366,16 +6366,16 @@ class Typeson {
|
|
|
6366
6366
|
if (true === i) return finishRevival(e.$);
|
|
6367
6367
|
if (!i || "object" != typeof i || Array.isArray(i)) return finishRevival(e);
|
|
6368
6368
|
const c = [],
|
|
6369
|
-
|
|
6370
|
-
|
|
6369
|
+
u = Object.create(null),
|
|
6370
|
+
y = {};
|
|
6371
6371
|
let l = true;
|
|
6372
6372
|
i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, l = false);
|
|
6373
6373
|
const executeReviver = (e, t) => {
|
|
6374
6374
|
const [r] = this.revivers[e] ?? [];
|
|
6375
6375
|
if (!r) throw new Error("Unregistered type: " + e);
|
|
6376
6376
|
if (s && !("revive" in r)) return t;
|
|
6377
|
-
if (!s && r.reviveAsync) return r.reviveAsync(t,
|
|
6378
|
-
if (r.revive) return r.revive(t,
|
|
6377
|
+
if (!s && r.reviveAsync) return r.reviveAsync(t, y);
|
|
6378
|
+
if (r.revive) return r.revive(t, y);
|
|
6379
6379
|
throw new Error("Missing reviver");
|
|
6380
6380
|
},
|
|
6381
6381
|
p = [];
|
|
@@ -6413,7 +6413,7 @@ class Typeson {
|
|
|
6413
6413
|
}, void 0);
|
|
6414
6414
|
})();
|
|
6415
6415
|
let d;
|
|
6416
|
-
return hasConstructorOf(f, TypesonPromise) ? d = f.then(() => e) : (d = function _revive(e, t, o,
|
|
6416
|
+
return hasConstructorOf(f, TypesonPromise) ? d = f.then(() => e) : (d = function _revive(e, t, o, y, f) {
|
|
6417
6417
|
if (l && "$types" === e) return;
|
|
6418
6418
|
const d = p.length,
|
|
6419
6419
|
m = n(i, e) ? i[e] : void 0,
|
|
@@ -6426,18 +6426,18 @@ class Typeson {
|
|
|
6426
6426
|
hasConstructorOf(n, TypesonPromise) ? p.push(n.then(e => set(e))) : set(n);
|
|
6427
6427
|
}), t = a; c.length;) {
|
|
6428
6428
|
const [[e, t, r, a]] = c,
|
|
6429
|
-
o = n(
|
|
6430
|
-
s = o ?
|
|
6429
|
+
o = n(u, t),
|
|
6430
|
+
s = o ? u[t] : getByKeyPath(e, t);
|
|
6431
6431
|
if (!o && void 0 === s) break;
|
|
6432
6432
|
setOwnEnumerable(r, a, s), c.shift();
|
|
6433
6433
|
}
|
|
6434
6434
|
}
|
|
6435
|
-
if (!m) return
|
|
6435
|
+
if (!m) return u[e] = t, t;
|
|
6436
6436
|
if ("#" === m) {
|
|
6437
6437
|
const e = t.slice(1),
|
|
6438
|
-
r = n(
|
|
6439
|
-
a = r ?
|
|
6440
|
-
return r || void 0 !== a || c.push([o, e,
|
|
6438
|
+
r = n(u, e),
|
|
6439
|
+
a = r ? u[e] : getByKeyPath(o, e);
|
|
6440
|
+
return r || void 0 !== a || c.push([o, e, y, f]), a;
|
|
6441
6441
|
}
|
|
6442
6442
|
const applyType = t => {
|
|
6443
6443
|
const r = [].concat(m).reduce(function reducer(e, t) {
|
|
@@ -6445,7 +6445,7 @@ class Typeson {
|
|
|
6445
6445
|
if ("string" != typeof t) throw new TypeError("Bad type JSON");
|
|
6446
6446
|
return executeReviver(t, e);
|
|
6447
6447
|
}, t);
|
|
6448
|
-
return hasConstructorOf(r, TypesonPromise) ? r.then(t => (
|
|
6448
|
+
return hasConstructorOf(r, TypesonPromise) ? r.then(t => (u[e] = t, t)) : (u[e] = r, r);
|
|
6449
6449
|
};
|
|
6450
6450
|
return !s && p.length > d ? TypesonPromise.all(p.slice(d)).then(() => applyType(t)) : applyType(t);
|
|
6451
6451
|
}("", e, null), p.length && (d = TypesonPromise.resolve(d).then(e => TypesonPromise.all([e, ...p])).then(([e]) => e))), isThenable(d) ? s && o.throwOnBadSyncType ? (() => {
|
|
@@ -6521,8 +6521,8 @@ class Typeson {
|
|
|
6521
6521
|
class Undefined {}
|
|
6522
6522
|
Undefined.__typeson__type__ = "TypesonUndefined";
|
|
6523
6523
|
const s = ["null", "boolean", "number", "string", "array", "object"];
|
|
6524
|
-
for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256),
|
|
6525
|
-
var
|
|
6524
|
+
for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), u = 0; u < 64; u++) c[i.codePointAt(u)] = u;
|
|
6525
|
+
var y = function encode(e, t, r) {
|
|
6526
6526
|
null == r && (r = e.byteLength);
|
|
6527
6527
|
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]];
|
|
6528
6528
|
return a % 3 == 2 ? o = o.slice(0, -1) + "=" : a % 3 == 1 && (o = o.slice(0, -2) + "=="), o;
|
|
@@ -6535,10 +6535,10 @@ var u = function encode(e, t, r) {
|
|
|
6535
6535
|
o,
|
|
6536
6536
|
s,
|
|
6537
6537
|
i = .75 * e.length,
|
|
6538
|
-
|
|
6538
|
+
u = 0;
|
|
6539
6539
|
"=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
|
|
6540
|
-
for (var
|
|
6541
|
-
return
|
|
6540
|
+
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;
|
|
6541
|
+
return y;
|
|
6542
6542
|
};
|
|
6543
6543
|
const p = {
|
|
6544
6544
|
arraybuffer: {
|
|
@@ -6549,7 +6549,7 @@ const p = {
|
|
|
6549
6549
|
return -1 !== r ? {
|
|
6550
6550
|
index: r
|
|
6551
6551
|
} : (t.buffers.push(e), {
|
|
6552
|
-
s:
|
|
6552
|
+
s: y(e),
|
|
6553
6553
|
maxByteLength: e.maxByteLength,
|
|
6554
6554
|
resizable: e.resizable
|
|
6555
6555
|
});
|
|
@@ -6583,13 +6583,13 @@ const p = {
|
|
|
6583
6583
|
});
|
|
6584
6584
|
i.push(r), c += r;
|
|
6585
6585
|
}
|
|
6586
|
-
const
|
|
6587
|
-
let
|
|
6586
|
+
const u = new ArrayBuffer(c);
|
|
6587
|
+
let y = 0;
|
|
6588
6588
|
for (let t = 0; t < s; t++) {
|
|
6589
|
-
const r = new Uint8Array(
|
|
6589
|
+
const r = new Uint8Array(u, y, i[t]);
|
|
6590
6590
|
e.copyTo(r, {
|
|
6591
6591
|
planeIndex: t
|
|
6592
|
-
}),
|
|
6592
|
+
}), y += i[t];
|
|
6593
6593
|
}
|
|
6594
6594
|
return {
|
|
6595
6595
|
format: t,
|
|
@@ -6597,7 +6597,7 @@ const p = {
|
|
|
6597
6597
|
numberOfFrames: n,
|
|
6598
6598
|
numberOfChannels: a,
|
|
6599
6599
|
timestamp: o,
|
|
6600
|
-
data:
|
|
6600
|
+
data: u
|
|
6601
6601
|
};
|
|
6602
6602
|
},
|
|
6603
6603
|
revive: ({
|
|
@@ -6713,7 +6713,7 @@ const v = {
|
|
|
6713
6713
|
byteOffset: t,
|
|
6714
6714
|
byteLength: r
|
|
6715
6715
|
} : (n.buffers.push(e), {
|
|
6716
|
-
encoded:
|
|
6716
|
+
encoded: y(e),
|
|
6717
6717
|
maxByteLength: e.maxByteLength,
|
|
6718
6718
|
resizable: e.resizable,
|
|
6719
6719
|
byteOffset: t,
|
|
@@ -7199,7 +7199,7 @@ const X = {};
|
|
|
7199
7199
|
} : (n.buffers.push(e), {
|
|
7200
7200
|
maxByteLength: e.maxByteLength,
|
|
7201
7201
|
resizable: e.resizable,
|
|
7202
|
-
encoded:
|
|
7202
|
+
encoded: y(e),
|
|
7203
7203
|
byteOffset: t,
|
|
7204
7204
|
length: r
|
|
7205
7205
|
});
|
|
@@ -7214,10 +7214,10 @@ const X = {};
|
|
|
7214
7214
|
maxByteLength: i,
|
|
7215
7215
|
resizable: c
|
|
7216
7216
|
} = t;
|
|
7217
|
-
let
|
|
7218
|
-
return "index" in t ?
|
|
7217
|
+
let u;
|
|
7218
|
+
return "index" in t ? u = r.buffers[s] : (u = l(o, c ? {
|
|
7219
7219
|
maxByteLength: i
|
|
7220
|
-
} : void 0), r.buffers.push(
|
|
7220
|
+
} : void 0), r.buffers.push(u)), new e(u, n, a);
|
|
7221
7221
|
}
|
|
7222
7222
|
};
|
|
7223
7223
|
}(e));
|
|
@@ -7250,8 +7250,8 @@ const Y = {
|
|
|
7250
7250
|
duration: s,
|
|
7251
7251
|
visibleRect: i,
|
|
7252
7252
|
displayWidth: c,
|
|
7253
|
-
displayHeight:
|
|
7254
|
-
colorSpace:
|
|
7253
|
+
displayHeight: u,
|
|
7254
|
+
colorSpace: y
|
|
7255
7255
|
} = e,
|
|
7256
7256
|
l = new ArrayBuffer(e.allocationSize());
|
|
7257
7257
|
await e.copyTo(l), t({
|
|
@@ -7267,12 +7267,12 @@ const Y = {
|
|
|
7267
7267
|
height: i.height
|
|
7268
7268
|
},
|
|
7269
7269
|
displayWidth: c,
|
|
7270
|
-
displayHeight:
|
|
7270
|
+
displayHeight: u,
|
|
7271
7271
|
colorSpace: {
|
|
7272
|
-
primaries:
|
|
7273
|
-
transfer:
|
|
7274
|
-
matrix:
|
|
7275
|
-
fullRange:
|
|
7272
|
+
primaries: y.primaries,
|
|
7273
|
+
transfer: y.transfer,
|
|
7274
|
+
matrix: y.matrix,
|
|
7275
|
+
fullRange: y.fullRange
|
|
7276
7276
|
},
|
|
7277
7277
|
data: l
|
|
7278
7278
|
});
|
|
@@ -7290,8 +7290,8 @@ const Y = {
|
|
|
7290
7290
|
displayWidth: s,
|
|
7291
7291
|
displayHeight: i,
|
|
7292
7292
|
colorSpace: c,
|
|
7293
|
-
data:
|
|
7294
|
-
}) => new VideoFrame(new Uint8Array(
|
|
7293
|
+
data: u
|
|
7294
|
+
}) => new VideoFrame(new Uint8Array(u), {
|
|
7295
7295
|
format: e,
|
|
7296
7296
|
codedWidth: t,
|
|
7297
7297
|
codedHeight: r,
|
|
@@ -7345,11 +7345,11 @@ const Y = {
|
|
|
7345
7345
|
}],
|
|
7346
7346
|
ne = [D, M, L, F],
|
|
7347
7347
|
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 : []);
|
|
7348
|
-
const
|
|
7348
|
+
const ue = ce.concat({
|
|
7349
7349
|
checkDataCloneException: {
|
|
7350
7350
|
test(e) {
|
|
7351
7351
|
const t = {}.toString.call(e).slice(8, -1);
|
|
7352
|
-
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) {
|
|
7352
|
+
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) {
|
|
7353
7353
|
if ("boolean" == typeof e.detached) return e.detached;
|
|
7354
7354
|
if (0 !== e.byteLength) return false;
|
|
7355
7355
|
try {
|
|
@@ -7365,7 +7365,7 @@ const ye = ce.concat({
|
|
|
7365
7365
|
|
|
7366
7366
|
// See: https://stackoverflow.com/questions/42170826/categories-for-rejection-by-the-structured-cloning-algorithm
|
|
7367
7367
|
|
|
7368
|
-
let typeson = new Typeson().register(
|
|
7368
|
+
let typeson = new Typeson().register(ue);
|
|
7369
7369
|
|
|
7370
7370
|
/**
|
|
7371
7371
|
* @param {(preset: import('typeson-registry').Preset) =>
|
|
@@ -7374,7 +7374,7 @@ let typeson = new Typeson().register(ye);
|
|
|
7374
7374
|
*/
|
|
7375
7375
|
function register(func) {
|
|
7376
7376
|
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Should be one-time cache
|
|
7377
|
-
typeson = new Typeson().register(func(
|
|
7377
|
+
typeson = new Typeson().register(func(ue));
|
|
7378
7378
|
}
|
|
7379
7379
|
|
|
7380
7380
|
/**
|
|
@@ -8424,6 +8424,11 @@ const IDBObjectStoreAlias = IDBObjectStore;
|
|
|
8424
8424
|
* success: (key: import('./Key.js').Key, cn?: Integer) => void,
|
|
8425
8425
|
* failCb: import('./Key.js').SQLFailureCallback
|
|
8426
8426
|
* ) => void,
|
|
8427
|
+
* __checkIndexConstraints: (
|
|
8428
|
+
* tx: WebSQLTransaction,
|
|
8429
|
+
* value: import('./Key.js').Value,
|
|
8430
|
+
* excludeKey: import('./Key.js').Key|Integer|undefined
|
|
8431
|
+
* ) => SyncPromise,
|
|
8427
8432
|
* __insertData: (
|
|
8428
8433
|
* tx: WebSQLTransaction,
|
|
8429
8434
|
* encoded: string,
|
|
@@ -8844,6 +8849,69 @@ IDBObjectStore.prototype.__deriveKey = function (tx, value, key, success, failCb
|
|
|
8844
8849
|
}
|
|
8845
8850
|
};
|
|
8846
8851
|
|
|
8852
|
+
/**
|
|
8853
|
+
* Validates `value`'s unique index entries against the table's *current*
|
|
8854
|
+
* state without mutating anything -- used by `__storingRecordObjectStore`
|
|
8855
|
+
* to check a `put()`'s constraints *before* `__overwrite` deletes the
|
|
8856
|
+
* existing row for that key, so a rejected `put()` can't end up losing
|
|
8857
|
+
* the record it was trying to replace (see
|
|
8858
|
+
* `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
|
|
8859
|
+
* `excludeKey`, when given, treats a conflicting record as a non-conflict
|
|
8860
|
+
* if it's the very record being overwritten (its own current entry would
|
|
8861
|
+
* otherwise self-conflict on every no-op `put()` of an unchanged value).
|
|
8862
|
+
* `__insertData` below still runs its own (now redundant, but harmless --
|
|
8863
|
+
* the old row is gone by then) equivalent check as its first step; this
|
|
8864
|
+
* isn't merged into it because `__insertData` also performs the actual
|
|
8865
|
+
* `INSERT`, which cannot safely run before `__overwrite`'s `DELETE` when
|
|
8866
|
+
* overwriting an existing key.
|
|
8867
|
+
* @param {WebSQLTransaction} tx
|
|
8868
|
+
* @param {import('./Key.js').Value} value
|
|
8869
|
+
* @param {import('./Key.js').Key|Integer|undefined} excludeKey
|
|
8870
|
+
* @this {IDBObjectStoreFull}
|
|
8871
|
+
* @returns {SyncPromise}
|
|
8872
|
+
*/
|
|
8873
|
+
IDBObjectStore.prototype.__checkIndexConstraints = function (tx, value, excludeKey) {
|
|
8874
|
+
const me = this;
|
|
8875
|
+
const indexPromises = Object.keys(me.__indexes).map(indexName => {
|
|
8876
|
+
return new SyncPromise((resolve, reject) => {
|
|
8877
|
+
const index = me.__indexes[indexName];
|
|
8878
|
+
if (index.__pendingCreate || index.__deleted || !index.unique) {
|
|
8879
|
+
resolve(undefined);
|
|
8880
|
+
return;
|
|
8881
|
+
}
|
|
8882
|
+
/**
|
|
8883
|
+
* @type {import('./Key.js').KeyValueObject|
|
|
8884
|
+
* import('./Key.js').KeyPathEvaluateValue}
|
|
8885
|
+
*/
|
|
8886
|
+
let indexKey;
|
|
8887
|
+
try {
|
|
8888
|
+
indexKey = extractKeyValueDecodedFromValueUsingKeyPath(value, index.keyPath, index.multiEntry);
|
|
8889
|
+
if ('invalid' in indexKey && indexKey.invalid || 'failure' in indexKey && indexKey.failure) {
|
|
8890
|
+
throw new Error('Go to catch');
|
|
8891
|
+
}
|
|
8892
|
+
} catch (err) {
|
|
8893
|
+
resolve(undefined);
|
|
8894
|
+
return;
|
|
8895
|
+
}
|
|
8896
|
+
indexKey = indexKey.value;
|
|
8897
|
+
if (indexKey === undefined) {
|
|
8898
|
+
resolve(undefined);
|
|
8899
|
+
return;
|
|
8900
|
+
}
|
|
8901
|
+
const multiCheck = index.multiEntry && Array.isArray(indexKey);
|
|
8902
|
+
const fetchArgs = buildFetchIndexDataSQL(true, index, indexKey, 'key', multiCheck);
|
|
8903
|
+
executeFetchIndexData(null, ...fetchArgs, tx, null, function success(key) {
|
|
8904
|
+
if (key === undefined || excludeKey !== undefined && cmp(key, excludeKey) === 0) {
|
|
8905
|
+
resolve(undefined);
|
|
8906
|
+
return;
|
|
8907
|
+
}
|
|
8908
|
+
reject(createDOMException('ConstraintError', 'Index already contains a record equal to ' + (multiCheck ? 'one of the subkeys of' : '') + '`indexKey`'));
|
|
8909
|
+
}, reject);
|
|
8910
|
+
});
|
|
8911
|
+
});
|
|
8912
|
+
return SyncPromise.all(indexPromises);
|
|
8913
|
+
};
|
|
8914
|
+
|
|
8847
8915
|
/**
|
|
8848
8916
|
*
|
|
8849
8917
|
* @param {WebSQLTransaction} tx
|
|
@@ -9096,7 +9164,32 @@ IDBObjectStore.__storingRecordObjectStore = function (request, store, invalidate
|
|
|
9096
9164
|
}, error);
|
|
9097
9165
|
}
|
|
9098
9166
|
if (!noOverwrite) {
|
|
9099
|
-
|
|
9167
|
+
// Validate unique index constraints *before* `__overwrite`
|
|
9168
|
+
// deletes the existing row at this key -- otherwise a
|
|
9169
|
+
// `put()` that ends up rejected still permanently loses
|
|
9170
|
+
// the record it was trying to replace (see
|
|
9171
|
+
// `idbobjectstore-put-unique-index-constraint-is-atomic.any.js`).
|
|
9172
|
+
store.__checkIndexConstraints(tx, value, clonedKeyOrCurrentNumber).then(() => {
|
|
9173
|
+
store.__overwrite(tx, clonedKeyOrCurrentNumber, insert, error);
|
|
9174
|
+
return undefined;
|
|
9175
|
+
/**
|
|
9176
|
+
* @param {Error|DOMException} err
|
|
9177
|
+
* @returns {null}
|
|
9178
|
+
*/
|
|
9179
|
+
}).catch(function (err) {
|
|
9180
|
+
/**
|
|
9181
|
+
* @returns {void}
|
|
9182
|
+
*/
|
|
9183
|
+
function fail() {
|
|
9184
|
+
error(err);
|
|
9185
|
+
}
|
|
9186
|
+
if (typeof oldCn === 'number') {
|
|
9187
|
+
assignCurrentNumber(tx, store, oldCn, fail, fail);
|
|
9188
|
+
return null;
|
|
9189
|
+
}
|
|
9190
|
+
fail();
|
|
9191
|
+
return null;
|
|
9192
|
+
});
|
|
9100
9193
|
return;
|
|
9101
9194
|
}
|
|
9102
9195
|
insert(tx);
|
|
@@ -11034,6 +11127,14 @@ readonlyProperties.forEach(prop => {
|
|
|
11034
11127
|
* @returns {import('./Key.js').Key|import('./Key.js').Value}
|
|
11035
11128
|
*/
|
|
11036
11129
|
get [prop]() {
|
|
11130
|
+
// This is defined on the *shared* prototype (see above), so,
|
|
11131
|
+
// unlike a per-instance getter, it's reachable by calling it
|
|
11132
|
+
// directly on `IDBRecord.prototype` itself (not a real
|
|
11133
|
+
// instance) -- WebIDL requires that to throw.
|
|
11134
|
+
if (!(this instanceof IDBRecordAlias)) {
|
|
11135
|
+
throw new TypeError('Illegal invocation');
|
|
11136
|
+
}
|
|
11137
|
+
// @ts-ignore `this` is a real instance past the check above (not an issue in TS7)
|
|
11037
11138
|
return this['__' + prop];
|
|
11038
11139
|
}
|
|
11039
11140
|
};
|