indexeddbshim 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/badges/licenses-badge-dev.svg +1 -1
- package/badges/licenses-badge.svg +1 -1
- package/dist/CFG.d.ts.map +1 -1
- package/dist/DOMException.d.ts.map +1 -1
- package/dist/DOMStringList.d.ts.map +1 -1
- package/dist/IDBCursor.d.ts +5 -2
- package/dist/IDBCursor.d.ts.map +1 -1
- package/dist/IDBDatabase.d.ts +2 -1
- package/dist/IDBDatabase.d.ts.map +1 -1
- package/dist/IDBFactory.d.ts +2 -1
- package/dist/IDBFactory.d.ts.map +1 -1
- package/dist/IDBIndex.d.ts +2 -1
- package/dist/IDBIndex.d.ts.map +1 -1
- package/dist/IDBKeyRange.d.ts +1 -1
- package/dist/IDBKeyRange.d.ts.map +1 -1
- package/dist/IDBObjectStore.d.ts +2 -1
- package/dist/IDBObjectStore.d.ts.map +1 -1
- package/dist/IDBRequest.d.ts +5 -3
- package/dist/IDBRequest.d.ts.map +1 -1
- package/dist/IDBTransaction.d.ts +2 -1
- package/dist/IDBTransaction.d.ts.map +1 -1
- package/dist/Key.d.ts.map +1 -1
- package/dist/Sca.d.ts.map +1 -1
- package/dist/UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/browser-noninvasive.d.ts.map +1 -1
- package/dist/indexeddbshim-Key.js +32 -27
- package/dist/indexeddbshim-Key.js.map +1 -1
- package/dist/indexeddbshim-Key.min.js +2 -2
- package/dist/indexeddbshim-Key.min.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs +984 -1092
- package/dist/indexeddbshim-UnicodeIdentifiers-node.cjs.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +1220 -1233
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +8 -3
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.cjs +984 -1092
- package/dist/indexeddbshim-node.cjs.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +1219 -1232
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +8 -3
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +1219 -1232
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +8 -3
- package/dist/indexeddbshim.min.js.map +1 -1
- package/dist/node-UnicodeIdentifiers.d.ts +2 -2
- package/dist/node-UnicodeIdentifiers.d.ts.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -1
- package/dist/setGlobalVars.d.ts.map +1 -1
- package/dist/util.d.ts.map +1 -1
- package/package.json +112 -105
- package/src/CFG.js +2 -3
- package/src/DOMException.js +11 -9
- package/src/DOMStringList.js +8 -3
- package/src/Event.js +2 -0
- package/src/IDBCursor.js +22 -11
- package/src/IDBDatabase.js +9 -6
- package/src/IDBFactory.js +21 -15
- package/src/IDBIndex.js +82 -77
- package/src/IDBKeyRange.js +42 -35
- package/src/IDBObjectStore.js +83 -77
- package/src/IDBRequest.js +28 -15
- package/src/IDBTransaction.js +8 -4
- package/src/IDBVersionChangeEvent.js +2 -0
- package/src/Key.js +22 -12
- package/src/Sca.js +2 -1
- package/src/UnicodeIdentifiers.js +2 -2
- package/src/browser-UnicodeIdentifiers.js +1 -2
- package/src/browser-noninvasive.js +0 -1
- package/src/browser.js +0 -1
- package/src/node-UnicodeIdentifiers.js +1 -1
- package/src/node.js +1 -1
- package/src/setGlobalVars.js +13 -15
- package/src/unicode-regex.js +1 -1
- package/src/util.js +13 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! indexeddbshim -
|
|
1
|
+
/*! indexeddbshim - v17.0.0 - 7/28/2026 */
|
|
2
2
|
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -8,14 +8,14 @@ var require$$0 = require('fs');
|
|
|
8
8
|
var require$$2 = require('events');
|
|
9
9
|
var require$$0$1 = require('util');
|
|
10
10
|
|
|
11
|
-
function _typeof
|
|
11
|
+
function _typeof(obj) {
|
|
12
12
|
"@babel/helpers - typeof";
|
|
13
13
|
|
|
14
|
-
return _typeof
|
|
14
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
15
15
|
return typeof obj;
|
|
16
16
|
} : function (obj) {
|
|
17
17
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
18
|
-
}, _typeof
|
|
18
|
+
}, _typeof(obj);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
/* eslint-disable n/no-sync -- Want sync naming */
|
|
@@ -843,7 +843,7 @@ Object.assign(EventTarget.prototype, {
|
|
|
843
843
|
}
|
|
844
844
|
var triggerGlobalErrorEvent;
|
|
845
845
|
var useNodeImpl = false;
|
|
846
|
-
if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === "undefined" ? "undefined" : _typeof
|
|
846
|
+
if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.dispatchEvent) {
|
|
847
847
|
useNodeImpl = true;
|
|
848
848
|
triggerGlobalErrorEvent = function triggerGlobalErrorEvent() {
|
|
849
849
|
setTimeout(function () {
|
|
@@ -936,12 +936,10 @@ function setPrototypeOfCustomEvent() {
|
|
|
936
936
|
Object.setPrototypeOf(ShimCustomEvent.prototype, ShimEvent.prototype);
|
|
937
937
|
}
|
|
938
938
|
|
|
939
|
-
/* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/147 */
|
|
940
939
|
/**
|
|
941
940
|
* @typedef {T[keyof T]} ValueOf<T>
|
|
942
941
|
* @template T
|
|
943
942
|
*/
|
|
944
|
-
/* eslint-enable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/147 */
|
|
945
943
|
|
|
946
944
|
/**
|
|
947
945
|
* @typedef {{unlink: (path: string, cb: import('fs').NoParamCallback) => void}} FSApi
|
|
@@ -1003,6 +1001,7 @@ const CFG = /** @type {ConfigValues} */{};
|
|
|
1003
1001
|
*/
|
|
1004
1002
|
|
|
1005
1003
|
/** @type {Config} */
|
|
1004
|
+
// eslint-disable-next-line unicorn/no-top-level-side-effects -- Would be good
|
|
1006
1005
|
[
|
|
1007
1006
|
// Boolean for verbose reporting
|
|
1008
1007
|
'DEBUG',
|
|
@@ -1020,7 +1019,7 @@ const CFG = /** @type {ConfigValues} */{};
|
|
|
1020
1019
|
// calls required for full WebIDL compliance will be used. Probably
|
|
1021
1020
|
// only needed for testing or environments where full introspection
|
|
1022
1021
|
// on class relationships is required; see
|
|
1023
|
-
//
|
|
1022
|
+
// https://stackoverflow.com/questions/41927589/rationales-consequences-of-webidl-class-inheritance-requirements
|
|
1024
1023
|
'fullIDLSupport',
|
|
1025
1024
|
// Effectively defaults to false (ignored unless `true`)
|
|
1026
1025
|
|
|
@@ -1165,14 +1164,13 @@ var hasRequiredRegex;
|
|
|
1165
1164
|
function requireRegex() {
|
|
1166
1165
|
if (hasRequiredRegex) return regex$1;
|
|
1167
1166
|
hasRequiredRegex = 1;
|
|
1168
|
-
regex$1 = /[\xC0-\xC5\xC7-\xCF\xD1-\xD6\xD9-\xDD\xE0-\xE5\xE7-\xEF\xF1-\xF6\xF9-\xFD\xFF-\u010F\u0112-\u0125\u0128-\u0130\u0134-\u0137\u0139-\u013E\u0143-\u0148\u014C-\u0151\u0154-\u0165\u0168-\u017E\u01A0\u01A1\u01AF\u01B0\u01CD-\u01DC\u01DE-\u01E3\u01E6-\u01F0\u01F4\u01F5\u01F8-\u021B\u021E\u021F\u0226-\u0233\u0344\u0385\u0386\u0388-\u038A\u038C\u038E-\u0390\u03AA-\u03B0\u03CA-\u03CE\u03D3\u03D4\u0400\u0401\u0403\u0407\u040C-\u040E\u0419\u0439\u0450\u0451\u0453\u0457\u045C-\u045E\u0476\u0477\u04C1\u04C2\u04D0-\u04D3\u04D6\u04D7\u04DA-\u04DF\u04E2-\u04E7\u04EA-\u04F5\u04F8\u04F9\u0622-\u0626\u06C0\u06C2\u06D3\u0929\u0931\u0934\u0958-\u095F\u09CB\u09CC\u09DC\u09DD\u09DF\u0A33\u0A36\u0A59-\u0A5B\u0A5E\u0B48\u0B4B\u0B4C\u0B5C\u0B5D\u0B94\u0BCA-\u0BCC\u0C48\u0CC0\u0CC7\u0CC8\u0CCA\u0CCB\u0D4A-\u0D4C\u0DDA\u0DDC-\u0DDE\u0F43\u0F4D\u0F52\u0F57\u0F5C\u0F69\u0F73\u0F75\u0F76\u0F78\u0F81\u0F93\u0F9D\u0FA2\u0FA7\u0FAC\u0FB9\u1026\u1B06\u1B08\u1B0A\u1B0C\u1B0E\u1B12\u1B3B\u1B3D\u1B40\u1B41\u1B43\u1E00-\u1E99\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FC1-\u1FC4\u1FC6-\u1FD3\u1FD6-\u1FDB\u1FDD-\u1FEE\u1FF2-\u1FF4\u1FF6-\u1FFC\u212B\u219A\u219B\u21AE\u21CD-\u21CF\u2204\u2209\u220C\u2224\u2226\u2241\u2244\u2247\u2249\u2260\u2262\u226D-\u2271\u2274\u2275\u2278\u2279\u2280\u2281\u2284\u2285\u2288\u2289\u22AC-\u22AF\u22E0-\u22E3\u22EA-\u22ED\u2ADC\u304C\u304E\u3050\u3052\u3054\u3056\u3058\u305A\u305C\u305E\u3060\u3062\u3065\u3067\u3069\u3070\u3071\u3073\u3074\u3076\u3077\u3079\u307A\u307C\u307D\u3094\u309E\u30AC\u30AE\u30B0\u30B2\u30B4\u30B6\u30B8\u30BA\u30BC\u30BE\u30C0\u30C2\u30C5\u30C7\u30C9\u30D0\u30D1\u30D3\u30D4\u30D6\u30D7\u30D9\u30DA\u30DC\u30DD\u30F4\u30F7-\u30FA\u30FE\uAC00-\uD7A3\uFB1D\uFB1F\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFB4E]|\uD804[\uDC9A\uDC9C\uDCAB\uDD2E\uDD2F\uDF4B\uDF4C]|\uD805[\uDCBB\uDCBC\uDCBE\uDDBA\uDDBB]|\uD806\uDD38|\uD834[\uDD5E-\uDD64\uDDBB-\uDDC0]/;
|
|
1167
|
+
regex$1 = /[\xC0-\xC5\xC7-\xCF\xD1-\xD6\xD9-\xDD\xE0-\xE5\xE7-\xEF\xF1-\xF6\xF9-\xFD\xFF-\u010F\u0112-\u0125\u0128-\u0130\u0134-\u0137\u0139-\u013E\u0143-\u0148\u014C-\u0151\u0154-\u0165\u0168-\u017E\u01A0\u01A1\u01AF\u01B0\u01CD-\u01DC\u01DE-\u01E3\u01E6-\u01F0\u01F4\u01F5\u01F8-\u021B\u021E\u021F\u0226-\u0233\u0344\u0385\u0386\u0388-\u038A\u038C\u038E-\u0390\u03AA-\u03B0\u03CA-\u03CE\u03D3\u03D4\u0400\u0401\u0403\u0407\u040C-\u040E\u0419\u0439\u0450\u0451\u0453\u0457\u045C-\u045E\u0476\u0477\u04C1\u04C2\u04D0-\u04D3\u04D6\u04D7\u04DA-\u04DF\u04E2-\u04E7\u04EA-\u04F5\u04F8\u04F9\u0622-\u0626\u06C0\u06C2\u06D3\u0929\u0931\u0934\u0958-\u095F\u09CB\u09CC\u09DC\u09DD\u09DF\u0A33\u0A36\u0A59-\u0A5B\u0A5E\u0B48\u0B4B\u0B4C\u0B5C\u0B5D\u0B94\u0BCA-\u0BCC\u0C48\u0CC0\u0CC7\u0CC8\u0CCA\u0CCB\u0D4A-\u0D4C\u0DDA\u0DDC-\u0DDE\u0F43\u0F4D\u0F52\u0F57\u0F5C\u0F69\u0F73\u0F75\u0F76\u0F78\u0F81\u0F93\u0F9D\u0FA2\u0FA7\u0FAC\u0FB9\u1026\u1B06\u1B08\u1B0A\u1B0C\u1B0E\u1B12\u1B3B\u1B3D\u1B40\u1B41\u1B43\u1E00-\u1E99\u1E9B\u1EA0-\u1EF9\u1F00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FC1-\u1FC4\u1FC6-\u1FD3\u1FD6-\u1FDB\u1FDD-\u1FEE\u1FF2-\u1FF4\u1FF6-\u1FFC\u212B\u219A\u219B\u21AE\u21CD-\u21CF\u2204\u2209\u220C\u2224\u2226\u2241\u2244\u2247\u2249\u2260\u2262\u226D-\u2271\u2274\u2275\u2278\u2279\u2280\u2281\u2284\u2285\u2288\u2289\u22AC-\u22AF\u22E0-\u22E3\u22EA-\u22ED\u2ADC\u304C\u304E\u3050\u3052\u3054\u3056\u3058\u305A\u305C\u305E\u3060\u3062\u3065\u3067\u3069\u3070\u3071\u3073\u3074\u3076\u3077\u3079\u307A\u307C\u307D\u3094\u309E\u30AC\u30AE\u30B0\u30B2\u30B4\u30B6\u30B8\u30BA\u30BC\u30BE\u30C0\u30C2\u30C5\u30C7\u30C9\u30D0\u30D1\u30D3\u30D4\u30D6\u30D7\u30D9\u30DA\u30DC\u30DD\u30F4\u30F7-\u30FA\u30FE\uAC00-\uD7A3\uFB1D\uFB1F\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFB4E]|\uD801[\uDDC9\uDDE4]|\uD804[\uDC9A\uDC9C\uDCAB\uDD2E\uDD2F\uDF4B\uDF4C\uDF83\uDF85\uDF8E\uDF91\uDFC5\uDFC7\uDFC8]|\uD805[\uDCBB\uDCBC\uDCBE\uDDBA\uDDBB]|\uD806\uDD38|\uD818[\uDD21-\uDD28]|\uD81B[\uDD68-\uDD6A]|\uD834[\uDD5E-\uDD64\uDDBB-\uDDC0]/;
|
|
1169
1168
|
return regex$1;
|
|
1170
1169
|
}
|
|
1171
1170
|
var regexExports = requireRegex();
|
|
1172
1171
|
var regex = /*@__PURE__*/getDefaultExportFromCjs$1(regexExports);
|
|
1173
1172
|
|
|
1174
1173
|
/* eslint-disable new-cap -- ToString is how it is defined */
|
|
1175
|
-
/* eslint-disable sonarjs/no-control-regex -- Needed */
|
|
1176
1174
|
|
|
1177
1175
|
/**
|
|
1178
1176
|
* @typedef {number} Integer
|
|
@@ -1183,9 +1181,9 @@ var regex = /*@__PURE__*/getDefaultExportFromCjs$1(regexExports);
|
|
|
1183
1181
|
* @returns {string}
|
|
1184
1182
|
*/
|
|
1185
1183
|
function escapeUnmatchedSurrogates(arg) {
|
|
1186
|
-
//
|
|
1184
|
+
// https://stackoverflow.com/a/6701665/271577
|
|
1187
1185
|
return arg.replaceAll(/([\uD800-\uDBFF])(?![\uDC00-\uDFFF])|(^|[^\uD800-\uDBFF])([\uDC00-\uDFFF])/gu, function (_, unmatchedHighSurrogate, precedingLow, unmatchedLowSurrogate) {
|
|
1188
|
-
// Could add a corresponding surrogate for compatibility with `node-sqlite3`:
|
|
1186
|
+
// Could add a corresponding surrogate for compatibility with `node-sqlite3`: https://bugs.python.org/issue12569 and https://stackoverflow.com/a/6701665/271577
|
|
1189
1187
|
// but Chrome having problems
|
|
1190
1188
|
if (unmatchedHighSurrogate) {
|
|
1191
1189
|
return '^2' + unmatchedHighSurrogate.codePointAt().toString(16).padStart(4, '0');
|
|
@@ -1199,14 +1197,14 @@ function escapeUnmatchedSurrogates(arg) {
|
|
|
1199
1197
|
* @returns {string}
|
|
1200
1198
|
*/
|
|
1201
1199
|
function escapeNameForSQLiteIdentifier(arg) {
|
|
1202
|
-
//
|
|
1200
|
+
// https://stackoverflow.com/a/6701665/271577
|
|
1203
1201
|
return '_' +
|
|
1204
1202
|
// Prevent empty string
|
|
1205
1203
|
escapeUnmatchedSurrogates(arg.replaceAll('^', '^^') // Escape our escape
|
|
1206
|
-
//
|
|
1204
|
+
// https://www.sqlite.org/src/tktview?name=57c971fc74
|
|
1207
1205
|
.replaceAll('\0', '^0')
|
|
1208
1206
|
// We need to avoid identifiers being treated as duplicates based on SQLite's ASCII-only case-insensitive table and column names
|
|
1209
|
-
// (For SQL in general, however, see
|
|
1207
|
+
// (For SQL in general, however, see https://stackoverflow.com/a/17215009/271577
|
|
1210
1208
|
// See also https://www.sqlite.org/faq.html#q18 re: Unicode (non-ASCII) case-insensitive not working
|
|
1211
1209
|
.replaceAll(/([A-Z])/gu, '^$1'));
|
|
1212
1210
|
}
|
|
@@ -1236,7 +1234,7 @@ function unescapeSQLiteResponse(arg) {
|
|
|
1236
1234
|
*/
|
|
1237
1235
|
function sqlEscape(arg) {
|
|
1238
1236
|
// https://www.sqlite.org/lang_keywords.html
|
|
1239
|
-
//
|
|
1237
|
+
// https://stackoverflow.com/a/6701665/271577
|
|
1240
1238
|
// There is no need to escape ', `, or [], as
|
|
1241
1239
|
// we should always be within double quotes
|
|
1242
1240
|
// NUL should have already been stripped
|
|
@@ -1272,7 +1270,7 @@ function escapeDatabaseNameForSQLAndFiles(db) {
|
|
|
1272
1270
|
});
|
|
1273
1271
|
}
|
|
1274
1272
|
if (CFG.databaseCharacterEscapeList !== false) {
|
|
1275
|
-
db = db.replace(CFG.databaseCharacterEscapeList ? new RegExp(CFG.databaseCharacterEscapeList, 'gu') : /[\
|
|
1273
|
+
db = db.replace(CFG.databaseCharacterEscapeList ? new RegExp(CFG.databaseCharacterEscapeList, 'gu') : /[\u{0000}-\u{001F}\u{007F}"*/:<>?\\|]/gu,
|
|
1276
1274
|
// eslint-disable-line no-control-regex -- Controls needed
|
|
1277
1275
|
function (n0) {
|
|
1278
1276
|
// eslint-disable-next-line unicorn/prefer-code-point -- Switch to `codePointAt`?
|
|
@@ -1400,7 +1398,9 @@ function isBinary(obj) {
|
|
|
1400
1398
|
* @returns {boolean}
|
|
1401
1399
|
*/
|
|
1402
1400
|
function isIterable(obj) {
|
|
1403
|
-
return isObj(obj) &&
|
|
1401
|
+
return isObj(obj) &&
|
|
1402
|
+
// eslint-disable-next-line unicorn/no-computed-property-existence-check -- May not be "own"
|
|
1403
|
+
Symbol.iterator in obj && typeof obj[Symbol.iterator] === 'function';
|
|
1404
1404
|
}
|
|
1405
1405
|
|
|
1406
1406
|
/**
|
|
@@ -1492,7 +1492,7 @@ function defineReadonlyProperties(obj, props, getter = null) {
|
|
|
1492
1492
|
props = typeof props === 'string' ? [props] : props;
|
|
1493
1493
|
props.forEach(function (prop) {
|
|
1494
1494
|
let o;
|
|
1495
|
-
if (getter && prop
|
|
1495
|
+
if (getter && Object.hasOwn(getter, prop)) {
|
|
1496
1496
|
o = getter[prop];
|
|
1497
1497
|
} else {
|
|
1498
1498
|
Object.defineProperty(obj, '__' + prop, {
|
|
@@ -1530,7 +1530,7 @@ function isIdentifier(item) {
|
|
|
1530
1530
|
// ID_Continue (includes Other_ID_Continue)
|
|
1531
1531
|
const UnicodeIDContinue = CFG.UnicodeIDContinue || '[$0-9A-Z_a-z]';
|
|
1532
1532
|
const IdentifierStart = '(?:' + UnicodeIDStart + '|[$_])';
|
|
1533
|
-
const IdentifierPart = '(?:' + UnicodeIDContinue + '|[$_\
|
|
1533
|
+
const IdentifierPart = '(?:' + UnicodeIDContinue + '|[$_\u{200C}\u{200D}])';
|
|
1534
1534
|
return new RegExp('^' + IdentifierStart + IdentifierPart + '*$', 'u').test(item);
|
|
1535
1535
|
}
|
|
1536
1536
|
|
|
@@ -1552,7 +1552,7 @@ function isValidKeyPathString(keyPathString) {
|
|
|
1552
1552
|
*/
|
|
1553
1553
|
function isValidKeyPath(keyPath) {
|
|
1554
1554
|
return isValidKeyPathString(keyPath) || Array.isArray(keyPath) && Boolean(keyPath.length) &&
|
|
1555
|
-
// Convert array from sparse to dense
|
|
1555
|
+
// Convert array from sparse to dense https://www.2ality.com/2012/06/dense-arrays.html
|
|
1556
1556
|
// See also https://heycam.github.io/webidl/#idl-DOMString
|
|
1557
1557
|
[...keyPath].every(pathComponent => {
|
|
1558
1558
|
return isValidKeyPathString(pathComponent);
|
|
@@ -1658,8 +1658,10 @@ function createEvent(type, debug, evInit) {
|
|
|
1658
1658
|
return ev;
|
|
1659
1659
|
}
|
|
1660
1660
|
|
|
1661
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
1661
1662
|
// We don't add within polyfill repo as might not always be the desired implementation
|
|
1662
1663
|
Object.defineProperty(ShimEvent, Symbol.hasInstance, {
|
|
1664
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
1663
1665
|
/**
|
|
1664
1666
|
* @typedef {any} AnyValue
|
|
1665
1667
|
*/
|
|
@@ -1699,6 +1701,7 @@ IDBVersionChangeEvent.prototype[Symbol.toStringTag] = 'IDBVersionChangeEventProt
|
|
|
1699
1701
|
* @typedef {number} Integer
|
|
1700
1702
|
*/
|
|
1701
1703
|
|
|
1704
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
1702
1705
|
readonlyProperties$6.forEach(prop => {
|
|
1703
1706
|
// Ensure for proper interface testing that "get <name>" is the function name
|
|
1704
1707
|
const o = {
|
|
@@ -1852,7 +1855,7 @@ function createNonNativeDOMExceptionClass() {
|
|
|
1852
1855
|
function DOMException(message, name) {
|
|
1853
1856
|
// const err = Error.prototype.constructor.call(this, message); // Any use to this? Won't set this.message
|
|
1854
1857
|
this[Symbol.toStringTag] = 'DOMException';
|
|
1855
|
-
this._code = name
|
|
1858
|
+
this._code = Object.hasOwn(codes, name) ? codes[(/** @type {Code} */name)] : legacyCodes[(/** @type {LegacyCode} */name)] || 0;
|
|
1856
1859
|
this._name = name || 'Error';
|
|
1857
1860
|
// We avoid `String()` in this next line as it converts Symbols
|
|
1858
1861
|
this._message = message === undefined ? '' : '' + message; // eslint-disable-line no-implicit-coercion -- Don't convert symbols
|
|
@@ -1988,13 +1991,14 @@ function createNonNativeDOMException(name, message) {
|
|
|
1988
1991
|
* @returns {void}
|
|
1989
1992
|
*/
|
|
1990
1993
|
function logError(name, message, error) {
|
|
1991
|
-
if (CFG.DEBUG) {
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1994
|
+
if (!CFG.DEBUG) {
|
|
1995
|
+
return;
|
|
1996
|
+
}
|
|
1997
|
+
const msg = error && typeof error === 'object' && error.message ? error.message : (/** @type {string} */error);
|
|
1998
|
+
const method = typeof console.error === 'function' ? 'error' : 'log';
|
|
1999
|
+
console[method](name + ': ' + message + '. ' + (msg || ''));
|
|
2000
|
+
if (console.trace) {
|
|
2001
|
+
console.trace();
|
|
1998
2002
|
}
|
|
1999
2003
|
}
|
|
2000
2004
|
|
|
@@ -2125,8 +2129,9 @@ const doneFlagGetters = ['result', 'error'];
|
|
|
2125
2129
|
|
|
2126
2130
|
/**
|
|
2127
2131
|
* The IDBRequest Object that is returns for all async calls.
|
|
2128
|
-
* @see
|
|
2132
|
+
* @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#request-api
|
|
2129
2133
|
* @class
|
|
2134
|
+
* @throws {TypeError}
|
|
2130
2135
|
*/
|
|
2131
2136
|
function IDBRequest() {
|
|
2132
2137
|
throw new TypeError('Illegal constructor');
|
|
@@ -2165,19 +2170,21 @@ IDBRequest.__super = function IDBRequest() {
|
|
|
2165
2170
|
legacyOutputDidListenersThrowFlag: true // Event hook for IndexedB
|
|
2166
2171
|
});
|
|
2167
2172
|
doneFlagGetters.forEach(prop => {
|
|
2168
|
-
Object.
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2173
|
+
Object.defineProperties(this, {
|
|
2174
|
+
['__' + prop]: {
|
|
2175
|
+
enumerable: false,
|
|
2176
|
+
configurable: false,
|
|
2177
|
+
writable: true
|
|
2178
|
+
},
|
|
2179
|
+
[prop]: {
|
|
2180
|
+
enumerable: true,
|
|
2181
|
+
configurable: true,
|
|
2182
|
+
get() {
|
|
2183
|
+
if (!this.__done) {
|
|
2184
|
+
throw createDOMException('InvalidStateError', "Can't get " + prop + '; the request is still pending.');
|
|
2185
|
+
}
|
|
2186
|
+
return this['__' + prop];
|
|
2179
2187
|
}
|
|
2180
|
-
return this['__' + prop];
|
|
2181
2188
|
}
|
|
2182
2189
|
});
|
|
2183
2190
|
});
|
|
@@ -2224,6 +2231,7 @@ IDBRequest.prototype.__getParent = function () {
|
|
|
2224
2231
|
return this.__transaction;
|
|
2225
2232
|
};
|
|
2226
2233
|
|
|
2234
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
2227
2235
|
// Illegal invocations
|
|
2228
2236
|
defineReadonlyOuterInterface(IDBRequest.prototype, readonlyProperties$5);
|
|
2229
2237
|
defineReadonlyOuterInterface(IDBRequest.prototype, doneFlagGetters);
|
|
@@ -2238,15 +2246,18 @@ IDBRequest.__super.prototype = IDBRequest.prototype;
|
|
|
2238
2246
|
Object.defineProperty(IDBRequest, 'prototype', {
|
|
2239
2247
|
writable: false
|
|
2240
2248
|
});
|
|
2249
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
2250
|
+
|
|
2241
2251
|
const openListeners = ['onblocked', 'onupgradeneeded'];
|
|
2242
2252
|
|
|
2243
2253
|
/**
|
|
2244
|
-
* @typedef {IDBRequestFull & IDBOpenDBRequest
|
|
2254
|
+
* @typedef {IDBRequestFull & IDBOpenDBRequest} IDBOpenDBRequestFull
|
|
2245
2255
|
*/
|
|
2246
2256
|
|
|
2247
2257
|
/**
|
|
2248
2258
|
* The IDBOpenDBRequest called when a database is opened.
|
|
2249
2259
|
* @class
|
|
2260
|
+
* @throws {TypeError}
|
|
2250
2261
|
*/
|
|
2251
2262
|
function IDBOpenDBRequest() {
|
|
2252
2263
|
throw new TypeError('Illegal constructor');
|
|
@@ -2254,12 +2265,16 @@ function IDBOpenDBRequest() {
|
|
|
2254
2265
|
|
|
2255
2266
|
// @ts-expect-error It's ok
|
|
2256
2267
|
IDBOpenDBRequest.prototype = Object.create(IDBRequest.prototype);
|
|
2268
|
+
|
|
2269
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
2257
2270
|
Object.defineProperty(IDBOpenDBRequest.prototype, 'constructor', {
|
|
2258
2271
|
enumerable: false,
|
|
2259
2272
|
writable: true,
|
|
2260
2273
|
configurable: true,
|
|
2261
2274
|
value: IDBOpenDBRequest
|
|
2262
2275
|
});
|
|
2276
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
2277
|
+
|
|
2263
2278
|
const IDBOpenDBRequestAlias = IDBOpenDBRequest;
|
|
2264
2279
|
/**
|
|
2265
2280
|
* @returns {IDBRequestFull & IDBOpenDBRequest}
|
|
@@ -2287,6 +2302,8 @@ IDBOpenDBRequest.__createInstance = function () {
|
|
|
2287
2302
|
// @ts-expect-error It's ok
|
|
2288
2303
|
return new IDBOpenDBRequest();
|
|
2289
2304
|
};
|
|
2305
|
+
|
|
2306
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
2290
2307
|
defineOuterInterface(IDBOpenDBRequest.prototype, openListeners);
|
|
2291
2308
|
IDBOpenDBRequest.prototype[Symbol.toStringTag] = 'IDBOpenDBRequestPrototype';
|
|
2292
2309
|
Object.defineProperty(IDBOpenDBRequest, 'prototype', {
|
|
@@ -2665,10 +2682,14 @@ const keyTypeToEncodedChar = {
|
|
|
2665
2682
|
binary: 500,
|
|
2666
2683
|
array: 600
|
|
2667
2684
|
};
|
|
2685
|
+
|
|
2686
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
2668
2687
|
const keyTypes = /** @type {(KeyType|"invalid")[]} */Object.keys(keyTypeToEncodedChar);
|
|
2669
2688
|
keyTypes.forEach(k => {
|
|
2670
2689
|
keyTypeToEncodedChar[k] = String.fromCodePoint(/** @type {number} */keyTypeToEncodedChar[k]);
|
|
2671
2690
|
});
|
|
2691
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
2692
|
+
|
|
2672
2693
|
const encodedCharToKeyType = keyTypes.reduce((o, k) => {
|
|
2673
2694
|
o[keyTypeToEncodedChar[k]] = k;
|
|
2674
2695
|
return o;
|
|
@@ -2754,13 +2775,12 @@ const types = {
|
|
|
2754
2775
|
if (key > -1) {
|
|
2755
2776
|
sign = signValues.indexOf('smallNegative');
|
|
2756
2777
|
exponent = padBase32Exponent(significantDigitIndex);
|
|
2757
|
-
mantissa = flipBase32(padBase32Mantissa(key32));
|
|
2758
2778
|
// Non-negative exponent case:
|
|
2759
2779
|
} else {
|
|
2760
2780
|
sign = signValues.indexOf('bigNegative');
|
|
2761
2781
|
exponent = flipBase32(padBase32Exponent(decimalIndex !== -1 ? decimalIndex : key32.length));
|
|
2762
|
-
mantissa = flipBase32(padBase32Mantissa(key32));
|
|
2763
2782
|
}
|
|
2783
|
+
mantissa = flipBase32(padBase32Mantissa(key32));
|
|
2764
2784
|
// Non-negative cases:
|
|
2765
2785
|
// Negative exponent case:
|
|
2766
2786
|
} else if (key < 1) {
|
|
@@ -2794,9 +2814,9 @@ const types = {
|
|
|
2794
2814
|
let mantissa = key.slice(5, 16);
|
|
2795
2815
|
switch (signValues[sign]) {
|
|
2796
2816
|
case 'negativeInfinity':
|
|
2797
|
-
return
|
|
2817
|
+
return -Infinity;
|
|
2798
2818
|
case 'positiveInfinity':
|
|
2799
|
-
return
|
|
2819
|
+
return Infinity;
|
|
2800
2820
|
case 'bigPositive':
|
|
2801
2821
|
return pow32(mantissa, exponent);
|
|
2802
2822
|
case 'smallPositive':
|
|
@@ -2916,7 +2936,7 @@ const types = {
|
|
|
2916
2936
|
decode(key) {
|
|
2917
2937
|
// Set the entries in buffer's [[ArrayBufferData]] to those in `value`
|
|
2918
2938
|
const k = key.slice(2);
|
|
2919
|
-
const arr = k.length ? k.split(',').map(
|
|
2939
|
+
const arr = k.length ? k.split(',').map(Number) : [];
|
|
2920
2940
|
const buffer = new ArrayBuffer(arr.length);
|
|
2921
2941
|
const uint8 = new Uint8Array(buffer);
|
|
2922
2942
|
uint8.set(arr);
|
|
@@ -2995,7 +3015,7 @@ function pow32(mantissa, exponent) {
|
|
|
2995
3015
|
* @returns {Float}
|
|
2996
3016
|
*/
|
|
2997
3017
|
function roundToPrecision(num, precision = 16) {
|
|
2998
|
-
return Number
|
|
3018
|
+
return Number(num.toPrecision(precision));
|
|
2999
3019
|
}
|
|
3000
3020
|
|
|
3001
3021
|
/**
|
|
@@ -3063,7 +3083,7 @@ function convertValueToMultiEntryKey(input) {
|
|
|
3063
3083
|
*/
|
|
3064
3084
|
function getCopyBytesHeldByBufferSource(O) {
|
|
3065
3085
|
let offset = 0;
|
|
3066
|
-
let length
|
|
3086
|
+
let length;
|
|
3067
3087
|
if (ArrayBuffer.isView(O)) {
|
|
3068
3088
|
// Has [[ViewedArrayBuffer]] internal slot
|
|
3069
3089
|
const arrayBuffer = O.buffer;
|
|
@@ -3096,7 +3116,7 @@ function getCopyBytesHeldByBufferSource(O) {
|
|
|
3096
3116
|
* @returns {KeyValueObject}
|
|
3097
3117
|
*/
|
|
3098
3118
|
function convertValueToKeyValueDecoded(input, seen, multiEntry, fullKeys) {
|
|
3099
|
-
seen
|
|
3119
|
+
seen ||= [];
|
|
3100
3120
|
if (seen.includes(input)) {
|
|
3101
3121
|
return {
|
|
3102
3122
|
type: 'array',
|
|
@@ -3473,7 +3493,6 @@ function findMultiEntryMatches(keyEntry, range) {
|
|
|
3473
3493
|
continue;
|
|
3474
3494
|
}
|
|
3475
3495
|
if (key.length === 1) {
|
|
3476
|
-
// eslint-disable-next-line sonarjs/updated-loop-counter -- Convenient
|
|
3477
3496
|
key = key[0];
|
|
3478
3497
|
} else {
|
|
3479
3498
|
const nested = findMultiEntryMatches(key, range);
|
|
@@ -3653,8 +3672,13 @@ function assignCurrentNumber(tx, store, num, successCb, failCb) {
|
|
|
3653
3672
|
* @returns {void}
|
|
3654
3673
|
*/
|
|
3655
3674
|
function setCurrentNumber(tx, store, num, successCb, failCb) {
|
|
3656
|
-
num = num === MAX_ALLOWED_CURRENT_NUMBER
|
|
3657
|
-
|
|
3675
|
+
num = 1 + (num === MAX_ALLOWED_CURRENT_NUMBER
|
|
3676
|
+
// Since incrementing by one will have no effect in JavaScript on this
|
|
3677
|
+
// unsafe max, we represent the max as a number incremented by two.
|
|
3678
|
+
// The getting of the current number is never returned to the user and
|
|
3679
|
+
// is only used in safe comparisons, so it is safe for us to represent
|
|
3680
|
+
// it in this manner
|
|
3681
|
+
? num + 1 : num);
|
|
3658
3682
|
return assignCurrentNumber(tx, store, num, successCb, failCb);
|
|
3659
3683
|
}
|
|
3660
3684
|
|
|
@@ -3767,7 +3791,7 @@ const readonlyProperties$4 = /** @type {const} */['lower', 'upper', 'lowerOpen',
|
|
|
3767
3791
|
|
|
3768
3792
|
/**
|
|
3769
3793
|
* The IndexedDB KeyRange object.
|
|
3770
|
-
* @see
|
|
3794
|
+
* @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#dfn-key-range
|
|
3771
3795
|
* @throws {TypeError}
|
|
3772
3796
|
* @class
|
|
3773
3797
|
*/
|
|
@@ -3788,6 +3812,7 @@ const IDBKeyRangeAlias = IDBKeyRange;
|
|
|
3788
3812
|
IDBKeyRange.__createInstance = function (lower, upper, lowerOpen, upperOpen) {
|
|
3789
3813
|
/**
|
|
3790
3814
|
* @class
|
|
3815
|
+
* @throws {DOMException|Error}
|
|
3791
3816
|
*/
|
|
3792
3817
|
function IDBKeyRange() {
|
|
3793
3818
|
this[Symbol.toStringTag] = 'IDBKeyRange';
|
|
@@ -3884,6 +3909,8 @@ IDBKeyRange.bound = function (lower, upper /* , lowerOpen, upperOpen */) {
|
|
|
3884
3909
|
return IDBKeyRange.__createInstance(lower, upper, arguments[2], arguments[3]);
|
|
3885
3910
|
};
|
|
3886
3911
|
IDBKeyRange.prototype[Symbol.toStringTag] = 'IDBKeyRangePrototype';
|
|
3912
|
+
|
|
3913
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
3887
3914
|
readonlyProperties$4.forEach(prop => {
|
|
3888
3915
|
Object.defineProperty(IDBKeyRange.prototype, '__' + prop, {
|
|
3889
3916
|
enumerable: false,
|
|
@@ -3909,18 +3936,22 @@ readonlyProperties$4.forEach(prop => {
|
|
|
3909
3936
|
// desc.configurable = true; // Default
|
|
3910
3937
|
Object.defineProperty(IDBKeyRange.prototype, prop, desc);
|
|
3911
3938
|
});
|
|
3912
|
-
Object.
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3939
|
+
Object.defineProperties(IDBKeyRange, {
|
|
3940
|
+
[Symbol.hasInstance]: {
|
|
3941
|
+
value:
|
|
3942
|
+
/**
|
|
3943
|
+
* @param {object} obj
|
|
3944
|
+
* @returns {boolean}
|
|
3945
|
+
*/
|
|
3946
|
+
obj => isObj(obj) && 'upper' in obj && 'lowerOpen' in obj && typeof obj.lowerOpen === 'boolean'
|
|
3947
|
+
},
|
|
3948
|
+
prototype: {
|
|
3949
|
+
writable: false
|
|
3950
|
+
}
|
|
3922
3951
|
});
|
|
3923
3952
|
|
|
3953
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
3954
|
+
|
|
3924
3955
|
/**
|
|
3925
3956
|
* @param {IDBKeyRangeFull|undefined} range
|
|
3926
3957
|
* @param {string} quotedKeyColumnName
|
|
@@ -3931,34 +3962,35 @@ Object.defineProperty(IDBKeyRange, 'prototype', {
|
|
|
3931
3962
|
* @returns {void}
|
|
3932
3963
|
*/
|
|
3933
3964
|
function setSQLForKeyRange(range, quotedKeyColumnName, sql, sqlValues, addAnd, checkCached) {
|
|
3934
|
-
if (range && (range.lower !== undefined || range.upper !== undefined)) {
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
}
|
|
3955
|
-
if (hasLower && hasUpper) {
|
|
3956
|
-
sql.push('AND');
|
|
3957
|
-
}
|
|
3958
|
-
if (hasUpper) {
|
|
3959
|
-
sql.push(quotedKeyColumnName, range.upperOpen ? '<' : '<=', '?');
|
|
3960
|
-
sqlValues.push(escapeSQLiteStatement(/** @type {string} */encodedUpperKey));
|
|
3965
|
+
if (!(range && (range.lower !== undefined || range.upper !== undefined))) {
|
|
3966
|
+
return;
|
|
3967
|
+
}
|
|
3968
|
+
if (addAnd) {
|
|
3969
|
+
sql.push('AND');
|
|
3970
|
+
}
|
|
3971
|
+
let encodedLowerKey, encodedUpperKey;
|
|
3972
|
+
const hasLower = range.lower !== undefined;
|
|
3973
|
+
const hasUpper = range.upper !== undefined;
|
|
3974
|
+
if (hasLower) {
|
|
3975
|
+
encodedLowerKey = checkCached ? range.__lowerCached : encode$1(range.lower);
|
|
3976
|
+
}
|
|
3977
|
+
if (hasUpper) {
|
|
3978
|
+
encodedUpperKey = checkCached ? range.__upperCached : encode$1(range.upper);
|
|
3979
|
+
}
|
|
3980
|
+
if (hasLower) {
|
|
3981
|
+
sqlValues.push(escapeSQLiteStatement(/** @type {string} */encodedLowerKey));
|
|
3982
|
+
if (hasUpper && encodedLowerKey === encodedUpperKey && !range.lowerOpen && !range.upperOpen) {
|
|
3983
|
+
sql.push(quotedKeyColumnName, '=', '?');
|
|
3984
|
+
return;
|
|
3961
3985
|
}
|
|
3986
|
+
sql.push(quotedKeyColumnName, range.lowerOpen ? '>' : '>=', '?');
|
|
3987
|
+
}
|
|
3988
|
+
if (hasLower && hasUpper) {
|
|
3989
|
+
sql.push('AND');
|
|
3990
|
+
}
|
|
3991
|
+
if (hasUpper) {
|
|
3992
|
+
sql.push(quotedKeyColumnName, range.upperOpen ? '<' : '<=', '?');
|
|
3993
|
+
sqlValues.push(escapeSQLiteStatement(/** @type {string} */encodedUpperKey));
|
|
3962
3994
|
}
|
|
3963
3995
|
}
|
|
3964
3996
|
|
|
@@ -4060,7 +4092,9 @@ DOMStringList.prototype = {
|
|
|
4060
4092
|
if (!arguments.length) {
|
|
4061
4093
|
throw new TypeError('DOMStringList.item must be supplied a value');
|
|
4062
4094
|
}
|
|
4063
|
-
if (key < 0 || key >= this.length ||
|
|
4095
|
+
if (key < 0 || key >= this.length ||
|
|
4096
|
+
// eslint-disable-next-line unicorn/prefer-number-is-safe-integer -- We want all
|
|
4097
|
+
!Number.isInteger(key)) {
|
|
4064
4098
|
return null;
|
|
4065
4099
|
}
|
|
4066
4100
|
return this._items[key];
|
|
@@ -4090,8 +4124,9 @@ DOMStringList.prototype = {
|
|
|
4090
4124
|
* @returns {string[]}
|
|
4091
4125
|
*/
|
|
4092
4126
|
sortList() {
|
|
4093
|
-
//
|
|
4127
|
+
// https://w3c.github.io/IndexedDB/#sorted-list
|
|
4094
4128
|
// https://tc39.github.io/ecma262/#sec-abstract-relational-comparison
|
|
4129
|
+
// eslint-disable-next-line unicorn/require-array-sort-compare -- IndexedDB requires code unit comparison (default behavior)
|
|
4095
4130
|
this._items.sort();
|
|
4096
4131
|
this.addIndexes();
|
|
4097
4132
|
return this._items;
|
|
@@ -4143,7 +4178,7 @@ DOMStringList.prototype = {
|
|
|
4143
4178
|
this._items.splice(...args);
|
|
4144
4179
|
this._length = this._items.length;
|
|
4145
4180
|
for (const i in this) {
|
|
4146
|
-
if (i === String(
|
|
4181
|
+
if (i === String(Math.trunc(Number(i)))) {
|
|
4147
4182
|
delete this[i];
|
|
4148
4183
|
}
|
|
4149
4184
|
}
|
|
@@ -4163,6 +4198,7 @@ DOMStringList.prototype = {
|
|
|
4163
4198
|
}
|
|
4164
4199
|
};
|
|
4165
4200
|
|
|
4201
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
4166
4202
|
/**
|
|
4167
4203
|
* @typedef {any} AnyValue
|
|
4168
4204
|
*/
|
|
@@ -4177,6 +4213,7 @@ Object.defineProperty(DOMStringList, Symbol.hasInstance, {
|
|
|
4177
4213
|
});
|
|
4178
4214
|
const DOMStringListAlias = DOMStringList;
|
|
4179
4215
|
Object.defineProperty(DOMStringList, '__createInstance', {
|
|
4216
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
4180
4217
|
/**
|
|
4181
4218
|
* @returns {DOMStringListFull}
|
|
4182
4219
|
*/
|
|
@@ -4310,8 +4347,9 @@ const readonlyProperties$3 = ['objectStoreNames', 'mode', 'db', 'error'];
|
|
|
4310
4347
|
|
|
4311
4348
|
/**
|
|
4312
4349
|
* The IndexedDB Transaction.
|
|
4313
|
-
* @see
|
|
4350
|
+
* @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransaction
|
|
4314
4351
|
* @class
|
|
4352
|
+
* @throws {TypeError}
|
|
4315
4353
|
*/
|
|
4316
4354
|
function IDBTransaction() {
|
|
4317
4355
|
throw new TypeError('Illegal constructor');
|
|
@@ -4333,6 +4371,7 @@ IDBTransaction.__createInstance = function (db, storeNames, mode) {
|
|
|
4333
4371
|
// @ts-expect-error It's ok
|
|
4334
4372
|
me[Symbol.toStringTag] = 'IDBTransaction';
|
|
4335
4373
|
defineReadonlyProperties(me, readonlyProperties$3);
|
|
4374
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Debugging only
|
|
4336
4375
|
me.__id = ++uniqueID; // for debugging simultaneous transactions
|
|
4337
4376
|
me.__active = true;
|
|
4338
4377
|
me.__running = false;
|
|
@@ -4740,7 +4779,7 @@ IDBTransaction.prototype.objectStore = function (objectStoreName) {
|
|
|
4740
4779
|
if (!store) {
|
|
4741
4780
|
throw createDOMException('NotFoundError', objectStoreName + ' does not exist in ' + me.db.name);
|
|
4742
4781
|
}
|
|
4743
|
-
if (!me.__storeHandles
|
|
4782
|
+
if (!Object.hasOwn(me.__storeHandles, objectStoreName) ||
|
|
4744
4783
|
// These latter conditions are to allow store
|
|
4745
4784
|
// recreation to create new clone object
|
|
4746
4785
|
me.__storeHandles[objectStoreName].__pendingDelete || me.__storeHandles[objectStoreName].__deleted) {
|
|
@@ -4846,7 +4885,7 @@ IDBTransaction.prototype.__abortTransaction = function (err) {
|
|
|
4846
4885
|
}
|
|
4847
4886
|
q.req.dispatchEvent(reqEvt); // No need to catch errors
|
|
4848
4887
|
resolve();
|
|
4849
|
-
});
|
|
4888
|
+
}, 0);
|
|
4850
4889
|
});
|
|
4851
4890
|
});
|
|
4852
4891
|
}, SyncPromise.resolve(undefined)).then(function () {
|
|
@@ -4860,7 +4899,7 @@ IDBTransaction.prototype.__abortTransaction = function (err) {
|
|
|
4860
4899
|
me.dispatchEvent(evt);
|
|
4861
4900
|
me.__storeHandles = {};
|
|
4862
4901
|
me.dispatchEvent(createEvent('__abort'));
|
|
4863
|
-
});
|
|
4902
|
+
}, 0);
|
|
4864
4903
|
return undefined;
|
|
4865
4904
|
}).catch(err => {
|
|
4866
4905
|
console.log('Abort error');
|
|
@@ -4983,6 +5022,8 @@ IDBTransaction.__assertActive = function (tx) {
|
|
|
4983
5022
|
IDBTransaction.prototype.__getParent = function () {
|
|
4984
5023
|
return this.db;
|
|
4985
5024
|
};
|
|
5025
|
+
|
|
5026
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
4986
5027
|
defineOuterInterface(IDBTransaction.prototype, listeners$1);
|
|
4987
5028
|
defineReadonlyOuterInterface(IDBTransaction.prototype, readonlyProperties$3);
|
|
4988
5029
|
Object.defineProperty(IDBTransaction.prototype, 'constructor', {
|
|
@@ -4995,779 +5036,598 @@ Object.defineProperty(IDBTransaction, 'prototype', {
|
|
|
4995
5036
|
writable: false
|
|
4996
5037
|
});
|
|
4997
5038
|
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
var n = Object.getOwnPropertySymbols(e);
|
|
5002
|
-
t && (n = n.filter(function (t) {
|
|
5003
|
-
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
5004
|
-
})), r.push.apply(r, n);
|
|
5005
|
-
}
|
|
5006
|
-
return r;
|
|
5007
|
-
}
|
|
5008
|
-
function _objectSpread2(e) {
|
|
5009
|
-
for (var t = 1; t < arguments.length; t++) {
|
|
5010
|
-
var r = null != arguments[t] ? arguments[t] : {};
|
|
5011
|
-
t % 2 ? ownKeys(Object(r), true).forEach(function (t) {
|
|
5012
|
-
_defineProperty(e, t, r[t]);
|
|
5013
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ownKeys(Object(r)).forEach(function (t) {
|
|
5014
|
-
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
|
|
5015
|
-
});
|
|
5016
|
-
}
|
|
5017
|
-
return e;
|
|
5018
|
-
}
|
|
5019
|
-
function _typeof(e) {
|
|
5020
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (e) {
|
|
5021
|
-
return typeof e;
|
|
5022
|
-
} : function (e) {
|
|
5023
|
-
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
5024
|
-
}, _typeof(e);
|
|
5025
|
-
}
|
|
5026
|
-
function _classCallCheck(e, t) {
|
|
5027
|
-
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
5028
|
-
}
|
|
5029
|
-
function _createClass(e, t, r) {
|
|
5030
|
-
return t && function _defineProperties(e, t) {
|
|
5031
|
-
for (var r = 0; r < t.length; r++) {
|
|
5032
|
-
var n = t[r];
|
|
5033
|
-
n.enumerable = n.enumerable || false, n.configurable = true, "value" in n && (n.writable = true), Object.defineProperty(e, _toPropertyKey(n.key), n);
|
|
5034
|
-
}
|
|
5035
|
-
}(e.prototype, t), Object.defineProperty(e, "prototype", {
|
|
5036
|
-
writable: false
|
|
5037
|
-
}), e;
|
|
5038
|
-
}
|
|
5039
|
-
function _defineProperty(e, t, r) {
|
|
5040
|
-
return (t = _toPropertyKey(t)) in e ? Object.defineProperty(e, t, {
|
|
5041
|
-
value: r,
|
|
5042
|
-
enumerable: true,
|
|
5043
|
-
configurable: true,
|
|
5044
|
-
writable: true
|
|
5045
|
-
}) : e[t] = r, e;
|
|
5046
|
-
}
|
|
5047
|
-
function _slicedToArray(e, t) {
|
|
5048
|
-
return function _arrayWithHoles(e) {
|
|
5049
|
-
if (Array.isArray(e)) return e;
|
|
5050
|
-
}(e) || function _iterableToArrayLimit(e, t) {
|
|
5051
|
-
var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
5052
|
-
if (null != r) {
|
|
5053
|
-
var n,
|
|
5054
|
-
a,
|
|
5055
|
-
o,
|
|
5056
|
-
i,
|
|
5057
|
-
c = [],
|
|
5058
|
-
s = true,
|
|
5059
|
-
u = false;
|
|
5060
|
-
try {
|
|
5061
|
-
if (o = (r = r.call(e)).next, 0 === t) {
|
|
5062
|
-
if (Object(r) !== r) return;
|
|
5063
|
-
s = !1;
|
|
5064
|
-
} else for (; !(s = (n = o.call(r)).done) && (c.push(n.value), c.length !== t); s = !0);
|
|
5065
|
-
} catch (e) {
|
|
5066
|
-
u = true, a = e;
|
|
5067
|
-
} finally {
|
|
5068
|
-
try {
|
|
5069
|
-
if (!s && null != r.return && (i = r.return(), Object(i) !== i)) return;
|
|
5070
|
-
} finally {
|
|
5071
|
-
if (u) throw a;
|
|
5072
|
-
}
|
|
5073
|
-
}
|
|
5074
|
-
return c;
|
|
5075
|
-
}
|
|
5076
|
-
}(e, t) || _unsupportedIterableToArray(e, t) || function _nonIterableRest() {
|
|
5077
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5078
|
-
}();
|
|
5079
|
-
}
|
|
5080
|
-
function _unsupportedIterableToArray(e, t) {
|
|
5081
|
-
if (e) {
|
|
5082
|
-
if ("string" == typeof e) return _arrayLikeToArray(e, t);
|
|
5083
|
-
var r = Object.prototype.toString.call(e).slice(8, -1);
|
|
5084
|
-
return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? _arrayLikeToArray(e, t) : void 0;
|
|
5039
|
+
class TypesonPromise {
|
|
5040
|
+
constructor(e) {
|
|
5041
|
+
this.p = new Promise(e);
|
|
5085
5042
|
}
|
|
5086
5043
|
}
|
|
5087
|
-
|
|
5088
|
-
(
|
|
5089
|
-
|
|
5090
|
-
return n
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
var t = function _toPrimitive(e, t) {
|
|
5094
|
-
if ("object" != typeof e || null === e) return e;
|
|
5095
|
-
var r = e[Symbol.toPrimitive];
|
|
5096
|
-
if (void 0 !== r) {
|
|
5097
|
-
var n = r.call(e, t);
|
|
5098
|
-
if ("object" != typeof n) return n;
|
|
5099
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
5100
|
-
}
|
|
5101
|
-
return (String )(e);
|
|
5102
|
-
}(e, "string");
|
|
5103
|
-
return "symbol" == typeof t ? t : String(t);
|
|
5104
|
-
}
|
|
5105
|
-
var e = _createClass(function TypesonPromise(e) {
|
|
5106
|
-
_classCallCheck(this, TypesonPromise), this.p = new Promise(e);
|
|
5107
|
-
});
|
|
5108
|
-
e.__typeson__type__ = "TypesonPromise", "undefined" != typeof Symbol && Object.defineProperty(e.prototype, Symbol.toStringTag, {
|
|
5109
|
-
get: function get() {
|
|
5110
|
-
return "TypesonPromise";
|
|
5111
|
-
}
|
|
5112
|
-
}), e.prototype.then = function (t, r) {
|
|
5113
|
-
var n = this;
|
|
5114
|
-
return new e(function (e, a) {
|
|
5115
|
-
n.p.then(function (r) {
|
|
5116
|
-
e(t ? t(r) : r);
|
|
5044
|
+
TypesonPromise.__typeson__type__ = "TypesonPromise", "undefined" != typeof Symbol && Object.defineProperty(TypesonPromise.prototype, Symbol.toStringTag, {
|
|
5045
|
+
get: () => "TypesonPromise"
|
|
5046
|
+
}), TypesonPromise.prototype.then = function (e, t) {
|
|
5047
|
+
return new TypesonPromise((r, n) => {
|
|
5048
|
+
this.p.then(function (t) {
|
|
5049
|
+
r(e ? e(t) : t);
|
|
5117
5050
|
}).catch(function (e) {
|
|
5118
|
-
return
|
|
5119
|
-
}).then(
|
|
5051
|
+
return t ? t(e) : Promise.reject(e);
|
|
5052
|
+
}).then(r, n);
|
|
5120
5053
|
});
|
|
5121
|
-
},
|
|
5122
|
-
return this.then(
|
|
5123
|
-
},
|
|
5124
|
-
return new
|
|
5125
|
-
e
|
|
5054
|
+
}, TypesonPromise.prototype.catch = function (e) {
|
|
5055
|
+
return this.then(() => {}, e);
|
|
5056
|
+
}, TypesonPromise.resolve = function (e) {
|
|
5057
|
+
return new TypesonPromise(t => {
|
|
5058
|
+
t(e);
|
|
5126
5059
|
});
|
|
5127
|
-
},
|
|
5128
|
-
return new
|
|
5129
|
-
r(
|
|
5060
|
+
}, TypesonPromise.reject = function (e) {
|
|
5061
|
+
return new TypesonPromise((t, r) => {
|
|
5062
|
+
r(e);
|
|
5130
5063
|
});
|
|
5131
|
-
},
|
|
5132
|
-
return new
|
|
5133
|
-
Promise.all(
|
|
5134
|
-
return null != e && e.constructor && "__typeson__type__" in e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e;
|
|
5135
|
-
})).then(e, r);
|
|
5064
|
+
}, TypesonPromise.all = function (e) {
|
|
5065
|
+
return new TypesonPromise(function (t, r) {
|
|
5066
|
+
Promise.all(e.map(e => e?.constructor && "__typeson__type__" in e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e)).then(t, r);
|
|
5136
5067
|
});
|
|
5137
|
-
},
|
|
5138
|
-
return new
|
|
5139
|
-
Promise.race(
|
|
5140
|
-
return null != e && e.constructor && "__typeson__type__" in e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e;
|
|
5141
|
-
})).then(e, r);
|
|
5068
|
+
}, TypesonPromise.race = function (e) {
|
|
5069
|
+
return new TypesonPromise(function (t, r) {
|
|
5070
|
+
Promise.race(e.map(e => e?.constructor && "__typeson__type__" in e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e)).then(t, r);
|
|
5142
5071
|
});
|
|
5143
|
-
},
|
|
5144
|
-
return new
|
|
5145
|
-
Promise.allSettled(
|
|
5146
|
-
return null != e && e.constructor && "__typeson__type__" in e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e;
|
|
5147
|
-
})).then(e, r);
|
|
5072
|
+
}, TypesonPromise.allSettled = function (e) {
|
|
5073
|
+
return new TypesonPromise(function (t, r) {
|
|
5074
|
+
Promise.allSettled(e.map(e => e?.constructor && "__typeson__type__" in e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e)).then(t, r);
|
|
5148
5075
|
});
|
|
5149
5076
|
};
|
|
5150
|
-
|
|
5151
|
-
|
|
5077
|
+
const {
|
|
5078
|
+
hasOwn: e
|
|
5079
|
+
} = Object,
|
|
5080
|
+
t = Object.getPrototypeOf;
|
|
5152
5081
|
function isThenable(e, t) {
|
|
5153
5082
|
return isObject(e) && "function" == typeof e.then && (true || "function" == typeof e.catch);
|
|
5154
5083
|
}
|
|
5155
5084
|
function toStringTag(e) {
|
|
5156
5085
|
return Object.prototype.toString.call(e).slice(8, -1);
|
|
5157
5086
|
}
|
|
5158
|
-
function hasConstructorOf(
|
|
5159
|
-
if (!
|
|
5160
|
-
|
|
5161
|
-
if (!
|
|
5162
|
-
|
|
5163
|
-
return "function" != typeof
|
|
5087
|
+
function hasConstructorOf(r, n) {
|
|
5088
|
+
if (!r || "object" != typeof r) return false;
|
|
5089
|
+
const o = t(r);
|
|
5090
|
+
if (!o) return null === n;
|
|
5091
|
+
const s = e(o, "constructor") && o.constructor;
|
|
5092
|
+
return "function" != typeof s ? null === n : n === s || null !== n && Function.prototype.toString.call(s) === Function.prototype.toString.call(n) || "function" == typeof n && "string" == typeof s.__typeson__type__ && s.__typeson__type__ === n.__typeson__type__;
|
|
5164
5093
|
}
|
|
5165
5094
|
function isPlainObject(e) {
|
|
5166
|
-
return !(!e || "Object" !== toStringTag(e)) && (!
|
|
5095
|
+
return !(!e || "Object" !== toStringTag(e)) && (!t(e) || hasConstructorOf(e, Object));
|
|
5167
5096
|
}
|
|
5168
5097
|
function isUserObject(e) {
|
|
5169
5098
|
if (!e || "Object" !== toStringTag(e)) return false;
|
|
5170
|
-
|
|
5171
|
-
return !
|
|
5099
|
+
const r = t(e);
|
|
5100
|
+
return !r || hasConstructorOf(e, Object) || isUserObject(r);
|
|
5172
5101
|
}
|
|
5173
5102
|
function isObject(e) {
|
|
5174
|
-
return null !== e && "object"
|
|
5103
|
+
return null !== e && "object" == typeof e;
|
|
5175
5104
|
}
|
|
5176
5105
|
function escapeKeyPathComponent(e) {
|
|
5177
|
-
return e.replaceAll("''", "''''").replace(
|
|
5106
|
+
return e.replaceAll("''", "''''").replace(/^$/u, "''").replaceAll("~", "~0").replaceAll(".", "~1");
|
|
5178
5107
|
}
|
|
5179
5108
|
function unescapeKeyPathComponent(e) {
|
|
5180
|
-
return e.replaceAll("~1", ".").replaceAll("~0", "~").replace(/^''
|
|
5109
|
+
return e.replaceAll("~1", ".").replaceAll("~0", "~").replace(/^''$/u, "").replaceAll("''''", "''");
|
|
5181
5110
|
}
|
|
5182
5111
|
function getByKeyPath(e, t) {
|
|
5183
5112
|
if ("" === t) return e;
|
|
5184
|
-
if (null === e || "object"
|
|
5185
|
-
|
|
5186
|
-
if (
|
|
5187
|
-
|
|
5113
|
+
if (null === e || "object" != typeof e) throw new TypeError("Unexpected non-object type");
|
|
5114
|
+
const r = t.indexOf(".");
|
|
5115
|
+
if (-1 !== r) {
|
|
5116
|
+
const n = e[unescapeKeyPathComponent(t.slice(0, r))];
|
|
5188
5117
|
return void 0 === n ? void 0 : getByKeyPath(n, t.slice(r + 1));
|
|
5189
5118
|
}
|
|
5190
5119
|
return e[unescapeKeyPathComponent(t)];
|
|
5191
5120
|
}
|
|
5192
5121
|
function setAtKeyPath(e, t, r) {
|
|
5193
5122
|
if ("" === t) return r;
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5123
|
+
let n = e,
|
|
5124
|
+
o = t;
|
|
5125
|
+
for (;;) {
|
|
5126
|
+
if (!n || "object" != typeof n) throw new TypeError("Unexpected non-object type");
|
|
5127
|
+
if ("__proto__" === o) throw new TypeError("Invalid property");
|
|
5128
|
+
const t = o.indexOf(".");
|
|
5129
|
+
if (-1 === t) return n[unescapeKeyPathComponent(o)] = r, e;
|
|
5130
|
+
n = n[unescapeKeyPathComponent(o.slice(0, t))], o = o.slice(t + 1);
|
|
5131
|
+
}
|
|
5197
5132
|
}
|
|
5198
5133
|
function getJSONType(e) {
|
|
5199
|
-
return null === e ? "null" : Array.isArray(e) ? "array" :
|
|
5200
|
-
}
|
|
5201
|
-
function _await(e, t, r) {
|
|
5202
|
-
return e && e.then || (e = Promise.resolve(e)), t ? e.then(t) : e;
|
|
5203
|
-
}
|
|
5204
|
-
var n = Object.keys,
|
|
5205
|
-
a = Object.hasOwn,
|
|
5206
|
-
o = Array.isArray,
|
|
5207
|
-
i = ["type", "replaced", "iterateIn", "iterateUnsetNumeric", "addLength"];
|
|
5208
|
-
function _async(e) {
|
|
5209
|
-
return function () {
|
|
5210
|
-
for (var t = [], r = 0; r < arguments.length; r++) t[r] = arguments[r];
|
|
5211
|
-
try {
|
|
5212
|
-
return Promise.resolve(e.apply(this, t));
|
|
5213
|
-
} catch (e) {
|
|
5214
|
-
return Promise.reject(e);
|
|
5215
|
-
}
|
|
5216
|
-
};
|
|
5134
|
+
return null === e ? "null" : Array.isArray(e) ? "array" : typeof e;
|
|
5217
5135
|
}
|
|
5136
|
+
/**
|
|
5137
|
+
* @file Typeson - JSON with types.
|
|
5138
|
+
* @license The MIT License (MIT)
|
|
5139
|
+
* @copyright (c) 2016-2018 David Fahlander, Brett Zamir
|
|
5140
|
+
*/
|
|
5141
|
+
const {
|
|
5142
|
+
keys: r,
|
|
5143
|
+
hasOwn: n
|
|
5144
|
+
} = Object,
|
|
5145
|
+
{
|
|
5146
|
+
isArray: o
|
|
5147
|
+
} = Array,
|
|
5148
|
+
s = ["type", "replaced", "iterateIn", "iterateUnsetNumeric", "addLength"];
|
|
5218
5149
|
function nestedPathsFirst(e, t) {
|
|
5219
|
-
var r, n;
|
|
5220
5150
|
if ("" === e.keypath) return -1;
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
return
|
|
5224
|
-
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5151
|
+
let r = e.keypath.match(/\./gu) ?? 0,
|
|
5152
|
+
n = t.keypath.match(/\./gu) ?? 0;
|
|
5153
|
+
return r && (r = r.length), n && (n = n.length), r > n ? -1 : r < n ? 1 : e.keypath < t.keypath ? -1 : e.keypath > t.keypath ? 1 : 0;
|
|
5154
|
+
}
|
|
5155
|
+
class Typeson {
|
|
5156
|
+
constructor(e) {
|
|
5157
|
+
this.options = e, this.plainObjectReplacers = [], this.nonplainObjectReplacers = [], this.revivers = {}, this.types = {};
|
|
5158
|
+
}
|
|
5159
|
+
stringify(e, t, r, n) {
|
|
5160
|
+
n = {
|
|
5161
|
+
...this.options,
|
|
5162
|
+
...n,
|
|
5163
|
+
stringification: true
|
|
5164
|
+
};
|
|
5165
|
+
const s = this.encapsulate(e, null, n);
|
|
5166
|
+
return o(s) ? JSON.stringify(s[0], t, r) : s.then(e => JSON.stringify(e, t, r));
|
|
5167
|
+
}
|
|
5168
|
+
stringifySync(e, t, r, n) {
|
|
5169
|
+
return this.stringify(e, t, r, {
|
|
5170
|
+
throwOnBadSyncType: true,
|
|
5171
|
+
...n,
|
|
5172
|
+
sync: true
|
|
5173
|
+
});
|
|
5174
|
+
}
|
|
5175
|
+
stringifyAsync(e, t, r, n) {
|
|
5176
|
+
return this.stringify(e, t, r, {
|
|
5177
|
+
throwOnBadSyncType: true,
|
|
5178
|
+
...n,
|
|
5179
|
+
sync: false
|
|
5180
|
+
});
|
|
5181
|
+
}
|
|
5182
|
+
parse(e, t, r) {
|
|
5183
|
+
return r = {
|
|
5184
|
+
...this.options,
|
|
5185
|
+
...r,
|
|
5186
|
+
parse: true
|
|
5187
|
+
}, this.revive(JSON.parse(e, t), r);
|
|
5188
|
+
}
|
|
5189
|
+
parseSync(e, t, r) {
|
|
5190
|
+
return this.parse(e, t, {
|
|
5191
|
+
throwOnBadSyncType: true,
|
|
5192
|
+
...r,
|
|
5193
|
+
sync: true
|
|
5194
|
+
});
|
|
5195
|
+
}
|
|
5196
|
+
parseAsync(e, t, r) {
|
|
5197
|
+
return this.parse(e, t, {
|
|
5198
|
+
throwOnBadSyncType: true,
|
|
5199
|
+
...r,
|
|
5200
|
+
sync: false
|
|
5201
|
+
});
|
|
5202
|
+
}
|
|
5203
|
+
specialTypeNames(e, t, r = {}) {
|
|
5204
|
+
return r.returnTypeNames = true, this.encapsulate(e, t, r);
|
|
5205
|
+
}
|
|
5206
|
+
rootTypeName(e, t, r = {}) {
|
|
5207
|
+
return r.iterateNone = true, this.encapsulate(e, t, r);
|
|
5208
|
+
}
|
|
5209
|
+
encapsulate(e, t, a) {
|
|
5210
|
+
const i = {
|
|
5211
|
+
sync: true,
|
|
5212
|
+
...this.options,
|
|
5213
|
+
...a
|
|
5214
|
+
},
|
|
5215
|
+
{
|
|
5216
|
+
sync: c
|
|
5217
|
+
} = i,
|
|
5218
|
+
y = {},
|
|
5219
|
+
l = [],
|
|
5220
|
+
u = [],
|
|
5221
|
+
p = [],
|
|
5222
|
+
f = !("cyclic" in i) || i.cyclic,
|
|
5223
|
+
{
|
|
5224
|
+
encapsulateObserver: d
|
|
5225
|
+
} = i,
|
|
5226
|
+
finish = e => {
|
|
5227
|
+
const t = Object.values(y);
|
|
5228
|
+
if (i.iterateNone) return t.length ? t[0] : getJSONType(e);
|
|
5229
|
+
if (t.length) {
|
|
5230
|
+
if (i.returnTypeNames) return [...new Set(t)];
|
|
5231
|
+
e && isPlainObject(e) && !n(e, "$types") ? e.$types = y : e = {
|
|
5232
|
+
$: e,
|
|
5233
|
+
$types: {
|
|
5234
|
+
$: y
|
|
5235
|
+
}
|
|
5236
|
+
};
|
|
5237
|
+
} else isObject(e) && n(e, "$types") && (e = {
|
|
5238
|
+
$: e,
|
|
5239
|
+
$types: true
|
|
5234
5240
|
});
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5241
|
+
return !i.returnTypeNames && e;
|
|
5242
|
+
},
|
|
5243
|
+
checkPromises = async (e, t) => {
|
|
5244
|
+
const r = await Promise.all(t.map(e => e[1].p));
|
|
5245
|
+
return await Promise.all(r.map(async function (r) {
|
|
5246
|
+
const n = [],
|
|
5247
|
+
[o] = t.splice(0, 1),
|
|
5248
|
+
[s,, a, i, c, y, l] = o,
|
|
5249
|
+
u = _encapsulate(s, r, a, i, n, true, l),
|
|
5250
|
+
p = hasConstructorOf(u, TypesonPromise);
|
|
5251
|
+
if (s && p) {
|
|
5252
|
+
const t = await u.p;
|
|
5253
|
+
return c[y] = t, checkPromises(e, n);
|
|
5254
|
+
}
|
|
5255
|
+
return s ? c[y] = u : e = p ? u.p : u, checkPromises(e, n);
|
|
5256
|
+
})), e;
|
|
5257
|
+
},
|
|
5258
|
+
_adaptBuiltinStateObjectProperties = (e, t, r) => {
|
|
5259
|
+
Object.assign(e, t);
|
|
5260
|
+
const n = s.map(t => {
|
|
5261
|
+
const r = e[t];
|
|
5262
|
+
return delete e[t], r;
|
|
5238
5263
|
});
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
}
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
},
|
|
5280
|
-
|
|
5281
|
-
}));
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
5293
|
-
return r.iterateNone = true, this.encapsulate(e, t, r);
|
|
5294
|
-
}
|
|
5295
|
-
}, {
|
|
5296
|
-
key: "encapsulate",
|
|
5297
|
-
value: function encapsulate(t, r, c) {
|
|
5298
|
-
var s = this,
|
|
5299
|
-
u = _objectSpread2(_objectSpread2({
|
|
5300
|
-
sync: true
|
|
5301
|
-
}, this.options), c),
|
|
5302
|
-
l = u.sync,
|
|
5303
|
-
f = {},
|
|
5304
|
-
y = [],
|
|
5305
|
-
p = [],
|
|
5306
|
-
d = [],
|
|
5307
|
-
v = !("cyclic" in u) || u.cyclic,
|
|
5308
|
-
b = u.encapsulateObserver,
|
|
5309
|
-
m = function finish(e) {
|
|
5310
|
-
var t = Object.values(f);
|
|
5311
|
-
if (u.iterateNone) return t.length ? t[0] : getJSONType(e);
|
|
5312
|
-
if (t.length) {
|
|
5313
|
-
if (u.returnTypeNames) return function _toConsumableArray(e) {
|
|
5314
|
-
return function _arrayWithoutHoles(e) {
|
|
5315
|
-
if (Array.isArray(e)) return _arrayLikeToArray(e);
|
|
5316
|
-
}(e) || function _iterableToArray(e) {
|
|
5317
|
-
if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e);
|
|
5318
|
-
}(e) || _unsupportedIterableToArray(e) || function _nonIterableSpread() {
|
|
5319
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
5320
|
-
}();
|
|
5321
|
-
}(new Set(t));
|
|
5322
|
-
e && isPlainObject(e) && !a(e, "$types") ? e.$types = f : e = {
|
|
5323
|
-
$: e,
|
|
5324
|
-
$types: {
|
|
5325
|
-
$: f
|
|
5326
|
-
}
|
|
5327
|
-
};
|
|
5328
|
-
} else isObject(e) && a(e, "$types") && (e = {
|
|
5329
|
-
$: e,
|
|
5330
|
-
$types: true
|
|
5331
|
-
});
|
|
5332
|
-
return !u.returnTypeNames && e;
|
|
5333
|
-
},
|
|
5334
|
-
h = _async(function (t, r) {
|
|
5335
|
-
return _await(Promise.all(r.map(function (e) {
|
|
5336
|
-
return e[1].p;
|
|
5337
|
-
})), function (n) {
|
|
5338
|
-
return _await(Promise.all(n.map(_async(function (n) {
|
|
5339
|
-
var a = false,
|
|
5340
|
-
o = [],
|
|
5341
|
-
i = _slicedToArray(r.splice(0, 1), 1),
|
|
5342
|
-
c = _slicedToArray(i[0], 7),
|
|
5343
|
-
s = c[0],
|
|
5344
|
-
u = c[2],
|
|
5345
|
-
l = c[3],
|
|
5346
|
-
f = c[4],
|
|
5347
|
-
y = c[5],
|
|
5348
|
-
p = c[6],
|
|
5349
|
-
d = O(s, n, u, l, o, true, p),
|
|
5350
|
-
v = hasConstructorOf(d, e);
|
|
5351
|
-
return function _invoke(e, t) {
|
|
5352
|
-
var r = e();
|
|
5353
|
-
return r && r.then ? r.then(t) : t(r);
|
|
5354
|
-
}(function () {
|
|
5355
|
-
if (s && v) return _await(d.p, function (e) {
|
|
5356
|
-
f[y] = e;
|
|
5357
|
-
var r = h(t, o);
|
|
5358
|
-
return a = true, r;
|
|
5359
|
-
});
|
|
5360
|
-
}, function (e) {
|
|
5361
|
-
return a ? e : (s ? f[y] = d : t = v ? d.p : d, h(t, o));
|
|
5362
|
-
});
|
|
5363
|
-
}))), function () {
|
|
5364
|
-
return t;
|
|
5365
|
-
});
|
|
5366
|
-
});
|
|
5367
|
-
}),
|
|
5368
|
-
g = function _adaptBuiltinStateObjectProperties(e, t, r) {
|
|
5369
|
-
Object.assign(e, t);
|
|
5370
|
-
var n = i.map(function (t) {
|
|
5371
|
-
var r = e[t];
|
|
5372
|
-
return delete e[t], r;
|
|
5373
|
-
});
|
|
5374
|
-
r(), i.forEach(function (t, r) {
|
|
5375
|
-
e[t] = n[r];
|
|
5264
|
+
r(), s.forEach((t, r) => {
|
|
5265
|
+
e[t] = n[r];
|
|
5266
|
+
});
|
|
5267
|
+
},
|
|
5268
|
+
_encapsulate = (e, t, s, a, c, p, f) => {
|
|
5269
|
+
let m,
|
|
5270
|
+
h = {};
|
|
5271
|
+
const g = d ? function (r) {
|
|
5272
|
+
const n = f ?? a.type ?? getJSONType(t);
|
|
5273
|
+
d(Object.assign(r ?? h, {
|
|
5274
|
+
keypath: e,
|
|
5275
|
+
value: t,
|
|
5276
|
+
cyclic: s,
|
|
5277
|
+
stateObj: a,
|
|
5278
|
+
promisesData: c,
|
|
5279
|
+
resolvingTypesonPromise: p,
|
|
5280
|
+
awaitingTypesonPromise: hasConstructorOf(t, TypesonPromise)
|
|
5281
|
+
}, {
|
|
5282
|
+
type: n
|
|
5283
|
+
}));
|
|
5284
|
+
} : null;
|
|
5285
|
+
if (["string", "boolean", "number", "undefined"].includes(typeof t)) return void 0 === t || t === 1 / 0 || 0 === t || t === -1 / 0 || Number.isNaN(t) ? (m = a.replaced ? t : replace(e, t, a, c, false, p, g), m !== t && (h = {
|
|
5286
|
+
replaced: m
|
|
5287
|
+
})) : m = t, g && g(), m;
|
|
5288
|
+
if (null === t) return g && g(), t;
|
|
5289
|
+
if (s && t && "object" == typeof t && !a.iterateIn && !a.iterateUnsetNumeric) {
|
|
5290
|
+
const r = l.indexOf(t);
|
|
5291
|
+
if (-1 !== r) return y[e] = "#", g && g({
|
|
5292
|
+
cyclicKeypath: u[r]
|
|
5293
|
+
}), "#" + u[r];
|
|
5294
|
+
true === s && (l.push(t), u.push(e));
|
|
5295
|
+
}
|
|
5296
|
+
const b = isPlainObject(t),
|
|
5297
|
+
v = o(t),
|
|
5298
|
+
O = (b || v) && (!this.plainObjectReplacers.length || a.replaced) || a.iterateIn ? t : replace(e, t, a, c, b || v, null, g);
|
|
5299
|
+
let w;
|
|
5300
|
+
if (O !== t ? (m = O, h = {
|
|
5301
|
+
replaced: O
|
|
5302
|
+
}) : "" === e && hasConstructorOf(t, TypesonPromise) ? (c.push([e, t, s, a, void 0, void 0, a.type]), m = t) : v && "object" !== a.iterateIn || "array" === a.iterateIn ? (w = new Array(t.length), h = {
|
|
5303
|
+
clone: w
|
|
5304
|
+
}) : !b && (["function", "symbol"].includes(typeof t) || "toJSON" in t || hasConstructorOf(t, TypesonPromise) || hasConstructorOf(t, Promise) || hasConstructorOf(t, ArrayBuffer)) && "object" !== a.iterateIn ? m = t : (w = {}, a.addLength && (w.length = t.length), h = {
|
|
5305
|
+
clone: w
|
|
5306
|
+
}), g && g(), i.iterateNone) return w ?? m;
|
|
5307
|
+
if (!w) return m;
|
|
5308
|
+
if (a.iterateIn) {
|
|
5309
|
+
for (const r in t) {
|
|
5310
|
+
const o = {
|
|
5311
|
+
ownKeys: n(t, r)
|
|
5312
|
+
};
|
|
5313
|
+
_adaptBuiltinStateObjectProperties(a, o, () => {
|
|
5314
|
+
const n = e + (e ? "." : "") + escapeKeyPathComponent(r),
|
|
5315
|
+
o = _encapsulate(n, t[r], Boolean(s), a, c, p);
|
|
5316
|
+
hasConstructorOf(o, TypesonPromise) ? c.push([n, o, Boolean(s), a, w, r, a.type]) : void 0 !== o && (w[r] = o);
|
|
5376
5317
|
});
|
|
5377
|
-
}
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
if (
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
cyclicKeypath: p[A]
|
|
5405
|
-
}), "#" + p[A];
|
|
5406
|
-
true === i && (y.push(r), p.push(t));
|
|
5407
|
-
}
|
|
5408
|
-
var S,
|
|
5409
|
-
j,
|
|
5410
|
-
T = isPlainObject(r),
|
|
5411
|
-
I = o(r),
|
|
5412
|
-
N = (T || I) && (!s.plainObjectReplacers.length || c.replaced) || c.iterateIn ? r : w(t, r, c, l, T || I, null, _);
|
|
5413
|
-
if (N !== r ? (m = N, h = {
|
|
5414
|
-
replaced: N
|
|
5415
|
-
}) : "" === t && hasConstructorOf(r, e) ? (l.push([t, r, i, c, void 0, void 0, c.type]), m = r) : I && "object" !== c.iterateIn || "array" === c.iterateIn ? (S = new Array(r.length), h = {
|
|
5416
|
-
clone: S
|
|
5417
|
-
}) : (["function", "symbol"].includes(_typeof(r)) || "toJSON" in r || hasConstructorOf(r, e) || hasConstructorOf(r, Promise) || hasConstructorOf(r, ArrayBuffer)) && !T && "object" !== c.iterateIn ? m = r : (S = {}, c.addLength && (S.length = r.length), h = {
|
|
5418
|
-
clone: S
|
|
5419
|
-
}), _ && _(), u.iterateNone) return null !== (j = S) && void 0 !== j ? j : m;
|
|
5420
|
-
if (!S) return m;
|
|
5421
|
-
if (c.iterateIn) {
|
|
5422
|
-
var P = function _loop(n) {
|
|
5423
|
-
var o = {
|
|
5424
|
-
ownKeys: a(r, n)
|
|
5425
|
-
};
|
|
5426
|
-
g(c, o, function () {
|
|
5427
|
-
var a = t + (t ? "." : "") + escapeKeyPathComponent(n),
|
|
5428
|
-
o = _encapsulate(a, r[n], Boolean(i), c, l, d);
|
|
5429
|
-
hasConstructorOf(o, e) ? l.push([a, o, Boolean(i), c, S, n, c.type]) : void 0 !== o && (S[n] = o);
|
|
5430
|
-
});
|
|
5431
|
-
};
|
|
5432
|
-
for (var x in r) P(x);
|
|
5433
|
-
_ && _({
|
|
5434
|
-
endIterateIn: true,
|
|
5435
|
-
end: true
|
|
5436
|
-
});
|
|
5437
|
-
} else n(r).forEach(function (n) {
|
|
5438
|
-
var a = t + (t ? "." : "") + escapeKeyPathComponent(n);
|
|
5439
|
-
g(c, {
|
|
5440
|
-
ownKeys: true
|
|
5441
|
-
}, function () {
|
|
5442
|
-
var t = _encapsulate(a, r[n], Boolean(i), c, l, d);
|
|
5443
|
-
hasConstructorOf(t, e) ? l.push([a, t, Boolean(i), c, S, n, c.type]) : void 0 !== t && (S[n] = t);
|
|
5444
|
-
});
|
|
5445
|
-
}), _ && _({
|
|
5446
|
-
endIterateOwn: true,
|
|
5447
|
-
end: true
|
|
5318
|
+
}
|
|
5319
|
+
g && g({
|
|
5320
|
+
endIterateIn: true,
|
|
5321
|
+
end: true
|
|
5322
|
+
});
|
|
5323
|
+
} else r(t).forEach(function (r) {
|
|
5324
|
+
const n = e + (e ? "." : "") + escapeKeyPathComponent(r);
|
|
5325
|
+
_adaptBuiltinStateObjectProperties(a, {
|
|
5326
|
+
ownKeys: true
|
|
5327
|
+
}, () => {
|
|
5328
|
+
const e = _encapsulate(n, t[r], Boolean(s), a, c, p);
|
|
5329
|
+
hasConstructorOf(e, TypesonPromise) ? c.push([n, e, Boolean(s), a, w, r, a.type]) : void 0 !== e && (w[r] = e);
|
|
5330
|
+
});
|
|
5331
|
+
}), g && g({
|
|
5332
|
+
endIterateOwn: true,
|
|
5333
|
+
end: true
|
|
5334
|
+
});
|
|
5335
|
+
if (a.iterateUnsetNumeric) {
|
|
5336
|
+
const r = t.length;
|
|
5337
|
+
for (let n = 0; n < r; n++) {
|
|
5338
|
+
if (n in t) continue;
|
|
5339
|
+
const r = `${e}${e ? "." : ""}${String(n)}`;
|
|
5340
|
+
_adaptBuiltinStateObjectProperties(a, {
|
|
5341
|
+
ownKeys: false
|
|
5342
|
+
}, () => {
|
|
5343
|
+
const e = _encapsulate(r, void 0, Boolean(s), a, c, p);
|
|
5344
|
+
hasConstructorOf(e, TypesonPromise) ? c.push([r, e, Boolean(s), a, w, n, a.type]) : void 0 !== e && (w[n] = e);
|
|
5448
5345
|
});
|
|
5449
|
-
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
ownKeys: false
|
|
5455
|
-
}, function () {
|
|
5456
|
-
var t = _encapsulate(a, void 0, Boolean(i), c, l, d);
|
|
5457
|
-
hasConstructorOf(t, e) ? l.push([a, t, Boolean(i), c, S, n, c.type]) : void 0 !== t && (S[n] = t);
|
|
5458
|
-
});
|
|
5459
|
-
}
|
|
5460
|
-
}, B = 0; B < E; B++) C(B);
|
|
5461
|
-
_ && _({
|
|
5462
|
-
endIterateUnsetNumeric: true,
|
|
5463
|
-
end: true
|
|
5464
|
-
});
|
|
5465
|
-
}
|
|
5466
|
-
return S;
|
|
5467
|
-
},
|
|
5468
|
-
w = function replace(e, t, r, n, a, o, i) {
|
|
5469
|
-
for (var c = a ? s.plainObjectReplacers : s.nonplainObjectReplacers, u = c.length; u--;) {
|
|
5470
|
-
var y = c[u];
|
|
5471
|
-
if (y.test(t, r)) {
|
|
5472
|
-
var p = y.type;
|
|
5473
|
-
if (s.revivers[p]) {
|
|
5474
|
-
var d = f[e];
|
|
5475
|
-
f[e] = d ? [p].concat(d) : p;
|
|
5476
|
-
}
|
|
5477
|
-
if (Object.assign(r, {
|
|
5478
|
-
type: p,
|
|
5479
|
-
replaced: true
|
|
5480
|
-
}), (l || !y.replaceAsync) && !y.replace) return i && i({
|
|
5481
|
-
typeDetected: true
|
|
5482
|
-
}), O(e, t, v && "readonly", r, n, o, p);
|
|
5483
|
-
i && i({
|
|
5484
|
-
replacing: true
|
|
5485
|
-
});
|
|
5486
|
-
var b = void 0;
|
|
5487
|
-
if (l || !y.replaceAsync) {
|
|
5488
|
-
if (void 0 === y.replace) throw new TypeError("Missing replacer");
|
|
5489
|
-
b = y.replace(t, r);
|
|
5490
|
-
} else b = y.replaceAsync(t, r);
|
|
5491
|
-
return O(e, b, v && "readonly", r, n, o, p);
|
|
5492
|
-
}
|
|
5493
|
-
}
|
|
5494
|
-
return t;
|
|
5495
|
-
},
|
|
5496
|
-
_ = O("", t, v, null != r ? r : {}, d);
|
|
5497
|
-
if (d.length) return l && u.throwOnBadSyncType ? function () {
|
|
5498
|
-
throw new TypeError("Sync method requested but async result obtained");
|
|
5499
|
-
}() : Promise.resolve(h(_, d)).then(m);
|
|
5500
|
-
if (!l && u.throwOnBadSyncType) throw new TypeError("Async method requested but sync result obtained");
|
|
5501
|
-
return u.stringification && l ? [m(_)] : l ? m(_) : Promise.resolve(m(_));
|
|
5502
|
-
}
|
|
5503
|
-
}, {
|
|
5504
|
-
key: "encapsulateSync",
|
|
5505
|
-
value: function encapsulateSync(e, t, r) {
|
|
5506
|
-
return this.encapsulate(e, t, _objectSpread2(_objectSpread2({
|
|
5507
|
-
throwOnBadSyncType: true
|
|
5508
|
-
}, r), {}, {
|
|
5509
|
-
sync: true
|
|
5510
|
-
}));
|
|
5511
|
-
}
|
|
5512
|
-
}, {
|
|
5513
|
-
key: "encapsulateAsync",
|
|
5514
|
-
value: function encapsulateAsync(e, t, r) {
|
|
5515
|
-
return this.encapsulate(e, t, _objectSpread2(_objectSpread2({
|
|
5516
|
-
throwOnBadSyncType: true
|
|
5517
|
-
}, r), {}, {
|
|
5518
|
-
sync: false
|
|
5519
|
-
}));
|
|
5520
|
-
}
|
|
5521
|
-
}, {
|
|
5522
|
-
key: "revive",
|
|
5523
|
-
value: function revive(t, r) {
|
|
5524
|
-
var a = this,
|
|
5525
|
-
i = _objectSpread2(_objectSpread2({
|
|
5526
|
-
sync: true
|
|
5527
|
-
}, this.options), r),
|
|
5528
|
-
c = i.sync;
|
|
5529
|
-
function finishRevival(e) {
|
|
5530
|
-
if (c) return e;
|
|
5531
|
-
if (i.throwOnBadSyncType) throw new TypeError("Async method requested but sync result obtained");
|
|
5532
|
-
return Promise.resolve(e);
|
|
5533
|
-
}
|
|
5534
|
-
if (!t || "object" !== _typeof(t) || Array.isArray(t)) return finishRevival(t);
|
|
5535
|
-
var u = t.$types;
|
|
5536
|
-
if (true === u) return finishRevival(t.$);
|
|
5537
|
-
if (!u || "object" !== _typeof(u) || Array.isArray(u)) return finishRevival(t);
|
|
5538
|
-
var l = [],
|
|
5539
|
-
f = {},
|
|
5540
|
-
y = true;
|
|
5541
|
-
u.$ && isPlainObject(u.$) && (t = t.$, u = u.$, y = false);
|
|
5542
|
-
var p = function executeReviver(e, t) {
|
|
5543
|
-
var r,
|
|
5544
|
-
n = _slicedToArray(null !== (r = a.revivers[e]) && void 0 !== r ? r : [], 1)[0];
|
|
5545
|
-
if (!n) throw new Error("Unregistered type: " + e);
|
|
5546
|
-
if (c && !("revive" in n)) return t;
|
|
5547
|
-
if (!c && n.reviveAsync) return n.reviveAsync(t, f);
|
|
5548
|
-
if (n.revive) return n.revive(t, f);
|
|
5549
|
-
throw new Error("Missing reviver");
|
|
5550
|
-
},
|
|
5551
|
-
d = [];
|
|
5552
|
-
function checkUndefined(e) {
|
|
5553
|
-
return hasConstructorOf(e, s) ? void 0 : e;
|
|
5346
|
+
}
|
|
5347
|
+
g && g({
|
|
5348
|
+
endIterateUnsetNumeric: true,
|
|
5349
|
+
end: true
|
|
5350
|
+
});
|
|
5554
5351
|
}
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
});
|
|
5570
|
-
}), r.length) return r.sort(nestedPathsFirst).reduce(function reducer(r, n) {
|
|
5571
|
-
var a = n.keypath,
|
|
5572
|
-
o = n.type;
|
|
5573
|
-
if (isThenable(r)) return r.then(function (e) {
|
|
5574
|
-
return reducer(e, {
|
|
5575
|
-
keypath: a,
|
|
5576
|
-
type: o
|
|
5577
|
-
});
|
|
5578
|
-
});
|
|
5579
|
-
var i = getByKeyPath(t, a);
|
|
5580
|
-
if (hasConstructorOf(i = p(o, i), e)) return i.then(function (e) {
|
|
5581
|
-
var r = setAtKeyPath(t, a, e);
|
|
5582
|
-
r === e && (t = r);
|
|
5583
|
-
});
|
|
5584
|
-
var c = setAtKeyPath(t, a, i);
|
|
5585
|
-
c === i && (t = c);
|
|
5586
|
-
}, void 0);
|
|
5587
|
-
}();
|
|
5588
|
-
return hasConstructorOf(b, e) ? v = b.then(function () {
|
|
5589
|
-
return t;
|
|
5590
|
-
}) : (v = function _revive(t, r, a, i, c) {
|
|
5591
|
-
if (!y || "$types" !== t) {
|
|
5592
|
-
var f = u[t],
|
|
5593
|
-
v = o(r);
|
|
5594
|
-
if (v || isPlainObject(r)) {
|
|
5595
|
-
var b = v ? new Array(r.length) : {};
|
|
5596
|
-
for (n(r).forEach(function (n) {
|
|
5597
|
-
var o = _revive(t + (t ? "." : "") + escapeKeyPathComponent(n), r[n], null != a ? a : b, b, n),
|
|
5598
|
-
i = function set(e) {
|
|
5599
|
-
return hasConstructorOf(e, s) ? b[n] = void 0 : void 0 !== e && (b[n] = e), e;
|
|
5600
|
-
};
|
|
5601
|
-
hasConstructorOf(o, e) ? d.push(o.then(function (e) {
|
|
5602
|
-
return i(e);
|
|
5603
|
-
})) : i(o);
|
|
5604
|
-
}), r = b; l.length;) {
|
|
5605
|
-
var m = _slicedToArray(l[0], 4),
|
|
5606
|
-
h = m[0],
|
|
5607
|
-
g = m[1],
|
|
5608
|
-
O = m[2],
|
|
5609
|
-
w = m[3],
|
|
5610
|
-
_ = getByKeyPath(h, g);
|
|
5611
|
-
if (void 0 === _) break;
|
|
5612
|
-
O[w] = _, l.splice(0, 1);
|
|
5613
|
-
}
|
|
5614
|
-
}
|
|
5615
|
-
if (!f) return r;
|
|
5616
|
-
if ("#" === f) {
|
|
5617
|
-
var A = getByKeyPath(a, r.slice(1));
|
|
5618
|
-
return void 0 === A && l.push([a, r.slice(1), i, c]), A;
|
|
5352
|
+
return w;
|
|
5353
|
+
},
|
|
5354
|
+
replace = (e, t, r, n, o, s, a) => {
|
|
5355
|
+
const i = o ? this.plainObjectReplacers : this.nonplainObjectReplacers;
|
|
5356
|
+
let l = i.length;
|
|
5357
|
+
for (; l--;) {
|
|
5358
|
+
const o = i[l];
|
|
5359
|
+
if (o.test(t, r)) {
|
|
5360
|
+
const {
|
|
5361
|
+
type: i
|
|
5362
|
+
} = o;
|
|
5363
|
+
if (Object.hasOwn(this.revivers, i)) {
|
|
5364
|
+
const t = y[e];
|
|
5365
|
+
y[e] = t ? [i].concat(t) : i;
|
|
5619
5366
|
}
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5367
|
+
if (Object.assign(r, {
|
|
5368
|
+
type: i,
|
|
5369
|
+
replaced: true
|
|
5370
|
+
}), (c || !o.replaceAsync) && !o.replace) return a && a({
|
|
5371
|
+
typeDetected: true
|
|
5372
|
+
}), _encapsulate(e, t, f && "readonly", r, n, s, i);
|
|
5373
|
+
let l;
|
|
5374
|
+
if (a && a({
|
|
5375
|
+
replacing: true
|
|
5376
|
+
}), c || !o.replaceAsync) {
|
|
5377
|
+
if (void 0 === o.replace) throw new TypeError("Missing replacer");
|
|
5378
|
+
l = o.replace(t, r);
|
|
5379
|
+
} else l = o.replaceAsync(t, r);
|
|
5380
|
+
return _encapsulate(e, l, f && "readonly", r, n, s, i);
|
|
5627
5381
|
}
|
|
5628
|
-
}
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5382
|
+
}
|
|
5383
|
+
return t;
|
|
5384
|
+
},
|
|
5385
|
+
m = _encapsulate("", e, f, t ?? {}, p);
|
|
5386
|
+
if (p.length) return c && i.throwOnBadSyncType ? (() => {
|
|
5387
|
+
throw new TypeError("Sync method requested but async result obtained");
|
|
5388
|
+
})() : Promise.resolve(checkPromises(m, p)).then(finish);
|
|
5389
|
+
if (!c && i.throwOnBadSyncType) throw new TypeError("Async method requested but sync result obtained");
|
|
5390
|
+
return c && i.stringification ? [finish(m)] : c ? finish(m) : Promise.resolve(finish(m));
|
|
5391
|
+
}
|
|
5392
|
+
encapsulateSync(e, t, r) {
|
|
5393
|
+
return this.encapsulate(e, t, {
|
|
5394
|
+
throwOnBadSyncType: true,
|
|
5395
|
+
...r,
|
|
5396
|
+
sync: true
|
|
5397
|
+
});
|
|
5398
|
+
}
|
|
5399
|
+
encapsulateAsync(e, t, r) {
|
|
5400
|
+
return this.encapsulate(e, t, {
|
|
5401
|
+
throwOnBadSyncType: true,
|
|
5402
|
+
...r,
|
|
5403
|
+
sync: false
|
|
5404
|
+
});
|
|
5405
|
+
}
|
|
5406
|
+
revive(e, t) {
|
|
5407
|
+
const s = {
|
|
5408
|
+
sync: true,
|
|
5409
|
+
...this.options,
|
|
5410
|
+
...t
|
|
5411
|
+
},
|
|
5412
|
+
{
|
|
5413
|
+
sync: a
|
|
5414
|
+
} = s;
|
|
5415
|
+
function finishRevival(e) {
|
|
5416
|
+
if (a) return e;
|
|
5417
|
+
if (s.throwOnBadSyncType) throw new TypeError("Async method requested but sync result obtained");
|
|
5418
|
+
return Promise.resolve(e);
|
|
5419
|
+
}
|
|
5420
|
+
if (!e || "object" != typeof e || Array.isArray(e)) return finishRevival(e);
|
|
5421
|
+
let i = e.$types;
|
|
5422
|
+
if (true === i) return finishRevival(e.$);
|
|
5423
|
+
if (!i || "object" != typeof i || Array.isArray(i)) return finishRevival(e);
|
|
5424
|
+
const c = [],
|
|
5425
|
+
y = Object.create(null),
|
|
5426
|
+
l = {};
|
|
5427
|
+
let u = true;
|
|
5428
|
+
i.$ && isPlainObject(i.$) && (e = e.$, i = i.$, u = false);
|
|
5429
|
+
const executeReviver = (e, t) => {
|
|
5430
|
+
const [r] = this.revivers[e] ?? [];
|
|
5431
|
+
if (!r) throw new Error("Unregistered type: " + e);
|
|
5432
|
+
if (a && !("revive" in r)) return t;
|
|
5433
|
+
if (!a && r.reviveAsync) return r.reviveAsync(t, l);
|
|
5434
|
+
if (r.revive) return r.revive(t, l);
|
|
5435
|
+
throw new Error("Missing reviver");
|
|
5436
|
+
},
|
|
5437
|
+
p = [];
|
|
5438
|
+
function checkUndefined(e) {
|
|
5439
|
+
return hasConstructorOf(e, Undefined) ? void 0 : e;
|
|
5440
|
+
}
|
|
5441
|
+
const f = (() => {
|
|
5442
|
+
if (!i) throw new Error("Found bad `types`");
|
|
5443
|
+
const t = [];
|
|
5444
|
+
if (Object.entries(i).forEach(([e, r]) => {
|
|
5445
|
+
"#" !== r && [].concat(r).forEach(r => {
|
|
5446
|
+
const [, {
|
|
5447
|
+
plain: n
|
|
5448
|
+
}] = this.revivers[r] ?? [null, {}];
|
|
5449
|
+
n && (t.push({
|
|
5450
|
+
keypath: e,
|
|
5451
|
+
type: r
|
|
5452
|
+
}), delete i[e]);
|
|
5453
|
+
});
|
|
5454
|
+
}), t.length) return t.sort(nestedPathsFirst), t.reduce(function reducer(t, {
|
|
5455
|
+
keypath: r,
|
|
5456
|
+
type: n
|
|
5457
|
+
}) {
|
|
5458
|
+
if (isThenable(t)) return t.then(e => reducer(e, {
|
|
5459
|
+
keypath: r,
|
|
5460
|
+
type: n
|
|
5654
5461
|
}));
|
|
5462
|
+
let o = getByKeyPath(e, r);
|
|
5463
|
+
if (o = executeReviver(n, o), hasConstructorOf(o, TypesonPromise)) return o.then(t => {
|
|
5464
|
+
const n = setAtKeyPath(e, r, t);
|
|
5465
|
+
n === t && (e = n);
|
|
5466
|
+
});
|
|
5467
|
+
const s = setAtKeyPath(e, r, o);
|
|
5468
|
+
s === o && (e = s);
|
|
5469
|
+
}, void 0);
|
|
5470
|
+
})();
|
|
5471
|
+
let d;
|
|
5472
|
+
return hasConstructorOf(f, TypesonPromise) ? d = f.then(() => e) : (d = function _revive(e, t, s, l, f) {
|
|
5473
|
+
if (u && "$types" === e) return;
|
|
5474
|
+
const d = p.length,
|
|
5475
|
+
m = i[e],
|
|
5476
|
+
h = o(t);
|
|
5477
|
+
if (h || isPlainObject(t)) {
|
|
5478
|
+
const o = h ? new Array(t.length) : {};
|
|
5479
|
+
for (r(t).forEach(r => {
|
|
5480
|
+
const n = _revive(e + (e ? "." : "") + escapeKeyPathComponent(r), t[r], s ?? o, o, r),
|
|
5481
|
+
set = e => (hasConstructorOf(e, Undefined) ? o[r] = void 0 : void 0 !== e && (o[r] = e), e);
|
|
5482
|
+
hasConstructorOf(n, TypesonPromise) ? p.push(n.then(e => set(e))) : set(n);
|
|
5483
|
+
}), t = o; c.length;) {
|
|
5484
|
+
const [[e, t, r, o]] = c,
|
|
5485
|
+
s = n(y, t),
|
|
5486
|
+
a = s ? y[t] : getByKeyPath(e, t);
|
|
5487
|
+
if (!s && void 0 === a) break;
|
|
5488
|
+
r[o] = a, c.shift();
|
|
5489
|
+
}
|
|
5655
5490
|
}
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
plain: i.testPlainObjects
|
|
5705
|
-
}];
|
|
5706
|
-
}
|
|
5707
|
-
r.types[t] = i;
|
|
5708
|
-
}
|
|
5491
|
+
if (!m) return y[e] = t, t;
|
|
5492
|
+
if ("#" === m) {
|
|
5493
|
+
const e = t.slice(1),
|
|
5494
|
+
r = n(y, e),
|
|
5495
|
+
o = r ? y[e] : getByKeyPath(s, e);
|
|
5496
|
+
return r || void 0 !== o || c.push([s, e, l, f]), o;
|
|
5497
|
+
}
|
|
5498
|
+
const applyType = t => {
|
|
5499
|
+
const r = [].concat(m).reduce(function reducer(e, t) {
|
|
5500
|
+
if (hasConstructorOf(e, TypesonPromise)) return e.then(e => reducer(e, t));
|
|
5501
|
+
if ("string" != typeof t) throw new TypeError("Bad type JSON");
|
|
5502
|
+
return executeReviver(t, e);
|
|
5503
|
+
}, t);
|
|
5504
|
+
return hasConstructorOf(r, TypesonPromise) ? r.then(t => (y[e] = t, t)) : (y[e] = r, r);
|
|
5505
|
+
};
|
|
5506
|
+
return !a && p.length > d ? TypesonPromise.all(p.slice(d)).then(() => applyType(t)) : applyType(t);
|
|
5507
|
+
}("", e, null), p.length && (d = TypesonPromise.resolve(d).then(e => TypesonPromise.all([e, ...p])).then(([e]) => e))), isThenable(d) ? a && s.throwOnBadSyncType ? (() => {
|
|
5508
|
+
throw new TypeError("Sync method requested but async result obtained");
|
|
5509
|
+
})() : hasConstructorOf(d, TypesonPromise) ? d.p.then(checkUndefined) : d : !a && s.throwOnBadSyncType ? (() => {
|
|
5510
|
+
throw new TypeError("Async method requested but sync result obtained");
|
|
5511
|
+
})() : a ? checkUndefined(d) : Promise.resolve(checkUndefined(d));
|
|
5512
|
+
}
|
|
5513
|
+
reviveSync(e, t) {
|
|
5514
|
+
return this.revive(e, {
|
|
5515
|
+
throwOnBadSyncType: true,
|
|
5516
|
+
...t,
|
|
5517
|
+
sync: true
|
|
5518
|
+
});
|
|
5519
|
+
}
|
|
5520
|
+
reviveAsync(e, t) {
|
|
5521
|
+
return this.revive(e, {
|
|
5522
|
+
throwOnBadSyncType: true,
|
|
5523
|
+
...t,
|
|
5524
|
+
sync: false
|
|
5525
|
+
});
|
|
5526
|
+
}
|
|
5527
|
+
register(e, t) {
|
|
5528
|
+
const n = t ?? {},
|
|
5529
|
+
reg = e => {
|
|
5530
|
+
o(e) ? e.forEach(e => {
|
|
5531
|
+
reg(e);
|
|
5532
|
+
}) : r(e).forEach(t => {
|
|
5533
|
+
if ("#" === t) throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");
|
|
5534
|
+
if (a.includes(t)) throw new TypeError("Plain JSON object types are reserved as type names");
|
|
5535
|
+
let r = e[t];
|
|
5536
|
+
const s = r && "function" != typeof r && !Array.isArray(r) && r.testPlainObjects ? this.plainObjectReplacers : this.nonplainObjectReplacers,
|
|
5537
|
+
i = s.filter(function (e) {
|
|
5538
|
+
return e.type === t;
|
|
5709
5539
|
});
|
|
5540
|
+
if (i.length && (s.splice(s.indexOf(i[0]), 1), delete this.revivers[t], delete this.types[t]), "function" == typeof r) {
|
|
5541
|
+
const e = r;
|
|
5542
|
+
r = {
|
|
5543
|
+
test: t => t && t.constructor === e,
|
|
5544
|
+
replace: e => ({
|
|
5545
|
+
...e
|
|
5546
|
+
}),
|
|
5547
|
+
revive: t => Object.assign(Object.create(e.prototype), t)
|
|
5548
|
+
};
|
|
5549
|
+
} else if (o(r)) {
|
|
5550
|
+
const [e, t, n] = r;
|
|
5551
|
+
r = {
|
|
5552
|
+
test: e,
|
|
5553
|
+
replace: t,
|
|
5554
|
+
revive: n
|
|
5555
|
+
};
|
|
5556
|
+
}
|
|
5557
|
+
if (!r?.test) return;
|
|
5558
|
+
const c = {
|
|
5559
|
+
type: t,
|
|
5560
|
+
test: r.test.bind(r)
|
|
5710
5561
|
};
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
5562
|
+
r.replace && (c.replace = r.replace.bind(r)), r.replaceAsync && (c.replaceAsync = r.replaceAsync.bind(r));
|
|
5563
|
+
const y = "number" == typeof n.fallback ? n.fallback : n.fallback ? 0 : 1 / 0;
|
|
5564
|
+
if (r.testPlainObjects ? this.plainObjectReplacers.splice(y, 0, c) : this.nonplainObjectReplacers.splice(y, 0, c), r.revive || r.reviveAsync) {
|
|
5565
|
+
const e = {};
|
|
5566
|
+
r.revive && (e.revive = r.revive.bind(r)), r.reviveAsync && (e.reviveAsync = r.reviveAsync.bind(r)), this.revivers[t] = [e, {
|
|
5567
|
+
plain: r.testPlainObjects
|
|
5568
|
+
}];
|
|
5569
|
+
}
|
|
5570
|
+
this.types[t] = r;
|
|
5571
|
+
});
|
|
5572
|
+
};
|
|
5573
|
+
return [].concat(e).forEach(e => {
|
|
5574
|
+
reg(e);
|
|
5575
|
+
}), this;
|
|
5576
|
+
}
|
|
5577
|
+
}
|
|
5578
|
+
class Undefined {}
|
|
5579
|
+
Undefined.__typeson__type__ = "TypesonUndefined";
|
|
5580
|
+
const a = ["null", "boolean", "number", "string", "array", "object"];
|
|
5581
|
+
for (var i = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", c = new Uint8Array(256), y = 0; y < 64; y++) c[i.codePointAt(y)] = y;
|
|
5582
|
+
var l = function encode(e, t, r) {
|
|
5723
5583
|
null == r && (r = e.byteLength);
|
|
5724
|
-
for (var n = new Uint8Array(e, 0, r),
|
|
5725
|
-
return
|
|
5584
|
+
for (var n = new Uint8Array(e, 0, r), o = n.length, s = "", a = 0; a < o; a += 3) s += i[n[a] >> 2], s += i[(3 & n[a]) << 4 | n[a + 1] >> 4], s += i[(15 & n[a + 1]) << 2 | n[a + 2] >> 6], s += i[63 & n[a + 2]];
|
|
5585
|
+
return o % 3 == 2 ? s = s.slice(0, -1) + "=" : o % 3 == 1 && (s = s.slice(0, -2) + "=="), s;
|
|
5726
5586
|
},
|
|
5727
|
-
|
|
5587
|
+
u = function decode(e, t) {
|
|
5728
5588
|
var r = e.length;
|
|
5729
5589
|
if (r % 4) throw new Error("Bad base64 length: not divisible by four");
|
|
5730
5590
|
var n,
|
|
5731
|
-
a,
|
|
5732
5591
|
o,
|
|
5733
|
-
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5592
|
+
s,
|
|
5593
|
+
a,
|
|
5594
|
+
i = .75 * e.length,
|
|
5595
|
+
y = 0;
|
|
5596
|
+
"=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
|
|
5597
|
+
for (var l = new ArrayBuffer(i, t), u = new Uint8Array(l), p = 0; p < r; p += 4) n = c[e.codePointAt(p)], o = c[e.codePointAt(p + 1)], s = c[e.codePointAt(p + 2)], a = c[e.codePointAt(p + 3)], u[y++] = n << 2 | o >> 4, u[y++] = (15 & o) << 4 | s >> 2, u[y++] = (3 & s) << 6 | 63 & a;
|
|
5598
|
+
return l;
|
|
5739
5599
|
};
|
|
5740
|
-
const
|
|
5600
|
+
const p = {
|
|
5741
5601
|
arraybuffer: {
|
|
5742
5602
|
test: e => "ArrayBuffer" === toStringTag(e),
|
|
5743
5603
|
replace(e, t) {
|
|
5744
5604
|
t.buffers || (t.buffers = []);
|
|
5745
5605
|
const r = t.buffers.indexOf(e);
|
|
5746
|
-
return
|
|
5606
|
+
return -1 !== r ? {
|
|
5747
5607
|
index: r
|
|
5748
5608
|
} : (t.buffers.push(e), {
|
|
5749
|
-
s:
|
|
5609
|
+
s: l(e),
|
|
5750
5610
|
maxByteLength: e.maxByteLength,
|
|
5751
5611
|
resizable: e.resizable
|
|
5752
5612
|
});
|
|
5753
5613
|
},
|
|
5754
5614
|
revive(e, t) {
|
|
5755
5615
|
if (t.buffers || (t.buffers = []), Object.hasOwn(e, "index")) return t.buffers[e.index];
|
|
5756
|
-
const r =
|
|
5616
|
+
const r = u(e.s, e.resizable ? {
|
|
5757
5617
|
maxByteLength: e.maxByteLength
|
|
5758
5618
|
} : void 0);
|
|
5759
5619
|
return t.buffers.push(r), r;
|
|
5760
5620
|
}
|
|
5761
5621
|
}
|
|
5762
5622
|
},
|
|
5763
|
-
|
|
5623
|
+
f = {
|
|
5764
5624
|
bigintObject: {
|
|
5765
5625
|
test: e => "object" == typeof e && hasConstructorOf(e, BigInt),
|
|
5766
5626
|
replace: String,
|
|
5767
5627
|
revive: e => new Object(BigInt(e))
|
|
5768
5628
|
}
|
|
5769
5629
|
},
|
|
5770
|
-
|
|
5630
|
+
d = {
|
|
5771
5631
|
bigint: {
|
|
5772
5632
|
test: e => "bigint" == typeof e,
|
|
5773
5633
|
replace: String,
|
|
@@ -5782,7 +5642,7 @@ function string2arraybuffer(e) {
|
|
|
5782
5642
|
for (let r = 0; r < e.length; r++) t[r] = e.charCodeAt(r);
|
|
5783
5643
|
return t.buffer;
|
|
5784
5644
|
}
|
|
5785
|
-
const
|
|
5645
|
+
const m = {
|
|
5786
5646
|
blob: {
|
|
5787
5647
|
test: e => "Blob" === toStringTag(e),
|
|
5788
5648
|
replace(e) {
|
|
@@ -5802,33 +5662,33 @@ const h = {
|
|
|
5802
5662
|
type: t
|
|
5803
5663
|
});
|
|
5804
5664
|
},
|
|
5805
|
-
replaceAsync:
|
|
5665
|
+
replaceAsync: e => new TypesonPromise((t, r) => {
|
|
5806
5666
|
const n = new FileReader();
|
|
5807
5667
|
n.addEventListener("load", () => {
|
|
5808
|
-
|
|
5809
|
-
type:
|
|
5668
|
+
t({
|
|
5669
|
+
type: e.type,
|
|
5810
5670
|
stringContents: arraybuffer2string(n.result)
|
|
5811
5671
|
});
|
|
5812
5672
|
}), n.addEventListener("error", () => {
|
|
5813
5673
|
r(n.error);
|
|
5814
|
-
}), n.readAsArrayBuffer(
|
|
5674
|
+
}), n.readAsArrayBuffer(e);
|
|
5815
5675
|
})
|
|
5816
5676
|
}
|
|
5817
5677
|
};
|
|
5818
|
-
const
|
|
5678
|
+
const b = {
|
|
5819
5679
|
cryptokey: {
|
|
5820
5680
|
test: e => "CryptoKey" === toStringTag(e) && e.extractable,
|
|
5821
|
-
replaceAsync:
|
|
5681
|
+
replaceAsync: e => new TypesonPromise(async (t, r) => {
|
|
5822
5682
|
let n;
|
|
5823
5683
|
try {
|
|
5824
|
-
n = await crypto.subtle.exportKey("jwk",
|
|
5684
|
+
n = await crypto.subtle.exportKey("jwk", e);
|
|
5825
5685
|
} catch (e) {
|
|
5826
5686
|
return void r(e);
|
|
5827
5687
|
}
|
|
5828
|
-
|
|
5688
|
+
t({
|
|
5829
5689
|
jwk: n,
|
|
5830
|
-
algorithm:
|
|
5831
|
-
usages:
|
|
5690
|
+
algorithm: e.algorithm,
|
|
5691
|
+
usages: e.usages
|
|
5832
5692
|
});
|
|
5833
5693
|
}),
|
|
5834
5694
|
revive(e) {
|
|
@@ -5841,7 +5701,7 @@ const w = {
|
|
|
5841
5701
|
}
|
|
5842
5702
|
}
|
|
5843
5703
|
},
|
|
5844
|
-
|
|
5704
|
+
v = {
|
|
5845
5705
|
dataview: {
|
|
5846
5706
|
test: e => "DataView" === toStringTag(e),
|
|
5847
5707
|
replace({
|
|
@@ -5850,13 +5710,13 @@ const w = {
|
|
|
5850
5710
|
byteLength: r
|
|
5851
5711
|
}, n) {
|
|
5852
5712
|
n.buffers || (n.buffers = []);
|
|
5853
|
-
const
|
|
5854
|
-
return
|
|
5855
|
-
index:
|
|
5713
|
+
const o = n.buffers.indexOf(e);
|
|
5714
|
+
return -1 !== o ? {
|
|
5715
|
+
index: o,
|
|
5856
5716
|
byteOffset: t,
|
|
5857
5717
|
byteLength: r
|
|
5858
5718
|
} : (n.buffers.push(e), {
|
|
5859
|
-
encoded:
|
|
5719
|
+
encoded: l(e),
|
|
5860
5720
|
maxByteLength: e.maxByteLength,
|
|
5861
5721
|
resizable: e.resizable,
|
|
5862
5722
|
byteOffset: t,
|
|
@@ -5868,29 +5728,29 @@ const w = {
|
|
|
5868
5728
|
const {
|
|
5869
5729
|
byteOffset: r,
|
|
5870
5730
|
byteLength: n,
|
|
5871
|
-
encoded:
|
|
5872
|
-
index:
|
|
5873
|
-
maxByteLength:
|
|
5874
|
-
resizable:
|
|
5731
|
+
encoded: o,
|
|
5732
|
+
index: s,
|
|
5733
|
+
maxByteLength: a,
|
|
5734
|
+
resizable: i
|
|
5875
5735
|
} = e;
|
|
5876
|
-
let
|
|
5877
|
-
return "index" in e ?
|
|
5878
|
-
maxByteLength:
|
|
5879
|
-
} :
|
|
5736
|
+
let c;
|
|
5737
|
+
return "index" in e ? c = t.buffers[s] : (c = u(o, i ? {
|
|
5738
|
+
maxByteLength: a
|
|
5739
|
+
} : a), t.buffers.push(c)), new DataView(c, r, n);
|
|
5880
5740
|
}
|
|
5881
5741
|
}
|
|
5882
5742
|
},
|
|
5883
|
-
|
|
5743
|
+
O = {
|
|
5884
5744
|
date: {
|
|
5885
5745
|
test: e => "Date" === toStringTag(e),
|
|
5886
5746
|
replace(e) {
|
|
5887
5747
|
const t = e.getTime();
|
|
5888
5748
|
return Number.isNaN(t) ? "NaN" : t;
|
|
5889
5749
|
},
|
|
5890
|
-
revive: e => "NaN" === e ? new Date(
|
|
5750
|
+
revive: e => "NaN" === e ? new Date(NaN) : new Date(e)
|
|
5891
5751
|
}
|
|
5892
5752
|
},
|
|
5893
|
-
|
|
5753
|
+
w = {
|
|
5894
5754
|
domexception: {
|
|
5895
5755
|
test: e => "DOMException" === toStringTag(e),
|
|
5896
5756
|
replace: e => ({
|
|
@@ -5903,9 +5763,9 @@ const w = {
|
|
|
5903
5763
|
}) => new DOMException(e, t)
|
|
5904
5764
|
}
|
|
5905
5765
|
},
|
|
5906
|
-
|
|
5766
|
+
T = {};
|
|
5907
5767
|
function create$5(e) {
|
|
5908
|
-
|
|
5768
|
+
T[e.name.toLowerCase()] = {
|
|
5909
5769
|
test: t => toStringTag(t) === e.name,
|
|
5910
5770
|
replace: e => e.is2D ? {
|
|
5911
5771
|
a: e.a,
|
|
@@ -5936,9 +5796,9 @@ function create$5(e) {
|
|
|
5936
5796
|
};
|
|
5937
5797
|
}
|
|
5938
5798
|
"undefined" != typeof DOMMatrix && create$5(DOMMatrix), "undefined" != typeof DOMMatrixReadOnly && create$5(DOMMatrixReadOnly);
|
|
5939
|
-
const
|
|
5799
|
+
const A = {};
|
|
5940
5800
|
function create$4(e) {
|
|
5941
|
-
|
|
5801
|
+
A[e.name.toLowerCase()] = {
|
|
5942
5802
|
test: t => toStringTag(t) === e.name,
|
|
5943
5803
|
replace: e => ({
|
|
5944
5804
|
x: e.x,
|
|
@@ -5950,12 +5810,12 @@ function create$4(e) {
|
|
|
5950
5810
|
x: t,
|
|
5951
5811
|
y: r,
|
|
5952
5812
|
z: n,
|
|
5953
|
-
w:
|
|
5954
|
-
}) => new e(t, r, n,
|
|
5813
|
+
w: o
|
|
5814
|
+
}) => new e(t, r, n, o)
|
|
5955
5815
|
};
|
|
5956
5816
|
}
|
|
5957
5817
|
"undefined" != typeof DOMPoint && create$4(DOMPoint), "undefined" != typeof DOMPointReadOnly && create$4(DOMPointReadOnly);
|
|
5958
|
-
const
|
|
5818
|
+
const P = {
|
|
5959
5819
|
domquad: {
|
|
5960
5820
|
test: e => "DOMQuad" === toStringTag(e),
|
|
5961
5821
|
replace: e => ({
|
|
@@ -5972,9 +5832,9 @@ const I = {
|
|
|
5972
5832
|
}) => new DOMQuad(e, t, r, n)
|
|
5973
5833
|
}
|
|
5974
5834
|
},
|
|
5975
|
-
|
|
5835
|
+
S = {};
|
|
5976
5836
|
function create$3(e) {
|
|
5977
|
-
|
|
5837
|
+
S[e.name.toLowerCase()] = {
|
|
5978
5838
|
test: t => toStringTag(t) === e.name,
|
|
5979
5839
|
replace: e => ({
|
|
5980
5840
|
x: e.x,
|
|
@@ -5986,12 +5846,12 @@ function create$3(e) {
|
|
|
5986
5846
|
x: t,
|
|
5987
5847
|
y: r,
|
|
5988
5848
|
width: n,
|
|
5989
|
-
height:
|
|
5990
|
-
}) => new e(t, r, n,
|
|
5849
|
+
height: o
|
|
5850
|
+
}) => new e(t, r, n, o)
|
|
5991
5851
|
};
|
|
5992
5852
|
}
|
|
5993
5853
|
"undefined" != typeof DOMRect && create$3(DOMRect), "undefined" != typeof DOMRectReadOnly && create$3(DOMRectReadOnly);
|
|
5994
|
-
const
|
|
5854
|
+
const x = {
|
|
5995
5855
|
error: {
|
|
5996
5856
|
test: e => "Error" === toStringTag(e),
|
|
5997
5857
|
replace: ({
|
|
@@ -5999,17 +5859,17 @@ const P = {
|
|
|
5999
5859
|
message: t,
|
|
6000
5860
|
cause: r,
|
|
6001
5861
|
stack: n,
|
|
6002
|
-
fileName:
|
|
6003
|
-
lineNumber:
|
|
6004
|
-
columnNumber:
|
|
5862
|
+
fileName: o,
|
|
5863
|
+
lineNumber: s,
|
|
5864
|
+
columnNumber: a
|
|
6005
5865
|
}) => ({
|
|
6006
5866
|
name: e,
|
|
6007
5867
|
message: t,
|
|
6008
5868
|
cause: r,
|
|
6009
5869
|
stack: n,
|
|
6010
|
-
fileName:
|
|
6011
|
-
lineNumber:
|
|
6012
|
-
columnNumber:
|
|
5870
|
+
fileName: o,
|
|
5871
|
+
lineNumber: s,
|
|
5872
|
+
columnNumber: a
|
|
6013
5873
|
}),
|
|
6014
5874
|
revive(e) {
|
|
6015
5875
|
const t = new Error(e.message);
|
|
@@ -6017,28 +5877,28 @@ const P = {
|
|
|
6017
5877
|
}
|
|
6018
5878
|
}
|
|
6019
5879
|
},
|
|
6020
|
-
|
|
5880
|
+
j = {};
|
|
6021
5881
|
function create$2(e) {
|
|
6022
|
-
|
|
5882
|
+
j[e.name.toLowerCase()] = {
|
|
6023
5883
|
test: t => hasConstructorOf(t, e),
|
|
6024
5884
|
replace: ({
|
|
6025
5885
|
name: e,
|
|
6026
5886
|
message: t,
|
|
6027
5887
|
cause: r,
|
|
6028
5888
|
stack: n,
|
|
6029
|
-
fileName:
|
|
6030
|
-
lineNumber:
|
|
6031
|
-
columnNumber:
|
|
6032
|
-
errors:
|
|
5889
|
+
fileName: o,
|
|
5890
|
+
lineNumber: s,
|
|
5891
|
+
columnNumber: a,
|
|
5892
|
+
errors: i
|
|
6033
5893
|
}) => ({
|
|
6034
5894
|
name: e,
|
|
6035
5895
|
message: t,
|
|
6036
5896
|
cause: r,
|
|
6037
5897
|
stack: n,
|
|
6038
|
-
fileName:
|
|
6039
|
-
lineNumber:
|
|
6040
|
-
columnNumber:
|
|
6041
|
-
errors:
|
|
5898
|
+
fileName: o,
|
|
5899
|
+
lineNumber: s,
|
|
5900
|
+
columnNumber: a,
|
|
5901
|
+
errors: i
|
|
6042
5902
|
}),
|
|
6043
5903
|
revive(t) {
|
|
6044
5904
|
const r = "undefined" != typeof AggregateError && e === AggregateError ? new e(t.errors, t.message) : new e(t.message);
|
|
@@ -6047,7 +5907,7 @@ function create$2(e) {
|
|
|
6047
5907
|
};
|
|
6048
5908
|
}
|
|
6049
5909
|
[TypeError, RangeError, SyntaxError, ReferenceError, EvalError, URIError].forEach(e => create$2(e)), "undefined" != typeof AggregateError && create$2(AggregateError), "function" == typeof InternalError && create$2(InternalError);
|
|
6050
|
-
const
|
|
5910
|
+
const N = {
|
|
6051
5911
|
file: {
|
|
6052
5912
|
test: e => "File" === toStringTag(e),
|
|
6053
5913
|
replace(e) {
|
|
@@ -6069,23 +5929,23 @@ const E = {
|
|
|
6069
5929
|
type: t,
|
|
6070
5930
|
lastModified: n
|
|
6071
5931
|
}),
|
|
6072
|
-
replaceAsync:
|
|
5932
|
+
replaceAsync: e => new TypesonPromise(function (t, r) {
|
|
6073
5933
|
const n = new FileReader();
|
|
6074
5934
|
n.addEventListener("load", function () {
|
|
6075
|
-
|
|
6076
|
-
type:
|
|
5935
|
+
t({
|
|
5936
|
+
type: e.type,
|
|
6077
5937
|
stringContents: arraybuffer2string(n.result),
|
|
6078
|
-
name:
|
|
6079
|
-
lastModified:
|
|
5938
|
+
name: e.name,
|
|
5939
|
+
lastModified: e.lastModified
|
|
6080
5940
|
});
|
|
6081
5941
|
}), n.addEventListener("error", function () {
|
|
6082
5942
|
r(n.error);
|
|
6083
|
-
}), n.readAsArrayBuffer(
|
|
5943
|
+
}), n.readAsArrayBuffer(e);
|
|
6084
5944
|
})
|
|
6085
5945
|
}
|
|
6086
5946
|
},
|
|
6087
|
-
|
|
6088
|
-
file:
|
|
5947
|
+
_ = {
|
|
5948
|
+
file: N.file,
|
|
6089
5949
|
filelist: {
|
|
6090
5950
|
test: e => "FileList" === toStringTag(e),
|
|
6091
5951
|
replace(e) {
|
|
@@ -6128,23 +5988,23 @@ const E = {
|
|
|
6128
5988
|
r.drawImage(n, 0, 0);
|
|
6129
5989
|
}), n.src = e.dataURL, "undefined" == typeof OffscreenCanvas ? t : t.transferToImageBitmap();
|
|
6130
5990
|
},
|
|
6131
|
-
reviveAsync(
|
|
6132
|
-
const
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
return
|
|
6136
|
-
|
|
6137
|
-
}),
|
|
5991
|
+
reviveAsync(e) {
|
|
5992
|
+
const t = document.createElement("canvas"),
|
|
5993
|
+
r = t.getContext("2d"),
|
|
5994
|
+
n = document.createElement("img");
|
|
5995
|
+
return n.addEventListener("load", function () {
|
|
5996
|
+
r.drawImage(n, 0, 0);
|
|
5997
|
+
}), n.src = e.dataURL, new TypesonPromise(async (e, r) => {
|
|
6138
5998
|
try {
|
|
6139
|
-
e(await createImageBitmap(
|
|
5999
|
+
e(await createImageBitmap(t));
|
|
6140
6000
|
} catch (e) {
|
|
6141
|
-
|
|
6001
|
+
r(e);
|
|
6142
6002
|
}
|
|
6143
6003
|
});
|
|
6144
6004
|
}
|
|
6145
6005
|
}
|
|
6146
6006
|
},
|
|
6147
|
-
|
|
6007
|
+
E = {
|
|
6148
6008
|
imagedata: {
|
|
6149
6009
|
test: e => "ImageData" === toStringTag(e),
|
|
6150
6010
|
replace: e => ({
|
|
@@ -6155,42 +6015,42 @@ const E = {
|
|
|
6155
6015
|
revive: e => new ImageData(new Uint8ClampedArray(e.array), e.width, e.height)
|
|
6156
6016
|
}
|
|
6157
6017
|
},
|
|
6158
|
-
|
|
6018
|
+
C = {
|
|
6159
6019
|
infinity: {
|
|
6160
|
-
test: e => e ===
|
|
6020
|
+
test: e => e === 1 / 0,
|
|
6161
6021
|
replace: () => "Infinity",
|
|
6162
|
-
revive: () =>
|
|
6022
|
+
revive: () => 1 / 0
|
|
6163
6023
|
}
|
|
6164
6024
|
},
|
|
6165
|
-
|
|
6025
|
+
U = {
|
|
6166
6026
|
map: {
|
|
6167
6027
|
test: e => "Map" === toStringTag(e),
|
|
6168
|
-
replace: e =>
|
|
6028
|
+
replace: e => e.entries().toArray(),
|
|
6169
6029
|
revive: e => new Map(e)
|
|
6170
6030
|
}
|
|
6171
6031
|
},
|
|
6172
|
-
|
|
6032
|
+
M = {
|
|
6173
6033
|
nan: {
|
|
6174
6034
|
test: e => Number.isNaN(e),
|
|
6175
6035
|
replace: () => "NaN",
|
|
6176
|
-
revive: () =>
|
|
6036
|
+
revive: () => NaN
|
|
6177
6037
|
}
|
|
6178
6038
|
},
|
|
6179
|
-
|
|
6039
|
+
L = {
|
|
6180
6040
|
negativeInfinity: {
|
|
6181
|
-
test: e => e ===
|
|
6041
|
+
test: e => e === -1 / 0,
|
|
6182
6042
|
replace: () => "-Infinity",
|
|
6183
|
-
revive: () =>
|
|
6043
|
+
revive: () => -1 / 0
|
|
6184
6044
|
}
|
|
6185
6045
|
},
|
|
6186
|
-
|
|
6046
|
+
D = {
|
|
6187
6047
|
negativeZero: {
|
|
6188
6048
|
test: e => Object.is(e, -0),
|
|
6189
6049
|
replace: () => 0,
|
|
6190
6050
|
revive: () => -0
|
|
6191
6051
|
}
|
|
6192
6052
|
},
|
|
6193
|
-
|
|
6053
|
+
k = {
|
|
6194
6054
|
StringObject: {
|
|
6195
6055
|
test: e => "String" === toStringTag(e) && "object" == typeof e,
|
|
6196
6056
|
replace: String,
|
|
@@ -6207,12 +6067,12 @@ const E = {
|
|
|
6207
6067
|
revive: e => new Number(e)
|
|
6208
6068
|
}
|
|
6209
6069
|
},
|
|
6210
|
-
|
|
6070
|
+
$ = {
|
|
6211
6071
|
regexp: {
|
|
6212
6072
|
test: e => "RegExp" === toStringTag(e),
|
|
6213
6073
|
replace: e => ({
|
|
6214
6074
|
source: e.source,
|
|
6215
|
-
flags: (e.global ? "g" : "") + (e.ignoreCase ? "i" : "") + (e.multiline ? "m" : "") + (e.sticky ? "y" : "") + (e.unicode ? "u" : "")
|
|
6075
|
+
flags: (e.global ? "g" : "") + (e.ignoreCase ? "i" : "") + (e.multiline ? "m" : "") + (e.sticky ? "y" : "") + (e.unicode ? "u" : "") + (e.unicodeSets ? "v" : "") + (e.hasIndices ? "d" : "") + (e.dotAll ? "s" : "")
|
|
6216
6076
|
}),
|
|
6217
6077
|
revive: ({
|
|
6218
6078
|
source: e,
|
|
@@ -6220,26 +6080,26 @@ const E = {
|
|
|
6220
6080
|
}) => new RegExp(e, t)
|
|
6221
6081
|
}
|
|
6222
6082
|
},
|
|
6223
|
-
|
|
6083
|
+
J = {
|
|
6224
6084
|
set: {
|
|
6225
6085
|
test: e => "Set" === toStringTag(e),
|
|
6226
|
-
replace: e =>
|
|
6086
|
+
replace: e => e.values().toArray(),
|
|
6227
6087
|
revive: e => new Set(e)
|
|
6228
6088
|
}
|
|
6229
6089
|
},
|
|
6230
|
-
|
|
6090
|
+
V = {};
|
|
6231
6091
|
"function" == typeof Int8Array && [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, ...("function" == typeof BigInt64Array ? [BigInt64Array, BigUint64Array] : [])].forEach(e => function create$1(e) {
|
|
6232
6092
|
const t = e.name;
|
|
6233
|
-
|
|
6093
|
+
V[t.toLowerCase()] = {
|
|
6234
6094
|
test: e => toStringTag(e) === t,
|
|
6235
6095
|
replace: e => (0 === e.byteOffset && e.byteLength === e.buffer.byteLength ? e : e.slice(0)).buffer,
|
|
6236
6096
|
revive: t => "ArrayBuffer" === toStringTag(t) ? new e(t) : t
|
|
6237
6097
|
};
|
|
6238
6098
|
}(e));
|
|
6239
|
-
const
|
|
6099
|
+
const W = {};
|
|
6240
6100
|
"function" == typeof Int8Array && [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, ...("function" == typeof BigInt64Array ? [BigInt64Array, BigUint64Array] : [])].forEach(e => function create(e) {
|
|
6241
6101
|
const t = e.name;
|
|
6242
|
-
|
|
6102
|
+
W[t.toLowerCase()] = {
|
|
6243
6103
|
test: e => toStringTag(e) === t,
|
|
6244
6104
|
replace({
|
|
6245
6105
|
buffer: e,
|
|
@@ -6247,15 +6107,15 @@ const X = {};
|
|
|
6247
6107
|
length: r
|
|
6248
6108
|
}, n) {
|
|
6249
6109
|
n.buffers || (n.buffers = []);
|
|
6250
|
-
const
|
|
6251
|
-
return
|
|
6252
|
-
index:
|
|
6110
|
+
const o = n.buffers.indexOf(e);
|
|
6111
|
+
return -1 !== o ? {
|
|
6112
|
+
index: o,
|
|
6253
6113
|
byteOffset: t,
|
|
6254
6114
|
length: r
|
|
6255
6115
|
} : (n.buffers.push(e), {
|
|
6256
6116
|
maxByteLength: e.maxByteLength,
|
|
6257
6117
|
resizable: e.resizable,
|
|
6258
|
-
encoded:
|
|
6118
|
+
encoded: l(e),
|
|
6259
6119
|
byteOffset: t,
|
|
6260
6120
|
length: r
|
|
6261
6121
|
});
|
|
@@ -6264,27 +6124,27 @@ const X = {};
|
|
|
6264
6124
|
r.buffers || (r.buffers = []);
|
|
6265
6125
|
const {
|
|
6266
6126
|
byteOffset: n,
|
|
6267
|
-
length:
|
|
6268
|
-
encoded:
|
|
6269
|
-
index:
|
|
6270
|
-
maxByteLength:
|
|
6271
|
-
resizable:
|
|
6127
|
+
length: o,
|
|
6128
|
+
encoded: s,
|
|
6129
|
+
index: a,
|
|
6130
|
+
maxByteLength: i,
|
|
6131
|
+
resizable: c
|
|
6272
6132
|
} = t;
|
|
6273
|
-
let
|
|
6274
|
-
return "index" in t ?
|
|
6275
|
-
maxByteLength:
|
|
6276
|
-
} : void 0), r.buffers.push(
|
|
6133
|
+
let y;
|
|
6134
|
+
return "index" in t ? y = r.buffers[a] : (y = u(s, c ? {
|
|
6135
|
+
maxByteLength: i
|
|
6136
|
+
} : void 0), r.buffers.push(y)), new e(y, n, o);
|
|
6277
6137
|
}
|
|
6278
6138
|
};
|
|
6279
6139
|
}(e));
|
|
6280
|
-
const
|
|
6140
|
+
const Q = {
|
|
6281
6141
|
undef: {
|
|
6282
6142
|
test: (e, t) => void 0 === e && (t.ownKeys || !("ownKeys" in t)),
|
|
6283
6143
|
replace: () => 0,
|
|
6284
|
-
revive: () => new
|
|
6144
|
+
revive: () => new Undefined()
|
|
6285
6145
|
}
|
|
6286
6146
|
},
|
|
6287
|
-
|
|
6147
|
+
G = {
|
|
6288
6148
|
userObject: {
|
|
6289
6149
|
test: e => isUserObject(e),
|
|
6290
6150
|
replace: e => ({
|
|
@@ -6293,10 +6153,10 @@ const Z = {
|
|
|
6293
6153
|
revive: e => e
|
|
6294
6154
|
}
|
|
6295
6155
|
},
|
|
6296
|
-
|
|
6156
|
+
H = [{
|
|
6297
6157
|
arrayNonindexKeys: {
|
|
6298
6158
|
testPlainObjects: true,
|
|
6299
|
-
test: (e, t) => !!Array.isArray(e) && (Object.keys(e).some(e => String(Number
|
|
6159
|
+
test: (e, t) => !!Array.isArray(e) && (Object.keys(e).some(e => String(Number(e)) !== e) && (t.iterateIn = "object", t.addLength = true), true),
|
|
6300
6160
|
replace: (e, t) => (t.iterateUnsetNumeric = true, e),
|
|
6301
6161
|
revive(e) {
|
|
6302
6162
|
if (Array.isArray(e)) return e;
|
|
@@ -6313,9 +6173,9 @@ const Z = {
|
|
|
6313
6173
|
revive() {}
|
|
6314
6174
|
}
|
|
6315
6175
|
}],
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6176
|
+
X = [M, C, L, D],
|
|
6177
|
+
re = [G, Q, H, k, X, O, $, E, B, N, _, m, x, j].concat("function" == typeof Map ? U : [], "function" == typeof Set ? J : [], "function" == typeof ArrayBuffer ? p : [], "function" == typeof Uint8Array ? W : [], "function" == typeof DataView ? v : [], "undefined" != typeof crypto ? b : [], "undefined" != typeof BigInt ? [d, f] : [], "undefined" != typeof DOMException ? w : [], "undefined" != typeof DOMRect ? S : [], "undefined" != typeof DOMPoint ? A : [], "undefined" != typeof DOMQuad ? P : [], "undefined" != typeof DOMMatrix ? T : []),
|
|
6178
|
+
ne = re.concat({
|
|
6319
6179
|
checkDataCloneException: {
|
|
6320
6180
|
test(e) {
|
|
6321
6181
|
const t = {}.toString.call(e).slice(8, -1);
|
|
@@ -6325,9 +6185,9 @@ const Z = {
|
|
|
6325
6185
|
}
|
|
6326
6186
|
});
|
|
6327
6187
|
|
|
6328
|
-
// See:
|
|
6188
|
+
// See: https://stackoverflow.com/questions/42170826/categories-for-rejection-by-the-structured-cloning-algorithm
|
|
6329
6189
|
|
|
6330
|
-
let typeson = new
|
|
6190
|
+
let typeson = new Typeson().register(ne);
|
|
6331
6191
|
|
|
6332
6192
|
/**
|
|
6333
6193
|
* @param {(preset: import('typeson-registry').Preset) =>
|
|
@@ -6335,7 +6195,8 @@ let typeson = new c().register(se);
|
|
|
6335
6195
|
* @returns {void}
|
|
6336
6196
|
*/
|
|
6337
6197
|
function register(func) {
|
|
6338
|
-
|
|
6198
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Should be one-time cache
|
|
6199
|
+
typeson = new Typeson().register(func(ne));
|
|
6339
6200
|
}
|
|
6340
6201
|
|
|
6341
6202
|
/**
|
|
@@ -6423,7 +6284,8 @@ const readonlyProperties$2 = ['objectStore', 'keyPath', 'multiEntry', 'unique'];
|
|
|
6423
6284
|
|
|
6424
6285
|
/**
|
|
6425
6286
|
* IDB Index.
|
|
6426
|
-
* @see
|
|
6287
|
+
* @see https://www.w3.org/TR/IndexedDB/#idl-def-IDBIndex
|
|
6288
|
+
* @throws {TypeError}
|
|
6427
6289
|
* @class
|
|
6428
6290
|
*/
|
|
6429
6291
|
function IDBIndex() {
|
|
@@ -6479,65 +6341,67 @@ IDBIndex.__createInstance = function (store, indexProperties) {
|
|
|
6479
6341
|
me.__unique = Boolean(optionalParams && optionalParams.unique);
|
|
6480
6342
|
me.__deleted = Boolean(indexProperties.__deleted);
|
|
6481
6343
|
me.__objectStore.__cursors = indexProperties.cursors || [];
|
|
6482
|
-
Object.
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
});
|
|
6491
|
-
Object.defineProperty(me, 'name', {
|
|
6492
|
-
enumerable: false,
|
|
6493
|
-
configurable: false,
|
|
6494
|
-
/**
|
|
6495
|
-
* @this {IDBIndexFull}
|
|
6496
|
-
* @returns {string}
|
|
6497
|
-
*/
|
|
6498
|
-
get() {
|
|
6499
|
-
return this.__name;
|
|
6500
|
-
},
|
|
6501
|
-
/**
|
|
6502
|
-
* @param {string} newName
|
|
6503
|
-
* @this {IDBIndexFull}
|
|
6504
|
-
* @returns {void}
|
|
6505
|
-
*/
|
|
6506
|
-
set(newName) {
|
|
6507
|
-
const me = this;
|
|
6508
|
-
newName = convertToDOMString(newName);
|
|
6509
|
-
const oldName = me.name;
|
|
6510
|
-
IDBTransaction.__assertVersionChange(me.objectStore.transaction);
|
|
6511
|
-
IDBTransaction.__assertActive(me.objectStore.transaction);
|
|
6512
|
-
IDBIndexAlias.__invalidStateIfDeleted(me);
|
|
6513
|
-
IDBObjectStore.__invalidStateIfDeleted(me);
|
|
6514
|
-
if (newName === oldName) {
|
|
6515
|
-
return;
|
|
6516
|
-
}
|
|
6517
|
-
if (me.objectStore.__indexes[newName] && !me.objectStore.__indexes[newName].__deleted && !me.objectStore.__indexes[newName].__pendingDelete) {
|
|
6518
|
-
throw createDOMException('ConstraintError', 'Index "' + newName + '" already exists on ' + me.objectStore.__currentName);
|
|
6344
|
+
Object.defineProperties(me, {
|
|
6345
|
+
__currentName: {
|
|
6346
|
+
/**
|
|
6347
|
+
* @this {IDBIndexFull}
|
|
6348
|
+
* @returns {string}
|
|
6349
|
+
*/
|
|
6350
|
+
get() {
|
|
6351
|
+
return '__pendingName' in me ? (/** @type {string} */me.__pendingName) : me.name;
|
|
6519
6352
|
}
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6535
|
-
|
|
6536
|
-
|
|
6537
|
-
|
|
6538
|
-
|
|
6353
|
+
},
|
|
6354
|
+
name: {
|
|
6355
|
+
enumerable: false,
|
|
6356
|
+
configurable: false,
|
|
6357
|
+
/**
|
|
6358
|
+
* @this {IDBIndexFull}
|
|
6359
|
+
* @returns {string}
|
|
6360
|
+
*/
|
|
6361
|
+
get() {
|
|
6362
|
+
return this.__name;
|
|
6363
|
+
},
|
|
6364
|
+
/**
|
|
6365
|
+
* @param {string} newName
|
|
6366
|
+
* @this {IDBIndexFull}
|
|
6367
|
+
* @returns {void}
|
|
6368
|
+
*/
|
|
6369
|
+
set(newName) {
|
|
6370
|
+
const me = this;
|
|
6371
|
+
newName = convertToDOMString(newName);
|
|
6372
|
+
const oldName = me.name;
|
|
6373
|
+
IDBTransaction.__assertVersionChange(me.objectStore.transaction);
|
|
6374
|
+
IDBTransaction.__assertActive(me.objectStore.transaction);
|
|
6375
|
+
IDBIndexAlias.__invalidStateIfDeleted(me);
|
|
6376
|
+
IDBObjectStore.__invalidStateIfDeleted(me);
|
|
6377
|
+
if (newName === oldName) {
|
|
6378
|
+
return;
|
|
6379
|
+
}
|
|
6380
|
+
if (Object.hasOwn(me.objectStore.__indexes, newName) && !me.objectStore.__indexes[newName].__deleted && !me.objectStore.__indexes[newName].__pendingDelete) {
|
|
6381
|
+
throw createDOMException('ConstraintError', 'Index "' + newName + '" already exists on ' + me.objectStore.__currentName);
|
|
6382
|
+
}
|
|
6383
|
+
me.__name = newName;
|
|
6384
|
+
const {
|
|
6385
|
+
objectStore
|
|
6386
|
+
} = me;
|
|
6387
|
+
delete objectStore.__indexes[oldName];
|
|
6388
|
+
objectStore.__indexes[newName] = me;
|
|
6389
|
+
objectStore.indexNames.splice(objectStore.indexNames.indexOf(oldName), 1, newName);
|
|
6390
|
+
const storeHandle = /** @type {import('./IDBTransaction.js').IDBTransactionFull} */objectStore.transaction.__storeHandles[objectStore.name];
|
|
6391
|
+
const oldIndexHandle = storeHandle.__indexHandles[oldName];
|
|
6392
|
+
oldIndexHandle.__name = newName; // Fix old references
|
|
6393
|
+
storeHandle.__indexHandles[newName] = oldIndexHandle; // Ensure new reference accessible
|
|
6394
|
+
me.__pendingName = oldName;
|
|
6395
|
+
const colInfoToPreserveArr = [['key', 'BLOB ' + (objectStore.autoIncrement ? 'UNIQUE, inc INTEGER PRIMARY KEY AUTOINCREMENT' : 'PRIMARY KEY')], ['value', 'BLOB']].concat(
|
|
6396
|
+
// @ts-expect-error Has numeric indexes instead of iterator
|
|
6397
|
+
[...objectStore.indexNames].filter(indexName => indexName !== newName).map(indexName => [escapeIndexNameForSQL(indexName), 'BLOB']));
|
|
6398
|
+
me.__renameIndex(objectStore, oldName, newName, colInfoToPreserveArr, function (tx, success) {
|
|
6399
|
+
IDBIndexAlias.__updateIndexList(store, tx, function (store) {
|
|
6400
|
+
delete storeHandle.__pendingName;
|
|
6401
|
+
success(store);
|
|
6402
|
+
});
|
|
6539
6403
|
});
|
|
6540
|
-
}
|
|
6404
|
+
}
|
|
6541
6405
|
}
|
|
6542
6406
|
});
|
|
6543
6407
|
}
|
|
@@ -6654,7 +6518,7 @@ IDBIndex.__createIndex = function (store, index) {
|
|
|
6654
6518
|
const indexKeyStr = /** @type {string} */
|
|
6655
6519
|
encode$1(indexKey.value, index.multiEntry);
|
|
6656
6520
|
if (index.unique) {
|
|
6657
|
-
if (indexValues
|
|
6521
|
+
if (Object.hasOwn(indexValues, indexKeyStr)) {
|
|
6658
6522
|
indexValues = {};
|
|
6659
6523
|
failure(createDOMException('ConstraintError', 'Duplicate values already exist within the store'));
|
|
6660
6524
|
return;
|
|
@@ -6973,7 +6837,7 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
6973
6837
|
const listColInfoToPreserve = colInfoToPreserve.length ? colInfoToPreserve.join(', ') + ', ' : '';
|
|
6974
6838
|
const listColsToPreserve = colNamesToPreserve.length ? colNamesToPreserve.join(', ') + ', ' : '';
|
|
6975
6839
|
|
|
6976
|
-
// We could adapt the approach at
|
|
6840
|
+
// We could adapt the approach at https://stackoverflow.com/a/8430746/271577
|
|
6977
6841
|
// to make the approach reusable without passing column names, but it is a bit fragile
|
|
6978
6842
|
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
6979
6843
|
store.transaction.__addNonRequestToTransactionQueue(function renameIndex(tx, args, success, error) {
|
|
@@ -7077,6 +6941,7 @@ IDBIndex.prototype.__renameIndex = function (store, oldName, newName, colInfoToP
|
|
|
7077
6941
|
* @typedef {any} AnyValue
|
|
7078
6942
|
*/
|
|
7079
6943
|
|
|
6944
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
7080
6945
|
Object.defineProperty(IDBIndex, Symbol.hasInstance, {
|
|
7081
6946
|
/**
|
|
7082
6947
|
* @param {AnyValue} obj
|
|
@@ -7090,6 +6955,7 @@ IDBIndex.prototype[Symbol.toStringTag] = 'IDBIndexPrototype';
|
|
|
7090
6955
|
Object.defineProperty(IDBIndex, 'prototype', {
|
|
7091
6956
|
writable: false
|
|
7092
6957
|
});
|
|
6958
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
7093
6959
|
|
|
7094
6960
|
/**
|
|
7095
6961
|
* @param {number|null} count
|
|
@@ -7261,8 +7127,9 @@ const readonlyProperties$1 = ['keyPath', 'indexNames', 'transaction', 'autoIncre
|
|
|
7261
7127
|
|
|
7262
7128
|
/**
|
|
7263
7129
|
* IndexedDB Object Store.
|
|
7264
|
-
* @see
|
|
7130
|
+
* @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBObjectStore
|
|
7265
7131
|
* @class
|
|
7132
|
+
* @throws {TypeError}
|
|
7266
7133
|
*/
|
|
7267
7134
|
function IDBObjectStore() {
|
|
7268
7135
|
throw new TypeError('Illegal constructor');
|
|
@@ -7329,84 +7196,87 @@ IDBObjectStore.__createInstance = function (storeProperties, transaction) {
|
|
|
7329
7196
|
indexList
|
|
7330
7197
|
} = storeProperties;
|
|
7331
7198
|
for (const indexName in indexList) {
|
|
7332
|
-
if (Object.hasOwn(indexList, indexName)) {
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
|
|
7337
|
-
|
|
7199
|
+
if (!Object.hasOwn(indexList, indexName)) {
|
|
7200
|
+
continue;
|
|
7201
|
+
}
|
|
7202
|
+
const index = IDBIndex.__createInstance(me, indexList[indexName]);
|
|
7203
|
+
me.__indexes[index.name] = index;
|
|
7204
|
+
if (!index.__deleted) {
|
|
7205
|
+
me.indexNames.push(index.name);
|
|
7338
7206
|
}
|
|
7339
7207
|
}
|
|
7340
7208
|
me.__oldIndexNames = me.indexNames.clone();
|
|
7341
|
-
Object.
|
|
7342
|
-
|
|
7343
|
-
|
|
7344
|
-
|
|
7345
|
-
});
|
|
7346
|
-
Object.defineProperty(this, 'name', {
|
|
7347
|
-
enumerable: false,
|
|
7348
|
-
configurable: false,
|
|
7349
|
-
/**
|
|
7350
|
-
* @this {IDBObjectStoreFull}
|
|
7351
|
-
* @returns {string}
|
|
7352
|
-
*/
|
|
7353
|
-
get() {
|
|
7354
|
-
return this.__name;
|
|
7355
|
-
},
|
|
7356
|
-
/**
|
|
7357
|
-
* @param {string} name
|
|
7358
|
-
* @this {IDBObjectStoreFull}
|
|
7359
|
-
* @returns {void}
|
|
7360
|
-
*/
|
|
7361
|
-
set(name) {
|
|
7362
|
-
const me = this;
|
|
7363
|
-
name = convertToDOMString(name);
|
|
7364
|
-
const oldName = me.name;
|
|
7365
|
-
IDBObjectStoreAlias.__invalidStateIfDeleted(me);
|
|
7366
|
-
IDBTransaction.__assertVersionChange(me.transaction);
|
|
7367
|
-
IDBTransaction.__assertActive(me.transaction);
|
|
7368
|
-
if (oldName === name) {
|
|
7369
|
-
return;
|
|
7370
|
-
}
|
|
7371
|
-
if (me.__idbdb.__objectStores[name] && !me.__idbdb.__objectStores[name].__pendingDelete) {
|
|
7372
|
-
throw createDOMException('ConstraintError', 'Object store "' + name + '" already exists in ' + me.__idbdb.name);
|
|
7373
|
-
}
|
|
7374
|
-
me.__name = name;
|
|
7375
|
-
const oldStore = me.__idbdb.__objectStores[oldName];
|
|
7376
|
-
oldStore.__name = name; // Fix old references
|
|
7377
|
-
me.__idbdb.__objectStores[name] = oldStore; // Ensure new reference accessible
|
|
7378
|
-
delete me.__idbdb.__objectStores[oldName]; // Ensure won't be found
|
|
7379
|
-
|
|
7380
|
-
me.__idbdb.objectStoreNames.splice(me.__idbdb.objectStoreNames.indexOf(oldName), 1, name);
|
|
7381
|
-
const oldHandle = /** @type {IDBObjectStoreFull} */
|
|
7382
|
-
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */me.transaction.__storeHandles[oldName];
|
|
7383
|
-
oldHandle.__name = name; // Fix old references
|
|
7384
|
-
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
7385
|
-
me.transaction.__storeHandles[name] = oldHandle; // Ensure new reference accessible
|
|
7386
|
-
|
|
7387
|
-
me.__pendingName = oldName;
|
|
7388
|
-
const sql = 'UPDATE __sys__ SET "name" = ? WHERE "name" = ?';
|
|
7389
|
-
const sqlValues = [escapeSQLiteStatement(name), escapeSQLiteStatement(oldName)];
|
|
7390
|
-
if (CFG.DEBUG) {
|
|
7391
|
-
console.log(sql, sqlValues);
|
|
7209
|
+
Object.defineProperties(this, {
|
|
7210
|
+
__currentName: {
|
|
7211
|
+
get() {
|
|
7212
|
+
return '__pendingName' in this ? this.__pendingName : this.name;
|
|
7392
7213
|
}
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
|
|
7400
|
-
|
|
7401
|
-
|
|
7402
|
-
|
|
7403
|
-
|
|
7214
|
+
},
|
|
7215
|
+
name: {
|
|
7216
|
+
enumerable: false,
|
|
7217
|
+
configurable: false,
|
|
7218
|
+
/**
|
|
7219
|
+
* @this {IDBObjectStoreFull}
|
|
7220
|
+
* @returns {string}
|
|
7221
|
+
*/
|
|
7222
|
+
get() {
|
|
7223
|
+
return this.__name;
|
|
7224
|
+
},
|
|
7225
|
+
/**
|
|
7226
|
+
* @param {string} name
|
|
7227
|
+
* @this {IDBObjectStoreFull}
|
|
7228
|
+
* @returns {void}
|
|
7229
|
+
*/
|
|
7230
|
+
set(name) {
|
|
7231
|
+
const me = this;
|
|
7232
|
+
name = convertToDOMString(name);
|
|
7233
|
+
const oldName = me.name;
|
|
7234
|
+
IDBObjectStoreAlias.__invalidStateIfDeleted(me);
|
|
7235
|
+
IDBTransaction.__assertVersionChange(me.transaction);
|
|
7236
|
+
IDBTransaction.__assertActive(me.transaction);
|
|
7237
|
+
if (oldName === name) {
|
|
7238
|
+
return;
|
|
7239
|
+
}
|
|
7240
|
+
if (Object.hasOwn(me.__idbdb.__objectStores, name) && !me.__idbdb.__objectStores[name].__pendingDelete) {
|
|
7241
|
+
throw createDOMException('ConstraintError', 'Object store "' + name + '" already exists in ' + me.__idbdb.name);
|
|
7242
|
+
}
|
|
7243
|
+
me.__name = name;
|
|
7244
|
+
const oldStore = me.__idbdb.__objectStores[oldName];
|
|
7245
|
+
oldStore.__name = name; // Fix old references
|
|
7246
|
+
me.__idbdb.__objectStores[name] = oldStore; // Ensure new reference accessible
|
|
7247
|
+
delete me.__idbdb.__objectStores[oldName]; // Ensure won't be found
|
|
7248
|
+
|
|
7249
|
+
me.__idbdb.objectStoreNames.splice(me.__idbdb.objectStoreNames.indexOf(oldName), 1, name);
|
|
7250
|
+
const oldHandle = /** @type {IDBObjectStoreFull} */
|
|
7251
|
+
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */me.transaction.__storeHandles[oldName];
|
|
7252
|
+
oldHandle.__name = name; // Fix old references
|
|
7253
|
+
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
7254
|
+
me.transaction.__storeHandles[name] = oldHandle; // Ensure new reference accessible
|
|
7255
|
+
|
|
7256
|
+
me.__pendingName = oldName;
|
|
7257
|
+
const sql = 'UPDATE __sys__ SET "name" = ? WHERE "name" = ?';
|
|
7258
|
+
const sqlValues = [escapeSQLiteStatement(name), escapeSQLiteStatement(oldName)];
|
|
7259
|
+
if (CFG.DEBUG) {
|
|
7260
|
+
console.log(sql, sqlValues);
|
|
7261
|
+
}
|
|
7262
|
+
/** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
7263
|
+
me.transaction.__addNonRequestToTransactionQueue(function objectStoreClear(tx, args, success, error) {
|
|
7264
|
+
tx.executeSql(sql, sqlValues, function (tx) {
|
|
7265
|
+
// This SQL preserves indexes per https://www.sqlite.org/lang_altertable.html
|
|
7266
|
+
const sql = 'ALTER TABLE ' + escapeStoreNameForSQL(oldName) + ' RENAME TO ' + escapeStoreNameForSQL(name);
|
|
7267
|
+
if (CFG.DEBUG) {
|
|
7268
|
+
console.log(sql);
|
|
7269
|
+
}
|
|
7270
|
+
tx.executeSql(sql, [], function () {
|
|
7271
|
+
delete me.__pendingName;
|
|
7272
|
+
success();
|
|
7273
|
+
});
|
|
7274
|
+
}, function (tx, err) {
|
|
7275
|
+
error(err);
|
|
7276
|
+
return false;
|
|
7404
7277
|
});
|
|
7405
|
-
}, function (tx, err) {
|
|
7406
|
-
error(err);
|
|
7407
|
-
return false;
|
|
7408
7278
|
});
|
|
7409
|
-
}
|
|
7279
|
+
}
|
|
7410
7280
|
}
|
|
7411
7281
|
});
|
|
7412
7282
|
}
|
|
@@ -7470,7 +7340,7 @@ IDBObjectStore.__createObjectStore = function (db, store) {
|
|
|
7470
7340
|
const transaction = /** @type {import('./IDBTransaction.js').IDBTransactionFull} */
|
|
7471
7341
|
db.__versionTransaction;
|
|
7472
7342
|
const storeHandles = transaction.__storeHandles;
|
|
7473
|
-
if (!storeHandles
|
|
7343
|
+
if (!Object.hasOwn(storeHandles, storeName) ||
|
|
7474
7344
|
// These latter conditions are to allow store
|
|
7475
7345
|
// recreation to create new clone object
|
|
7476
7346
|
storeHandles[storeName].__pendingDelete || storeHandles[storeName].__deleted) {
|
|
@@ -7813,7 +7683,6 @@ IDBObjectStore.prototype.__insertData = function (tx, encoded, value, clonedKeyO
|
|
|
7813
7683
|
return false;
|
|
7814
7684
|
});
|
|
7815
7685
|
return undefined;
|
|
7816
|
-
// eslint-disable-next-line sonarjs/no-invariant-returns -- Convenient
|
|
7817
7686
|
}).catch(function (err) {
|
|
7818
7687
|
/**
|
|
7819
7688
|
* @returns {void}
|
|
@@ -8230,7 +8099,7 @@ IDBObjectStore.prototype.index = function (indexName) {
|
|
|
8230
8099
|
if (!index || index.__deleted) {
|
|
8231
8100
|
throw createDOMException('NotFoundError', 'Index "' + indexName + '" does not exist on ' + me.__currentName);
|
|
8232
8101
|
}
|
|
8233
|
-
if (!me.__indexHandles
|
|
8102
|
+
if (!Object.hasOwn(me.__indexHandles, indexName) || me.__indexes[indexName].__pendingDelete || me.__indexes[indexName].__deleted) {
|
|
8234
8103
|
me.__indexHandles[indexName] = IDBIndex.__clone(index, me);
|
|
8235
8104
|
}
|
|
8236
8105
|
return me.__indexHandles[indexName];
|
|
@@ -8260,7 +8129,7 @@ IDBObjectStore.prototype.createIndex = function (indexName, keyPath /* , optiona
|
|
|
8260
8129
|
IDBTransaction.__assertVersionChange(me.transaction);
|
|
8261
8130
|
IDBObjectStore.__invalidStateIfDeleted(me);
|
|
8262
8131
|
IDBTransaction.__assertActive(me.transaction);
|
|
8263
|
-
if (me.__indexes
|
|
8132
|
+
if (Object.hasOwn(me.__indexes, indexName) && !me.__indexes[indexName].__deleted && !me.__indexes[indexName].__pendingDelete) {
|
|
8264
8133
|
throw createDOMException('ConstraintError', 'Index "' + indexName + '" already exists on ' + me.__currentName);
|
|
8265
8134
|
}
|
|
8266
8135
|
keyPath = convertToSequenceDOMString(keyPath);
|
|
@@ -8270,7 +8139,7 @@ IDBObjectStore.prototype.createIndex = function (indexName, keyPath /* , optiona
|
|
|
8270
8139
|
if (Array.isArray(keyPath) && optionalParameters && optionalParameters.multiEntry) {
|
|
8271
8140
|
throw createDOMException('InvalidAccessError', 'The keyPath argument was an array and the multiEntry option is true.');
|
|
8272
8141
|
}
|
|
8273
|
-
optionalParameters
|
|
8142
|
+
optionalParameters ||= {};
|
|
8274
8143
|
/** @type {import('./IDBIndex.js').IDBIndexProperties} */
|
|
8275
8144
|
const indexProperties = {
|
|
8276
8145
|
columnName: indexName,
|
|
@@ -8308,6 +8177,8 @@ IDBObjectStore.prototype.deleteIndex = function (name) {
|
|
|
8308
8177
|
}
|
|
8309
8178
|
IDBIndex.__deleteIndex(me, index);
|
|
8310
8179
|
};
|
|
8180
|
+
|
|
8181
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
8311
8182
|
defineReadonlyOuterInterface(IDBObjectStore.prototype, readonlyProperties$1);
|
|
8312
8183
|
defineOuterInterface(IDBObjectStore.prototype, ['name']);
|
|
8313
8184
|
IDBObjectStore.prototype[Symbol.toStringTag] = 'IDBObjectStorePrototype';
|
|
@@ -8332,8 +8203,9 @@ const readonlyProperties = ['name', 'version', 'objectStoreNames'];
|
|
|
8332
8203
|
|
|
8333
8204
|
/**
|
|
8334
8205
|
* IDB Database Object.
|
|
8335
|
-
* @see
|
|
8206
|
+
* @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#database-interface
|
|
8336
8207
|
* @class
|
|
8208
|
+
* @throws {TypeError}
|
|
8337
8209
|
*/
|
|
8338
8210
|
function IDBDatabase() {
|
|
8339
8211
|
this.__versionTransaction = null;
|
|
@@ -8476,7 +8348,7 @@ IDBDatabase.prototype.createObjectStore = function (storeName /* , createOptions
|
|
|
8476
8348
|
if (keyPath !== null && !isValidKeyPath(keyPath)) {
|
|
8477
8349
|
throw createDOMException('SyntaxError', 'The keyPath argument contains an invalid key path.');
|
|
8478
8350
|
}
|
|
8479
|
-
if (this.__objectStores
|
|
8351
|
+
if (Object.hasOwn(this.__objectStores, storeName) && !this.__objectStores[storeName].__pendingDelete) {
|
|
8480
8352
|
throw createDOMException('ConstraintError', 'Object store "' + storeName + '" already exists in ' + this.name);
|
|
8481
8353
|
}
|
|
8482
8354
|
const autoInc = createOptions.autoIncrement;
|
|
@@ -8553,7 +8425,8 @@ IDBDatabase.prototype.transaction = function (storeNames /* , mode */) {
|
|
|
8553
8425
|
? [...new Set(
|
|
8554
8426
|
// to be unique
|
|
8555
8427
|
convertToSequenceDOMString(storeNames) // iterables have `ToString` applied (and we convert to array for convenience)
|
|
8556
|
-
|
|
8428
|
+
// eslint-disable-next-line unicorn/require-array-sort-compare -- IndexedDB requires code unit comparison (default behavior)
|
|
8429
|
+
)].toSorted() // must be sorted
|
|
8557
8430
|
: [convertToDOMString(storeNames)];
|
|
8558
8431
|
|
|
8559
8432
|
/* (function () {
|
|
@@ -8567,7 +8440,7 @@ IDBDatabase.prototype.transaction = function (storeNames /* , mode */) {
|
|
|
8567
8440
|
// prioritizing readonly but not starving readwrite).
|
|
8568
8441
|
// Even for readonly transactions, due to [issue 17](https://github.com/nolanlawson/node-websql/issues/17),
|
|
8569
8442
|
// we're not currently actually running the SQL requests in parallel.
|
|
8570
|
-
mode
|
|
8443
|
+
mode ||= 'readonly';
|
|
8571
8444
|
IDBTransaction.__assertNotVersionChange(this.__versionTransaction);
|
|
8572
8445
|
if (this.__closePending) {
|
|
8573
8446
|
throw createDOMException('InvalidStateError', 'An attempt was made to start a new transaction on a database connection that is not open');
|
|
@@ -8626,13 +8499,14 @@ IDBDatabase.prototype.__forceClose = function (msg) {
|
|
|
8626
8499
|
const evt = createEvent('close');
|
|
8627
8500
|
setTimeout(() => {
|
|
8628
8501
|
me.dispatchEvent(evt);
|
|
8629
|
-
});
|
|
8502
|
+
}, 0);
|
|
8630
8503
|
}
|
|
8631
8504
|
};
|
|
8632
8505
|
trans.__abortTransaction(createDOMException('AbortError', 'The connection was force-closed: ' + (msg || '')));
|
|
8633
8506
|
});
|
|
8634
8507
|
me.__transactions = [];
|
|
8635
8508
|
};
|
|
8509
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
8636
8510
|
defineOuterInterface(IDBDatabase.prototype, listeners);
|
|
8637
8511
|
defineReadonlyOuterInterface(IDBDatabase.prototype, readonlyProperties);
|
|
8638
8512
|
Object.defineProperty(IDBDatabase.prototype, 'constructor', {
|
|
@@ -8665,6 +8539,7 @@ let fs;
|
|
|
8665
8539
|
* @returns {void}
|
|
8666
8540
|
*/
|
|
8667
8541
|
const setFS = _fs => {
|
|
8542
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Necessary?
|
|
8668
8543
|
fs = _fs;
|
|
8669
8544
|
};
|
|
8670
8545
|
|
|
@@ -8672,7 +8547,6 @@ const setFS = _fs => {
|
|
|
8672
8547
|
* @returns {string}
|
|
8673
8548
|
*/
|
|
8674
8549
|
const getOrigin = () => {
|
|
8675
|
-
// eslint-disable-next-line no-undef -- If browser/polyfilled
|
|
8676
8550
|
return typeof location !== 'object' || !location ? 'null' : location.origin;
|
|
8677
8551
|
};
|
|
8678
8552
|
const hasNullOrigin = () => CFG.checkOrigin !== false && getOrigin() === 'null';
|
|
@@ -8732,7 +8606,7 @@ function processNextInConnectionQueue(name, origin = getOrigin()) {
|
|
|
8732
8606
|
*/
|
|
8733
8607
|
function addRequestToConnectionQueue(req, name, origin = getOrigin(), cb) {
|
|
8734
8608
|
/* eslint-enable default-param-last -- Keep cb at end */
|
|
8735
|
-
if (!connectionQueue[origin]
|
|
8609
|
+
if (!Object.hasOwn(connectionQueue[origin], name)) {
|
|
8736
8610
|
connectionQueue[origin][name] = [];
|
|
8737
8611
|
}
|
|
8738
8612
|
connectionQueue[origin][name].push({
|
|
@@ -8783,7 +8657,7 @@ function triggerAnyVersionChangeAndBlockedEvents(openConnections, req, oldVersio
|
|
|
8783
8657
|
setTimeout(() => {
|
|
8784
8658
|
entry.dispatchEvent(e); // No need to catch errors
|
|
8785
8659
|
resolve(undefined);
|
|
8786
|
-
});
|
|
8660
|
+
}, 0);
|
|
8787
8661
|
});
|
|
8788
8662
|
});
|
|
8789
8663
|
}, SyncPromise.resolve(undefined)).then(function () {
|
|
@@ -8814,7 +8688,7 @@ function triggerAnyVersionChangeAndBlockedEvents(openConnections, req, oldVersio
|
|
|
8814
8688
|
} else {
|
|
8815
8689
|
resolve(undefined);
|
|
8816
8690
|
}
|
|
8817
|
-
});
|
|
8691
|
+
}, 0);
|
|
8818
8692
|
});
|
|
8819
8693
|
});
|
|
8820
8694
|
}
|
|
@@ -8871,7 +8745,7 @@ function getLatestCachedWebSQLDB(name) {
|
|
|
8871
8745
|
function cleanupDatabaseResources(__openDatabase, name, escapedDatabaseName, databaseDeleted, dbError) {
|
|
8872
8746
|
const useMemoryDatabase = typeof CFG.memoryDatabase === 'string';
|
|
8873
8747
|
if (useMemoryDatabase) {
|
|
8874
|
-
const latestSQLiteDBCached = websqlDBCache
|
|
8748
|
+
const latestSQLiteDBCached = Object.hasOwn(websqlDBCache, name) ? getLatestCachedWebSQLDB(name) : null;
|
|
8875
8749
|
if (!latestSQLiteDBCached) {
|
|
8876
8750
|
console.warn('Could not find a memory database instance to delete.');
|
|
8877
8751
|
databaseDeleted();
|
|
@@ -8969,6 +8843,7 @@ function createSysDB(__openDatabase, success, failure) {
|
|
|
8969
8843
|
if (sysdb) {
|
|
8970
8844
|
success();
|
|
8971
8845
|
} else {
|
|
8846
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Necessary?
|
|
8972
8847
|
sysdb = __openDatabase(typeof CFG.memoryDatabase === 'string' ? CFG.memoryDatabase : path.join(typeof CFG.sysDatabaseBasePath === 'string' ? CFG.sysDatabaseBasePath : CFG.databaseBasePath || '', '__sysdb__' + (CFG.addSQLiteExtension !== false ? '.sqlite' : '')), '1', 'System Database', CFG.DEFAULT_DB_SIZE);
|
|
8973
8848
|
sysdb.transaction(function (systx) {
|
|
8974
8849
|
systx.executeSql('CREATE TABLE IF NOT EXISTS dbVersions (name BLOB, version INT);', [], function (systx) {
|
|
@@ -8985,6 +8860,7 @@ function createSysDB(__openDatabase, success, failure) {
|
|
|
8985
8860
|
/**
|
|
8986
8861
|
* IDBFactory Class.
|
|
8987
8862
|
* @see https://w3c.github.io/IndexedDB/#idl-def-IDBFactory
|
|
8863
|
+
* @throws {TypeError}
|
|
8988
8864
|
* @class
|
|
8989
8865
|
*/
|
|
8990
8866
|
function IDBFactory() {
|
|
@@ -9053,6 +8929,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9053
8929
|
const req = IDBOpenDBRequest.__createInstance();
|
|
9054
8930
|
let calledDbCreateError = false;
|
|
9055
8931
|
if (CFG.autoName && name === '') {
|
|
8932
|
+
// eslint-disable-next-line unicorn/no-top-level-assignment-in-function -- Necessary?
|
|
9056
8933
|
name = 'autoNamedDatabase_' + nameCounter++;
|
|
9057
8934
|
}
|
|
9058
8935
|
name = String(name); // cast to a string
|
|
@@ -9111,7 +8988,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9111
8988
|
req.__done = true;
|
|
9112
8989
|
}
|
|
9113
8990
|
const connection = IDBDatabase.__createInstance(db, name, oldVersion, version, data);
|
|
9114
|
-
if (!me.__connections
|
|
8991
|
+
if (!Object.hasOwn(me.__connections, name)) {
|
|
9115
8992
|
me.__connections[name] = [];
|
|
9116
8993
|
}
|
|
9117
8994
|
me.__connections[name].push(connection);
|
|
@@ -9206,7 +9083,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9206
9083
|
connection.__upgradeTransaction = null;
|
|
9207
9084
|
// We ensure any cache is deleted before any request error events fire and try to reopen
|
|
9208
9085
|
if (useDatabaseCache) {
|
|
9209
|
-
if (name
|
|
9086
|
+
if (Object.hasOwn(websqlDBCache, name)) {
|
|
9210
9087
|
delete websqlDBCache[name][version];
|
|
9211
9088
|
}
|
|
9212
9089
|
}
|
|
@@ -9231,7 +9108,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9231
9108
|
dbCreateError(err);
|
|
9232
9109
|
return false;
|
|
9233
9110
|
});
|
|
9234
|
-
});
|
|
9111
|
+
}, 0);
|
|
9235
9112
|
};
|
|
9236
9113
|
|
|
9237
9114
|
// eslint-disable-next-line camelcase -- Clear API
|
|
@@ -9304,12 +9181,12 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9304
9181
|
function openDB(oldVersion) {
|
|
9305
9182
|
/** @type {DatabaseFull} */
|
|
9306
9183
|
let db;
|
|
9307
|
-
if ((useMemoryDatabase || useDatabaseCache) && name
|
|
9184
|
+
if ((useMemoryDatabase || useDatabaseCache) && Object.hasOwn(websqlDBCache, name) && Object.hasOwn(websqlDBCache[name], version)) {
|
|
9308
9185
|
db = websqlDBCache[name][version];
|
|
9309
9186
|
} else {
|
|
9310
9187
|
db = me.__openDatabase(useMemoryDatabase ? CFG.memoryDatabase : path.join(CFG.databaseBasePath || '', escapedDatabaseName), '1', name, CFG.DEFAULT_DB_SIZE);
|
|
9311
9188
|
if (useDatabaseCache) {
|
|
9312
|
-
if (!(name
|
|
9189
|
+
if (!Object.hasOwn(websqlDBCache, name)) {
|
|
9313
9190
|
websqlDBCache[name] = {};
|
|
9314
9191
|
}
|
|
9315
9192
|
websqlDBCache[name][version] = db;
|
|
@@ -9323,7 +9200,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9323
9200
|
if (useDatabaseCache) {
|
|
9324
9201
|
setTimeout(() => {
|
|
9325
9202
|
dbCreateError(err);
|
|
9326
|
-
});
|
|
9203
|
+
}, 0);
|
|
9327
9204
|
} else {
|
|
9328
9205
|
dbCreateError(err);
|
|
9329
9206
|
}
|
|
@@ -9348,7 +9225,7 @@ IDBFactory.prototype.open = function (name /* , version */) {
|
|
|
9348
9225
|
addRequestToConnectionQueue(req, name, /* origin */undefined, function () {
|
|
9349
9226
|
let latestCachedVersion;
|
|
9350
9227
|
if (useDatabaseCache) {
|
|
9351
|
-
if (!(name
|
|
9228
|
+
if (!Object.hasOwn(websqlDBCache, name)) {
|
|
9352
9229
|
websqlDBCache[name] = {};
|
|
9353
9230
|
}
|
|
9354
9231
|
latestCachedVersion = getLatestCachedWebSQLVersion(name);
|
|
@@ -9468,7 +9345,7 @@ IDBFactory.prototype.deleteDatabase = function (name) {
|
|
|
9468
9345
|
/** @type {DatabaseDeleted} */
|
|
9469
9346
|
function databaseDeleted() {
|
|
9470
9347
|
sysdbFinishedCbDelete(false, function () {
|
|
9471
|
-
if (useDatabaseCache && name
|
|
9348
|
+
if (useDatabaseCache && Object.hasOwn(websqlDBCache, name)) {
|
|
9472
9349
|
delete websqlDBCache[name]; // New calls will treat as though never existed
|
|
9473
9350
|
}
|
|
9474
9351
|
delete me.__connections[name];
|
|
@@ -9605,7 +9482,7 @@ IDBFactory.prototype.databases = function () {
|
|
|
9605
9482
|
* @todo forceClose: Test
|
|
9606
9483
|
* This is provided to facilitate unit-testing of the
|
|
9607
9484
|
* closing of a database connection with a forced flag:
|
|
9608
|
-
* <
|
|
9485
|
+
* <https://w3c.github.io/IndexedDB/#steps-for-closing-a-database-connection>
|
|
9609
9486
|
* @param {string} dbName
|
|
9610
9487
|
* @param {Integer} connIdx
|
|
9611
9488
|
* @param {string} msg
|
|
@@ -9629,12 +9506,13 @@ IDBFactory.prototype.__forceClose = function (dbName, connIdx, msg) {
|
|
|
9629
9506
|
forceClose(connection);
|
|
9630
9507
|
});
|
|
9631
9508
|
});
|
|
9632
|
-
} else if (!me.__connections
|
|
9509
|
+
} else if (!Object.hasOwn(me.__connections, dbName)) {
|
|
9633
9510
|
console.log('No database connections with that name to force close');
|
|
9634
9511
|
} else if (isNullish(connIdx)) {
|
|
9635
9512
|
me.__connections[dbName].forEach(conn => {
|
|
9636
9513
|
forceClose(conn);
|
|
9637
9514
|
});
|
|
9515
|
+
// eslint-disable-next-line unicorn/prefer-number-is-safe-integer -- Ok
|
|
9638
9516
|
} else if (!Number.isInteger(connIdx) || connIdx < 0 || connIdx > me.__connections[dbName].length - 1) {
|
|
9639
9517
|
throw new TypeError('If providing an argument, __forceClose must be called with a ' + 'numeric index to indicate a specific connection to close');
|
|
9640
9518
|
} else {
|
|
@@ -9651,9 +9529,13 @@ IDBFactory.prototype.__setConnectionQueueOrigin = function (origin = getOrigin()
|
|
|
9651
9529
|
connectionQueue[origin] = {};
|
|
9652
9530
|
};
|
|
9653
9531
|
IDBFactory.prototype[Symbol.toStringTag] = 'IDBFactoryPrototype';
|
|
9532
|
+
|
|
9533
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
9654
9534
|
Object.defineProperty(IDBFactory, 'prototype', {
|
|
9655
9535
|
writable: false
|
|
9656
9536
|
});
|
|
9537
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
9538
|
+
|
|
9657
9539
|
const shimIndexedDB = IDBFactory.__createInstance();
|
|
9658
9540
|
|
|
9659
9541
|
/**
|
|
@@ -9704,6 +9586,7 @@ const shimIndexedDB = IDBFactory.__createInstance();
|
|
|
9704
9586
|
|
|
9705
9587
|
/**
|
|
9706
9588
|
* @class
|
|
9589
|
+
* @throws {TypeError}
|
|
9707
9590
|
*/
|
|
9708
9591
|
function IDBCursor() {
|
|
9709
9592
|
throw new TypeError('Illegal constructor');
|
|
@@ -9713,7 +9596,7 @@ const IDBCursorAlias = IDBCursor;
|
|
|
9713
9596
|
/* eslint-disable func-name-matching -- API */
|
|
9714
9597
|
/**
|
|
9715
9598
|
* The IndexedDB Cursor Object.
|
|
9716
|
-
* @see
|
|
9599
|
+
* @see https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBCursor
|
|
9717
9600
|
* @param {IDBKeyRange} query
|
|
9718
9601
|
* @param {string} direction
|
|
9719
9602
|
* @param {import('./IDBObjectStore.js').IDBObjectStoreFull} store
|
|
@@ -9796,11 +9679,10 @@ IDBCursor.__createInstance = function (...args) {
|
|
|
9796
9679
|
* @returns {void}
|
|
9797
9680
|
*/
|
|
9798
9681
|
IDBCursor.prototype.__find = function (...args /* key, tx, success, error, recordsToLoad */) {
|
|
9682
|
+
const [key, primaryKey, tx, success, error, recordsToLoad] = args;
|
|
9799
9683
|
if (this.__multiEntryIndex) {
|
|
9800
|
-
|
|
9801
|
-
this.__findMultiEntry(key, primaryKey, tx, success, error);
|
|
9684
|
+
this.__findMultiEntry(key, primaryKey, tx, success, error, recordsToLoad);
|
|
9802
9685
|
} else {
|
|
9803
|
-
const [key, primaryKey, tx, success, error, recordsToLoad] = args;
|
|
9804
9686
|
this.__findBasic(key, primaryKey, tx, success, error, recordsToLoad);
|
|
9805
9687
|
}
|
|
9806
9688
|
};
|
|
@@ -9830,7 +9712,7 @@ IDBCursor.prototype.__find = function (...args /* key, tx, success, error, recor
|
|
|
9830
9712
|
*/
|
|
9831
9713
|
IDBCursor.prototype.__findBasic = function (key, primaryKey, tx, success, error, recordsToLoad) {
|
|
9832
9714
|
const continueCall = recordsToLoad !== undefined;
|
|
9833
|
-
recordsToLoad
|
|
9715
|
+
recordsToLoad ||= 1;
|
|
9834
9716
|
const me = this;
|
|
9835
9717
|
const quotedKeyColumnName = sqlQuote(me.__keyColumnName);
|
|
9836
9718
|
const quotedKey = sqlQuote('key');
|
|
@@ -9917,10 +9799,11 @@ const leftBracketRegex = /\[/gu;
|
|
|
9917
9799
|
* @param {SQLTransaction} tx
|
|
9918
9800
|
* @param {KeySuccess} success
|
|
9919
9801
|
* @param {FindError} error
|
|
9802
|
+
* @param {Integer|undefined} recordsToLoad
|
|
9920
9803
|
* @this {IDBCursorFull}
|
|
9921
9804
|
* @returns {void}
|
|
9922
9805
|
*/
|
|
9923
|
-
IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, error) {
|
|
9806
|
+
IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, error, recordsToLoad) {
|
|
9924
9807
|
const me = this;
|
|
9925
9808
|
if (me.__prefetchedData && me.__prefetchedData.length === me.__prefetchedIndex) {
|
|
9926
9809
|
if (CFG.DEBUG) {
|
|
@@ -9975,6 +9858,7 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
9975
9858
|
// 4. Sort by object store position (if defined and not unique)
|
|
9976
9859
|
sql.push(',', sqlQuote(me.__valueColumnName), direction);
|
|
9977
9860
|
}
|
|
9861
|
+
sql.push('LIMIT', String(recordsToLoad));
|
|
9978
9862
|
}
|
|
9979
9863
|
const sqlStr = sql.join(' ');
|
|
9980
9864
|
if (CFG.DEBUG) {
|
|
@@ -10006,10 +9890,10 @@ IDBCursor.prototype.__findMultiEntry = function (key, primaryKey, tx, success, e
|
|
|
10006
9890
|
const clone = {
|
|
10007
9891
|
matchingKey: (/** @type {string} */
|
|
10008
9892
|
encode$1(matchingKey, true)),
|
|
10009
|
-
key: rowItem.key
|
|
9893
|
+
key: rowItem.key,
|
|
9894
|
+
[me.__keyColumnName]: rowItem[me.__keyColumnName],
|
|
9895
|
+
[me.__valueColumnName]: rowItem[me.__valueColumnName]
|
|
10010
9896
|
};
|
|
10011
|
-
clone[me.__keyColumnName] = rowItem[me.__keyColumnName];
|
|
10012
|
-
clone[me.__valueColumnName] = rowItem[me.__valueColumnName];
|
|
10013
9897
|
rows.push(clone);
|
|
10014
9898
|
}
|
|
10015
9899
|
}
|
|
@@ -10145,7 +10029,7 @@ IDBCursor.prototype.__decode = function (rowItem, callback) {
|
|
|
10145
10029
|
if (!me.__matchedKeys) {
|
|
10146
10030
|
me.__matchedKeys = {};
|
|
10147
10031
|
}
|
|
10148
|
-
if (me.__matchedKeys[rowItem.matchingKey]) {
|
|
10032
|
+
if (me.__matchedKeys[rowItem.matchingKey] === true) {
|
|
10149
10033
|
callback(undefined, undefined, undefined);
|
|
10150
10034
|
return;
|
|
10151
10035
|
}
|
|
@@ -10255,9 +10139,11 @@ IDBCursor.prototype.__continueFinish = function (key, primaryKey, advanceState)
|
|
|
10255
10139
|
triggerSuccess(k, val, primKey);
|
|
10256
10140
|
return;
|
|
10257
10141
|
}
|
|
10142
|
+
// @ts-expect-error Todo: Our bug to fix
|
|
10258
10143
|
cursorContinue(tx, args, success, error);
|
|
10259
10144
|
}
|
|
10260
10145
|
if (me.__unique && !me.__multiEntryIndex && encKey === encode$1(me.key, me.__multiEntryIndex)) {
|
|
10146
|
+
// @ts-expect-error Todo: Our bug to fix
|
|
10261
10147
|
cursorContinue(tx, args, success, error);
|
|
10262
10148
|
return;
|
|
10263
10149
|
}
|
|
@@ -10394,6 +10280,7 @@ IDBCursor.prototype.update = function (valueToUpdate) {
|
|
|
10394
10280
|
if (cmp(me.primaryKey, evaluatedKey) !== 0) {
|
|
10395
10281
|
throw createDOMException('DataError', 'The key of the supplied value to `update` is not equal to the cursor\'s effective key');
|
|
10396
10282
|
}
|
|
10283
|
+
// eslint-disable-next-line unicorn/prefer-hoisting-branch-code -- Different
|
|
10397
10284
|
addToQueue(clonedValue);
|
|
10398
10285
|
} else {
|
|
10399
10286
|
const clonedValue = clone(valueToUpdate);
|
|
@@ -10443,18 +10330,23 @@ IDBCursor.prototype.delete = function () {
|
|
|
10443
10330
|
}, undefined, me);
|
|
10444
10331
|
};
|
|
10445
10332
|
IDBCursor.prototype[Symbol.toStringTag] = 'IDBCursorPrototype';
|
|
10333
|
+
|
|
10334
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
10446
10335
|
defineReadonlyOuterInterface(IDBCursor.prototype, ['source', 'direction', 'key', 'primaryKey', 'request']);
|
|
10447
10336
|
Object.defineProperty(IDBCursor, 'prototype', {
|
|
10448
10337
|
writable: false
|
|
10449
10338
|
});
|
|
10339
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
10450
10340
|
|
|
10451
10341
|
/**
|
|
10452
10342
|
* @class
|
|
10343
|
+
* @throws {TypeError}
|
|
10453
10344
|
*/
|
|
10454
10345
|
function IDBCursorWithValue() {
|
|
10455
10346
|
throw new TypeError('Illegal constructor');
|
|
10456
10347
|
}
|
|
10457
10348
|
|
|
10349
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
10458
10350
|
// @ts-expect-error It's ok
|
|
10459
10351
|
IDBCursorWithValue.prototype = Object.create(IDBCursor.prototype);
|
|
10460
10352
|
Object.defineProperty(IDBCursorWithValue.prototype, 'constructor', {
|
|
@@ -10463,6 +10355,8 @@ Object.defineProperty(IDBCursorWithValue.prototype, 'constructor', {
|
|
|
10463
10355
|
configurable: true,
|
|
10464
10356
|
value: IDBCursorWithValue
|
|
10465
10357
|
});
|
|
10358
|
+
/* eslint-enable unicorn/no-top-level-side-effects -- Would be good */
|
|
10359
|
+
|
|
10466
10360
|
const IDBCursorWithValueAlias = IDBCursorWithValue;
|
|
10467
10361
|
/**
|
|
10468
10362
|
*
|
|
@@ -10486,14 +10380,14 @@ IDBCursorWithValue.__createInstance = function (...args) {
|
|
|
10486
10380
|
// @ts-expect-error It's ok
|
|
10487
10381
|
return new IDBCursorWithValue();
|
|
10488
10382
|
};
|
|
10383
|
+
|
|
10384
|
+
/* eslint-disable unicorn/no-top-level-side-effects -- Would be good */
|
|
10489
10385
|
defineReadonlyOuterInterface(IDBCursorWithValue.prototype, ['value']);
|
|
10490
10386
|
IDBCursorWithValue.prototype[Symbol.toStringTag] = 'IDBCursorWithValuePrototype';
|
|
10491
10387
|
Object.defineProperty(IDBCursorWithValue, 'prototype', {
|
|
10492
10388
|
writable: false
|
|
10493
10389
|
});
|
|
10494
10390
|
|
|
10495
|
-
/* eslint-disable unicorn/prefer-global-this -- Older browsers? */
|
|
10496
|
-
|
|
10497
10391
|
/**
|
|
10498
10392
|
* @typedef {any} AnyValue
|
|
10499
10393
|
*/
|
|
@@ -10516,7 +10410,7 @@ function setConfig(prop, val) {
|
|
|
10516
10410
|
});
|
|
10517
10411
|
return;
|
|
10518
10412
|
}
|
|
10519
|
-
if (!(prop
|
|
10413
|
+
if (!Object.hasOwn(CFG, prop)) {
|
|
10520
10414
|
throw new Error(prop + ' is not a valid configuration property');
|
|
10521
10415
|
}
|
|
10522
10416
|
// @ts-expect-error Should not be `never` here!
|
|
@@ -10720,7 +10614,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
10720
10614
|
setFS(CFG.fs);
|
|
10721
10615
|
}
|
|
10722
10616
|
if (CFG.fullIDLSupport) {
|
|
10723
|
-
// Slow per MDN so off by default! Though apparently needed for WebIDL:
|
|
10617
|
+
// Slow per MDN so off by default! Though apparently needed for WebIDL: https://stackoverflow.com/questions/41927589/rationales-consequences-of-webidl-class-inheritance-requirements
|
|
10724
10618
|
|
|
10725
10619
|
Object.setPrototypeOf(IDB.IDBOpenDBRequest, IDB.IDBRequest);
|
|
10726
10620
|
Object.setPrototypeOf(IDB.IDBCursorWithValue, IDB.IDBCursor);
|
|
@@ -10757,7 +10651,7 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
10757
10651
|
|
|
10758
10652
|
/** @type {GetConfig} */
|
|
10759
10653
|
IDB.shimIndexedDB.__getConfig = function (prop) {
|
|
10760
|
-
if (!(prop
|
|
10654
|
+
if (!Object.hasOwn(CFG, prop)) {
|
|
10761
10655
|
throw new Error(prop + ' is not a valid configuration property');
|
|
10762
10656
|
}
|
|
10763
10657
|
return CFG[prop];
|
|
@@ -10789,12 +10683,12 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
10789
10683
|
// Workaround to prevent an error in Firefox
|
|
10790
10684
|
if (!('indexedDB' in IDB) && typeof window !== 'undefined') {
|
|
10791
10685
|
// 2nd condition avoids problems in Node
|
|
10792
|
-
IDB.indexedDB
|
|
10686
|
+
IDB.indexedDB ||= /** @type {IDBFactory} */
|
|
10687
|
+
'webkitIndexedDB' in IDB && IDB.webkitIndexedDB || 'mozIndexedDB' in IDB && IDB.mozIndexedDB || 'oIndexedDB' in IDB && IDB.oIndexedDB || 'msIndexedDB' in IDB && IDB.msIndexedDB;
|
|
10793
10688
|
}
|
|
10794
10689
|
|
|
10795
10690
|
// Detect browsers with known IndexedDB issues (e.g. Android pre-4.4)
|
|
10796
|
-
|
|
10797
|
-
if (typeof navigator !== 'undefined' &&
|
|
10691
|
+
const poorIndexedDbSupport = typeof navigator !== 'undefined' &&
|
|
10798
10692
|
// Not apparently defined in React Native
|
|
10799
10693
|
navigator.userAgent && (
|
|
10800
10694
|
// Ignore Node or other environments
|
|
@@ -10802,15 +10696,11 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
10802
10696
|
/Android (?:2|3|4\.[0-3])/u.test(navigator.userAgent) && !navigator.userAgent.includes('Chrome') ||
|
|
10803
10697
|
// Bad non-Safari iOS9 support (see <https://github.com/axemclion/IndexedDBShim/issues/252>)
|
|
10804
10698
|
(!navigator.userAgent.includes('Safari') || navigator.userAgent.includes('Chrome')) &&
|
|
10805
|
-
// Exclude genuine Safari:
|
|
10806
|
-
// Detect iOS:
|
|
10807
|
-
// and detect version 9:
|
|
10808
|
-
/(iPad|iPhone|iPod).* os 9_/ui.test(navigator.userAgent) && typeof window !== 'undefined' &&
|
|
10809
|
-
|
|
10810
|
-
!('MSStream' in window) // But avoid IE11
|
|
10811
|
-
)) {
|
|
10812
|
-
poorIndexedDbSupport = true;
|
|
10813
|
-
}
|
|
10699
|
+
// Exclude genuine Safari: https://stackoverflow.com/a/7768006/271577
|
|
10700
|
+
// Detect iOS: https://stackoverflow.com/questions/9038625/detect-if-device-is-ios/9039885#9039885
|
|
10701
|
+
// and detect version 9: https://stackoverflow.com/a/26363560/271577
|
|
10702
|
+
/(iPad|iPhone|iPod).* os 9_/ui.test(navigator.userAgent) && typeof window !== 'undefined' && !('MSStream' in window) // But avoid IE11
|
|
10703
|
+
);
|
|
10814
10704
|
if (!CFG.DEFAULT_DB_SIZE) {
|
|
10815
10705
|
CFG.DEFAULT_DB_SIZE = (
|
|
10816
10706
|
// Safari currently requires larger size: (We don't need a larger size for Node as node-websql doesn't use this info)
|
|
@@ -10823,10 +10713,12 @@ function setGlobalVars(idb, initialConfig) {
|
|
|
10823
10713
|
if (!CFG.avoidAutoShim && (!IDB.indexedDB || poorIndexedDbSupport) && CFG.win.openDatabase !== undefined) {
|
|
10824
10714
|
IDB.shimIndexedDB.__useShim();
|
|
10825
10715
|
} else {
|
|
10716
|
+
/* eslint-disable unicorn/logical-assignment-operators -- TS */
|
|
10826
10717
|
IDB.IDBDatabase = IDB.IDBDatabase || 'webkitIDBDatabase' in IDB && IDB.webkitIDBDatabase;
|
|
10827
10718
|
IDB.IDBTransaction = IDB.IDBTransaction || 'webkitIDBTransaction' in IDB && IDB.webkitIDBTransaction || {};
|
|
10828
10719
|
IDB.IDBCursor = IDB.IDBCursor || 'webkitIDBCursor' in IDB && IDB.webkitIDBCursor;
|
|
10829
10720
|
IDB.IDBKeyRange = IDB.IDBKeyRange || 'webkitIDBKeyRange' in IDB && IDB.webkitIDBKeyRange;
|
|
10721
|
+
/* eslint-enable unicorn/logical-assignment-operators -- TS */
|
|
10830
10722
|
}
|
|
10831
10723
|
return /** @type {ShimmedObject} */IDB;
|
|
10832
10724
|
}
|
|
@@ -12042,7 +11934,7 @@ CFG.win = {
|
|
|
12042
11934
|
/**
|
|
12043
11935
|
* @param {import('./setGlobalVars.js').ShimmedObject} idb
|
|
12044
11936
|
* @param {import('./CFG.js').default} initialConfig
|
|
12045
|
-
* @returns {
|
|
11937
|
+
* @returns {import('./setGlobalVars.js').ShimmedObject|Window}
|
|
12046
11938
|
*/
|
|
12047
11939
|
const __setGlobalVars = function (idb, initialConfig = {}) {
|
|
12048
11940
|
const obj = setGlobalVars(idb, {
|