indexeddbshim 9.0.0 → 10.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/dist/indexeddbshim-Key.js +1 -1
- package/dist/indexeddbshim-Key.min.js +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers-node.js +1151 -3156
- package/dist/indexeddbshim-UnicodeIdentifiers-node.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.js +1233 -2965
- package/dist/indexeddbshim-UnicodeIdentifiers.js.map +1 -1
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js +5 -15
- package/dist/indexeddbshim-UnicodeIdentifiers.min.js.map +1 -1
- package/dist/indexeddbshim-node.js +1151 -3156
- package/dist/indexeddbshim-node.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.js +1233 -2965
- package/dist/indexeddbshim-noninvasive.js.map +1 -1
- package/dist/indexeddbshim-noninvasive.min.js +5 -15
- package/dist/indexeddbshim-noninvasive.min.js.map +1 -1
- package/dist/indexeddbshim.js +1233 -2965
- package/dist/indexeddbshim.js.map +1 -1
- package/dist/indexeddbshim.min.js +5 -15
- package/dist/indexeddbshim.min.js.map +1 -1
- package/package.json +100 -100
- package/src/IDBFactory.js +1 -3
- package/src/Key.js +1 -1
- package/src/Sca.js +8 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! indexeddbshim - v9.0.0 -
|
|
1
|
+
/*! indexeddbshim - v9.0.0 - 2/26/2022 */
|
|
2
2
|
|
|
3
3
|
(function (factory) {
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
UnicodeIDContinue: UnicodeIDContinue
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
function ownKeys(object, enumerableOnly) {
|
|
19
|
+
function ownKeys$1(object, enumerableOnly) {
|
|
20
20
|
var keys = Object.keys(object);
|
|
21
21
|
|
|
22
22
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
return keys;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function _objectSpread2(target) {
|
|
32
|
+
function _objectSpread2$1(target) {
|
|
33
33
|
for (var i = 1; i < arguments.length; i++) {
|
|
34
34
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
35
|
-
i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
|
|
36
|
-
_defineProperty(target, key, source[key]);
|
|
37
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
|
|
35
|
+
i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
|
|
36
|
+
_defineProperty$1(target, key, source[key]);
|
|
37
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
|
|
38
38
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
39
39
|
});
|
|
40
40
|
}
|
|
@@ -42,23 +42,59 @@
|
|
|
42
42
|
return target;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
function _typeof$
|
|
45
|
+
function _typeof$2(obj) {
|
|
46
46
|
"@babel/helpers - typeof";
|
|
47
47
|
|
|
48
|
-
return _typeof$
|
|
48
|
+
return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
49
49
|
return typeof obj;
|
|
50
50
|
} : function (obj) {
|
|
51
51
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
52
|
-
}, _typeof$
|
|
52
|
+
}, _typeof$2(obj);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
56
|
+
try {
|
|
57
|
+
var info = gen[key](arg);
|
|
58
|
+
var value = info.value;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
reject(error);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (info.done) {
|
|
65
|
+
resolve(value);
|
|
66
|
+
} else {
|
|
67
|
+
Promise.resolve(value).then(_next, _throw);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function _asyncToGenerator(fn) {
|
|
72
|
+
return function () {
|
|
73
|
+
var self = this,
|
|
74
|
+
args = arguments;
|
|
75
|
+
return new Promise(function (resolve, reject) {
|
|
76
|
+
var gen = fn.apply(self, args);
|
|
77
|
+
|
|
78
|
+
function _next(value) {
|
|
79
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function _throw(err) {
|
|
83
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_next(undefined);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
53
89
|
}
|
|
54
90
|
|
|
55
|
-
function _classCallCheck(instance, Constructor) {
|
|
91
|
+
function _classCallCheck$1(instance, Constructor) {
|
|
56
92
|
if (!(instance instanceof Constructor)) {
|
|
57
93
|
throw new TypeError("Cannot call a class as a function");
|
|
58
94
|
}
|
|
59
95
|
}
|
|
60
96
|
|
|
61
|
-
function _defineProperties(target, props) {
|
|
97
|
+
function _defineProperties$1(target, props) {
|
|
62
98
|
for (var i = 0; i < props.length; i++) {
|
|
63
99
|
var descriptor = props[i];
|
|
64
100
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -68,9 +104,9 @@
|
|
|
68
104
|
}
|
|
69
105
|
}
|
|
70
106
|
|
|
71
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
72
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
73
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
107
|
+
function _createClass$1(Constructor, protoProps, staticProps) {
|
|
108
|
+
if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
|
|
109
|
+
if (staticProps) _defineProperties$1(Constructor, staticProps);
|
|
74
110
|
Object.defineProperty(Constructor, "prototype", {
|
|
75
111
|
writable: false
|
|
76
112
|
});
|
|
@@ -100,7 +136,7 @@
|
|
|
100
136
|
return obj;
|
|
101
137
|
}
|
|
102
138
|
|
|
103
|
-
function _defineProperty(obj, key, value) {
|
|
139
|
+
function _defineProperty$1(obj, key, value) {
|
|
104
140
|
if (key in obj) {
|
|
105
141
|
Object.defineProperty(obj, key, {
|
|
106
142
|
value: value,
|
|
@@ -154,16 +190,16 @@
|
|
|
154
190
|
return _construct.apply(null, arguments);
|
|
155
191
|
}
|
|
156
192
|
|
|
157
|
-
function _slicedToArray(arr, i) {
|
|
158
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
193
|
+
function _slicedToArray$1(arr, i) {
|
|
194
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
|
|
159
195
|
}
|
|
160
196
|
|
|
161
197
|
function _toConsumableArray(arr) {
|
|
162
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
198
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();
|
|
163
199
|
}
|
|
164
200
|
|
|
165
201
|
function _arrayWithoutHoles(arr) {
|
|
166
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
202
|
+
if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
|
|
167
203
|
}
|
|
168
204
|
|
|
169
205
|
function _arrayWithHoles(arr) {
|
|
@@ -204,16 +240,16 @@
|
|
|
204
240
|
return _arr;
|
|
205
241
|
}
|
|
206
242
|
|
|
207
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
243
|
+
function _unsupportedIterableToArray$1(o, minLen) {
|
|
208
244
|
if (!o) return;
|
|
209
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
245
|
+
if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
|
|
210
246
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
211
247
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
212
248
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
213
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
249
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
|
|
214
250
|
}
|
|
215
251
|
|
|
216
|
-
function _arrayLikeToArray(arr, len) {
|
|
252
|
+
function _arrayLikeToArray$1(arr, len) {
|
|
217
253
|
if (len == null || len > arr.length) len = arr.length;
|
|
218
254
|
|
|
219
255
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
@@ -233,7 +269,7 @@
|
|
|
233
269
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
234
270
|
|
|
235
271
|
if (!it) {
|
|
236
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
272
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
|
|
237
273
|
if (it) o = it;
|
|
238
274
|
var i = 0;
|
|
239
275
|
|
|
@@ -286,24 +322,24 @@
|
|
|
286
322
|
};
|
|
287
323
|
}
|
|
288
324
|
|
|
289
|
-
var global$
|
|
325
|
+
var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
290
326
|
|
|
291
|
-
var global
|
|
327
|
+
var global = typeof global$1 !== "undefined" ? global$1 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
292
328
|
|
|
293
|
-
function _typeof(obj) {
|
|
329
|
+
function _typeof$1(obj) {
|
|
294
330
|
"@babel/helpers - typeof";
|
|
295
331
|
|
|
296
332
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
297
|
-
_typeof = function _typeof(obj) {
|
|
333
|
+
_typeof$1 = function _typeof(obj) {
|
|
298
334
|
return typeof obj;
|
|
299
335
|
};
|
|
300
336
|
} else {
|
|
301
|
-
_typeof = function _typeof(obj) {
|
|
337
|
+
_typeof$1 = function _typeof(obj) {
|
|
302
338
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
303
339
|
};
|
|
304
340
|
}
|
|
305
341
|
|
|
306
|
-
return _typeof(obj);
|
|
342
|
+
return _typeof$1(obj);
|
|
307
343
|
}
|
|
308
344
|
/* eslint-disable no-sync, no-restricted-syntax */
|
|
309
345
|
// Todo: Switch to ES6 classes
|
|
@@ -1002,7 +1038,7 @@
|
|
|
1002
1038
|
var triggerGlobalErrorEvent;
|
|
1003
1039
|
var useNodeImpl = false;
|
|
1004
1040
|
|
|
1005
|
-
if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.dispatchEvent) {
|
|
1041
|
+
if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === "undefined" ? "undefined" : _typeof$1(window)) === 'object' && !window.dispatchEvent) {
|
|
1006
1042
|
useNodeImpl = true;
|
|
1007
1043
|
|
|
1008
1044
|
triggerGlobalErrorEvent = function triggerGlobalErrorEvent() {
|
|
@@ -1084,7 +1120,7 @@
|
|
|
1084
1120
|
Object.setPrototypeOf(ShimCustomEvent.prototype, ShimEvent.prototype);
|
|
1085
1121
|
} // Todo: Move to own library (but allowing WeakMaps to be passed in for sharing here)
|
|
1086
1122
|
|
|
1087
|
-
var map
|
|
1123
|
+
var map = {};
|
|
1088
1124
|
var CFG = {};
|
|
1089
1125
|
[// Boolean for verbose reporting
|
|
1090
1126
|
'DEBUG', // Effectively defaults to false (ignored unless `true`)
|
|
@@ -1186,7 +1222,7 @@
|
|
|
1186
1222
|
if (Array.isArray(prop)) {
|
|
1187
1223
|
var _prop = prop;
|
|
1188
1224
|
|
|
1189
|
-
var _prop2 = _slicedToArray(_prop, 2);
|
|
1225
|
+
var _prop2 = _slicedToArray$1(_prop, 2);
|
|
1190
1226
|
|
|
1191
1227
|
prop = _prop2[0];
|
|
1192
1228
|
validator = _prop2[1];
|
|
@@ -1194,14 +1230,14 @@
|
|
|
1194
1230
|
|
|
1195
1231
|
Object.defineProperty(CFG, prop, {
|
|
1196
1232
|
get: function get() {
|
|
1197
|
-
return map
|
|
1233
|
+
return map[prop];
|
|
1198
1234
|
},
|
|
1199
1235
|
set: function set(val) {
|
|
1200
1236
|
if (validator) {
|
|
1201
1237
|
validator(val);
|
|
1202
1238
|
}
|
|
1203
1239
|
|
|
1204
|
-
map
|
|
1240
|
+
map[prop] = val;
|
|
1205
1241
|
}
|
|
1206
1242
|
});
|
|
1207
1243
|
});
|
|
@@ -1322,7 +1358,7 @@
|
|
|
1322
1358
|
}
|
|
1323
1359
|
|
|
1324
1360
|
function isObj(obj) {
|
|
1325
|
-
return obj && _typeof$
|
|
1361
|
+
return obj && _typeof$2(obj) === 'object';
|
|
1326
1362
|
}
|
|
1327
1363
|
|
|
1328
1364
|
function isDate(obj) {
|
|
@@ -1797,7 +1833,7 @@
|
|
|
1797
1833
|
}
|
|
1798
1834
|
|
|
1799
1835
|
function isErrorOrDOMErrorOrDOMException(obj) {
|
|
1800
|
-
return obj && _typeof$
|
|
1836
|
+
return obj && _typeof$2(obj) === 'object' && // We don't use util.isObj here as mutual dependency causing problems in Babel with browser
|
|
1801
1837
|
typeof obj.name === 'string';
|
|
1802
1838
|
}
|
|
1803
1839
|
/**
|
|
@@ -2037,8 +2073,6 @@
|
|
|
2037
2073
|
writable: false
|
|
2038
2074
|
});
|
|
2039
2075
|
|
|
2040
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2041
|
-
|
|
2042
2076
|
// not doing the trick for our WebSQL transactions (at least in Node),
|
|
2043
2077
|
// we are forced to make the promises run fully synchronously.
|
|
2044
2078
|
|
|
@@ -2225,12 +2259,12 @@
|
|
|
2225
2259
|
var decodedKey1 = _decode(encodedKey1);
|
|
2226
2260
|
var decodedKey2 = _decode(encodedKey2);
|
|
2227
2261
|
|
|
2228
|
-
if (_typeof$
|
|
2262
|
+
if (_typeof$2(first) === 'object') {
|
|
2229
2263
|
first = JSON.stringify(first);
|
|
2230
2264
|
decodedKey1 = JSON.stringify(decodedKey1);
|
|
2231
2265
|
}
|
|
2232
2266
|
|
|
2233
|
-
if (_typeof$
|
|
2267
|
+
if (_typeof$2(second) === 'object') {
|
|
2234
2268
|
second = JSON.stringify(second);
|
|
2235
2269
|
decodedKey2 = JSON.stringify(decodedKey2);
|
|
2236
2270
|
} // Encoding/decoding mismatches are usually due to a loss of
|
|
@@ -2433,7 +2467,7 @@
|
|
|
2433
2467
|
|
|
2434
2468
|
try {
|
|
2435
2469
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
2436
|
-
var _step$value = _slicedToArray(_step.value, 2),
|
|
2470
|
+
var _step$value = _slicedToArray$1(_step.value, 2),
|
|
2437
2471
|
i = _step$value[0],
|
|
2438
2472
|
item = _step$value[1];
|
|
2439
2473
|
|
|
@@ -2622,7 +2656,7 @@
|
|
|
2622
2656
|
if (isDate(key)) return 'date';
|
|
2623
2657
|
if (isBinary(key)) return 'binary';
|
|
2624
2658
|
|
|
2625
|
-
var keyType = _typeof$
|
|
2659
|
+
var keyType = _typeof$2(key);
|
|
2626
2660
|
|
|
2627
2661
|
return ['string', 'number'].includes(keyType) ? keyType : 'invalid';
|
|
2628
2662
|
}
|
|
@@ -2797,7 +2831,7 @@
|
|
|
2797
2831
|
}();
|
|
2798
2832
|
|
|
2799
2833
|
if (_ret === "continue") continue;
|
|
2800
|
-
if (_typeof$
|
|
2834
|
+
if (_typeof$2(_ret) === "object") return _ret.v;
|
|
2801
2835
|
} catch (err) {
|
|
2802
2836
|
if (!multiEntry) {
|
|
2803
2837
|
throw err;
|
|
@@ -2835,7 +2869,7 @@
|
|
|
2835
2869
|
{
|
|
2836
2870
|
// Other `typeof` types which are not valid keys:
|
|
2837
2871
|
// 'undefined', 'boolean', 'object' (including `null`), 'symbol', 'function
|
|
2838
|
-
var _type = input === null ? 'null' : _typeof$
|
|
2872
|
+
var _type = input === null ? 'null' : _typeof$2(input); // Convert `null` for convenience of consumers in reporting errors
|
|
2839
2873
|
|
|
2840
2874
|
|
|
2841
2875
|
return {
|
|
@@ -3781,7 +3815,7 @@
|
|
|
3781
3815
|
|
|
3782
3816
|
this.sortList();
|
|
3783
3817
|
}
|
|
3784
|
-
}, _defineProperty(_DOMStringList$protot, Symbol.toStringTag, 'DOMStringListPrototype'), _defineProperty(_DOMStringList$protot, Symbol.iterator, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
3818
|
+
}, _defineProperty$1(_DOMStringList$protot, Symbol.toStringTag, 'DOMStringListPrototype'), _defineProperty$1(_DOMStringList$protot, Symbol.iterator, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
|
3785
3819
|
var i;
|
|
3786
3820
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
3787
3821
|
while (1) {
|
|
@@ -4503,3187 +4537,1421 @@
|
|
|
4503
4537
|
writable: false
|
|
4504
4538
|
});
|
|
4505
4539
|
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
(function (module, exports) {
|
|
4509
|
-
(function (global, factory) {
|
|
4510
|
-
module.exports = factory() ;
|
|
4511
|
-
})(commonjsGlobal, function () {
|
|
4512
|
-
|
|
4513
|
-
function _typeof(obj) {
|
|
4514
|
-
"@babel/helpers - typeof";
|
|
4515
|
-
|
|
4516
|
-
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
|
4517
|
-
_typeof = function _typeof(obj) {
|
|
4518
|
-
return typeof obj;
|
|
4519
|
-
};
|
|
4520
|
-
} else {
|
|
4521
|
-
_typeof = function _typeof(obj) {
|
|
4522
|
-
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
4523
|
-
};
|
|
4524
|
-
}
|
|
4525
|
-
|
|
4526
|
-
return _typeof(obj);
|
|
4527
|
-
}
|
|
4528
|
-
|
|
4529
|
-
function _classCallCheck(instance, Constructor) {
|
|
4530
|
-
if (!(instance instanceof Constructor)) {
|
|
4531
|
-
throw new TypeError("Cannot call a class as a function");
|
|
4532
|
-
}
|
|
4533
|
-
}
|
|
4534
|
-
|
|
4535
|
-
function _defineProperties(target, props) {
|
|
4536
|
-
for (var i = 0; i < props.length; i++) {
|
|
4537
|
-
var descriptor = props[i];
|
|
4538
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
4539
|
-
descriptor.configurable = true;
|
|
4540
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
4541
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
4542
|
-
}
|
|
4543
|
-
}
|
|
4544
|
-
|
|
4545
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
4546
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
4547
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
4548
|
-
return Constructor;
|
|
4549
|
-
}
|
|
4550
|
-
|
|
4551
|
-
function _defineProperty(obj, key, value) {
|
|
4552
|
-
if (key in obj) {
|
|
4553
|
-
Object.defineProperty(obj, key, {
|
|
4554
|
-
value: value,
|
|
4555
|
-
enumerable: true,
|
|
4556
|
-
configurable: true,
|
|
4557
|
-
writable: true
|
|
4558
|
-
});
|
|
4559
|
-
} else {
|
|
4560
|
-
obj[key] = value;
|
|
4561
|
-
}
|
|
4562
|
-
|
|
4563
|
-
return obj;
|
|
4564
|
-
}
|
|
4565
|
-
|
|
4566
|
-
function ownKeys(object, enumerableOnly) {
|
|
4567
|
-
var keys = Object.keys(object);
|
|
4540
|
+
function ownKeys(e, t) {
|
|
4541
|
+
var r = Object.keys(e);
|
|
4568
4542
|
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
}
|
|
4543
|
+
if (Object.getOwnPropertySymbols) {
|
|
4544
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
4545
|
+
t && (n = n.filter(function (t) {
|
|
4546
|
+
return Object.getOwnPropertyDescriptor(e, t).enumerable;
|
|
4547
|
+
})), r.push.apply(r, n);
|
|
4548
|
+
}
|
|
4576
4549
|
|
|
4577
|
-
|
|
4578
|
-
|
|
4550
|
+
return r;
|
|
4551
|
+
}
|
|
4579
4552
|
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4553
|
+
function _objectSpread2(e) {
|
|
4554
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
4555
|
+
var r = null != arguments[t] ? arguments[t] : {};
|
|
4556
|
+
t % 2 ? ownKeys(Object(r), !0).forEach(function (t) {
|
|
4557
|
+
_defineProperty(e, t, r[t]);
|
|
4558
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ownKeys(Object(r)).forEach(function (t) {
|
|
4559
|
+
Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
|
|
4560
|
+
});
|
|
4561
|
+
}
|
|
4583
4562
|
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
_defineProperty(target, key, source[key]);
|
|
4587
|
-
});
|
|
4588
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
4589
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
4590
|
-
} else {
|
|
4591
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
4592
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
4593
|
-
});
|
|
4594
|
-
}
|
|
4595
|
-
}
|
|
4563
|
+
return e;
|
|
4564
|
+
}
|
|
4596
4565
|
|
|
4597
|
-
|
|
4598
|
-
|
|
4566
|
+
function _typeof(e) {
|
|
4567
|
+
return (_typeof = "function" == typeof Symbol && "symbol" == _typeof$2(Symbol.iterator) ? function (e) {
|
|
4568
|
+
return _typeof$2(e);
|
|
4569
|
+
} : function (e) {
|
|
4570
|
+
return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof$2(e);
|
|
4571
|
+
})(e);
|
|
4572
|
+
}
|
|
4599
4573
|
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4574
|
+
function _classCallCheck(e, t) {
|
|
4575
|
+
if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
|
|
4576
|
+
}
|
|
4603
4577
|
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4578
|
+
function _defineProperties(e, t) {
|
|
4579
|
+
for (var r = 0; r < t.length; r++) {
|
|
4580
|
+
var n = t[r];
|
|
4581
|
+
n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
|
|
4582
|
+
}
|
|
4583
|
+
}
|
|
4607
4584
|
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4585
|
+
function _createClass(e, t, r) {
|
|
4586
|
+
return t && _defineProperties(e.prototype, t), r && _defineProperties(e, r), Object.defineProperty(e, "prototype", {
|
|
4587
|
+
writable: !1
|
|
4588
|
+
}), e;
|
|
4589
|
+
}
|
|
4611
4590
|
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4591
|
+
function _defineProperty(e, t, r) {
|
|
4592
|
+
return t in e ? Object.defineProperty(e, t, {
|
|
4593
|
+
value: r,
|
|
4594
|
+
enumerable: !0,
|
|
4595
|
+
configurable: !0,
|
|
4596
|
+
writable: !0
|
|
4597
|
+
}) : e[t] = r, e;
|
|
4598
|
+
}
|
|
4615
4599
|
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4600
|
+
function _slicedToArray(e, t) {
|
|
4601
|
+
return function _arrayWithHoles(e) {
|
|
4602
|
+
if (Array.isArray(e)) return e;
|
|
4603
|
+
}(e) || function _iterableToArrayLimit(e, t) {
|
|
4604
|
+
var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
|
|
4619
4605
|
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4606
|
+
if (null != r) {
|
|
4607
|
+
var n,
|
|
4608
|
+
a,
|
|
4609
|
+
o = [],
|
|
4610
|
+
i = !0,
|
|
4611
|
+
s = !1;
|
|
4626
4612
|
|
|
4627
4613
|
try {
|
|
4628
|
-
for (
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
if (i && _arr.length === i) break;
|
|
4614
|
+
for (r = r.call(e); !(i = (n = r.next()).done) && (o.push(n.value), !t || o.length !== t); i = !0) {
|
|
4615
|
+
;
|
|
4632
4616
|
}
|
|
4633
|
-
} catch (
|
|
4634
|
-
|
|
4635
|
-
_e = err;
|
|
4617
|
+
} catch (e) {
|
|
4618
|
+
s = !0, a = e;
|
|
4636
4619
|
} finally {
|
|
4637
4620
|
try {
|
|
4638
|
-
|
|
4621
|
+
i || null == r["return"] || r["return"]();
|
|
4639
4622
|
} finally {
|
|
4640
|
-
if (
|
|
4623
|
+
if (s) throw a;
|
|
4641
4624
|
}
|
|
4642
4625
|
}
|
|
4643
4626
|
|
|
4644
|
-
return
|
|
4627
|
+
return o;
|
|
4645
4628
|
}
|
|
4629
|
+
}(e, t) || _unsupportedIterableToArray(e, t) || function _nonIterableRest() {
|
|
4630
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4631
|
+
}();
|
|
4632
|
+
}
|
|
4646
4633
|
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
}
|
|
4634
|
+
function _unsupportedIterableToArray(e, t) {
|
|
4635
|
+
if (e) {
|
|
4636
|
+
if ("string" == typeof e) return _arrayLikeToArray(e, t);
|
|
4637
|
+
var r = Object.prototype.toString.call(e).slice(8, -1);
|
|
4638
|
+
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;
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4655
4641
|
|
|
4656
|
-
|
|
4657
|
-
|
|
4642
|
+
function _arrayLikeToArray(e, t) {
|
|
4643
|
+
(null == t || t > e.length) && (t = e.length);
|
|
4658
4644
|
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4645
|
+
for (var r = 0, n = new Array(t); r < t; r++) {
|
|
4646
|
+
n[r] = e[r];
|
|
4647
|
+
}
|
|
4662
4648
|
|
|
4663
|
-
|
|
4664
|
-
|
|
4649
|
+
return n;
|
|
4650
|
+
}
|
|
4665
4651
|
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4652
|
+
var e = _createClass(function TypesonPromise(e) {
|
|
4653
|
+
_classCallCheck(this, TypesonPromise), this.p = new Promise(e);
|
|
4654
|
+
});
|
|
4669
4655
|
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4656
|
+
e.__typeson__type__ = "TypesonPromise", "undefined" != typeof Symbol && (e.prototype[Symbol.toStringTag] = "TypesonPromise"), e.prototype.then = function (t, r) {
|
|
4657
|
+
var n = this;
|
|
4658
|
+
return new e(function (e, a) {
|
|
4659
|
+
n.p.then(function (r) {
|
|
4660
|
+
e(t ? t(r) : r);
|
|
4661
|
+
})["catch"](function (e) {
|
|
4662
|
+
return r ? r(e) : Promise.reject(e);
|
|
4663
|
+
}).then(e, a);
|
|
4664
|
+
});
|
|
4665
|
+
}, e.prototype["catch"] = function (e) {
|
|
4666
|
+
return this.then(null, e);
|
|
4667
|
+
}, e.resolve = function (t) {
|
|
4668
|
+
return new e(function (e) {
|
|
4669
|
+
e(t);
|
|
4670
|
+
});
|
|
4671
|
+
}, e.reject = function (t) {
|
|
4672
|
+
return new e(function (e, r) {
|
|
4673
|
+
r(t);
|
|
4674
|
+
});
|
|
4675
|
+
}, ["all", "race", "allSettled"].forEach(function (t) {
|
|
4676
|
+
e[t] = function (r) {
|
|
4677
|
+
return new e(function (e, n) {
|
|
4678
|
+
Promise[t](r.map(function (e) {
|
|
4679
|
+
return e && e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e;
|
|
4680
|
+
})).then(e, n);
|
|
4681
|
+
});
|
|
4682
|
+
};
|
|
4683
|
+
});
|
|
4684
|
+
var t = {}.toString,
|
|
4685
|
+
r = {}.hasOwnProperty,
|
|
4686
|
+
n = Object.getPrototypeOf,
|
|
4687
|
+
a = r.toString;
|
|
4677
4688
|
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
*/
|
|
4689
|
+
function isThenable(e, t) {
|
|
4690
|
+
return isObject(e) && "function" == typeof e.then && (!t || "function" == typeof e["catch"]);
|
|
4691
|
+
}
|
|
4682
4692
|
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
* @returns {Promise<any>}
|
|
4687
|
-
*/
|
|
4693
|
+
function toStringTag(e) {
|
|
4694
|
+
return t.call(e).slice(8, -1);
|
|
4695
|
+
}
|
|
4688
4696
|
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4697
|
+
function hasConstructorOf(e, t) {
|
|
4698
|
+
if (!e || "object" !== _typeof(e)) return !1;
|
|
4699
|
+
var o = n(e);
|
|
4700
|
+
if (!o) return null === t;
|
|
4701
|
+
var i = r.call(o, "constructor") && o.constructor;
|
|
4702
|
+
return "function" != typeof i ? null === t : t === i || null !== t && a.call(i) === a.call(t) || "function" == typeof t && "string" == typeof i.__typeson__type__ && i.__typeson__type__ === t.__typeson__type__;
|
|
4703
|
+
}
|
|
4694
4704
|
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
* @param {TypesonReject} typesonReject
|
|
4699
|
-
* @returns {Promise<any>}
|
|
4700
|
-
*/
|
|
4705
|
+
function isPlainObject(e) {
|
|
4706
|
+
return !(!e || "Object" !== toStringTag(e)) && (!n(e) || hasConstructorOf(e, Object));
|
|
4707
|
+
}
|
|
4701
4708
|
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4709
|
+
function isUserObject(e) {
|
|
4710
|
+
if (!e || "Object" !== toStringTag(e)) return !1;
|
|
4711
|
+
var t = n(e);
|
|
4712
|
+
return !t || hasConstructorOf(e, Object) || isUserObject(t);
|
|
4713
|
+
}
|
|
4705
4714
|
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
* with `hasConstructorOf`.
|
|
4710
|
-
* With ES6 classes, we may be able to simply use `class TypesonPromise
|
|
4711
|
-
* extends Promise` and add a string tag for detection.
|
|
4712
|
-
* @param {TypesonResolveReject} f
|
|
4713
|
-
*/
|
|
4715
|
+
function isObject(e) {
|
|
4716
|
+
return e && "object" === _typeof(e);
|
|
4717
|
+
}
|
|
4714
4718
|
|
|
4719
|
+
function escapeKeyPathComponent(e) {
|
|
4720
|
+
return e.replace(/~/g, "~0").replace(/\./g, "~1");
|
|
4721
|
+
}
|
|
4715
4722
|
|
|
4716
|
-
|
|
4717
|
-
|
|
4723
|
+
function unescapeKeyPathComponent(e) {
|
|
4724
|
+
return e.replace(/~1/g, ".").replace(/~0/g, "~");
|
|
4725
|
+
}
|
|
4718
4726
|
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
space-before-blocks, space-infix-ops, semi, promise/avoid-new,
|
|
4723
|
-
jsdoc/require-jsdoc */
|
|
4724
|
-
// eslint-disable-next-line max-len
|
|
4725
|
-
// class TypesonPromise extends Promise {get[Symbol.toStringTag](){return 'TypesonPromise'};} // eslint-disable-line keyword-spacing, space-before-function-paren, space-before-blocks, block-spacing, semi
|
|
4727
|
+
function getByKeyPath(e, t) {
|
|
4728
|
+
if ("" === t) return e;
|
|
4729
|
+
var r = t.indexOf(".");
|
|
4726
4730
|
|
|
4731
|
+
if (r > -1) {
|
|
4732
|
+
var n = e[unescapeKeyPathComponent(t.slice(0, r))];
|
|
4733
|
+
return void 0 === n ? void 0 : getByKeyPath(n, t.slice(r + 1));
|
|
4734
|
+
}
|
|
4727
4735
|
|
|
4728
|
-
|
|
4736
|
+
return e[unescapeKeyPathComponent(t)];
|
|
4737
|
+
}
|
|
4729
4738
|
|
|
4730
|
-
|
|
4739
|
+
function setAtKeyPath(e, t, r) {
|
|
4740
|
+
if ("" === t) return r;
|
|
4741
|
+
var n = t.indexOf(".");
|
|
4742
|
+
return n > -1 ? setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0, n))], t.slice(n + 1), r) : (e[unescapeKeyPathComponent(t)] = r, e);
|
|
4743
|
+
}
|
|
4731
4744
|
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
}
|
|
4736
|
-
/**
|
|
4737
|
-
*
|
|
4738
|
-
* @param {TypesonFulfilled} [onFulfilled]
|
|
4739
|
-
* @param {TypesonRejected} [onRejected]
|
|
4740
|
-
* @returns {TypesonPromise}
|
|
4741
|
-
*/
|
|
4745
|
+
function getJSONType(e) {
|
|
4746
|
+
return null === e ? "null" : Array.isArray(e) ? "array" : _typeof(e);
|
|
4747
|
+
}
|
|
4742
4748
|
|
|
4749
|
+
function _await(e, t, r) {
|
|
4750
|
+
return r ? t ? t(e) : e : (e && e.then || (e = Promise.resolve(e)), t ? e.then(t) : e);
|
|
4751
|
+
}
|
|
4743
4752
|
|
|
4744
|
-
|
|
4745
|
-
|
|
4753
|
+
var o = Object.keys,
|
|
4754
|
+
i = Array.isArray,
|
|
4755
|
+
s = {}.hasOwnProperty,
|
|
4756
|
+
c = ["type", "replaced", "iterateIn", "iterateUnsetNumeric"];
|
|
4746
4757
|
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
})["catch"](function (res) {
|
|
4753
|
-
return onRejected ? onRejected(res) : Promise.reject(res);
|
|
4754
|
-
}).then(typesonResolve, typesonReject);
|
|
4755
|
-
});
|
|
4756
|
-
};
|
|
4757
|
-
/**
|
|
4758
|
-
*
|
|
4759
|
-
* @param {TypesonRejected} onRejected
|
|
4760
|
-
* @returns {TypesonPromise}
|
|
4761
|
-
*/
|
|
4758
|
+
function _async(e) {
|
|
4759
|
+
return function () {
|
|
4760
|
+
for (var t = [], r = 0; r < arguments.length; r++) {
|
|
4761
|
+
t[r] = arguments[r];
|
|
4762
|
+
}
|
|
4762
4763
|
|
|
4764
|
+
try {
|
|
4765
|
+
return Promise.resolve(e.apply(this, t));
|
|
4766
|
+
} catch (e) {
|
|
4767
|
+
return Promise.reject(e);
|
|
4768
|
+
}
|
|
4769
|
+
};
|
|
4770
|
+
}
|
|
4763
4771
|
|
|
4764
|
-
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
* @returns {TypesonPromise}
|
|
4771
|
-
*/
|
|
4772
|
+
function nestedPathsFirst(e, t) {
|
|
4773
|
+
if ("" === e.keypath) return -1;
|
|
4774
|
+
var r = e.keypath.match(/\./g) || 0,
|
|
4775
|
+
n = t.keypath.match(/\./g) || 0;
|
|
4776
|
+
return r && (r = r.length), n && (n = n.length), r > n ? -1 : r < n ? 1 : e.keypath < t.keypath ? -1 : e.keypath > t.keypath;
|
|
4777
|
+
}
|
|
4772
4778
|
|
|
4779
|
+
var u = function () {
|
|
4780
|
+
function Typeson(e) {
|
|
4781
|
+
_classCallCheck(this, Typeson), this.options = e, this.plainObjectReplacers = [], this.nonplainObjectReplacers = [], this.revivers = {}, this.types = {};
|
|
4782
|
+
}
|
|
4773
4783
|
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4784
|
+
return _createClass(Typeson, [{
|
|
4785
|
+
key: "stringify",
|
|
4786
|
+
value: function stringify(e, t, r, n) {
|
|
4787
|
+
n = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), n), {}, {
|
|
4788
|
+
stringification: !0
|
|
4777
4789
|
});
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
* @param {any} v
|
|
4782
|
-
* @returns {TypesonPromise}
|
|
4783
|
-
*/
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
TypesonPromise.reject = function (v) {
|
|
4787
|
-
return new TypesonPromise(function (typesonResolve, typesonReject) {
|
|
4788
|
-
typesonReject(v);
|
|
4790
|
+
var a = this.encapsulate(e, null, n);
|
|
4791
|
+
return i(a) ? JSON.stringify(a[0], t, r) : a.then(function (e) {
|
|
4792
|
+
return JSON.stringify(e, t, r);
|
|
4789
4793
|
});
|
|
4790
|
-
}
|
|
4791
|
-
|
|
4792
|
-
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4794
|
+
}
|
|
4795
|
+
}, {
|
|
4796
|
+
key: "stringifySync",
|
|
4797
|
+
value: function stringifySync(e, t, r, n) {
|
|
4798
|
+
return this.stringify(e, t, r, _objectSpread2(_objectSpread2({
|
|
4799
|
+
throwOnBadSyncType: !0
|
|
4800
|
+
}, n), {}, {
|
|
4801
|
+
sync: !0
|
|
4802
|
+
}));
|
|
4803
|
+
}
|
|
4804
|
+
}, {
|
|
4805
|
+
key: "stringifyAsync",
|
|
4806
|
+
value: function stringifyAsync(e, t, r, n) {
|
|
4807
|
+
return this.stringify(e, t, r, _objectSpread2(_objectSpread2({
|
|
4808
|
+
throwOnBadSyncType: !0
|
|
4809
|
+
}, n), {}, {
|
|
4810
|
+
sync: !1
|
|
4811
|
+
}));
|
|
4812
|
+
}
|
|
4813
|
+
}, {
|
|
4814
|
+
key: "parse",
|
|
4815
|
+
value: function parse(e, t, r) {
|
|
4816
|
+
return r = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), r), {}, {
|
|
4817
|
+
parse: !0
|
|
4818
|
+
}), this.revive(JSON.parse(e, t), r);
|
|
4819
|
+
}
|
|
4820
|
+
}, {
|
|
4821
|
+
key: "parseSync",
|
|
4822
|
+
value: function parseSync(e, t, r) {
|
|
4823
|
+
return this.parse(e, t, _objectSpread2(_objectSpread2({
|
|
4824
|
+
throwOnBadSyncType: !0
|
|
4825
|
+
}, r), {}, {
|
|
4826
|
+
sync: !0
|
|
4827
|
+
}));
|
|
4828
|
+
}
|
|
4829
|
+
}, {
|
|
4830
|
+
key: "parseAsync",
|
|
4831
|
+
value: function parseAsync(e, t, r) {
|
|
4832
|
+
return this.parse(e, t, _objectSpread2(_objectSpread2({
|
|
4833
|
+
throwOnBadSyncType: !0
|
|
4834
|
+
}, r), {}, {
|
|
4835
|
+
sync: !1
|
|
4836
|
+
}));
|
|
4837
|
+
}
|
|
4838
|
+
}, {
|
|
4839
|
+
key: "specialTypeNames",
|
|
4840
|
+
value: function specialTypeNames(e, t) {
|
|
4841
|
+
var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
4842
|
+
return r.returnTypeNames = !0, this.encapsulate(e, t, r);
|
|
4843
|
+
}
|
|
4844
|
+
}, {
|
|
4845
|
+
key: "rootTypeName",
|
|
4846
|
+
value: function rootTypeName(e, t) {
|
|
4847
|
+
var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
|
|
4848
|
+
return r.iterateNone = !0, this.encapsulate(e, t, r);
|
|
4849
|
+
}
|
|
4850
|
+
}, {
|
|
4851
|
+
key: "encapsulate",
|
|
4852
|
+
value: function encapsulate(t, r, n) {
|
|
4853
|
+
var a = _async(function (t, r) {
|
|
4854
|
+
return _await(Promise.all(r.map(function (e) {
|
|
4855
|
+
return e[1].p;
|
|
4856
|
+
})), function (n) {
|
|
4857
|
+
return _await(Promise.all(n.map(_async(function (n) {
|
|
4858
|
+
var o = !1,
|
|
4859
|
+
i = [],
|
|
4860
|
+
s = _slicedToArray(r.splice(0, 1), 1),
|
|
4861
|
+
c = _slicedToArray(s[0], 7),
|
|
4862
|
+
u = c[0],
|
|
4863
|
+
l = c[2],
|
|
4864
|
+
f = c[3],
|
|
4865
|
+
y = c[4],
|
|
4866
|
+
p = c[5],
|
|
4867
|
+
d = c[6],
|
|
4868
|
+
v = _encapsulate(u, n, l, f, i, !0, d),
|
|
4869
|
+
b = hasConstructorOf(v, e);
|
|
4870
|
+
|
|
4871
|
+
return function _invoke(e, t) {
|
|
4872
|
+
var r = e();
|
|
4873
|
+
return r && r.then ? r.then(t) : t(r);
|
|
4874
|
+
}(function () {
|
|
4875
|
+
if (u && b) return _await(v.p, function (e) {
|
|
4876
|
+
y[p] = e;
|
|
4877
|
+
var r = a(t, i);
|
|
4878
|
+
return o = !0, r;
|
|
4879
|
+
});
|
|
4880
|
+
}, function (e) {
|
|
4881
|
+
return o ? e : (u ? y[p] = v : t = b ? v.p : v, a(t, i));
|
|
4882
|
+
});
|
|
4883
|
+
}))), function () {
|
|
4884
|
+
return t;
|
|
4885
|
+
});
|
|
4886
|
+
});
|
|
4887
|
+
}),
|
|
4888
|
+
u = (n = _objectSpread2(_objectSpread2({
|
|
4889
|
+
sync: !0
|
|
4890
|
+
}, this.options), n)).sync,
|
|
4891
|
+
l = this,
|
|
4892
|
+
f = {},
|
|
4893
|
+
y = [],
|
|
4894
|
+
p = [],
|
|
4895
|
+
d = [],
|
|
4896
|
+
v = !("cyclic" in n) || n.cyclic,
|
|
4897
|
+
b = n.encapsulateObserver,
|
|
4898
|
+
h = _encapsulate("", t, v, r || {}, d);
|
|
4899
|
+
|
|
4900
|
+
function finish(e) {
|
|
4901
|
+
var t = Object.values(f);
|
|
4902
|
+
if (n.iterateNone) return t.length ? t[0] : getJSONType(e);
|
|
4903
|
+
|
|
4904
|
+
if (t.length) {
|
|
4905
|
+
if (n.returnTypeNames) return function _toConsumableArray(e) {
|
|
4906
|
+
return function _arrayWithoutHoles(e) {
|
|
4907
|
+
if (Array.isArray(e)) return _arrayLikeToArray(e);
|
|
4908
|
+
}(e) || function _iterableToArray(e) {
|
|
4909
|
+
if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e);
|
|
4910
|
+
}(e) || _unsupportedIterableToArray(e) || function _nonIterableSpread() {
|
|
4911
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
4912
|
+
}();
|
|
4913
|
+
}(new Set(t));
|
|
4914
|
+
e && isPlainObject(e) && !s.call(e, "$types") ? e.$types = f : e = {
|
|
4915
|
+
$: e,
|
|
4916
|
+
$types: {
|
|
4917
|
+
$: f
|
|
4918
|
+
}
|
|
4919
|
+
};
|
|
4920
|
+
} else isObject(e) && s.call(e, "$types") && (e = {
|
|
4921
|
+
$: e,
|
|
4922
|
+
$types: !0
|
|
4804
4923
|
});
|
|
4805
|
-
};
|
|
4806
|
-
});
|
|
4807
|
-
var _ref = {},
|
|
4808
|
-
toStr = _ref.toString,
|
|
4809
|
-
hasOwn$1 = {}.hasOwnProperty,
|
|
4810
|
-
getProto = Object.getPrototypeOf,
|
|
4811
|
-
fnToString = hasOwn$1.toString;
|
|
4812
|
-
/**
|
|
4813
|
-
* Second argument not in use internally, but provided for utility.
|
|
4814
|
-
* @param {any} v
|
|
4815
|
-
* @param {boolean} catchCheck
|
|
4816
|
-
* @returns {boolean}
|
|
4817
|
-
*/
|
|
4818
4924
|
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
}
|
|
4822
|
-
/**
|
|
4823
|
-
*
|
|
4824
|
-
* @param {any} val
|
|
4825
|
-
* @returns {string}
|
|
4826
|
-
*/
|
|
4925
|
+
return !n.returnTypeNames && e;
|
|
4926
|
+
}
|
|
4827
4927
|
|
|
4928
|
+
function _adaptBuiltinStateObjectProperties(e, t, r) {
|
|
4929
|
+
Object.assign(e, t);
|
|
4930
|
+
var n = c.map(function (t) {
|
|
4931
|
+
var r = e[t];
|
|
4932
|
+
return delete e[t], r;
|
|
4933
|
+
});
|
|
4934
|
+
r(), c.forEach(function (t, r) {
|
|
4935
|
+
e[t] = n[r];
|
|
4936
|
+
});
|
|
4937
|
+
}
|
|
4828
4938
|
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4939
|
+
function _encapsulate(t, r, a, c, u, d, v) {
|
|
4940
|
+
var h,
|
|
4941
|
+
g = {},
|
|
4942
|
+
m = _typeof(r),
|
|
4943
|
+
O = b ? function (n) {
|
|
4944
|
+
var o = v || c.type || getJSONType(r);
|
|
4945
|
+
b(Object.assign(n || g, {
|
|
4946
|
+
keypath: t,
|
|
4947
|
+
value: r,
|
|
4948
|
+
cyclic: a,
|
|
4949
|
+
stateObj: c,
|
|
4950
|
+
promisesData: u,
|
|
4951
|
+
resolvingTypesonPromise: d,
|
|
4952
|
+
awaitingTypesonPromise: hasConstructorOf(r, e)
|
|
4953
|
+
}, {
|
|
4954
|
+
type: o
|
|
4955
|
+
}));
|
|
4956
|
+
} : null;
|
|
4957
|
+
|
|
4958
|
+
if (["string", "boolean", "number", "undefined"].includes(m)) return void 0 === r || Number.isNaN(r) || r === Number.NEGATIVE_INFINITY || r === Number.POSITIVE_INFINITY ? (h = c.replaced ? r : replace(t, r, c, u, !1, d, O)) !== r && (g = {
|
|
4959
|
+
replaced: h
|
|
4960
|
+
}) : h = r, O && O(), h;
|
|
4961
|
+
if (null === r) return O && O(), r;
|
|
4962
|
+
|
|
4963
|
+
if (a && !c.iterateIn && !c.iterateUnsetNumeric && r && "object" === _typeof(r)) {
|
|
4964
|
+
var S = y.indexOf(r);
|
|
4965
|
+
if (!(S < 0)) return f[t] = "#", O && O({
|
|
4966
|
+
cyclicKeypath: p[S]
|
|
4967
|
+
}), "#" + p[S];
|
|
4968
|
+
!0 === a && (y.push(r), p.push(t));
|
|
4969
|
+
}
|
|
4839
4970
|
|
|
4971
|
+
var _,
|
|
4972
|
+
w = isPlainObject(r),
|
|
4973
|
+
A = i(r),
|
|
4974
|
+
j = (w || A) && (!l.plainObjectReplacers.length || c.replaced) || c.iterateIn ? r : replace(t, r, c, u, w || A, null, O);
|
|
4975
|
+
|
|
4976
|
+
if (j !== r ? (h = j, g = {
|
|
4977
|
+
replaced: j
|
|
4978
|
+
}) : "" === t && hasConstructorOf(r, e) ? (u.push([t, r, a, c, void 0, void 0, c.type]), h = r) : A && "object" !== c.iterateIn || "array" === c.iterateIn ? (_ = new Array(r.length), g = {
|
|
4979
|
+
clone: _
|
|
4980
|
+
}) : (["function", "symbol"].includes(_typeof(r)) || "toJSON" in r || hasConstructorOf(r, e) || hasConstructorOf(r, Promise) || hasConstructorOf(r, ArrayBuffer)) && !w && "object" !== c.iterateIn ? h = r : (_ = {}, c.addLength && (_.length = r.length), g = {
|
|
4981
|
+
clone: _
|
|
4982
|
+
}), O && O(), n.iterateNone) return _ || h;
|
|
4983
|
+
if (!_) return h;
|
|
4984
|
+
|
|
4985
|
+
if (c.iterateIn) {
|
|
4986
|
+
var T = function _loop(n) {
|
|
4987
|
+
var o = {
|
|
4988
|
+
ownKeys: s.call(r, n)
|
|
4989
|
+
};
|
|
4840
4990
|
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
}
|
|
4991
|
+
_adaptBuiltinStateObjectProperties(c, o, function () {
|
|
4992
|
+
var o = t + (t ? "." : "") + escapeKeyPathComponent(n),
|
|
4993
|
+
i = _encapsulate(o, r[n], Boolean(a), c, u, d);
|
|
4845
4994
|
|
|
4846
|
-
|
|
4995
|
+
hasConstructorOf(i, e) ? u.push([o, i, Boolean(a), c, _, n, c.type]) : void 0 !== i && (_[n] = i);
|
|
4996
|
+
});
|
|
4997
|
+
};
|
|
4847
4998
|
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4999
|
+
for (var I in r) {
|
|
5000
|
+
T(I);
|
|
5001
|
+
}
|
|
4851
5002
|
|
|
4852
|
-
|
|
5003
|
+
O && O({
|
|
5004
|
+
endIterateIn: !0,
|
|
5005
|
+
end: !0
|
|
5006
|
+
});
|
|
5007
|
+
} else o(r).forEach(function (n) {
|
|
5008
|
+
var o = t + (t ? "." : "") + escapeKeyPathComponent(n);
|
|
4853
5009
|
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
5010
|
+
_adaptBuiltinStateObjectProperties(c, {
|
|
5011
|
+
ownKeys: !0
|
|
5012
|
+
}, function () {
|
|
5013
|
+
var t = _encapsulate(o, r[n], Boolean(a), c, u, d);
|
|
4857
5014
|
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
5015
|
+
hasConstructorOf(t, e) ? u.push([o, t, Boolean(a), c, _, n, c.type]) : void 0 !== t && (_[n] = t);
|
|
5016
|
+
});
|
|
5017
|
+
}), O && O({
|
|
5018
|
+
endIterateOwn: !0,
|
|
5019
|
+
end: !0
|
|
5020
|
+
});
|
|
4861
5021
|
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
5022
|
+
if (c.iterateUnsetNumeric) {
|
|
5023
|
+
for (var P = r.length, N = function _loop2(n) {
|
|
5024
|
+
if (!(n in r)) {
|
|
5025
|
+
var o = t + (t ? "." : "") + n;
|
|
4865
5026
|
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
5027
|
+
_adaptBuiltinStateObjectProperties(c, {
|
|
5028
|
+
ownKeys: !1
|
|
5029
|
+
}, function () {
|
|
5030
|
+
var t = _encapsulate(o, void 0, Boolean(a), c, u, d);
|
|
4869
5031
|
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
*/
|
|
5032
|
+
hasConstructorOf(t, e) ? u.push([o, t, Boolean(a), c, _, n, c.type]) : void 0 !== t && (_[n] = t);
|
|
5033
|
+
});
|
|
5034
|
+
}
|
|
5035
|
+
}, C = 0; C < P; C++) {
|
|
5036
|
+
N(C);
|
|
5037
|
+
}
|
|
4877
5038
|
|
|
5039
|
+
O && O({
|
|
5040
|
+
endIterateUnsetNumeric: !0,
|
|
5041
|
+
end: !0
|
|
5042
|
+
});
|
|
5043
|
+
}
|
|
4878
5044
|
|
|
4879
|
-
|
|
4880
|
-
// Mirrors jQuery's
|
|
4881
|
-
if (!val || toStringTag(val) !== 'Object') {
|
|
4882
|
-
return false;
|
|
5045
|
+
return _;
|
|
4883
5046
|
}
|
|
4884
5047
|
|
|
4885
|
-
|
|
5048
|
+
function replace(e, t, r, n, a, o, i) {
|
|
5049
|
+
for (var s = a ? l.plainObjectReplacers : l.nonplainObjectReplacers, c = s.length; c--;) {
|
|
5050
|
+
var y = s[c];
|
|
4886
5051
|
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
return true;
|
|
4890
|
-
}
|
|
5052
|
+
if (y.test(t, r)) {
|
|
5053
|
+
var p = y.type;
|
|
4891
5054
|
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
* @param {any} val
|
|
4897
|
-
* @returns {boolean}
|
|
4898
|
-
*/
|
|
5055
|
+
if (l.revivers[p]) {
|
|
5056
|
+
var d = f[e];
|
|
5057
|
+
f[e] = d ? [p].concat(d) : p;
|
|
5058
|
+
}
|
|
4899
5059
|
|
|
5060
|
+
return Object.assign(r, {
|
|
5061
|
+
type: p,
|
|
5062
|
+
replaced: !0
|
|
5063
|
+
}), !u && y.replaceAsync || y.replace ? (i && i({
|
|
5064
|
+
replacing: !0
|
|
5065
|
+
}), _encapsulate(e, y[u || !y.replaceAsync ? "replace" : "replaceAsync"](t, r), v && "readonly", r, n, o, p)) : (i && i({
|
|
5066
|
+
typeDetected: !0
|
|
5067
|
+
}), _encapsulate(e, t, v && "readonly", r, n, o, p));
|
|
5068
|
+
}
|
|
5069
|
+
}
|
|
4900
5070
|
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
5071
|
+
return t;
|
|
5072
|
+
}
|
|
5073
|
+
|
|
5074
|
+
return d.length ? u && n.throwOnBadSyncType ? function () {
|
|
5075
|
+
throw new TypeError("Sync method requested but async result obtained");
|
|
5076
|
+
}() : Promise.resolve(a(h, d)).then(finish) : !u && n.throwOnBadSyncType ? function () {
|
|
5077
|
+
throw new TypeError("Async method requested but sync result obtained");
|
|
5078
|
+
}() : n.stringification && u ? [finish(h)] : u ? finish(h) : Promise.resolve(finish(h));
|
|
5079
|
+
}
|
|
5080
|
+
}, {
|
|
5081
|
+
key: "encapsulateSync",
|
|
5082
|
+
value: function encapsulateSync(e, t, r) {
|
|
5083
|
+
return this.encapsulate(e, t, _objectSpread2(_objectSpread2({
|
|
5084
|
+
throwOnBadSyncType: !0
|
|
5085
|
+
}, r), {}, {
|
|
5086
|
+
sync: !0
|
|
5087
|
+
}));
|
|
5088
|
+
}
|
|
5089
|
+
}, {
|
|
5090
|
+
key: "encapsulateAsync",
|
|
5091
|
+
value: function encapsulateAsync(e, t, r) {
|
|
5092
|
+
return this.encapsulate(e, t, _objectSpread2(_objectSpread2({
|
|
5093
|
+
throwOnBadSyncType: !0
|
|
5094
|
+
}, r), {}, {
|
|
5095
|
+
sync: !1
|
|
5096
|
+
}));
|
|
5097
|
+
}
|
|
5098
|
+
}, {
|
|
5099
|
+
key: "revive",
|
|
5100
|
+
value: function revive(t, r) {
|
|
5101
|
+
var n = t && t.$types;
|
|
5102
|
+
if (!n) return t;
|
|
5103
|
+
if (!0 === n) return t.$;
|
|
5104
|
+
|
|
5105
|
+
var a = (r = _objectSpread2(_objectSpread2({
|
|
5106
|
+
sync: !0
|
|
5107
|
+
}, this.options), r)).sync,
|
|
5108
|
+
s = [],
|
|
5109
|
+
c = {},
|
|
5110
|
+
u = !0;
|
|
5111
|
+
|
|
5112
|
+
n.$ && isPlainObject(n.$) && (t = t.$, n = n.$, u = !1);
|
|
5113
|
+
var f = this;
|
|
5114
|
+
|
|
5115
|
+
function executeReviver(e, t) {
|
|
5116
|
+
var r = _slicedToArray(f.revivers[e] || [], 1)[0];
|
|
5117
|
+
|
|
5118
|
+
if (!r) throw new Error("Unregistered type: " + e);
|
|
5119
|
+
return a && !("revive" in r) ? t : r[a && r.revive ? "revive" : !a && r.reviveAsync ? "reviveAsync" : "revive"](t, c);
|
|
5120
|
+
}
|
|
5121
|
+
|
|
5122
|
+
var y = [];
|
|
5123
|
+
|
|
5124
|
+
function checkUndefined(e) {
|
|
5125
|
+
return hasConstructorOf(e, l) ? void 0 : e;
|
|
5126
|
+
}
|
|
5127
|
+
|
|
5128
|
+
var p,
|
|
5129
|
+
d = function revivePlainObjects() {
|
|
5130
|
+
var r = [];
|
|
5131
|
+
if (Object.entries(n).forEach(function (e) {
|
|
5132
|
+
var t = _slicedToArray(e, 2),
|
|
5133
|
+
a = t[0],
|
|
5134
|
+
o = t[1];
|
|
5135
|
+
|
|
5136
|
+
"#" !== o && [].concat(o).forEach(function (e) {
|
|
5137
|
+
_slicedToArray(f.revivers[e] || [null, {}], 2)[1].plain && (r.push({
|
|
5138
|
+
keypath: a,
|
|
5139
|
+
type: e
|
|
5140
|
+
}), delete n[a]);
|
|
5141
|
+
});
|
|
5142
|
+
}), r.length) return r.sort(nestedPathsFirst).reduce(function reducer(r, n) {
|
|
5143
|
+
var a = n.keypath,
|
|
5144
|
+
o = n.type;
|
|
5145
|
+
if (isThenable(r)) return r.then(function (e) {
|
|
5146
|
+
return reducer(e, {
|
|
5147
|
+
keypath: a,
|
|
5148
|
+
type: o
|
|
5149
|
+
});
|
|
5150
|
+
});
|
|
5151
|
+
var i = getByKeyPath(t, a);
|
|
5152
|
+
if (hasConstructorOf(i = executeReviver(o, i), e)) return i.then(function (e) {
|
|
5153
|
+
var r = setAtKeyPath(t, a, e);
|
|
5154
|
+
r === e && (t = r);
|
|
5155
|
+
});
|
|
5156
|
+
var s = setAtKeyPath(t, a, i);
|
|
5157
|
+
s === i && (t = s);
|
|
5158
|
+
}, void 0);
|
|
5159
|
+
}();
|
|
5160
|
+
|
|
5161
|
+
return hasConstructorOf(d, e) ? p = d.then(function () {
|
|
5162
|
+
return t;
|
|
5163
|
+
}) : (p = function _revive(t, r, a, c, f) {
|
|
5164
|
+
if (!u || "$types" !== t) {
|
|
5165
|
+
var p = n[t],
|
|
5166
|
+
d = i(r);
|
|
5167
|
+
|
|
5168
|
+
if (d || isPlainObject(r)) {
|
|
5169
|
+
var v = d ? new Array(r.length) : {};
|
|
5170
|
+
|
|
5171
|
+
for (o(r).forEach(function (n) {
|
|
5172
|
+
var o = _revive(t + (t ? "." : "") + escapeKeyPathComponent(n), r[n], a || v, v, n),
|
|
5173
|
+
i = function set(e) {
|
|
5174
|
+
return hasConstructorOf(e, l) ? v[n] = void 0 : void 0 !== e && (v[n] = e), e;
|
|
5175
|
+
};
|
|
4905
5176
|
|
|
4906
|
-
|
|
5177
|
+
hasConstructorOf(o, e) ? y.push(o.then(function (e) {
|
|
5178
|
+
return i(e);
|
|
5179
|
+
})) : i(o);
|
|
5180
|
+
}), r = v; s.length;) {
|
|
5181
|
+
var b = _slicedToArray(s[0], 4),
|
|
5182
|
+
h = b[0],
|
|
5183
|
+
g = b[1],
|
|
5184
|
+
m = b[2],
|
|
5185
|
+
O = b[3],
|
|
5186
|
+
S = getByKeyPath(h, g);
|
|
5187
|
+
|
|
5188
|
+
if (void 0 === S) break;
|
|
5189
|
+
m[O] = S, s.splice(0, 1);
|
|
5190
|
+
}
|
|
5191
|
+
}
|
|
4907
5192
|
|
|
4908
|
-
|
|
4909
|
-
// `Object.create(null)`
|
|
4910
|
-
return true;
|
|
4911
|
-
}
|
|
5193
|
+
if (!p) return r;
|
|
4912
5194
|
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
/**
|
|
4916
|
-
*
|
|
4917
|
-
* @param {any} v
|
|
4918
|
-
* @returns {boolean}
|
|
4919
|
-
*/
|
|
5195
|
+
if ("#" === p) {
|
|
5196
|
+
var _ = getByKeyPath(a, r.slice(1));
|
|
4920
5197
|
|
|
5198
|
+
return void 0 === _ && s.push([a, r.slice(1), c, f]), _;
|
|
5199
|
+
}
|
|
4921
5200
|
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
5201
|
+
return [].concat(p).reduce(function reducer(t, r) {
|
|
5202
|
+
return hasConstructorOf(t, e) ? t.then(function (e) {
|
|
5203
|
+
return reducer(e, r);
|
|
5204
|
+
}) : executeReviver(r, t);
|
|
5205
|
+
}, r);
|
|
5206
|
+
}
|
|
5207
|
+
}("", t, null), y.length && (p = e.resolve(p).then(function (t) {
|
|
5208
|
+
return e.all([t].concat(y));
|
|
5209
|
+
}).then(function (e) {
|
|
5210
|
+
return _slicedToArray(e, 1)[0];
|
|
5211
|
+
}))), isThenable(p) ? a && r.throwOnBadSyncType ? function () {
|
|
5212
|
+
throw new TypeError("Sync method requested but async result obtained");
|
|
5213
|
+
}() : hasConstructorOf(p, e) ? p.p.then(checkUndefined) : p : !a && r.throwOnBadSyncType ? function () {
|
|
5214
|
+
throw new TypeError("Async method requested but sync result obtained");
|
|
5215
|
+
}() : a ? checkUndefined(p) : Promise.resolve(checkUndefined(p));
|
|
5216
|
+
}
|
|
5217
|
+
}, {
|
|
5218
|
+
key: "reviveSync",
|
|
5219
|
+
value: function reviveSync(e, t) {
|
|
5220
|
+
return this.revive(e, _objectSpread2(_objectSpread2({
|
|
5221
|
+
throwOnBadSyncType: !0
|
|
5222
|
+
}, t), {}, {
|
|
5223
|
+
sync: !0
|
|
5224
|
+
}));
|
|
5225
|
+
}
|
|
5226
|
+
}, {
|
|
5227
|
+
key: "reviveAsync",
|
|
5228
|
+
value: function reviveAsync(e, t) {
|
|
5229
|
+
return this.revive(e, _objectSpread2(_objectSpread2({
|
|
5230
|
+
throwOnBadSyncType: !0
|
|
5231
|
+
}, t), {}, {
|
|
5232
|
+
sync: !1
|
|
5233
|
+
}));
|
|
5234
|
+
}
|
|
5235
|
+
}, {
|
|
5236
|
+
key: "register",
|
|
5237
|
+
value: function register(e, t) {
|
|
5238
|
+
var r = this;
|
|
5239
|
+
t = t || {};
|
|
5240
|
+
|
|
5241
|
+
var n = function R(e) {
|
|
5242
|
+
i(e) ? e.forEach(function (e) {
|
|
5243
|
+
return R(e);
|
|
5244
|
+
}) : e && o(e).forEach(function (n) {
|
|
5245
|
+
if ("#" === n) throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");
|
|
5246
|
+
if (f.includes(n)) throw new TypeError("Plain JSON object types are reserved as type names");
|
|
5247
|
+
var a = e[n],
|
|
5248
|
+
o = a && a.testPlainObjects ? r.plainObjectReplacers : r.nonplainObjectReplacers,
|
|
5249
|
+
s = o.filter(function (e) {
|
|
5250
|
+
return e.type === n;
|
|
5251
|
+
});
|
|
5252
|
+
|
|
5253
|
+
if (s.length && (o.splice(o.indexOf(s[0]), 1), delete r.revivers[n], delete r.types[n]), "function" == typeof a) {
|
|
5254
|
+
var c = a;
|
|
5255
|
+
a = {
|
|
5256
|
+
test: function test(e) {
|
|
5257
|
+
return e && e.constructor === c;
|
|
5258
|
+
},
|
|
5259
|
+
replace: function replace(e) {
|
|
5260
|
+
return _objectSpread2({}, e);
|
|
5261
|
+
},
|
|
5262
|
+
revive: function revive(e) {
|
|
5263
|
+
return Object.assign(Object.create(c.prototype), e);
|
|
5264
|
+
}
|
|
5265
|
+
};
|
|
5266
|
+
} else if (i(a)) {
|
|
5267
|
+
var u = _slicedToArray(a, 3);
|
|
4930
5268
|
|
|
5269
|
+
a = {
|
|
5270
|
+
test: u[0],
|
|
5271
|
+
replace: u[1],
|
|
5272
|
+
revive: u[2]
|
|
5273
|
+
};
|
|
5274
|
+
}
|
|
4931
5275
|
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
5276
|
+
if (a && a.test) {
|
|
5277
|
+
var l = {
|
|
5278
|
+
type: n,
|
|
5279
|
+
test: a.test.bind(a)
|
|
5280
|
+
};
|
|
5281
|
+
a.replace && (l.replace = a.replace.bind(a)), a.replaceAsync && (l.replaceAsync = a.replaceAsync.bind(a));
|
|
5282
|
+
var y = "number" == typeof t.fallback ? t.fallback : t.fallback ? 0 : Number.POSITIVE_INFINITY;
|
|
5283
|
+
|
|
5284
|
+
if (a.testPlainObjects ? r.plainObjectReplacers.splice(y, 0, l) : r.nonplainObjectReplacers.splice(y, 0, l), a.revive || a.reviveAsync) {
|
|
5285
|
+
var p = {};
|
|
5286
|
+
a.revive && (p.revive = a.revive.bind(a)), a.reviveAsync && (p.reviveAsync = a.reviveAsync.bind(a)), r.revivers[n] = [p, {
|
|
5287
|
+
plain: a.testPlainObjects
|
|
5288
|
+
}];
|
|
5289
|
+
}
|
|
4940
5290
|
|
|
5291
|
+
r.types[n] = a;
|
|
5292
|
+
}
|
|
5293
|
+
});
|
|
5294
|
+
};
|
|
4941
5295
|
|
|
4942
|
-
|
|
4943
|
-
|
|
5296
|
+
return [].concat(e).forEach(function (e) {
|
|
5297
|
+
return n(e);
|
|
5298
|
+
}), this;
|
|
4944
5299
|
}
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
5300
|
+
}]), Typeson;
|
|
5301
|
+
}(),
|
|
5302
|
+
l = _createClass(function Undefined() {
|
|
5303
|
+
_classCallCheck(this, Undefined);
|
|
5304
|
+
});
|
|
4950
5305
|
|
|
5306
|
+
l.__typeson__type__ = "TypesonUndefined";
|
|
4951
5307
|
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
}
|
|
5308
|
+
for (var f = ["null", "boolean", "number", "string", "array", "object"], y = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", p = new Uint8Array(256), d = 0; d < y.length; d++) {
|
|
5309
|
+
p[y.codePointAt(d)] = d;
|
|
5310
|
+
}
|
|
4956
5311
|
|
|
4957
|
-
|
|
5312
|
+
var v = function encode(e, t, r) {
|
|
5313
|
+
null == r && (r = e.byteLength);
|
|
4958
5314
|
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
}
|
|
5315
|
+
for (var n = new Uint8Array(e, t || 0, r), a = n.length, o = "", i = 0; i < a; i += 3) {
|
|
5316
|
+
o += y[n[i] >> 2], o += y[(3 & n[i]) << 4 | n[i + 1] >> 4], o += y[(15 & n[i + 1]) << 2 | n[i + 2] >> 6], o += y[63 & n[i + 2]];
|
|
5317
|
+
}
|
|
4963
5318
|
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
5319
|
+
return a % 3 == 2 ? o = o.slice(0, -1) + "=" : a % 3 == 1 && (o = o.slice(0, -2) + "=="), o;
|
|
5320
|
+
},
|
|
5321
|
+
b = function decode(e) {
|
|
5322
|
+
var t,
|
|
5323
|
+
r,
|
|
5324
|
+
n,
|
|
5325
|
+
a,
|
|
5326
|
+
o = e.length,
|
|
5327
|
+
i = .75 * e.length,
|
|
5328
|
+
s = 0;
|
|
5329
|
+
"=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
|
|
4973
5330
|
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
if (keyPath === '') {
|
|
4977
|
-
return value;
|
|
4978
|
-
}
|
|
4979
|
-
|
|
4980
|
-
var period = keyPath.indexOf('.');
|
|
4981
|
-
|
|
4982
|
-
if (period > -1) {
|
|
4983
|
-
var innerObj = obj[unescapeKeyPathComponent(keyPath.slice(0, period))];
|
|
4984
|
-
return setAtKeyPath(innerObj, keyPath.slice(period + 1), value);
|
|
4985
|
-
}
|
|
4986
|
-
|
|
4987
|
-
obj[unescapeKeyPathComponent(keyPath)] = value;
|
|
4988
|
-
return obj;
|
|
4989
|
-
}
|
|
4990
|
-
/**
|
|
4991
|
-
*
|
|
4992
|
-
* @param {external:JSON} value
|
|
4993
|
-
* @returns {"null"|"array"|"undefined"|"boolean"|"number"|"string"|
|
|
4994
|
-
* "object"|"symbol"}
|
|
4995
|
-
*/
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
function getJSONType(value) {
|
|
4999
|
-
return value === null ? 'null' : Array.isArray(value) ? 'array' : _typeof(value);
|
|
5000
|
-
}
|
|
5001
|
-
|
|
5002
|
-
function _await(value, then, direct) {
|
|
5003
|
-
if (direct) {
|
|
5004
|
-
return then ? then(value) : value;
|
|
5005
|
-
}
|
|
5006
|
-
|
|
5007
|
-
if (!value || !value.then) {
|
|
5008
|
-
value = Promise.resolve(value);
|
|
5009
|
-
}
|
|
5010
|
-
|
|
5011
|
-
return then ? value.then(then) : value;
|
|
5012
|
-
}
|
|
5013
|
-
|
|
5014
|
-
var keys = Object.keys,
|
|
5015
|
-
isArray = Array.isArray,
|
|
5016
|
-
hasOwn = {}.hasOwnProperty,
|
|
5017
|
-
internalStateObjPropsToIgnore = ['type', 'replaced', 'iterateIn', 'iterateUnsetNumeric'];
|
|
5018
|
-
/**
|
|
5019
|
-
* Handle plain object revivers first so reference setting can use
|
|
5020
|
-
* revived type (e.g., array instead of object); assumes revived
|
|
5021
|
-
* has same structure or will otherwise break subsequent references.
|
|
5022
|
-
* @param {PlainObjectType} a
|
|
5023
|
-
* @param {PlainObjectType} b
|
|
5024
|
-
* @returns {1|-1|boolean}
|
|
5025
|
-
*/
|
|
5026
|
-
|
|
5027
|
-
function _async(f) {
|
|
5028
|
-
return function () {
|
|
5029
|
-
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
5030
|
-
args[i] = arguments[i];
|
|
5031
|
-
}
|
|
5032
|
-
|
|
5033
|
-
try {
|
|
5034
|
-
return Promise.resolve(f.apply(this, args));
|
|
5035
|
-
} catch (e) {
|
|
5036
|
-
return Promise.reject(e);
|
|
5037
|
-
}
|
|
5038
|
-
};
|
|
5039
|
-
}
|
|
5040
|
-
/**
|
|
5041
|
-
* @callback Tester
|
|
5042
|
-
* @param {any} value
|
|
5043
|
-
* @param {StateObject} stateobj
|
|
5044
|
-
* @returns {boolean}
|
|
5045
|
-
*/
|
|
5046
|
-
|
|
5047
|
-
/**
|
|
5048
|
-
* @callback Replacer
|
|
5049
|
-
* @param {any} value
|
|
5050
|
-
* @param {StateObject} stateObj
|
|
5051
|
-
* @returns {any} Should be JSON-stringifiable
|
|
5052
|
-
*/
|
|
5053
|
-
|
|
5054
|
-
/**
|
|
5055
|
-
* @callback Reviver
|
|
5056
|
-
* @param {JSON} value
|
|
5057
|
-
* @param {StateObject} stateObj
|
|
5058
|
-
* @returns {any}
|
|
5059
|
-
*/
|
|
5060
|
-
|
|
5061
|
-
/**
|
|
5062
|
-
* @typedef {PlainObject} TypesonOptions
|
|
5063
|
-
* @property {boolean} stringification Auto-set by `stringify`
|
|
5064
|
-
*/
|
|
5065
|
-
|
|
5066
|
-
/**
|
|
5067
|
-
* An instance of this class can be used to call `stringify()` and `parse()`.
|
|
5068
|
-
* Typeson resolves cyclic references by default. Can also be extended to
|
|
5069
|
-
* support custom types using the register() method.
|
|
5070
|
-
*
|
|
5071
|
-
* @class
|
|
5072
|
-
* @param {{cyclic: boolean}} [options] - if cyclic (default true),
|
|
5073
|
-
* cyclic references will be handled gracefully.
|
|
5074
|
-
*/
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
function _invoke(body, then) {
|
|
5078
|
-
var result = body();
|
|
5079
|
-
|
|
5080
|
-
if (result && result.then) {
|
|
5081
|
-
return result.then(then);
|
|
5082
|
-
}
|
|
5083
|
-
|
|
5084
|
-
return then(result);
|
|
5085
|
-
}
|
|
5086
|
-
|
|
5087
|
-
function nestedPathsFirst(a, b) {
|
|
5088
|
-
if (a.keypath === '') {
|
|
5089
|
-
return -1;
|
|
5090
|
-
}
|
|
5091
|
-
|
|
5092
|
-
var as = a.keypath.match(/\./g) || 0;
|
|
5093
|
-
var bs = b.keypath.match(/\./g) || 0;
|
|
5094
|
-
|
|
5095
|
-
if (as) {
|
|
5096
|
-
as = as.length;
|
|
5097
|
-
}
|
|
5098
|
-
|
|
5099
|
-
if (bs) {
|
|
5100
|
-
bs = bs.length;
|
|
5101
|
-
}
|
|
5102
|
-
|
|
5103
|
-
return as > bs ? -1 : as < bs ? 1 : a.keypath < b.keypath ? -1 : a.keypath > b.keypath;
|
|
5104
|
-
}
|
|
5105
|
-
|
|
5106
|
-
var Typeson = /*#__PURE__*/function () {
|
|
5107
|
-
/**
|
|
5108
|
-
* @param {TypesonOptions} options
|
|
5109
|
-
*/
|
|
5110
|
-
function Typeson(options) {
|
|
5111
|
-
_classCallCheck(this, Typeson);
|
|
5112
|
-
|
|
5113
|
-
this.options = options; // Replacers signature: replace (value). Returns falsy if not
|
|
5114
|
-
// replacing. Otherwise ['Date', value.getTime()]
|
|
5115
|
-
|
|
5116
|
-
this.plainObjectReplacers = [];
|
|
5117
|
-
this.nonplainObjectReplacers = []; // Revivers: [{type => reviver}, {plain: boolean}].
|
|
5118
|
-
// Sample: [{'Date': value => new Date(value)}, {plain: false}]
|
|
5119
|
-
|
|
5120
|
-
this.revivers = {};
|
|
5121
|
-
/** Types registered via `register()`. */
|
|
5122
|
-
|
|
5123
|
-
this.types = {};
|
|
5124
|
-
}
|
|
5125
|
-
/**
|
|
5126
|
-
* @typedef {null|boolean|number|string|GenericArray|PlainObject} JSON
|
|
5127
|
-
*/
|
|
5128
|
-
|
|
5129
|
-
/**
|
|
5130
|
-
* @callback JSONReplacer
|
|
5131
|
-
* @param {""|string} key
|
|
5132
|
-
* @param {JSON} value
|
|
5133
|
-
* @returns {number|string|boolean|null|PlainObject|undefined}
|
|
5134
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The%20replacer%20parameter
|
|
5135
|
-
*/
|
|
5136
|
-
|
|
5137
|
-
/**
|
|
5138
|
-
* Serialize given object to Typeson.
|
|
5139
|
-
* Initial arguments work identical to those of `JSON.stringify`.
|
|
5140
|
-
* The `replacer` argument has nothing to do with our replacers.
|
|
5141
|
-
* @param {any} obj
|
|
5142
|
-
* @param {JSONReplacer|string[]} replacer
|
|
5143
|
-
* @param {number|string} space
|
|
5144
|
-
* @param {TypesonOptions} opts
|
|
5145
|
-
* @returns {string|Promise<string>} Promise resolves to a string
|
|
5146
|
-
*/
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
_createClass(Typeson, [{
|
|
5150
|
-
key: "stringify",
|
|
5151
|
-
value: function stringify(obj, replacer, space, opts) {
|
|
5152
|
-
opts = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), opts), {}, {
|
|
5153
|
-
stringification: true
|
|
5154
|
-
});
|
|
5155
|
-
var encapsulated = this.encapsulate(obj, null, opts);
|
|
5156
|
-
|
|
5157
|
-
if (isArray(encapsulated)) {
|
|
5158
|
-
return JSON.stringify(encapsulated[0], replacer, space);
|
|
5159
|
-
}
|
|
5160
|
-
|
|
5161
|
-
return encapsulated.then(function (res) {
|
|
5162
|
-
return JSON.stringify(res, replacer, space);
|
|
5163
|
-
});
|
|
5164
|
-
}
|
|
5165
|
-
/**
|
|
5166
|
-
* Also sync but throws on non-sync result.
|
|
5167
|
-
* @param {any} obj
|
|
5168
|
-
* @param {JSONReplacer|string[]} replacer
|
|
5169
|
-
* @param {number|string} space
|
|
5170
|
-
* @param {TypesonOptions} opts
|
|
5171
|
-
* @returns {string}
|
|
5172
|
-
*/
|
|
5173
|
-
|
|
5174
|
-
}, {
|
|
5175
|
-
key: "stringifySync",
|
|
5176
|
-
value: function stringifySync(obj, replacer, space, opts) {
|
|
5177
|
-
return this.stringify(obj, replacer, space, _objectSpread2(_objectSpread2({
|
|
5178
|
-
throwOnBadSyncType: true
|
|
5179
|
-
}, opts), {}, {
|
|
5180
|
-
sync: true
|
|
5181
|
-
}));
|
|
5182
|
-
}
|
|
5183
|
-
/**
|
|
5184
|
-
*
|
|
5185
|
-
* @param {any} obj
|
|
5186
|
-
* @param {JSONReplacer|string[]} replacer
|
|
5187
|
-
* @param {number|string} space
|
|
5188
|
-
* @param {TypesonOptions} opts
|
|
5189
|
-
* @returns {Promise<string>}
|
|
5190
|
-
*/
|
|
5191
|
-
|
|
5192
|
-
}, {
|
|
5193
|
-
key: "stringifyAsync",
|
|
5194
|
-
value: function stringifyAsync(obj, replacer, space, opts) {
|
|
5195
|
-
return this.stringify(obj, replacer, space, _objectSpread2(_objectSpread2({
|
|
5196
|
-
throwOnBadSyncType: true
|
|
5197
|
-
}, opts), {}, {
|
|
5198
|
-
sync: false
|
|
5199
|
-
}));
|
|
5200
|
-
}
|
|
5201
|
-
/**
|
|
5202
|
-
* @callback JSONReviver
|
|
5203
|
-
* @param {string} key
|
|
5204
|
-
* @param {JSON} value
|
|
5205
|
-
* @returns {JSON}
|
|
5206
|
-
*/
|
|
5207
|
-
|
|
5208
|
-
/**
|
|
5209
|
-
* Parse Typeson back into an obejct.
|
|
5210
|
-
* Initial arguments works identical to those of `JSON.parse()`.
|
|
5211
|
-
* @param {string} text
|
|
5212
|
-
* @param {JSONReviver} reviver This JSON reviver has nothing to do with
|
|
5213
|
-
* our revivers.
|
|
5214
|
-
* @param {TypesonOptions} opts
|
|
5215
|
-
* @returns {external:JSON}
|
|
5216
|
-
*/
|
|
5217
|
-
|
|
5218
|
-
}, {
|
|
5219
|
-
key: "parse",
|
|
5220
|
-
value: function parse(text, reviver, opts) {
|
|
5221
|
-
opts = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), opts), {}, {
|
|
5222
|
-
parse: true
|
|
5223
|
-
});
|
|
5224
|
-
return this.revive(JSON.parse(text, reviver), opts);
|
|
5225
|
-
}
|
|
5226
|
-
/**
|
|
5227
|
-
* Also sync but throws on non-sync result.
|
|
5228
|
-
* @param {string} text
|
|
5229
|
-
* @param {JSONReviver} reviver This JSON reviver has nothing to do with
|
|
5230
|
-
* our revivers.
|
|
5231
|
-
* @param {TypesonOptions} opts
|
|
5232
|
-
* @returns {external:JSON}
|
|
5233
|
-
*/
|
|
5234
|
-
|
|
5235
|
-
}, {
|
|
5236
|
-
key: "parseSync",
|
|
5237
|
-
value: function parseSync(text, reviver, opts) {
|
|
5238
|
-
return this.parse(text, reviver, _objectSpread2(_objectSpread2({
|
|
5239
|
-
throwOnBadSyncType: true
|
|
5240
|
-
}, opts), {}, {
|
|
5241
|
-
sync: true
|
|
5242
|
-
}));
|
|
5243
|
-
}
|
|
5244
|
-
/**
|
|
5245
|
-
* @param {string} text
|
|
5246
|
-
* @param {JSONReviver} reviver This JSON reviver has nothing to do with
|
|
5247
|
-
* our revivers.
|
|
5248
|
-
* @param {TypesonOptions} opts
|
|
5249
|
-
* @returns {Promise<external:JSON>} Resolves to `external:JSON`
|
|
5250
|
-
*/
|
|
5251
|
-
|
|
5252
|
-
}, {
|
|
5253
|
-
key: "parseAsync",
|
|
5254
|
-
value: function parseAsync(text, reviver, opts) {
|
|
5255
|
-
return this.parse(text, reviver, _objectSpread2(_objectSpread2({
|
|
5256
|
-
throwOnBadSyncType: true
|
|
5257
|
-
}, opts), {}, {
|
|
5258
|
-
sync: false
|
|
5259
|
-
}));
|
|
5260
|
-
}
|
|
5261
|
-
/**
|
|
5262
|
-
* @typedef {} StateObject
|
|
5263
|
-
*/
|
|
5264
|
-
|
|
5265
|
-
/**
|
|
5266
|
-
*
|
|
5267
|
-
* @param {any} obj
|
|
5268
|
-
* @param {StateObject} stateObj
|
|
5269
|
-
* @param {TypesonOptions} [opts={}]
|
|
5270
|
-
* @returns {string[]|false}
|
|
5271
|
-
*/
|
|
5272
|
-
|
|
5273
|
-
}, {
|
|
5274
|
-
key: "specialTypeNames",
|
|
5275
|
-
value: function specialTypeNames(obj, stateObj) {
|
|
5276
|
-
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
5277
|
-
opts.returnTypeNames = true;
|
|
5278
|
-
return this.encapsulate(obj, stateObj, opts);
|
|
5279
|
-
}
|
|
5280
|
-
/**
|
|
5281
|
-
*
|
|
5282
|
-
* @param {any} obj
|
|
5283
|
-
* @param {PlainObject} stateObj
|
|
5284
|
-
* @param {PlainObject} [opts={}]
|
|
5285
|
-
* @returns {Promise<any>|GenericArray|PlainObject|string|false}
|
|
5286
|
-
*/
|
|
5287
|
-
|
|
5288
|
-
}, {
|
|
5289
|
-
key: "rootTypeName",
|
|
5290
|
-
value: function rootTypeName(obj, stateObj) {
|
|
5291
|
-
var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
5292
|
-
opts.iterateNone = true;
|
|
5293
|
-
return this.encapsulate(obj, stateObj, opts);
|
|
5294
|
-
}
|
|
5295
|
-
/**
|
|
5296
|
-
* Encapsulate a complex object into a plain Object by replacing
|
|
5297
|
-
* registered types with plain objects representing the types data.
|
|
5298
|
-
*
|
|
5299
|
-
* This method is used internally by `Typeson.stringify()`.
|
|
5300
|
-
* @param {any} obj - Object to encapsulate.
|
|
5301
|
-
* @param {PlainObject} stateObj
|
|
5302
|
-
* @param {PlainObject} opts
|
|
5303
|
-
* @returns {Promise<any>|GenericArray|PlainObject|string|false}
|
|
5304
|
-
*/
|
|
5305
|
-
|
|
5306
|
-
}, {
|
|
5307
|
-
key: "encapsulate",
|
|
5308
|
-
value: function encapsulate(obj, stateObj, opts) {
|
|
5309
|
-
/**
|
|
5310
|
-
*
|
|
5311
|
-
* @param {any} ret
|
|
5312
|
-
* @param {GenericArray} promisesData
|
|
5313
|
-
* @returns {Promise<any>}
|
|
5314
|
-
*/
|
|
5315
|
-
var checkPromises = _async(function (ret, promisesData) {
|
|
5316
|
-
return _await(Promise.all(promisesData.map(function (pd) {
|
|
5317
|
-
return pd[1].p;
|
|
5318
|
-
})), function (promResults) {
|
|
5319
|
-
return _await(Promise.all(promResults.map(_async(function (promResult) {
|
|
5320
|
-
var _exit = false;
|
|
5321
|
-
var newPromisesData = [];
|
|
5322
|
-
|
|
5323
|
-
var _promisesData$splice = promisesData.splice(0, 1),
|
|
5324
|
-
_promisesData$splice2 = _slicedToArray(_promisesData$splice, 1),
|
|
5325
|
-
prData = _promisesData$splice2[0];
|
|
5326
|
-
|
|
5327
|
-
var _prData = _slicedToArray(prData, 7),
|
|
5328
|
-
keyPath = _prData[0],
|
|
5329
|
-
cyclic = _prData[2],
|
|
5330
|
-
stateObj = _prData[3],
|
|
5331
|
-
parentObj = _prData[4],
|
|
5332
|
-
key = _prData[5],
|
|
5333
|
-
detectedType = _prData[6];
|
|
5334
|
-
|
|
5335
|
-
var encaps = _encapsulate(keyPath, promResult, cyclic, stateObj, newPromisesData, true, detectedType);
|
|
5336
|
-
|
|
5337
|
-
var isTypesonPromise = hasConstructorOf(encaps, TypesonPromise); // Handle case where an embedded custom type itself
|
|
5338
|
-
// returns a `Typeson.Promise`
|
|
5339
|
-
|
|
5340
|
-
return _invoke(function () {
|
|
5341
|
-
if (keyPath && isTypesonPromise) {
|
|
5342
|
-
return _await(encaps.p, function (encaps2) {
|
|
5343
|
-
parentObj[key] = encaps2;
|
|
5344
|
-
_exit = true;
|
|
5345
|
-
return checkPromises(ret, newPromisesData);
|
|
5346
|
-
});
|
|
5347
|
-
}
|
|
5348
|
-
}, function (_result) {
|
|
5349
|
-
if (_exit) return _result;
|
|
5350
|
-
|
|
5351
|
-
if (keyPath) {
|
|
5352
|
-
parentObj[key] = encaps;
|
|
5353
|
-
} else if (isTypesonPromise) {
|
|
5354
|
-
ret = encaps.p;
|
|
5355
|
-
} else {
|
|
5356
|
-
// If this is itself a `Typeson.Promise` (because the
|
|
5357
|
-
// original value supplied was a `Promise` or
|
|
5358
|
-
// because the supplied custom type value resolved
|
|
5359
|
-
// to one), returning it below will be fine since
|
|
5360
|
-
// a `Promise` is expected anyways given current
|
|
5361
|
-
// config (and if not a `Promise`, it will be ready
|
|
5362
|
-
// as the resolve value)
|
|
5363
|
-
ret = encaps;
|
|
5364
|
-
}
|
|
5365
|
-
|
|
5366
|
-
return checkPromises(ret, newPromisesData);
|
|
5367
|
-
});
|
|
5368
|
-
}))), function () {
|
|
5369
|
-
return ret;
|
|
5370
|
-
});
|
|
5371
|
-
});
|
|
5372
|
-
});
|
|
5373
|
-
/**
|
|
5374
|
-
* @typedef {PlainObject} OwnKeysObject
|
|
5375
|
-
* @property {boolean} ownKeys
|
|
5376
|
-
*/
|
|
5377
|
-
|
|
5378
|
-
/**
|
|
5379
|
-
* @callback BuiltinStateObjectPropertiesCallback
|
|
5380
|
-
* @returns {void}
|
|
5381
|
-
*/
|
|
5382
|
-
|
|
5383
|
-
/**
|
|
5384
|
-
*
|
|
5385
|
-
* @param {StateObject} stateObj
|
|
5386
|
-
* @param {OwnKeysObject} ownKeysObj
|
|
5387
|
-
* @param {BuiltinStateObjectPropertiesCallback} cb
|
|
5388
|
-
* @returns {undefined}
|
|
5389
|
-
*/
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
opts = _objectSpread2(_objectSpread2({
|
|
5393
|
-
sync: true
|
|
5394
|
-
}, this.options), opts);
|
|
5395
|
-
var _opts = opts,
|
|
5396
|
-
sync = _opts.sync;
|
|
5397
|
-
var that = this,
|
|
5398
|
-
types = {},
|
|
5399
|
-
refObjs = [],
|
|
5400
|
-
// For checking cyclic references
|
|
5401
|
-
refKeys = [],
|
|
5402
|
-
// For checking cyclic references
|
|
5403
|
-
promisesDataRoot = []; // Clone the object deeply while at the same time replacing any
|
|
5404
|
-
// special types or cyclic reference:
|
|
5405
|
-
|
|
5406
|
-
var cyclic = 'cyclic' in opts ? opts.cyclic : true;
|
|
5407
|
-
var _opts2 = opts,
|
|
5408
|
-
encapsulateObserver = _opts2.encapsulateObserver;
|
|
5409
|
-
|
|
5410
|
-
var ret = _encapsulate('', obj, cyclic, stateObj || {}, promisesDataRoot);
|
|
5411
|
-
/**
|
|
5412
|
-
*
|
|
5413
|
-
* @param {any} ret
|
|
5414
|
-
* @returns {GenericArray|PlainObject|string|false}
|
|
5415
|
-
*/
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
function finish(ret) {
|
|
5419
|
-
// Add `$types` to result only if we ever bumped into a
|
|
5420
|
-
// special type (or special case where object has own `$types`)
|
|
5421
|
-
var typeNames = Object.values(types);
|
|
5422
|
-
|
|
5423
|
-
if (opts.iterateNone) {
|
|
5424
|
-
if (typeNames.length) {
|
|
5425
|
-
return typeNames[0];
|
|
5426
|
-
}
|
|
5427
|
-
|
|
5428
|
-
return Typeson.getJSONType(ret);
|
|
5429
|
-
}
|
|
5430
|
-
|
|
5431
|
-
if (typeNames.length) {
|
|
5432
|
-
if (opts.returnTypeNames) {
|
|
5433
|
-
return _toConsumableArray(new Set(typeNames));
|
|
5434
|
-
} // Special if array (or a primitive) was serialized
|
|
5435
|
-
// because JSON would ignore custom `$types` prop on it
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
if (!ret || !isPlainObject(ret) || // Also need to handle if this is an object with its
|
|
5439
|
-
// own `$types` property (to avoid ambiguity)
|
|
5440
|
-
hasOwn.call(ret, '$types')) {
|
|
5441
|
-
ret = {
|
|
5442
|
-
$: ret,
|
|
5443
|
-
$types: {
|
|
5444
|
-
$: types
|
|
5445
|
-
}
|
|
5446
|
-
};
|
|
5447
|
-
} else {
|
|
5448
|
-
ret.$types = types;
|
|
5449
|
-
} // No special types
|
|
5450
|
-
|
|
5451
|
-
} else if (isObject(ret) && hasOwn.call(ret, '$types')) {
|
|
5452
|
-
ret = {
|
|
5453
|
-
$: ret,
|
|
5454
|
-
$types: true
|
|
5455
|
-
};
|
|
5456
|
-
}
|
|
5457
|
-
|
|
5458
|
-
if (opts.returnTypeNames) {
|
|
5459
|
-
return false;
|
|
5460
|
-
}
|
|
5461
|
-
|
|
5462
|
-
return ret;
|
|
5463
|
-
}
|
|
5464
|
-
|
|
5465
|
-
function _adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, cb) {
|
|
5466
|
-
Object.assign(stateObj, ownKeysObj);
|
|
5467
|
-
var vals = internalStateObjPropsToIgnore.map(function (prop) {
|
|
5468
|
-
var tmp = stateObj[prop];
|
|
5469
|
-
delete stateObj[prop];
|
|
5470
|
-
return tmp;
|
|
5471
|
-
}); // eslint-disable-next-line node/callback-return
|
|
5472
|
-
|
|
5473
|
-
cb();
|
|
5474
|
-
internalStateObjPropsToIgnore.forEach(function (prop, i) {
|
|
5475
|
-
stateObj[prop] = vals[i];
|
|
5476
|
-
});
|
|
5477
|
-
}
|
|
5478
|
-
/**
|
|
5479
|
-
*
|
|
5480
|
-
* @param {string} keypath
|
|
5481
|
-
* @param {any} value
|
|
5482
|
-
* @param {boolean} cyclic
|
|
5483
|
-
* @param {PlainObject} stateObj
|
|
5484
|
-
* @param {boolean} promisesData
|
|
5485
|
-
* @param {boolean} resolvingTypesonPromise
|
|
5486
|
-
* @param {string} detectedType
|
|
5487
|
-
* @returns {any}
|
|
5488
|
-
*/
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
function _encapsulate(keypath, value, cyclic, stateObj, promisesData, resolvingTypesonPromise, detectedType) {
|
|
5492
|
-
var ret;
|
|
5493
|
-
var observerData = {};
|
|
5494
|
-
|
|
5495
|
-
var $typeof = _typeof(value);
|
|
5496
|
-
|
|
5497
|
-
var runObserver = encapsulateObserver ? function (obj) {
|
|
5498
|
-
var type = detectedType || stateObj.type || Typeson.getJSONType(value);
|
|
5499
|
-
encapsulateObserver(Object.assign(obj || observerData, {
|
|
5500
|
-
keypath: keypath,
|
|
5501
|
-
value: value,
|
|
5502
|
-
cyclic: cyclic,
|
|
5503
|
-
stateObj: stateObj,
|
|
5504
|
-
promisesData: promisesData,
|
|
5505
|
-
resolvingTypesonPromise: resolvingTypesonPromise,
|
|
5506
|
-
awaitingTypesonPromise: hasConstructorOf(value, TypesonPromise)
|
|
5507
|
-
}, {
|
|
5508
|
-
type: type
|
|
5509
|
-
}));
|
|
5510
|
-
} : null;
|
|
5511
|
-
|
|
5512
|
-
if (['string', 'boolean', 'number', 'undefined'].includes($typeof)) {
|
|
5513
|
-
if (value === undefined || Number.isNaN(value) || value === Number.NEGATIVE_INFINITY || value === Number.POSITIVE_INFINITY) {
|
|
5514
|
-
ret = stateObj.replaced ? value : replace(keypath, value, stateObj, promisesData, false, resolvingTypesonPromise, runObserver);
|
|
5515
|
-
|
|
5516
|
-
if (ret !== value) {
|
|
5517
|
-
observerData = {
|
|
5518
|
-
replaced: ret
|
|
5519
|
-
};
|
|
5520
|
-
}
|
|
5521
|
-
} else {
|
|
5522
|
-
ret = value;
|
|
5523
|
-
}
|
|
5524
|
-
|
|
5525
|
-
if (runObserver) {
|
|
5526
|
-
runObserver();
|
|
5527
|
-
}
|
|
5528
|
-
|
|
5529
|
-
return ret;
|
|
5530
|
-
}
|
|
5531
|
-
|
|
5532
|
-
if (value === null) {
|
|
5533
|
-
if (runObserver) {
|
|
5534
|
-
runObserver();
|
|
5535
|
-
}
|
|
5536
|
-
|
|
5537
|
-
return value;
|
|
5538
|
-
}
|
|
5539
|
-
|
|
5540
|
-
if (cyclic && !stateObj.iterateIn && !stateObj.iterateUnsetNumeric && value && _typeof(value) === 'object') {
|
|
5541
|
-
// Options set to detect cyclic references and be able
|
|
5542
|
-
// to rewrite them.
|
|
5543
|
-
var refIndex = refObjs.indexOf(value);
|
|
5544
|
-
|
|
5545
|
-
if (refIndex < 0) {
|
|
5546
|
-
if (cyclic === true) {
|
|
5547
|
-
refObjs.push(value);
|
|
5548
|
-
refKeys.push(keypath);
|
|
5549
|
-
}
|
|
5550
|
-
} else {
|
|
5551
|
-
types[keypath] = '#';
|
|
5552
|
-
|
|
5553
|
-
if (runObserver) {
|
|
5554
|
-
runObserver({
|
|
5555
|
-
cyclicKeypath: refKeys[refIndex]
|
|
5556
|
-
});
|
|
5557
|
-
}
|
|
5558
|
-
|
|
5559
|
-
return '#' + refKeys[refIndex];
|
|
5560
|
-
}
|
|
5561
|
-
}
|
|
5562
|
-
|
|
5563
|
-
var isPlainObj = isPlainObject(value);
|
|
5564
|
-
var isArr = isArray(value);
|
|
5565
|
-
var replaced = // Running replace will cause infinite loop as will test
|
|
5566
|
-
// positive again
|
|
5567
|
-
(isPlainObj || isArr) && (!that.plainObjectReplacers.length || stateObj.replaced) || stateObj.iterateIn ? // Optimization: if plain object and no plain-object
|
|
5568
|
-
// replacers, don't try finding a replacer
|
|
5569
|
-
value : replace(keypath, value, stateObj, promisesData, isPlainObj || isArr, null, runObserver);
|
|
5570
|
-
var clone;
|
|
5571
|
-
|
|
5572
|
-
if (replaced !== value) {
|
|
5573
|
-
ret = replaced;
|
|
5574
|
-
observerData = {
|
|
5575
|
-
replaced: replaced
|
|
5576
|
-
};
|
|
5577
|
-
} else {
|
|
5578
|
-
// eslint-disable-next-line no-lonely-if
|
|
5579
|
-
if (keypath === '' && hasConstructorOf(value, TypesonPromise)) {
|
|
5580
|
-
promisesData.push([keypath, value, cyclic, stateObj, undefined, undefined, stateObj.type]);
|
|
5581
|
-
ret = value;
|
|
5582
|
-
} else if (isArr && stateObj.iterateIn !== 'object' || stateObj.iterateIn === 'array') {
|
|
5583
|
-
// eslint-disable-next-line unicorn/no-new-array -- Sparse
|
|
5584
|
-
clone = new Array(value.length);
|
|
5585
|
-
observerData = {
|
|
5586
|
-
clone: clone
|
|
5587
|
-
};
|
|
5588
|
-
} else if (!['function', 'symbol'].includes(_typeof(value)) && !('toJSON' in value) && !hasConstructorOf(value, TypesonPromise) && !hasConstructorOf(value, Promise) && !hasConstructorOf(value, ArrayBuffer) || isPlainObj || stateObj.iterateIn === 'object') {
|
|
5589
|
-
clone = {};
|
|
5590
|
-
|
|
5591
|
-
if (stateObj.addLength) {
|
|
5592
|
-
clone.length = value.length;
|
|
5593
|
-
}
|
|
5594
|
-
|
|
5595
|
-
observerData = {
|
|
5596
|
-
clone: clone
|
|
5597
|
-
};
|
|
5598
|
-
} else {
|
|
5599
|
-
ret = value; // Only clone vanilla objects and arrays
|
|
5600
|
-
}
|
|
5601
|
-
}
|
|
5602
|
-
|
|
5603
|
-
if (runObserver) {
|
|
5604
|
-
runObserver();
|
|
5605
|
-
}
|
|
5606
|
-
|
|
5607
|
-
if (opts.iterateNone) {
|
|
5608
|
-
return clone || ret;
|
|
5609
|
-
}
|
|
5610
|
-
|
|
5611
|
-
if (!clone) {
|
|
5612
|
-
return ret;
|
|
5613
|
-
} // Iterate object or array
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
if (stateObj.iterateIn) {
|
|
5617
|
-
var _loop = function _loop(key) {
|
|
5618
|
-
var ownKeysObj = {
|
|
5619
|
-
ownKeys: hasOwn.call(value, key)
|
|
5620
|
-
};
|
|
5621
|
-
|
|
5622
|
-
_adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, function () {
|
|
5623
|
-
var kp = keypath + (keypath ? '.' : '') + escapeKeyPathComponent(key);
|
|
5624
|
-
|
|
5625
|
-
var val = _encapsulate(kp, value[key], Boolean(cyclic), stateObj, promisesData, resolvingTypesonPromise);
|
|
5626
|
-
|
|
5627
|
-
if (hasConstructorOf(val, TypesonPromise)) {
|
|
5628
|
-
promisesData.push([kp, val, Boolean(cyclic), stateObj, clone, key, stateObj.type]);
|
|
5629
|
-
} else if (val !== undefined) {
|
|
5630
|
-
clone[key] = val;
|
|
5631
|
-
}
|
|
5632
|
-
});
|
|
5633
|
-
}; // eslint-disable-next-line guard-for-in
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
for (var key in value) {
|
|
5637
|
-
_loop(key);
|
|
5638
|
-
}
|
|
5639
|
-
|
|
5640
|
-
if (runObserver) {
|
|
5641
|
-
runObserver({
|
|
5642
|
-
endIterateIn: true,
|
|
5643
|
-
end: true
|
|
5644
|
-
});
|
|
5645
|
-
}
|
|
5646
|
-
} else {
|
|
5647
|
-
// Note: Non-indexes on arrays won't survive stringify so
|
|
5648
|
-
// somewhat wasteful for arrays, but so too is iterating
|
|
5649
|
-
// all numeric indexes on sparse arrays when not wanted
|
|
5650
|
-
// or filtering own keys for positive integers
|
|
5651
|
-
keys(value).forEach(function (key) {
|
|
5652
|
-
var kp = keypath + (keypath ? '.' : '') + escapeKeyPathComponent(key);
|
|
5653
|
-
var ownKeysObj = {
|
|
5654
|
-
ownKeys: true
|
|
5655
|
-
};
|
|
5656
|
-
|
|
5657
|
-
_adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, function () {
|
|
5658
|
-
var val = _encapsulate(kp, value[key], Boolean(cyclic), stateObj, promisesData, resolvingTypesonPromise);
|
|
5659
|
-
|
|
5660
|
-
if (hasConstructorOf(val, TypesonPromise)) {
|
|
5661
|
-
promisesData.push([kp, val, Boolean(cyclic), stateObj, clone, key, stateObj.type]);
|
|
5662
|
-
} else if (val !== undefined) {
|
|
5663
|
-
clone[key] = val;
|
|
5664
|
-
}
|
|
5665
|
-
});
|
|
5666
|
-
});
|
|
5667
|
-
|
|
5668
|
-
if (runObserver) {
|
|
5669
|
-
runObserver({
|
|
5670
|
-
endIterateOwn: true,
|
|
5671
|
-
end: true
|
|
5672
|
-
});
|
|
5673
|
-
}
|
|
5674
|
-
} // Iterate array for non-own numeric properties (we can't
|
|
5675
|
-
// replace the prior loop though as it iterates non-integer
|
|
5676
|
-
// keys)
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
if (stateObj.iterateUnsetNumeric) {
|
|
5680
|
-
var vl = value.length;
|
|
5681
|
-
|
|
5682
|
-
var _loop2 = function _loop2(i) {
|
|
5683
|
-
if (!(i in value)) {
|
|
5684
|
-
// No need to escape numeric
|
|
5685
|
-
var kp = keypath + (keypath ? '.' : '') + i;
|
|
5686
|
-
var ownKeysObj = {
|
|
5687
|
-
ownKeys: false
|
|
5688
|
-
};
|
|
5689
|
-
|
|
5690
|
-
_adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, function () {
|
|
5691
|
-
var val = _encapsulate(kp, undefined, Boolean(cyclic), stateObj, promisesData, resolvingTypesonPromise);
|
|
5692
|
-
|
|
5693
|
-
if (hasConstructorOf(val, TypesonPromise)) {
|
|
5694
|
-
promisesData.push([kp, val, Boolean(cyclic), stateObj, clone, i, stateObj.type]);
|
|
5695
|
-
} else if (val !== undefined) {
|
|
5696
|
-
clone[i] = val;
|
|
5697
|
-
}
|
|
5698
|
-
});
|
|
5699
|
-
}
|
|
5700
|
-
};
|
|
5701
|
-
|
|
5702
|
-
for (var i = 0; i < vl; i++) {
|
|
5703
|
-
_loop2(i);
|
|
5704
|
-
}
|
|
5705
|
-
|
|
5706
|
-
if (runObserver) {
|
|
5707
|
-
runObserver({
|
|
5708
|
-
endIterateUnsetNumeric: true,
|
|
5709
|
-
end: true
|
|
5710
|
-
});
|
|
5711
|
-
}
|
|
5712
|
-
}
|
|
5713
|
-
|
|
5714
|
-
return clone;
|
|
5715
|
-
}
|
|
5716
|
-
/**
|
|
5717
|
-
* @typedef {PlainObject} KeyPathEvent
|
|
5718
|
-
* @property {string} cyclicKeypath
|
|
5719
|
-
*/
|
|
5720
|
-
|
|
5721
|
-
/**
|
|
5722
|
-
* @typedef {PlainObject} EndIterateInEvent
|
|
5723
|
-
* @property {boolean} endIterateIn
|
|
5724
|
-
* @property {boolean} end
|
|
5725
|
-
*/
|
|
5726
|
-
|
|
5727
|
-
/**
|
|
5728
|
-
* @typedef {PlainObject} EndIterateUnsetNumericEvent
|
|
5729
|
-
* @property {boolean} endIterateUnsetNumeric
|
|
5730
|
-
* @property {boolean} end
|
|
5731
|
-
*/
|
|
5732
|
-
|
|
5733
|
-
/**
|
|
5734
|
-
* @typedef {PlainObject} TypeDetectedEvent
|
|
5735
|
-
* @property {boolean} typeDetected
|
|
5736
|
-
*/
|
|
5737
|
-
|
|
5738
|
-
/**
|
|
5739
|
-
* @typedef {PlainObject} ReplacingEvent
|
|
5740
|
-
* @property {boolean} replacing
|
|
5741
|
-
*/
|
|
5742
|
-
|
|
5743
|
-
/**
|
|
5744
|
-
* @callback Observer
|
|
5745
|
-
* @param {KeyPathEvent|EndIterateInEvent|EndIterateUnsetNumericEvent|
|
|
5746
|
-
* TypeDetectedEvent|ReplacingEvent} [event]
|
|
5747
|
-
* @returns {void}
|
|
5748
|
-
*/
|
|
5749
|
-
|
|
5750
|
-
/**
|
|
5751
|
-
*
|
|
5752
|
-
* @param {string} keypath
|
|
5753
|
-
* @param {any} value
|
|
5754
|
-
* @param {PlainObject} stateObj
|
|
5755
|
-
* @param {GenericArray} promisesData
|
|
5756
|
-
* @param {boolean} plainObject
|
|
5757
|
-
* @param {boolean} resolvingTypesonPromise
|
|
5758
|
-
* @param {Observer} [runObserver]
|
|
5759
|
-
* @returns {any}
|
|
5760
|
-
*/
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
function replace(keypath, value, stateObj, promisesData, plainObject, resolvingTypesonPromise, runObserver) {
|
|
5764
|
-
// Encapsulate registered types
|
|
5765
|
-
var replacers = plainObject ? that.plainObjectReplacers : that.nonplainObjectReplacers;
|
|
5766
|
-
var i = replacers.length;
|
|
5767
|
-
|
|
5768
|
-
while (i--) {
|
|
5769
|
-
var replacer = replacers[i];
|
|
5770
|
-
|
|
5771
|
-
if (replacer.test(value, stateObj)) {
|
|
5772
|
-
var type = replacer.type;
|
|
5773
|
-
|
|
5774
|
-
if (that.revivers[type]) {
|
|
5775
|
-
// Record the type only if a corresponding reviver
|
|
5776
|
-
// exists. This is to support specs where only
|
|
5777
|
-
// replacement is done.
|
|
5778
|
-
// For example, ensuring deep cloning of the object,
|
|
5779
|
-
// or replacing a type to its equivalent without
|
|
5780
|
-
// the need to revive it.
|
|
5781
|
-
var existing = types[keypath]; // type can comprise an array of types (see test
|
|
5782
|
-
// "should support intermediate types")
|
|
5783
|
-
|
|
5784
|
-
types[keypath] = existing ? [type].concat(existing) : type;
|
|
5785
|
-
}
|
|
5786
|
-
|
|
5787
|
-
Object.assign(stateObj, {
|
|
5788
|
-
type: type,
|
|
5789
|
-
replaced: true
|
|
5790
|
-
});
|
|
5791
|
-
|
|
5792
|
-
if ((sync || !replacer.replaceAsync) && !replacer.replace) {
|
|
5793
|
-
if (runObserver) {
|
|
5794
|
-
runObserver({
|
|
5795
|
-
typeDetected: true
|
|
5796
|
-
});
|
|
5797
|
-
}
|
|
5798
|
-
|
|
5799
|
-
return _encapsulate(keypath, value, cyclic && 'readonly', stateObj, promisesData, resolvingTypesonPromise, type);
|
|
5800
|
-
}
|
|
5801
|
-
|
|
5802
|
-
if (runObserver) {
|
|
5803
|
-
runObserver({
|
|
5804
|
-
replacing: true
|
|
5805
|
-
});
|
|
5806
|
-
} // Now, also traverse the result in case it contains its
|
|
5807
|
-
// own types to replace
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
var replaceMethod = sync || !replacer.replaceAsync ? 'replace' : 'replaceAsync';
|
|
5811
|
-
return _encapsulate(keypath, replacer[replaceMethod](value, stateObj), cyclic && 'readonly', stateObj, promisesData, resolvingTypesonPromise, type);
|
|
5812
|
-
}
|
|
5813
|
-
}
|
|
5814
|
-
|
|
5815
|
-
return value;
|
|
5816
|
-
}
|
|
5817
|
-
|
|
5818
|
-
return promisesDataRoot.length ? sync && opts.throwOnBadSyncType ? function () {
|
|
5819
|
-
throw new TypeError('Sync method requested but async result obtained');
|
|
5820
|
-
}() : Promise.resolve(checkPromises(ret, promisesDataRoot)).then(finish) : !sync && opts.throwOnBadSyncType ? function () {
|
|
5821
|
-
throw new TypeError('Async method requested but sync result obtained');
|
|
5822
|
-
}() // If this is a synchronous request for stringification, yet
|
|
5823
|
-
// a promise is the result, we don't want to resolve leading
|
|
5824
|
-
// to an async result, so we return an array to avoid
|
|
5825
|
-
// ambiguity
|
|
5826
|
-
: opts.stringification && sync ? [finish(ret)] : sync ? finish(ret) : Promise.resolve(finish(ret));
|
|
5827
|
-
}
|
|
5828
|
-
/**
|
|
5829
|
-
* Also sync but throws on non-sync result.
|
|
5830
|
-
* @param {any} obj
|
|
5831
|
-
* @param {StateObject} stateObj
|
|
5832
|
-
* @param {TypesonOptions} opts
|
|
5833
|
-
* @returns {any}
|
|
5834
|
-
*/
|
|
5835
|
-
|
|
5836
|
-
}, {
|
|
5837
|
-
key: "encapsulateSync",
|
|
5838
|
-
value: function encapsulateSync(obj, stateObj, opts) {
|
|
5839
|
-
return this.encapsulate(obj, stateObj, _objectSpread2(_objectSpread2({
|
|
5840
|
-
throwOnBadSyncType: true
|
|
5841
|
-
}, opts), {}, {
|
|
5842
|
-
sync: true
|
|
5843
|
-
}));
|
|
5844
|
-
}
|
|
5845
|
-
/**
|
|
5846
|
-
* @param {any} obj
|
|
5847
|
-
* @param {StateObject} stateObj
|
|
5848
|
-
* @param {TypesonOptions} opts
|
|
5849
|
-
* @returns {any}
|
|
5850
|
-
*/
|
|
5851
|
-
|
|
5852
|
-
}, {
|
|
5853
|
-
key: "encapsulateAsync",
|
|
5854
|
-
value: function encapsulateAsync(obj, stateObj, opts) {
|
|
5855
|
-
return this.encapsulate(obj, stateObj, _objectSpread2(_objectSpread2({
|
|
5856
|
-
throwOnBadSyncType: true
|
|
5857
|
-
}, opts), {}, {
|
|
5858
|
-
sync: false
|
|
5859
|
-
}));
|
|
5860
|
-
}
|
|
5861
|
-
/**
|
|
5862
|
-
* Revive an encapsulated object.
|
|
5863
|
-
* This method is used internally by `Typeson.parse()`.
|
|
5864
|
-
* @param {PlainObject} obj - Object to revive. If it has `$types` member,
|
|
5865
|
-
* the properties that are listed there will be replaced with its true
|
|
5866
|
-
* type instead of just plain objects.
|
|
5867
|
-
* @param {TypesonOptions} opts
|
|
5868
|
-
* @throws TypeError If mismatch between sync/async type and result
|
|
5869
|
-
* @returns {Promise<any>|any} If async, returns a Promise that resolves
|
|
5870
|
-
* to `any`.
|
|
5871
|
-
*/
|
|
5872
|
-
|
|
5873
|
-
}, {
|
|
5874
|
-
key: "revive",
|
|
5875
|
-
value: function revive(obj, opts) {
|
|
5876
|
-
var types = obj && obj.$types; // No type info added. Revival not needed.
|
|
5877
|
-
|
|
5878
|
-
if (!types) {
|
|
5879
|
-
return obj;
|
|
5880
|
-
} // Object happened to have own `$types` property but with
|
|
5881
|
-
// no actual types, so we unescape and return that object
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
if (types === true) {
|
|
5885
|
-
return obj.$;
|
|
5886
|
-
}
|
|
5887
|
-
|
|
5888
|
-
opts = _objectSpread2(_objectSpread2({
|
|
5889
|
-
sync: true
|
|
5890
|
-
}, this.options), opts);
|
|
5891
|
-
var _opts3 = opts,
|
|
5892
|
-
sync = _opts3.sync;
|
|
5893
|
-
var keyPathResolutions = [];
|
|
5894
|
-
var stateObj = {};
|
|
5895
|
-
var ignore$Types = true; // Special when root object is not a trivial Object, it will
|
|
5896
|
-
// be encapsulated in `$`. It will also be encapsulated in
|
|
5897
|
-
// `$` if it has its own `$` property to avoid ambiguity
|
|
5898
|
-
|
|
5899
|
-
if (types.$ && isPlainObject(types.$)) {
|
|
5900
|
-
obj = obj.$;
|
|
5901
|
-
types = types.$;
|
|
5902
|
-
ignore$Types = false;
|
|
5903
|
-
}
|
|
5904
|
-
|
|
5905
|
-
var that = this;
|
|
5906
|
-
/**
|
|
5907
|
-
* @callback RevivalReducer
|
|
5908
|
-
* @param {any} value
|
|
5909
|
-
* @param {string} type
|
|
5910
|
-
* @returns {any}
|
|
5911
|
-
*/
|
|
5912
|
-
|
|
5913
|
-
/**
|
|
5914
|
-
*
|
|
5915
|
-
* @param {string} type
|
|
5916
|
-
* @param {any} val
|
|
5917
|
-
* @throws {Error}
|
|
5918
|
-
* @returns {any}
|
|
5919
|
-
*/
|
|
5920
|
-
|
|
5921
|
-
function executeReviver(type, val) {
|
|
5922
|
-
var _ref = that.revivers[type] || [],
|
|
5923
|
-
_ref2 = _slicedToArray(_ref, 1),
|
|
5924
|
-
reviver = _ref2[0];
|
|
5925
|
-
|
|
5926
|
-
if (!reviver) {
|
|
5927
|
-
throw new Error('Unregistered type: ' + type);
|
|
5928
|
-
} // Only `sync` expected here, as problematic async would
|
|
5929
|
-
// be missing both `reviver` and `reviverAsync`, and
|
|
5930
|
-
// encapsulation shouldn't have added types, so
|
|
5931
|
-
// should have made an early exit
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
if (sync && !('revive' in reviver)) {
|
|
5935
|
-
// Just return value as is
|
|
5936
|
-
return val;
|
|
5937
|
-
}
|
|
5938
|
-
|
|
5939
|
-
return reviver[sync && reviver.revive ? 'revive' : !sync && reviver.reviveAsync ? 'reviveAsync' : 'revive'](val, stateObj);
|
|
5940
|
-
}
|
|
5941
|
-
/**
|
|
5942
|
-
*
|
|
5943
|
-
* @returns {void|TypesonPromise<void>}
|
|
5944
|
-
*/
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
function revivePlainObjects() {
|
|
5948
|
-
// const references = [];
|
|
5949
|
-
// const reviveTypes = [];
|
|
5950
|
-
var plainObjectTypes = [];
|
|
5951
|
-
Object.entries(types).forEach(function (_ref3) {
|
|
5952
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
5953
|
-
keypath = _ref4[0],
|
|
5954
|
-
type = _ref4[1];
|
|
5955
|
-
|
|
5956
|
-
if (type === '#') {
|
|
5957
|
-
/*
|
|
5958
|
-
references.push({
|
|
5959
|
-
keypath,
|
|
5960
|
-
reference: getByKeyPath(obj, keypath)
|
|
5961
|
-
});
|
|
5962
|
-
*/
|
|
5963
|
-
return;
|
|
5964
|
-
}
|
|
5965
|
-
|
|
5966
|
-
[].concat(type).forEach(function (type) {
|
|
5967
|
-
var _ref5 = that.revivers[type] || [null, {}],
|
|
5968
|
-
_ref6 = _slicedToArray(_ref5, 2),
|
|
5969
|
-
plain = _ref6[1].plain;
|
|
5970
|
-
|
|
5971
|
-
if (!plain) {
|
|
5972
|
-
// reviveTypes.push({keypath, type});
|
|
5973
|
-
return;
|
|
5974
|
-
}
|
|
5975
|
-
|
|
5976
|
-
plainObjectTypes.push({
|
|
5977
|
-
keypath: keypath,
|
|
5978
|
-
type: type
|
|
5979
|
-
});
|
|
5980
|
-
delete types[keypath]; // Avoid repeating
|
|
5981
|
-
});
|
|
5982
|
-
});
|
|
5983
|
-
|
|
5984
|
-
if (!plainObjectTypes.length) {
|
|
5985
|
-
return undefined;
|
|
5986
|
-
} // console.log(plainObjectTypes.sort(nestedPathsFirst));
|
|
5987
|
-
|
|
5988
|
-
/**
|
|
5989
|
-
* @typedef {PlainObject} PlainObjectType
|
|
5990
|
-
* @property {string} keypath
|
|
5991
|
-
* @property {string} type
|
|
5992
|
-
*/
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
return plainObjectTypes.sort(nestedPathsFirst).reduce(function reducer(possibleTypesonPromise, _ref7) {
|
|
5996
|
-
var keypath = _ref7.keypath,
|
|
5997
|
-
type = _ref7.type;
|
|
5998
|
-
|
|
5999
|
-
if (isThenable(possibleTypesonPromise)) {
|
|
6000
|
-
return possibleTypesonPromise.then(function (val) {
|
|
6001
|
-
return reducer(val, {
|
|
6002
|
-
keypath: keypath,
|
|
6003
|
-
type: type
|
|
6004
|
-
});
|
|
6005
|
-
});
|
|
6006
|
-
} // console.log('obj', JSON.stringify(keypath), obj);
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
var val = getByKeyPath(obj, keypath);
|
|
6010
|
-
val = executeReviver(type, val);
|
|
6011
|
-
|
|
6012
|
-
if (hasConstructorOf(val, TypesonPromise)) {
|
|
6013
|
-
return val.then(function (v) {
|
|
6014
|
-
var newVal = setAtKeyPath(obj, keypath, v);
|
|
6015
|
-
|
|
6016
|
-
if (newVal === v) {
|
|
6017
|
-
obj = newVal;
|
|
6018
|
-
}
|
|
6019
|
-
|
|
6020
|
-
return undefined;
|
|
6021
|
-
});
|
|
6022
|
-
}
|
|
6023
|
-
|
|
6024
|
-
var newVal = setAtKeyPath(obj, keypath, val);
|
|
6025
|
-
|
|
6026
|
-
if (newVal === val) {
|
|
6027
|
-
obj = newVal;
|
|
6028
|
-
}
|
|
6029
|
-
|
|
6030
|
-
return undefined;
|
|
6031
|
-
}, undefined // This argument must be explicit
|
|
6032
|
-
); // references.forEach(({keypath, reference}) => {});
|
|
6033
|
-
// reviveTypes.sort(nestedPathsFirst).forEach(() => {});
|
|
6034
|
-
}
|
|
6035
|
-
|
|
6036
|
-
var revivalPromises = [];
|
|
6037
|
-
/**
|
|
6038
|
-
*
|
|
6039
|
-
* @param {string} keypath
|
|
6040
|
-
* @param {any} value
|
|
6041
|
-
* @param {?(GenericArray|PlainObject)} target
|
|
6042
|
-
* @param {GenericArray|PlainObject} [clone]
|
|
6043
|
-
* @param {string} [key]
|
|
6044
|
-
* @returns {any}
|
|
6045
|
-
*/
|
|
6046
|
-
|
|
6047
|
-
function _revive(keypath, value, target, clone, key) {
|
|
6048
|
-
if (ignore$Types && keypath === '$types') {
|
|
6049
|
-
return undefined;
|
|
6050
|
-
}
|
|
6051
|
-
|
|
6052
|
-
var type = types[keypath];
|
|
6053
|
-
var isArr = isArray(value);
|
|
6054
|
-
|
|
6055
|
-
if (isArr || isPlainObject(value)) {
|
|
6056
|
-
// eslint-disable-next-line unicorn/no-new-array -- Sparse
|
|
6057
|
-
var _clone = isArr ? new Array(value.length) : {}; // Iterate object or array
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
keys(value).forEach(function (k) {
|
|
6061
|
-
var val = _revive(keypath + (keypath ? '.' : '') + escapeKeyPathComponent(k), value[k], target || _clone, _clone, k);
|
|
6062
|
-
|
|
6063
|
-
var set = function set(v) {
|
|
6064
|
-
if (hasConstructorOf(v, Undefined)) {
|
|
6065
|
-
_clone[k] = undefined;
|
|
6066
|
-
} else if (v !== undefined) {
|
|
6067
|
-
_clone[k] = v;
|
|
6068
|
-
}
|
|
6069
|
-
|
|
6070
|
-
return v;
|
|
6071
|
-
};
|
|
6072
|
-
|
|
6073
|
-
if (hasConstructorOf(val, TypesonPromise)) {
|
|
6074
|
-
revivalPromises.push(val.then(function (ret) {
|
|
6075
|
-
return set(ret);
|
|
6076
|
-
}));
|
|
6077
|
-
} else {
|
|
6078
|
-
set(val);
|
|
6079
|
-
}
|
|
6080
|
-
});
|
|
6081
|
-
value = _clone; // Try to resolve cyclic reference as soon as available
|
|
6082
|
-
|
|
6083
|
-
while (keyPathResolutions.length) {
|
|
6084
|
-
var _keyPathResolutions$ = _slicedToArray(keyPathResolutions[0], 4),
|
|
6085
|
-
_target = _keyPathResolutions$[0],
|
|
6086
|
-
keyPath = _keyPathResolutions$[1],
|
|
6087
|
-
_clone2 = _keyPathResolutions$[2],
|
|
6088
|
-
k = _keyPathResolutions$[3];
|
|
6089
|
-
|
|
6090
|
-
var val = getByKeyPath(_target, keyPath); // Typeson.Undefined not expected here as not cyclic or
|
|
6091
|
-
// `undefined`
|
|
6092
|
-
|
|
6093
|
-
if (val !== undefined) {
|
|
6094
|
-
_clone2[k] = val;
|
|
6095
|
-
} else {
|
|
6096
|
-
break;
|
|
6097
|
-
}
|
|
6098
|
-
|
|
6099
|
-
keyPathResolutions.splice(0, 1);
|
|
6100
|
-
}
|
|
6101
|
-
}
|
|
6102
|
-
|
|
6103
|
-
if (!type) {
|
|
6104
|
-
return value;
|
|
6105
|
-
}
|
|
6106
|
-
|
|
6107
|
-
if (type === '#') {
|
|
6108
|
-
var _ret = getByKeyPath(target, value.slice(1));
|
|
6109
|
-
|
|
6110
|
-
if (_ret === undefined) {
|
|
6111
|
-
// Cyclic reference not yet available
|
|
6112
|
-
keyPathResolutions.push([target, value.slice(1), clone, key]);
|
|
6113
|
-
}
|
|
6114
|
-
|
|
6115
|
-
return _ret;
|
|
6116
|
-
} // `type` can be an array here
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
return [].concat(type).reduce(function reducer(val, typ) {
|
|
6120
|
-
if (hasConstructorOf(val, TypesonPromise)) {
|
|
6121
|
-
return val.then(function (v) {
|
|
6122
|
-
// TypesonPromise here too
|
|
6123
|
-
return reducer(v, typ);
|
|
6124
|
-
});
|
|
6125
|
-
}
|
|
6126
|
-
|
|
6127
|
-
return executeReviver(typ, val);
|
|
6128
|
-
}, value);
|
|
6129
|
-
}
|
|
6130
|
-
/**
|
|
6131
|
-
*
|
|
6132
|
-
* @param {any} retrn
|
|
6133
|
-
* @returns {undefined|any}
|
|
6134
|
-
*/
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
function checkUndefined(retrn) {
|
|
6138
|
-
return hasConstructorOf(retrn, Undefined) ? undefined : retrn;
|
|
6139
|
-
}
|
|
6140
|
-
|
|
6141
|
-
var possibleTypesonPromise = revivePlainObjects();
|
|
6142
|
-
var ret;
|
|
6143
|
-
|
|
6144
|
-
if (hasConstructorOf(possibleTypesonPromise, TypesonPromise)) {
|
|
6145
|
-
ret = possibleTypesonPromise.then(function () {
|
|
6146
|
-
return obj;
|
|
6147
|
-
});
|
|
6148
|
-
} else {
|
|
6149
|
-
ret = _revive('', obj, null);
|
|
6150
|
-
|
|
6151
|
-
if (revivalPromises.length) {
|
|
6152
|
-
// Ensure children resolved
|
|
6153
|
-
ret = TypesonPromise.resolve(ret).then(function (r) {
|
|
6154
|
-
return TypesonPromise.all([// May be a TypesonPromise or not
|
|
6155
|
-
r].concat(revivalPromises));
|
|
6156
|
-
}).then(function (_ref8) {
|
|
6157
|
-
var _ref9 = _slicedToArray(_ref8, 1),
|
|
6158
|
-
r = _ref9[0];
|
|
6159
|
-
|
|
6160
|
-
return r;
|
|
6161
|
-
});
|
|
6162
|
-
}
|
|
6163
|
-
}
|
|
6164
|
-
|
|
6165
|
-
return isThenable(ret) ? sync && opts.throwOnBadSyncType ? function () {
|
|
6166
|
-
throw new TypeError('Sync method requested but async result obtained');
|
|
6167
|
-
}() : hasConstructorOf(ret, TypesonPromise) ? ret.p.then(checkUndefined) : ret : !sync && opts.throwOnBadSyncType ? function () {
|
|
6168
|
-
throw new TypeError('Async method requested but sync result obtained');
|
|
6169
|
-
}() : sync ? checkUndefined(ret) : Promise.resolve(checkUndefined(ret));
|
|
6170
|
-
}
|
|
6171
|
-
/**
|
|
6172
|
-
* Also sync but throws on non-sync result.
|
|
6173
|
-
* @param {any} obj
|
|
6174
|
-
* @param {TypesonOptions} opts
|
|
6175
|
-
* @returns {any}
|
|
6176
|
-
*/
|
|
6177
|
-
|
|
6178
|
-
}, {
|
|
6179
|
-
key: "reviveSync",
|
|
6180
|
-
value: function reviveSync(obj, opts) {
|
|
6181
|
-
return this.revive(obj, _objectSpread2(_objectSpread2({
|
|
6182
|
-
throwOnBadSyncType: true
|
|
6183
|
-
}, opts), {}, {
|
|
6184
|
-
sync: true
|
|
6185
|
-
}));
|
|
6186
|
-
}
|
|
6187
|
-
/**
|
|
6188
|
-
* @param {any} obj
|
|
6189
|
-
* @param {TypesonOptions} opts
|
|
6190
|
-
* @returns {Promise<any>}
|
|
6191
|
-
*/
|
|
6192
|
-
|
|
6193
|
-
}, {
|
|
6194
|
-
key: "reviveAsync",
|
|
6195
|
-
value: function reviveAsync(obj, opts) {
|
|
6196
|
-
return this.revive(obj, _objectSpread2(_objectSpread2({
|
|
6197
|
-
throwOnBadSyncType: true
|
|
6198
|
-
}, opts), {}, {
|
|
6199
|
-
sync: false
|
|
6200
|
-
}));
|
|
6201
|
-
}
|
|
6202
|
-
/**
|
|
6203
|
-
* @typedef {Tester|Replacer|Reviver} Spec
|
|
6204
|
-
*/
|
|
6205
|
-
|
|
6206
|
-
/**
|
|
6207
|
-
* Register types.
|
|
6208
|
-
* For examples on how to use this method, see
|
|
6209
|
-
* {@link https://github.com/dfahlander/typeson-registry/tree/master/types}.
|
|
6210
|
-
* @param {object<string,Spec[]>[]} typeSpecSets -
|
|
6211
|
-
* Types and their functions [test, encapsulate, revive];
|
|
6212
|
-
* @param {TypesonOptions} opts
|
|
6213
|
-
* @returns {Typeson}
|
|
6214
|
-
*/
|
|
6215
|
-
|
|
6216
|
-
}, {
|
|
6217
|
-
key: "register",
|
|
6218
|
-
value: function register(typeSpecSets, opts) {
|
|
6219
|
-
opts = opts || {};
|
|
6220
|
-
[].concat(typeSpecSets).forEach(function R(typeSpec) {
|
|
6221
|
-
var _this = this; // Allow arrays of arrays of arrays...
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
if (isArray(typeSpec)) {
|
|
6225
|
-
return typeSpec.map(function (typSpec) {
|
|
6226
|
-
return R.call(_this, typSpec);
|
|
6227
|
-
});
|
|
6228
|
-
}
|
|
6229
|
-
|
|
6230
|
-
typeSpec && keys(typeSpec).forEach(function (typeId) {
|
|
6231
|
-
if (typeId === '#') {
|
|
6232
|
-
throw new TypeError('# cannot be used as a type name as it is reserved ' + 'for cyclic objects');
|
|
6233
|
-
} else if (Typeson.JSON_TYPES.includes(typeId)) {
|
|
6234
|
-
throw new TypeError('Plain JSON object types are reserved as type names');
|
|
6235
|
-
}
|
|
6236
|
-
|
|
6237
|
-
var spec = typeSpec[typeId];
|
|
6238
|
-
var replacers = spec && spec.testPlainObjects ? this.plainObjectReplacers : this.nonplainObjectReplacers;
|
|
6239
|
-
var existingReplacer = replacers.filter(function (r) {
|
|
6240
|
-
return r.type === typeId;
|
|
6241
|
-
});
|
|
6242
|
-
|
|
6243
|
-
if (existingReplacer.length) {
|
|
6244
|
-
// Remove existing spec and replace with this one.
|
|
6245
|
-
replacers.splice(replacers.indexOf(existingReplacer[0]), 1);
|
|
6246
|
-
delete this.revivers[typeId];
|
|
6247
|
-
delete this.types[typeId];
|
|
6248
|
-
}
|
|
6249
|
-
|
|
6250
|
-
if (typeof spec === 'function') {
|
|
6251
|
-
// Support registering just a class without replacer/reviver
|
|
6252
|
-
var Class = spec;
|
|
6253
|
-
spec = {
|
|
6254
|
-
test: function test(x) {
|
|
6255
|
-
return x && x.constructor === Class;
|
|
6256
|
-
},
|
|
6257
|
-
replace: function replace(x) {
|
|
6258
|
-
return _objectSpread2({}, x);
|
|
6259
|
-
},
|
|
6260
|
-
revive: function revive(x) {
|
|
6261
|
-
return Object.assign(Object.create(Class.prototype), x);
|
|
6262
|
-
}
|
|
6263
|
-
};
|
|
6264
|
-
} else if (isArray(spec)) {
|
|
6265
|
-
var _spec = spec,
|
|
6266
|
-
_spec2 = _slicedToArray(_spec, 3),
|
|
6267
|
-
test = _spec2[0],
|
|
6268
|
-
replace = _spec2[1],
|
|
6269
|
-
revive = _spec2[2];
|
|
6270
|
-
|
|
6271
|
-
spec = {
|
|
6272
|
-
test: test,
|
|
6273
|
-
replace: replace,
|
|
6274
|
-
revive: revive
|
|
6275
|
-
};
|
|
6276
|
-
}
|
|
6277
|
-
|
|
6278
|
-
if (!spec || !spec.test) {
|
|
6279
|
-
return;
|
|
6280
|
-
}
|
|
6281
|
-
|
|
6282
|
-
var replacerObj = {
|
|
6283
|
-
type: typeId,
|
|
6284
|
-
test: spec.test.bind(spec)
|
|
6285
|
-
};
|
|
6286
|
-
|
|
6287
|
-
if (spec.replace) {
|
|
6288
|
-
replacerObj.replace = spec.replace.bind(spec);
|
|
6289
|
-
}
|
|
6290
|
-
|
|
6291
|
-
if (spec.replaceAsync) {
|
|
6292
|
-
replacerObj.replaceAsync = spec.replaceAsync.bind(spec);
|
|
6293
|
-
}
|
|
6294
|
-
|
|
6295
|
-
var start = typeof opts.fallback === 'number' ? opts.fallback : opts.fallback ? 0 : Number.POSITIVE_INFINITY;
|
|
6296
|
-
|
|
6297
|
-
if (spec.testPlainObjects) {
|
|
6298
|
-
this.plainObjectReplacers.splice(start, 0, replacerObj);
|
|
6299
|
-
} else {
|
|
6300
|
-
this.nonplainObjectReplacers.splice(start, 0, replacerObj);
|
|
6301
|
-
} // Todo: We might consider a testAsync type
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
if (spec.revive || spec.reviveAsync) {
|
|
6305
|
-
var reviverObj = {};
|
|
6306
|
-
|
|
6307
|
-
if (spec.revive) {
|
|
6308
|
-
reviverObj.revive = spec.revive.bind(spec);
|
|
6309
|
-
}
|
|
6310
|
-
|
|
6311
|
-
if (spec.reviveAsync) {
|
|
6312
|
-
reviverObj.reviveAsync = spec.reviveAsync.bind(spec);
|
|
6313
|
-
}
|
|
6314
|
-
|
|
6315
|
-
this.revivers[typeId] = [reviverObj, {
|
|
6316
|
-
plain: spec.testPlainObjects
|
|
6317
|
-
}];
|
|
6318
|
-
} // Record to be retrieved via public types property.
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
this.types[typeId] = spec;
|
|
6322
|
-
}, this);
|
|
6323
|
-
}, this);
|
|
6324
|
-
return this;
|
|
6325
|
-
}
|
|
6326
|
-
}]);
|
|
6327
|
-
|
|
6328
|
-
return Typeson;
|
|
6329
|
-
}();
|
|
6330
|
-
/**
|
|
6331
|
-
* We keep this function minimized so if using two instances of this
|
|
6332
|
-
* library, where one is minimized and one is not, it will still work
|
|
6333
|
-
* with `hasConstructorOf`.
|
|
6334
|
-
* @class
|
|
6335
|
-
*/
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
var Undefined = function Undefined() {
|
|
6339
|
-
_classCallCheck(this, Undefined);
|
|
6340
|
-
}; // eslint-disable-line space-before-blocks
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
Undefined.__typeson__type__ = 'TypesonUndefined'; // The following provide classes meant to avoid clashes with other values
|
|
6344
|
-
// To insist `undefined` should be added
|
|
6345
|
-
|
|
6346
|
-
Typeson.Undefined = Undefined; // To support async encapsulation/stringification
|
|
6347
|
-
|
|
6348
|
-
Typeson.Promise = TypesonPromise; // Some fundamental type-checking utilities
|
|
6349
|
-
|
|
6350
|
-
Typeson.isThenable = isThenable;
|
|
6351
|
-
Typeson.toStringTag = toStringTag;
|
|
6352
|
-
Typeson.hasConstructorOf = hasConstructorOf;
|
|
6353
|
-
Typeson.isObject = isObject;
|
|
6354
|
-
Typeson.isPlainObject = isPlainObject;
|
|
6355
|
-
Typeson.isUserObject = isUserObject;
|
|
6356
|
-
Typeson.escapeKeyPathComponent = escapeKeyPathComponent;
|
|
6357
|
-
Typeson.unescapeKeyPathComponent = unescapeKeyPathComponent;
|
|
6358
|
-
Typeson.getByKeyPath = getByKeyPath;
|
|
6359
|
-
Typeson.getJSONType = getJSONType;
|
|
6360
|
-
Typeson.JSON_TYPES = ['null', 'boolean', 'number', 'string', 'array', 'object'];
|
|
6361
|
-
return Typeson;
|
|
6362
|
-
});
|
|
6363
|
-
})(typeson$1);
|
|
6364
|
-
|
|
6365
|
-
var Typeson = typeson$1.exports;
|
|
6366
|
-
|
|
6367
|
-
/*
|
|
6368
|
-
* base64-arraybuffer
|
|
6369
|
-
* https://github.com/niklasvh/base64-arraybuffer
|
|
6370
|
-
*
|
|
6371
|
-
* Copyright (c) 2017 Brett Zamir, 2012 Niklas von Hertzen
|
|
6372
|
-
* Licensed under the MIT license.
|
|
6373
|
-
*/
|
|
6374
|
-
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; // Use a lookup table to find the index.
|
|
6375
|
-
|
|
6376
|
-
var lookup = new Uint8Array(256);
|
|
6377
|
-
|
|
6378
|
-
for (var i = 0; i < chars.length; i++) {
|
|
6379
|
-
lookup[chars.charCodeAt(i)] = i;
|
|
6380
|
-
}
|
|
6381
|
-
/**
|
|
6382
|
-
* @param {ArrayBuffer} arraybuffer
|
|
6383
|
-
* @param {Integer} byteOffset
|
|
6384
|
-
* @param {Integer} lngth
|
|
6385
|
-
* @returns {string}
|
|
6386
|
-
*/
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
var encode$1 = function encode(arraybuffer, byteOffset, lngth) {
|
|
6390
|
-
if (lngth === null || lngth === undefined) {
|
|
6391
|
-
lngth = arraybuffer.byteLength; // Needed for Safari
|
|
5331
|
+
for (var c = new ArrayBuffer(i), u = new Uint8Array(c), l = 0; l < o; l += 4) {
|
|
5332
|
+
t = p[e.codePointAt(l)], r = p[e.codePointAt(l + 1)], n = p[e.codePointAt(l + 2)], a = p[e.codePointAt(l + 3)], u[s++] = t << 2 | r >> 4, u[s++] = (15 & r) << 4 | n >> 2, u[s++] = (3 & n) << 6 | 63 & a;
|
|
6392
5333
|
}
|
|
6393
5334
|
|
|
6394
|
-
|
|
6395
|
-
lngth);
|
|
6396
|
-
var len = bytes.length;
|
|
6397
|
-
var base64 = '';
|
|
6398
|
-
|
|
6399
|
-
for (var _i = 0; _i < len; _i += 3) {
|
|
6400
|
-
base64 += chars[bytes[_i] >> 2];
|
|
6401
|
-
base64 += chars[(bytes[_i] & 3) << 4 | bytes[_i + 1] >> 4];
|
|
6402
|
-
base64 += chars[(bytes[_i + 1] & 15) << 2 | bytes[_i + 2] >> 6];
|
|
6403
|
-
base64 += chars[bytes[_i + 2] & 63];
|
|
6404
|
-
}
|
|
6405
|
-
|
|
6406
|
-
if (len % 3 === 2) {
|
|
6407
|
-
base64 = base64.slice(0, -1) + '=';
|
|
6408
|
-
} else if (len % 3 === 1) {
|
|
6409
|
-
base64 = base64.slice(0, -2) + '==';
|
|
6410
|
-
}
|
|
6411
|
-
|
|
6412
|
-
return base64;
|
|
6413
|
-
};
|
|
6414
|
-
/**
|
|
6415
|
-
* @param {string} base64
|
|
6416
|
-
* @returns {ArrayBuffer}
|
|
6417
|
-
*/
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
var decode$1 = function decode(base64) {
|
|
6421
|
-
var len = base64.length;
|
|
6422
|
-
var bufferLength = base64.length * 0.75;
|
|
6423
|
-
var p = 0;
|
|
6424
|
-
var encoded1, encoded2, encoded3, encoded4;
|
|
6425
|
-
|
|
6426
|
-
if (base64[base64.length - 1] === '=') {
|
|
6427
|
-
bufferLength--;
|
|
6428
|
-
|
|
6429
|
-
if (base64[base64.length - 2] === '=') {
|
|
6430
|
-
bufferLength--;
|
|
6431
|
-
}
|
|
6432
|
-
}
|
|
6433
|
-
|
|
6434
|
-
var arraybuffer = new ArrayBuffer(bufferLength),
|
|
6435
|
-
bytes = new Uint8Array(arraybuffer);
|
|
6436
|
-
|
|
6437
|
-
for (var _i2 = 0; _i2 < len; _i2 += 4) {
|
|
6438
|
-
encoded1 = lookup[base64.charCodeAt(_i2)];
|
|
6439
|
-
encoded2 = lookup[base64.charCodeAt(_i2 + 1)];
|
|
6440
|
-
encoded3 = lookup[base64.charCodeAt(_i2 + 2)];
|
|
6441
|
-
encoded4 = lookup[base64.charCodeAt(_i2 + 3)];
|
|
6442
|
-
bytes[p++] = encoded1 << 2 | encoded2 >> 4;
|
|
6443
|
-
bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
|
|
6444
|
-
bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
|
|
6445
|
-
}
|
|
6446
|
-
|
|
6447
|
-
return arraybuffer;
|
|
6448
|
-
};
|
|
6449
|
-
|
|
6450
|
-
var arraybuffer = {
|
|
6451
|
-
arraybuffer: {
|
|
6452
|
-
test: function test(x) {
|
|
6453
|
-
return Typeson.toStringTag(x) === 'ArrayBuffer';
|
|
6454
|
-
},
|
|
6455
|
-
replace: function replace(b, stateObj) {
|
|
6456
|
-
if (!stateObj.buffers) {
|
|
6457
|
-
stateObj.buffers = [];
|
|
6458
|
-
}
|
|
6459
|
-
|
|
6460
|
-
var index = stateObj.buffers.indexOf(b);
|
|
6461
|
-
|
|
6462
|
-
if (index > -1) {
|
|
6463
|
-
return {
|
|
6464
|
-
index: index
|
|
6465
|
-
};
|
|
6466
|
-
}
|
|
6467
|
-
|
|
6468
|
-
stateObj.buffers.push(b);
|
|
6469
|
-
return encode$1(b);
|
|
6470
|
-
},
|
|
6471
|
-
revive: function revive(b64, stateObj) {
|
|
6472
|
-
if (!stateObj.buffers) {
|
|
6473
|
-
stateObj.buffers = [];
|
|
6474
|
-
}
|
|
6475
|
-
|
|
6476
|
-
if (_typeof$1(b64) === 'object') {
|
|
6477
|
-
return stateObj.buffers[b64.index];
|
|
6478
|
-
}
|
|
6479
|
-
|
|
6480
|
-
var buffer = decode$1(b64);
|
|
6481
|
-
stateObj.buffers.push(buffer);
|
|
6482
|
-
return buffer;
|
|
6483
|
-
}
|
|
6484
|
-
}
|
|
5335
|
+
return c;
|
|
6485
5336
|
};
|
|
6486
|
-
// See also typed-arrays!
|
|
6487
5337
|
|
|
6488
|
-
var
|
|
5338
|
+
var h = {
|
|
5339
|
+
arraybuffer: {
|
|
5340
|
+
test: function test(e) {
|
|
5341
|
+
return "ArrayBuffer" === toStringTag(e);
|
|
5342
|
+
},
|
|
5343
|
+
replace: function replace(e, t) {
|
|
5344
|
+
t.buffers || (t.buffers = []);
|
|
5345
|
+
var r = t.buffers.indexOf(e);
|
|
5346
|
+
return r > -1 ? {
|
|
5347
|
+
index: r
|
|
5348
|
+
} : (t.buffers.push(e), v(e));
|
|
5349
|
+
},
|
|
5350
|
+
revive: function revive(e, t) {
|
|
5351
|
+
if (t.buffers || (t.buffers = []), "object" == _typeof$2(e)) return t.buffers[e.index];
|
|
5352
|
+
var r = b(e);
|
|
5353
|
+
return t.buffers.push(r), r;
|
|
5354
|
+
}
|
|
5355
|
+
}
|
|
5356
|
+
},
|
|
5357
|
+
g = {
|
|
6489
5358
|
bigintObject: {
|
|
6490
|
-
test: function test(
|
|
6491
|
-
return _typeof$
|
|
5359
|
+
test: function test(e) {
|
|
5360
|
+
return "object" == _typeof$2(e) && hasConstructorOf(e, BigInt);
|
|
6492
5361
|
},
|
|
6493
|
-
replace: function replace(
|
|
6494
|
-
return String(
|
|
5362
|
+
replace: function replace(e) {
|
|
5363
|
+
return String(e);
|
|
6495
5364
|
},
|
|
6496
|
-
revive: function revive(
|
|
6497
|
-
|
|
6498
|
-
// eslint-disable-next-line no-new-object
|
|
6499
|
-
return new Object(BigInt(s));
|
|
5365
|
+
revive: function revive(e) {
|
|
5366
|
+
return new Object(BigInt(e));
|
|
6500
5367
|
}
|
|
6501
5368
|
}
|
|
6502
|
-
}
|
|
6503
|
-
|
|
6504
|
-
/* globals BigInt */
|
|
6505
|
-
var bigint = {
|
|
5369
|
+
},
|
|
5370
|
+
m = {
|
|
6506
5371
|
bigint: {
|
|
6507
|
-
test: function test(
|
|
6508
|
-
return
|
|
5372
|
+
test: function test(e) {
|
|
5373
|
+
return "bigint" == typeof e;
|
|
6509
5374
|
},
|
|
6510
|
-
replace: function replace(
|
|
6511
|
-
return String(
|
|
5375
|
+
replace: function replace(e) {
|
|
5376
|
+
return String(e);
|
|
6512
5377
|
},
|
|
6513
|
-
revive: function revive(
|
|
6514
|
-
return BigInt(
|
|
5378
|
+
revive: function revive(e) {
|
|
5379
|
+
return BigInt(e);
|
|
6515
5380
|
}
|
|
6516
5381
|
}
|
|
6517
5382
|
};
|
|
6518
5383
|
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
* @param {ArrayBuffer} buf
|
|
6522
|
-
* @returns {Uint8Array}
|
|
6523
|
-
*/
|
|
6524
|
-
/**
|
|
6525
|
-
*
|
|
6526
|
-
* @param {string} str
|
|
6527
|
-
* @returns {ArrayBuffer}
|
|
6528
|
-
*/
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
function string2arraybuffer(str) {
|
|
6532
|
-
/*
|
|
6533
|
-
// UTF-8 approaches
|
|
6534
|
-
const utf8 = unescape(encodeURIComponent(str));
|
|
6535
|
-
const arr = new Uint8Array(utf8.length);
|
|
6536
|
-
for (let i = 0; i < utf8.length; i++) {
|
|
6537
|
-
arr[i] = utf8.charCodeAt(i);
|
|
6538
|
-
}
|
|
6539
|
-
return arr.buffer;
|
|
6540
|
-
const utf8 = [];
|
|
6541
|
-
for (let i = 0; i < str.length; i++) {
|
|
6542
|
-
let charcode = str.charCodeAt(i);
|
|
6543
|
-
if (charcode < 0x80) utf8.push(charcode);
|
|
6544
|
-
else if (charcode < 0x800) {
|
|
6545
|
-
utf8.push(0xc0 | (charcode >> 6),
|
|
6546
|
-
0x80 | (charcode & 0x3f));
|
|
6547
|
-
} else if (charcode < 0xd800 || charcode >= 0xe000) {
|
|
6548
|
-
utf8.push(0xe0 | (charcode >> 12),
|
|
6549
|
-
0x80 | ((charcode >> 6) & 0x3f),
|
|
6550
|
-
0x80 | (charcode & 0x3f));
|
|
6551
|
-
// surrogate pair
|
|
6552
|
-
} else {
|
|
6553
|
-
i++;
|
|
6554
|
-
// UTF-16 encodes 0x10000-0x10FFFF by
|
|
6555
|
-
// subtracting 0x10000 and splitting the
|
|
6556
|
-
// 20 bits of 0x0-0xFFFFF into two halves
|
|
6557
|
-
charcode = 0x10000 + (((charcode & 0x3ff) << 10) |
|
|
6558
|
-
(str.charCodeAt(i) & 0x3ff));
|
|
6559
|
-
utf8.push(0xf0 | (charcode >> 18),
|
|
6560
|
-
0x80 | ((charcode >> 12) & 0x3f),
|
|
6561
|
-
0x80 | ((charcode >> 6) & 0x3f),
|
|
6562
|
-
0x80 | (charcode & 0x3f));
|
|
6563
|
-
}
|
|
6564
|
-
}
|
|
6565
|
-
return utf8;
|
|
6566
|
-
*/
|
|
6567
|
-
|
|
6568
|
-
/*
|
|
6569
|
-
// Working UTF-16 options (equivalents)
|
|
6570
|
-
const buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
|
|
6571
|
-
const bufView = new Uint16Array(buf);
|
|
6572
|
-
for (let i = 0, strLen = str.length; i < strLen; i++) {
|
|
6573
|
-
bufView[i] = str.charCodeAt(i);
|
|
6574
|
-
}
|
|
6575
|
-
return buf;
|
|
6576
|
-
*/
|
|
6577
|
-
var array = new Uint8Array(str.length);
|
|
5384
|
+
function string2arraybuffer(e) {
|
|
5385
|
+
var t = new Uint8Array(e.length);
|
|
6578
5386
|
|
|
6579
|
-
for (var
|
|
6580
|
-
|
|
5387
|
+
for (var _r = 0; _r < e.length; _r++) {
|
|
5388
|
+
t[_r] = e.charCodeAt(_r);
|
|
6581
5389
|
}
|
|
6582
5390
|
|
|
6583
|
-
return
|
|
5391
|
+
return t.buffer;
|
|
6584
5392
|
}
|
|
6585
5393
|
|
|
6586
|
-
|
|
6587
|
-
var blob = {
|
|
5394
|
+
var O = {
|
|
6588
5395
|
blob: {
|
|
6589
|
-
test: function test(
|
|
6590
|
-
return
|
|
5396
|
+
test: function test(e) {
|
|
5397
|
+
return "Blob" === toStringTag(e);
|
|
6591
5398
|
},
|
|
6592
|
-
replace: function replace(
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
req.overrideMimeType('text/plain; charset=x-user-defined');
|
|
6596
|
-
req.open('GET', URL.createObjectURL(b), false); // Sync
|
|
6597
|
-
|
|
6598
|
-
req.send(); // Seems not feasible to accurately simulate
|
|
6599
|
-
|
|
6600
|
-
/* istanbul ignore next */
|
|
6601
|
-
|
|
6602
|
-
if (req.status !== 200 && req.status !== 0) {
|
|
6603
|
-
throw new Error('Bad Blob access: ' + req.status);
|
|
6604
|
-
}
|
|
6605
|
-
|
|
5399
|
+
replace: function replace(e) {
|
|
5400
|
+
var t = new XMLHttpRequest();
|
|
5401
|
+
if (t.overrideMimeType("text/plain; charset=x-user-defined"), t.open("GET", URL.createObjectURL(e), !1), t.send(), 200 !== t.status && 0 !== t.status) throw new Error("Bad Blob access: " + t.status);
|
|
6606
5402
|
return {
|
|
6607
|
-
type:
|
|
6608
|
-
stringContents:
|
|
5403
|
+
type: e.type,
|
|
5404
|
+
stringContents: t.responseText
|
|
6609
5405
|
};
|
|
6610
5406
|
},
|
|
6611
5407
|
revive: function revive(_ref) {
|
|
6612
|
-
var
|
|
6613
|
-
|
|
6614
|
-
return new Blob([string2arraybuffer(
|
|
6615
|
-
type:
|
|
5408
|
+
var e = _ref.type,
|
|
5409
|
+
t = _ref.stringContents;
|
|
5410
|
+
return new Blob([string2arraybuffer(t)], {
|
|
5411
|
+
type: e
|
|
6616
5412
|
});
|
|
6617
5413
|
},
|
|
6618
|
-
replaceAsync: function replaceAsync(
|
|
6619
|
-
return new
|
|
6620
|
-
|
|
6621
|
-
|
|
6622
|
-
|
|
6623
|
-
|
|
6624
|
-
|
|
6625
|
-
*/
|
|
6626
|
-
var reader = new FileReader();
|
|
6627
|
-
reader.addEventListener('load', function () {
|
|
6628
|
-
resolve({
|
|
6629
|
-
type: b.type,
|
|
6630
|
-
stringContents: reader.result
|
|
5414
|
+
replaceAsync: function replaceAsync(t) {
|
|
5415
|
+
return new e(function (e, r) {
|
|
5416
|
+
var n = new FileReader();
|
|
5417
|
+
n.addEventListener("load", function () {
|
|
5418
|
+
e({
|
|
5419
|
+
type: t.type,
|
|
5420
|
+
stringContents: n.result
|
|
6631
5421
|
});
|
|
6632
|
-
})
|
|
6633
|
-
|
|
6634
|
-
|
|
6635
|
-
|
|
6636
|
-
reader.addEventListener('error', function () {
|
|
6637
|
-
reject(reader.error);
|
|
6638
|
-
});
|
|
6639
|
-
reader.readAsBinaryString(b);
|
|
5422
|
+
}), n.addEventListener("error", function () {
|
|
5423
|
+
r(n.error);
|
|
5424
|
+
}), n.readAsBinaryString(t);
|
|
6640
5425
|
});
|
|
6641
5426
|
}
|
|
6642
5427
|
}
|
|
6643
5428
|
};
|
|
6644
5429
|
|
|
6645
|
-
|
|
6646
|
-
// The `performance` global is optional
|
|
6647
|
-
|
|
6648
|
-
/**
|
|
6649
|
-
* @todo We could use `import generateUUID from 'uuid/v4';` (but it needs
|
|
6650
|
-
* crypto library, etc.; `rollup-plugin-node-builtins` doesn't recommend
|
|
6651
|
-
* using its own version and though there is <https://www.npmjs.com/package/crypto-browserify>,
|
|
6652
|
-
* it may be troublesome to bundle and not strongly needed)
|
|
6653
|
-
* @returns {string}
|
|
6654
|
-
*/
|
|
6655
|
-
function generateUUID() {
|
|
6656
|
-
// Adapted from original: public domain/MIT: http://stackoverflow.com/a/8809472/271577
|
|
6657
|
-
|
|
6658
|
-
/* istanbul ignore next */
|
|
6659
|
-
var d = Date.now() + ( // use high-precision timer if available
|
|
6660
|
-
// istanbul ignore next
|
|
6661
|
-
typeof performance !== 'undefined' && typeof performance.now === 'function' ? performance.now() : 0);
|
|
6662
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
6663
|
-
/* eslint-disable no-bitwise */
|
|
6664
|
-
var r = Math.trunc((d + Math.random() * 16) % 16);
|
|
6665
|
-
d = Math.floor(d / 16);
|
|
6666
|
-
return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
|
|
6667
|
-
/* eslint-enable no-bitwise */
|
|
6668
|
-
});
|
|
6669
|
-
}
|
|
6670
|
-
|
|
6671
|
-
var cloneableObjectsByUUID = {};
|
|
6672
|
-
var cloneable = {
|
|
6673
|
-
cloneable: {
|
|
6674
|
-
test: function test(x) {
|
|
6675
|
-
return x && _typeof$1(x) === 'object' && typeof x[Symbol["for"]('cloneEncapsulate')] === 'function';
|
|
6676
|
-
},
|
|
6677
|
-
replace: function replace(clonable) {
|
|
6678
|
-
var encapsulated = clonable[Symbol["for"]('cloneEncapsulate')]();
|
|
6679
|
-
var uuid = generateUUID();
|
|
6680
|
-
cloneableObjectsByUUID[uuid] = clonable;
|
|
6681
|
-
return {
|
|
6682
|
-
uuid: uuid,
|
|
6683
|
-
encapsulated: encapsulated
|
|
6684
|
-
};
|
|
6685
|
-
},
|
|
6686
|
-
revive: function revive(_ref) {
|
|
6687
|
-
var uuid = _ref.uuid,
|
|
6688
|
-
encapsulated = _ref.encapsulated;
|
|
6689
|
-
return cloneableObjectsByUUID[uuid][Symbol["for"]('cloneRevive')](encapsulated);
|
|
6690
|
-
}
|
|
6691
|
-
}
|
|
6692
|
-
};
|
|
6693
|
-
|
|
6694
|
-
/* globals crypto */
|
|
6695
|
-
var cryptokey = {
|
|
5430
|
+
var w = {
|
|
6696
5431
|
cryptokey: {
|
|
6697
|
-
test: function test(
|
|
6698
|
-
return
|
|
6699
|
-
},
|
|
6700
|
-
replaceAsync: function replaceAsync(key) {
|
|
6701
|
-
return new Typeson.Promise(function (resolve, reject) {
|
|
6702
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
6703
|
-
crypto.subtle.exportKey('jwk', key)["catch"](
|
|
6704
|
-
/* eslint-disable promise/prefer-await-to-callbacks */
|
|
6705
|
-
// istanbul ignore next
|
|
6706
|
-
function (err) {
|
|
6707
|
-
/* eslint-enable promise/prefer-await-to-callbacks */
|
|
6708
|
-
// eslint-disable-next-line max-len
|
|
6709
|
-
// istanbul ignore next -- Our format should be valid and our key extractable
|
|
6710
|
-
reject(err);
|
|
6711
|
-
} // eslint-disable-next-line max-len
|
|
6712
|
-
// eslint-disable-next-line promise/always-return, promise/prefer-await-to-then
|
|
6713
|
-
).then(function (jwk) {
|
|
6714
|
-
resolve({
|
|
6715
|
-
jwk: jwk,
|
|
6716
|
-
algorithm: key.algorithm,
|
|
6717
|
-
usages: key.usages
|
|
6718
|
-
});
|
|
6719
|
-
});
|
|
6720
|
-
});
|
|
5432
|
+
test: function test(e) {
|
|
5433
|
+
return "CryptoKey" === toStringTag(e) && e.extractable;
|
|
6721
5434
|
},
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
5435
|
+
replaceAsync: function replaceAsync(t) {
|
|
5436
|
+
return new e( /*#__PURE__*/function () {
|
|
5437
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(e, r) {
|
|
5438
|
+
var n;
|
|
5439
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5440
|
+
while (1) {
|
|
5441
|
+
switch (_context.prev = _context.next) {
|
|
5442
|
+
case 0:
|
|
5443
|
+
_context.prev = 0;
|
|
5444
|
+
_context.next = 3;
|
|
5445
|
+
return crypto.subtle.exportKey("jwk", t);
|
|
5446
|
+
|
|
5447
|
+
case 3:
|
|
5448
|
+
n = _context.sent;
|
|
5449
|
+
_context.next = 9;
|
|
5450
|
+
break;
|
|
6730
5451
|
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6735
|
-
},
|
|
6736
|
-
replace: function replace(_ref, stateObj) {
|
|
6737
|
-
var buffer = _ref.buffer,
|
|
6738
|
-
byteOffset = _ref.byteOffset,
|
|
6739
|
-
byteLength = _ref.byteLength;
|
|
5452
|
+
case 6:
|
|
5453
|
+
_context.prev = 6;
|
|
5454
|
+
_context.t0 = _context["catch"](0);
|
|
5455
|
+
return _context.abrupt("return", void r(_context.t0));
|
|
6740
5456
|
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
5457
|
+
case 9:
|
|
5458
|
+
e({
|
|
5459
|
+
jwk: n,
|
|
5460
|
+
algorithm: t.algorithm,
|
|
5461
|
+
usages: t.usages
|
|
5462
|
+
});
|
|
6744
5463
|
|
|
6745
|
-
|
|
5464
|
+
case 10:
|
|
5465
|
+
case "end":
|
|
5466
|
+
return _context.stop();
|
|
5467
|
+
}
|
|
5468
|
+
}
|
|
5469
|
+
}, _callee, null, [[0, 6]]);
|
|
5470
|
+
}));
|
|
6746
5471
|
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
index: index,
|
|
6750
|
-
byteOffset: byteOffset,
|
|
6751
|
-
byteLength: byteLength
|
|
5472
|
+
return function (_x, _x2) {
|
|
5473
|
+
return _ref3.apply(this, arguments);
|
|
6752
5474
|
};
|
|
6753
|
-
}
|
|
6754
|
-
|
|
6755
|
-
stateObj.buffers.push(buffer);
|
|
6756
|
-
return {
|
|
6757
|
-
encoded: encode$1(buffer),
|
|
6758
|
-
byteOffset: byteOffset,
|
|
6759
|
-
byteLength: byteLength
|
|
6760
|
-
};
|
|
5475
|
+
}());
|
|
6761
5476
|
},
|
|
6762
|
-
revive: function revive(
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
var byteOffset = b64Obj.byteOffset,
|
|
6768
|
-
byteLength = b64Obj.byteLength,
|
|
6769
|
-
encoded = b64Obj.encoded,
|
|
6770
|
-
index = b64Obj.index;
|
|
6771
|
-
var buffer;
|
|
6772
|
-
|
|
6773
|
-
if ('index' in b64Obj) {
|
|
6774
|
-
buffer = stateObj.buffers[index];
|
|
6775
|
-
} else {
|
|
6776
|
-
buffer = decode$1(encoded);
|
|
6777
|
-
stateObj.buffers.push(buffer);
|
|
6778
|
-
}
|
|
6779
|
-
|
|
6780
|
-
return new DataView(buffer, byteOffset, byteLength);
|
|
5477
|
+
revive: function revive(_ref4) {
|
|
5478
|
+
var e = _ref4.jwk,
|
|
5479
|
+
t = _ref4.algorithm,
|
|
5480
|
+
r = _ref4.usages;
|
|
5481
|
+
return crypto.subtle.importKey("jwk", e, t, !0, r);
|
|
6781
5482
|
}
|
|
6782
5483
|
}
|
|
6783
|
-
}
|
|
6784
|
-
|
|
6785
|
-
|
|
5484
|
+
},
|
|
5485
|
+
A = {
|
|
5486
|
+
dataview: {
|
|
5487
|
+
test: function test(e) {
|
|
5488
|
+
return "DataView" === toStringTag(e);
|
|
5489
|
+
},
|
|
5490
|
+
replace: function replace(_ref5, n) {
|
|
5491
|
+
var e = _ref5.buffer,
|
|
5492
|
+
t = _ref5.byteOffset,
|
|
5493
|
+
r = _ref5.byteLength;
|
|
5494
|
+
n.buffers || (n.buffers = []);
|
|
5495
|
+
var a = n.buffers.indexOf(e);
|
|
5496
|
+
return a > -1 ? {
|
|
5497
|
+
index: a,
|
|
5498
|
+
byteOffset: t,
|
|
5499
|
+
byteLength: r
|
|
5500
|
+
} : (n.buffers.push(e), {
|
|
5501
|
+
encoded: v(e),
|
|
5502
|
+
byteOffset: t,
|
|
5503
|
+
byteLength: r
|
|
5504
|
+
});
|
|
5505
|
+
},
|
|
5506
|
+
revive: function revive(e, t) {
|
|
5507
|
+
t.buffers || (t.buffers = []);
|
|
5508
|
+
var r = e.byteOffset,
|
|
5509
|
+
n = e.byteLength,
|
|
5510
|
+
a = e.encoded,
|
|
5511
|
+
o = e.index;
|
|
5512
|
+
var i;
|
|
5513
|
+
return "index" in e ? i = t.buffers[o] : (i = b(a), t.buffers.push(i)), new DataView(i, r, n);
|
|
5514
|
+
}
|
|
5515
|
+
}
|
|
5516
|
+
},
|
|
5517
|
+
j = {
|
|
6786
5518
|
date: {
|
|
6787
|
-
test: function test(
|
|
6788
|
-
return
|
|
5519
|
+
test: function test(e) {
|
|
5520
|
+
return "Date" === toStringTag(e);
|
|
6789
5521
|
},
|
|
6790
|
-
replace: function replace(
|
|
6791
|
-
var
|
|
6792
|
-
|
|
6793
|
-
if (Number.isNaN(time)) {
|
|
6794
|
-
return 'NaN';
|
|
6795
|
-
}
|
|
6796
|
-
|
|
6797
|
-
return time;
|
|
5522
|
+
replace: function replace(e) {
|
|
5523
|
+
var t = e.getTime();
|
|
5524
|
+
return Number.isNaN(t) ? "NaN" : t;
|
|
6798
5525
|
},
|
|
6799
|
-
revive: function revive(
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
}
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
test: function test(x) {
|
|
6812
|
-
return Typeson.toStringTag(x) === 'Error';
|
|
5526
|
+
revive: function revive(e) {
|
|
5527
|
+
return "NaN" === e ? new Date(Number.NaN) : new Date(e);
|
|
5528
|
+
}
|
|
5529
|
+
}
|
|
5530
|
+
},
|
|
5531
|
+
I = "undefined" == typeof self ? global : self,
|
|
5532
|
+
P = {};
|
|
5533
|
+
["TypeError", "RangeError", "SyntaxError", "ReferenceError", "EvalError", "URIError", "InternalError"].forEach(function (e) {
|
|
5534
|
+
var t = I[e];
|
|
5535
|
+
t && (P[e.toLowerCase()] = {
|
|
5536
|
+
test: function test(e) {
|
|
5537
|
+
return hasConstructorOf(e, t);
|
|
6813
5538
|
},
|
|
6814
|
-
replace: function replace(
|
|
6815
|
-
|
|
6816
|
-
message = _ref.message;
|
|
6817
|
-
return {
|
|
6818
|
-
name: name,
|
|
6819
|
-
message: message
|
|
6820
|
-
};
|
|
5539
|
+
replace: function replace(e) {
|
|
5540
|
+
return e.message;
|
|
6821
5541
|
},
|
|
6822
|
-
revive: function revive(
|
|
6823
|
-
|
|
6824
|
-
message = _ref2.message;
|
|
6825
|
-
var e = new Error(message);
|
|
6826
|
-
e.name = name;
|
|
6827
|
-
return e;
|
|
5542
|
+
revive: function revive(e) {
|
|
5543
|
+
return new t(e);
|
|
6828
5544
|
}
|
|
6829
|
-
}
|
|
6830
|
-
}; // See also errors.js that may be registered after having registered this type.
|
|
6831
|
-
|
|
6832
|
-
/* istanbul ignore next */
|
|
6833
|
-
|
|
6834
|
-
var _global$2 = typeof self === 'undefined' ? global$1 : self;
|
|
6835
|
-
|
|
6836
|
-
var errors = {}; // Comprises all built-in errors.
|
|
6837
|
-
|
|
6838
|
-
['TypeError', 'RangeError', 'SyntaxError', 'ReferenceError', 'EvalError', 'URIError', 'InternalError' // non-standard
|
|
6839
|
-
].forEach(function (errName) {
|
|
6840
|
-
var Cnstrctr = _global$2[errName];
|
|
6841
|
-
|
|
6842
|
-
if (Cnstrctr) {
|
|
6843
|
-
errors[errName.toLowerCase()] = {
|
|
6844
|
-
test: function test(x) {
|
|
6845
|
-
return Typeson.hasConstructorOf(x, Cnstrctr);
|
|
6846
|
-
},
|
|
6847
|
-
replace: function replace(e) {
|
|
6848
|
-
return e.message;
|
|
6849
|
-
},
|
|
6850
|
-
revive: function revive(message) {
|
|
6851
|
-
return new Cnstrctr(message);
|
|
6852
|
-
}
|
|
6853
|
-
};
|
|
6854
|
-
}
|
|
5545
|
+
});
|
|
6855
5546
|
});
|
|
6856
|
-
|
|
6857
|
-
/* globals XMLHttpRequest, File, FileReader */
|
|
6858
|
-
var file = {
|
|
5547
|
+
var N = {
|
|
6859
5548
|
file: {
|
|
6860
|
-
test: function test(
|
|
6861
|
-
return
|
|
5549
|
+
test: function test(e) {
|
|
5550
|
+
return "File" === toStringTag(e);
|
|
6862
5551
|
},
|
|
6863
|
-
replace: function replace(
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
req.overrideMimeType('text/plain; charset=x-user-defined');
|
|
6867
|
-
req.open('GET', URL.createObjectURL(f), false); // Sync
|
|
6868
|
-
|
|
6869
|
-
req.send(); // Seems not feasible to accurately simulate
|
|
6870
|
-
|
|
6871
|
-
/* istanbul ignore next */
|
|
6872
|
-
|
|
6873
|
-
if (req.status !== 200 && req.status !== 0) {
|
|
6874
|
-
throw new Error('Bad File access: ' + req.status);
|
|
6875
|
-
}
|
|
6876
|
-
|
|
5552
|
+
replace: function replace(e) {
|
|
5553
|
+
var t = new XMLHttpRequest();
|
|
5554
|
+
if (t.overrideMimeType("text/plain; charset=x-user-defined"), t.open("GET", URL.createObjectURL(e), !1), t.send(), 200 !== t.status && 0 !== t.status) throw new Error("Bad File access: " + t.status);
|
|
6877
5555
|
return {
|
|
6878
|
-
type:
|
|
6879
|
-
stringContents:
|
|
6880
|
-
name:
|
|
6881
|
-
lastModified:
|
|
5556
|
+
type: e.type,
|
|
5557
|
+
stringContents: t.responseText,
|
|
5558
|
+
name: e.name,
|
|
5559
|
+
lastModified: e.lastModified
|
|
6882
5560
|
};
|
|
6883
5561
|
},
|
|
6884
|
-
revive: function revive(
|
|
6885
|
-
var
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
return new File([string2arraybuffer(
|
|
6890
|
-
type:
|
|
6891
|
-
lastModified:
|
|
5562
|
+
revive: function revive(_ref8) {
|
|
5563
|
+
var e = _ref8.name,
|
|
5564
|
+
t = _ref8.type,
|
|
5565
|
+
r = _ref8.stringContents,
|
|
5566
|
+
n = _ref8.lastModified;
|
|
5567
|
+
return new File([string2arraybuffer(r)], e, {
|
|
5568
|
+
type: t,
|
|
5569
|
+
lastModified: n
|
|
6892
5570
|
});
|
|
6893
5571
|
},
|
|
6894
|
-
replaceAsync: function replaceAsync(
|
|
6895
|
-
return new
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
|
|
6902
|
-
|
|
6903
|
-
reader.addEventListener('load', function () {
|
|
6904
|
-
resolve({
|
|
6905
|
-
type: f.type,
|
|
6906
|
-
stringContents: reader.result,
|
|
6907
|
-
name: f.name,
|
|
6908
|
-
lastModified: f.lastModified
|
|
5572
|
+
replaceAsync: function replaceAsync(t) {
|
|
5573
|
+
return new e(function (e, r) {
|
|
5574
|
+
var n = new FileReader();
|
|
5575
|
+
n.addEventListener("load", function () {
|
|
5576
|
+
e({
|
|
5577
|
+
type: t.type,
|
|
5578
|
+
stringContents: n.result,
|
|
5579
|
+
name: t.name,
|
|
5580
|
+
lastModified: t.lastModified
|
|
6909
5581
|
});
|
|
6910
|
-
})
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
reader.addEventListener('error', function () {
|
|
6915
|
-
reject(reader.error);
|
|
6916
|
-
});
|
|
6917
|
-
reader.readAsBinaryString(f);
|
|
5582
|
+
}), n.addEventListener("error", function () {
|
|
5583
|
+
r(n.error);
|
|
5584
|
+
}), n.readAsBinaryString(t);
|
|
6918
5585
|
});
|
|
6919
5586
|
}
|
|
6920
5587
|
}
|
|
6921
|
-
}
|
|
6922
|
-
|
|
6923
|
-
|
|
6924
|
-
file: file.file,
|
|
5588
|
+
},
|
|
5589
|
+
C = {
|
|
5590
|
+
file: N.file,
|
|
6925
5591
|
filelist: {
|
|
6926
|
-
test: function test(
|
|
6927
|
-
return
|
|
5592
|
+
test: function test(e) {
|
|
5593
|
+
return "FileList" === toStringTag(e);
|
|
6928
5594
|
},
|
|
6929
|
-
replace: function replace(
|
|
6930
|
-
var
|
|
5595
|
+
replace: function replace(e) {
|
|
5596
|
+
var t = [];
|
|
6931
5597
|
|
|
6932
|
-
for (var
|
|
6933
|
-
|
|
5598
|
+
for (var _r2 = 0; _r2 < e.length; _r2++) {
|
|
5599
|
+
t[_r2] = e.item(_r2);
|
|
6934
5600
|
}
|
|
6935
5601
|
|
|
6936
|
-
return
|
|
5602
|
+
return t;
|
|
6937
5603
|
},
|
|
6938
|
-
revive: function revive(
|
|
6939
|
-
/**
|
|
6940
|
-
* `FileList` polyfill.
|
|
6941
|
-
*/
|
|
5604
|
+
revive: function revive(e) {
|
|
6942
5605
|
var FileList = /*#__PURE__*/function (_Symbol$toStringTag) {
|
|
6943
|
-
/**
|
|
6944
|
-
* Set private properties and length.
|
|
6945
|
-
*/
|
|
6946
5606
|
function FileList() {
|
|
6947
|
-
_classCallCheck(this, FileList);
|
|
5607
|
+
_classCallCheck$1(this, FileList);
|
|
6948
5608
|
|
|
6949
|
-
|
|
6950
|
-
this._files = arguments[0];
|
|
6951
|
-
this.length = this._files.length;
|
|
5609
|
+
this._files = arguments[0], this.length = this._files.length;
|
|
6952
5610
|
}
|
|
6953
|
-
/**
|
|
6954
|
-
* @param {Integer} index
|
|
6955
|
-
* @returns {File}
|
|
6956
|
-
*/
|
|
6957
|
-
|
|
6958
5611
|
|
|
6959
|
-
_createClass(FileList, [{
|
|
5612
|
+
_createClass$1(FileList, [{
|
|
6960
5613
|
key: "item",
|
|
6961
|
-
value: function item(
|
|
6962
|
-
return this._files[
|
|
5614
|
+
value: function item(e) {
|
|
5615
|
+
return this._files[e];
|
|
6963
5616
|
}
|
|
6964
|
-
/* eslint-disable class-methods-use-this */
|
|
6965
|
-
|
|
6966
|
-
/**
|
|
6967
|
-
* @returns {"FileList"}
|
|
6968
|
-
*/
|
|
6969
|
-
|
|
6970
5617
|
}, {
|
|
6971
5618
|
key: _Symbol$toStringTag,
|
|
6972
5619
|
get: function get() {
|
|
6973
|
-
|
|
6974
|
-
return 'FileList';
|
|
5620
|
+
return "FileList";
|
|
6975
5621
|
}
|
|
6976
5622
|
}]);
|
|
6977
5623
|
|
|
6978
5624
|
return FileList;
|
|
6979
5625
|
}(Symbol.toStringTag);
|
|
6980
5626
|
|
|
6981
|
-
return new FileList(
|
|
5627
|
+
return new FileList(e);
|
|
6982
5628
|
}
|
|
6983
5629
|
}
|
|
6984
|
-
}
|
|
6985
|
-
|
|
6986
|
-
/* globals createImageBitmap */
|
|
6987
|
-
var imagebitmap = {
|
|
5630
|
+
},
|
|
5631
|
+
E = {
|
|
6988
5632
|
imagebitmap: {
|
|
6989
|
-
test: function test(
|
|
6990
|
-
return
|
|
6991
|
-
// element as JSDom no longer allows overriding toStringTag
|
|
6992
|
-
x && x.dataset && x.dataset.toStringTag === 'ImageBitmap';
|
|
5633
|
+
test: function test(e) {
|
|
5634
|
+
return "ImageBitmap" === toStringTag(e) || e && e.dataset && "ImageBitmap" === e.dataset.toStringTag;
|
|
6993
5635
|
},
|
|
6994
|
-
replace: function replace(
|
|
6995
|
-
var
|
|
6996
|
-
|
|
6997
|
-
ctx.drawImage(bm, 0, 0); // Although `width` and `height` are part of `ImageBitMap`,
|
|
6998
|
-
// these will be auto-created for us when reviving with the
|
|
6999
|
-
// data URL (and they are not settable even if they weren't)
|
|
7000
|
-
// return {
|
|
7001
|
-
// width: bm.width, height: bm.height, dataURL: canvas.toDataURL()
|
|
7002
|
-
// };
|
|
7003
|
-
|
|
7004
|
-
return canvas.toDataURL();
|
|
5636
|
+
replace: function replace(e) {
|
|
5637
|
+
var t = document.createElement("canvas");
|
|
5638
|
+
return t.getContext("2d").drawImage(e, 0, 0), t.toDataURL();
|
|
7005
5639
|
},
|
|
7006
|
-
revive: function revive(
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
}
|
|
7013
|
-
req.send();
|
|
7014
|
-
return req.responseText;
|
|
7015
|
-
*/
|
|
7016
|
-
var canvas = document.createElement('canvas');
|
|
7017
|
-
var ctx = canvas.getContext('2d');
|
|
7018
|
-
var img = document.createElement('img'); // The onload is needed by some browsers per http://stackoverflow.com/a/4776378/271577
|
|
7019
|
-
|
|
7020
|
-
img.addEventListener('load', function () {
|
|
7021
|
-
ctx.drawImage(img, 0, 0);
|
|
7022
|
-
});
|
|
7023
|
-
img.src = o; // Works in contexts allowing an `ImageBitmap` (We might use
|
|
7024
|
-
// `OffscreenCanvas.transferToBitmap` when supported)
|
|
7025
|
-
|
|
7026
|
-
return canvas;
|
|
5640
|
+
revive: function revive(e) {
|
|
5641
|
+
var t = document.createElement("canvas"),
|
|
5642
|
+
r = t.getContext("2d"),
|
|
5643
|
+
n = document.createElement("img");
|
|
5644
|
+
return n.addEventListener("load", function () {
|
|
5645
|
+
r.drawImage(n, 0, 0);
|
|
5646
|
+
}), n.src = e, t;
|
|
7027
5647
|
},
|
|
7028
|
-
reviveAsync: function reviveAsync(
|
|
7029
|
-
var
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
});
|
|
7036
|
-
img.src = o; // o.dataURL;
|
|
7037
|
-
|
|
7038
|
-
return createImageBitmap(canvas); // Returns a promise
|
|
5648
|
+
reviveAsync: function reviveAsync(e) {
|
|
5649
|
+
var t = document.createElement("canvas"),
|
|
5650
|
+
r = t.getContext("2d"),
|
|
5651
|
+
n = document.createElement("img");
|
|
5652
|
+
return n.addEventListener("load", function () {
|
|
5653
|
+
r.drawImage(n, 0, 0);
|
|
5654
|
+
}), n.src = e, createImageBitmap(t);
|
|
7039
5655
|
}
|
|
7040
5656
|
}
|
|
7041
|
-
}
|
|
7042
|
-
|
|
7043
|
-
var imagedata = {
|
|
5657
|
+
},
|
|
5658
|
+
x = {
|
|
7044
5659
|
imagedata: {
|
|
7045
|
-
test: function test(
|
|
7046
|
-
return
|
|
5660
|
+
test: function test(e) {
|
|
5661
|
+
return "ImageData" === toStringTag(e);
|
|
7047
5662
|
},
|
|
7048
|
-
replace: function replace(
|
|
5663
|
+
replace: function replace(e) {
|
|
7049
5664
|
return {
|
|
7050
|
-
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
height: d.height
|
|
5665
|
+
array: _toConsumableArray(e.data),
|
|
5666
|
+
width: e.width,
|
|
5667
|
+
height: e.height
|
|
7054
5668
|
};
|
|
7055
5669
|
},
|
|
7056
|
-
revive: function revive(
|
|
7057
|
-
return new ImageData(new Uint8ClampedArray(
|
|
5670
|
+
revive: function revive(e) {
|
|
5671
|
+
return new ImageData(new Uint8ClampedArray(e.array), e.width, e.height);
|
|
7058
5672
|
}
|
|
7059
5673
|
}
|
|
7060
|
-
}
|
|
7061
|
-
|
|
7062
|
-
var infinity = {
|
|
5674
|
+
},
|
|
5675
|
+
k = {
|
|
7063
5676
|
infinity: {
|
|
7064
|
-
test: function test(
|
|
7065
|
-
return
|
|
5677
|
+
test: function test(e) {
|
|
5678
|
+
return e === Number.POSITIVE_INFINITY;
|
|
7066
5679
|
},
|
|
7067
|
-
replace: function replace(
|
|
7068
|
-
return
|
|
5680
|
+
replace: function replace(e) {
|
|
5681
|
+
return "Infinity";
|
|
7069
5682
|
},
|
|
7070
|
-
revive: function revive(
|
|
5683
|
+
revive: function revive(e) {
|
|
7071
5684
|
return Number.POSITIVE_INFINITY;
|
|
7072
5685
|
}
|
|
7073
5686
|
}
|
|
7074
|
-
}
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
return Typeson.hasConstructorOf(x, Intl.Collator);
|
|
7079
|
-
},
|
|
7080
|
-
replace: function replace(c) {
|
|
7081
|
-
return c.resolvedOptions();
|
|
7082
|
-
},
|
|
7083
|
-
revive: function revive(options) {
|
|
7084
|
-
return new Intl.Collator(options.locale, options);
|
|
7085
|
-
}
|
|
7086
|
-
};
|
|
7087
|
-
var IntlDateTimeFormat = {
|
|
7088
|
-
test: function test(x) {
|
|
7089
|
-
return Typeson.hasConstructorOf(x, Intl.DateTimeFormat);
|
|
5687
|
+
},
|
|
5688
|
+
B = {
|
|
5689
|
+
test: function test(e) {
|
|
5690
|
+
return hasConstructorOf(e, Intl.Collator);
|
|
7090
5691
|
},
|
|
7091
|
-
replace: function replace(
|
|
7092
|
-
return
|
|
7093
|
-
},
|
|
7094
|
-
revive: function revive(options) {
|
|
7095
|
-
return new Intl.DateTimeFormat(options.locale, options);
|
|
7096
|
-
}
|
|
7097
|
-
};
|
|
7098
|
-
var IntlNumberFormat = {
|
|
7099
|
-
test: function test(x) {
|
|
7100
|
-
return Typeson.hasConstructorOf(x, Intl.NumberFormat);
|
|
5692
|
+
replace: function replace(e) {
|
|
5693
|
+
return e.resolvedOptions();
|
|
7101
5694
|
},
|
|
7102
|
-
|
|
7103
|
-
return
|
|
5695
|
+
revive: function revive(e) {
|
|
5696
|
+
return new Intl.Collator(e.locale, e);
|
|
5697
|
+
}
|
|
5698
|
+
},
|
|
5699
|
+
U = {
|
|
5700
|
+
IntlCollator: B,
|
|
5701
|
+
IntlDateTimeFormat: {
|
|
5702
|
+
test: function test(e) {
|
|
5703
|
+
return hasConstructorOf(e, Intl.DateTimeFormat);
|
|
5704
|
+
},
|
|
5705
|
+
replace: function replace(e) {
|
|
5706
|
+
return e.resolvedOptions();
|
|
5707
|
+
},
|
|
5708
|
+
revive: function revive(e) {
|
|
5709
|
+
return new Intl.DateTimeFormat(e.locale, e);
|
|
5710
|
+
}
|
|
7104
5711
|
},
|
|
7105
|
-
|
|
7106
|
-
|
|
5712
|
+
IntlNumberFormat: {
|
|
5713
|
+
test: function test(e) {
|
|
5714
|
+
return hasConstructorOf(e, Intl.NumberFormat);
|
|
5715
|
+
},
|
|
5716
|
+
replace: function replace(e) {
|
|
5717
|
+
return e.resolvedOptions();
|
|
5718
|
+
},
|
|
5719
|
+
revive: function revive(e) {
|
|
5720
|
+
return new Intl.NumberFormat(e.locale, e);
|
|
5721
|
+
}
|
|
7107
5722
|
}
|
|
7108
|
-
}
|
|
7109
|
-
|
|
7110
|
-
IntlCollator: IntlCollator,
|
|
7111
|
-
IntlDateTimeFormat: IntlDateTimeFormat,
|
|
7112
|
-
IntlNumberFormat: IntlNumberFormat
|
|
7113
|
-
};
|
|
7114
|
-
|
|
7115
|
-
var map = {
|
|
5723
|
+
},
|
|
5724
|
+
K = {
|
|
7116
5725
|
map: {
|
|
7117
|
-
test: function test(
|
|
7118
|
-
return
|
|
5726
|
+
test: function test(e) {
|
|
5727
|
+
return "Map" === toStringTag(e);
|
|
7119
5728
|
},
|
|
7120
|
-
replace: function replace(
|
|
7121
|
-
return _toConsumableArray(
|
|
5729
|
+
replace: function replace(e) {
|
|
5730
|
+
return _toConsumableArray(e.entries());
|
|
7122
5731
|
},
|
|
7123
|
-
revive: function revive(
|
|
7124
|
-
return new Map(
|
|
5732
|
+
revive: function revive(e) {
|
|
5733
|
+
return new Map(e);
|
|
7125
5734
|
}
|
|
7126
5735
|
}
|
|
7127
|
-
}
|
|
7128
|
-
|
|
7129
|
-
var nan = {
|
|
5736
|
+
},
|
|
5737
|
+
L = {
|
|
7130
5738
|
nan: {
|
|
7131
|
-
test: function test(
|
|
7132
|
-
return Number.isNaN(
|
|
5739
|
+
test: function test(e) {
|
|
5740
|
+
return Number.isNaN(e);
|
|
7133
5741
|
},
|
|
7134
|
-
replace: function replace(
|
|
7135
|
-
return
|
|
5742
|
+
replace: function replace(e) {
|
|
5743
|
+
return "NaN";
|
|
7136
5744
|
},
|
|
7137
|
-
revive: function revive(
|
|
5745
|
+
revive: function revive(e) {
|
|
7138
5746
|
return Number.NaN;
|
|
7139
5747
|
}
|
|
7140
5748
|
}
|
|
7141
|
-
}
|
|
7142
|
-
|
|
7143
|
-
var negativeInfinity = {
|
|
5749
|
+
},
|
|
5750
|
+
F = {
|
|
7144
5751
|
negativeInfinity: {
|
|
7145
|
-
test: function test(
|
|
7146
|
-
return
|
|
5752
|
+
test: function test(e) {
|
|
5753
|
+
return e === Number.NEGATIVE_INFINITY;
|
|
7147
5754
|
},
|
|
7148
|
-
replace: function replace(
|
|
7149
|
-
return
|
|
5755
|
+
replace: function replace(e) {
|
|
5756
|
+
return "-Infinity";
|
|
7150
5757
|
},
|
|
7151
|
-
revive: function revive(
|
|
5758
|
+
revive: function revive(e) {
|
|
7152
5759
|
return Number.NEGATIVE_INFINITY;
|
|
7153
5760
|
}
|
|
7154
5761
|
}
|
|
7155
|
-
}
|
|
7156
|
-
|
|
7157
|
-
var nonbuiltinIgnore = {
|
|
7158
|
-
nonbuiltinIgnore: {
|
|
7159
|
-
test: function test(x) {
|
|
7160
|
-
return x && _typeof$1(x) === 'object' && !Array.isArray(x) && !['Object', // `Proxy` and `Reflect`, two other built-in objects, will also
|
|
7161
|
-
// have a `toStringTag` of `Object`; we don't want built-in
|
|
7162
|
-
// function objects, however
|
|
7163
|
-
'Boolean', 'Number', 'String', 'Error', 'RegExp', 'Math', 'Date', 'Map', 'Set', 'JSON', 'ArrayBuffer', 'SharedArrayBuffer', 'DataView', 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array', 'Promise', 'String Iterator', 'Array Iterator', 'Map Iterator', 'Set Iterator', 'WeakMap', 'WeakSet', 'Atomics', 'Module'].includes(Typeson.toStringTag(x));
|
|
7164
|
-
},
|
|
7165
|
-
replace: function replace(rexp) {// Not in use
|
|
7166
|
-
}
|
|
7167
|
-
}
|
|
7168
|
-
};
|
|
7169
|
-
|
|
7170
|
-
var primitiveObjects = {
|
|
7171
|
-
// String Object (not primitive string which need no type spec)
|
|
5762
|
+
},
|
|
5763
|
+
M = {
|
|
7172
5764
|
StringObject: {
|
|
7173
|
-
test: function test(
|
|
7174
|
-
return
|
|
5765
|
+
test: function test(e) {
|
|
5766
|
+
return "String" === toStringTag(e) && "object" == _typeof$2(e);
|
|
7175
5767
|
},
|
|
7176
|
-
replace: function replace(
|
|
7177
|
-
return String(
|
|
5768
|
+
replace: function replace(e) {
|
|
5769
|
+
return String(e);
|
|
7178
5770
|
},
|
|
7179
|
-
|
|
7180
|
-
|
|
7181
|
-
|
|
7182
|
-
} // Revive to an objectified string
|
|
7183
|
-
|
|
5771
|
+
revive: function revive(e) {
|
|
5772
|
+
return new String(e);
|
|
5773
|
+
}
|
|
7184
5774
|
},
|
|
7185
|
-
// Boolean Object (not primitive boolean which need no type spec)
|
|
7186
5775
|
BooleanObject: {
|
|
7187
|
-
test: function test(
|
|
7188
|
-
return
|
|
5776
|
+
test: function test(e) {
|
|
5777
|
+
return "Boolean" === toStringTag(e) && "object" == _typeof$2(e);
|
|
7189
5778
|
},
|
|
7190
|
-
replace: function replace(
|
|
7191
|
-
return Boolean(
|
|
5779
|
+
replace: function replace(e) {
|
|
5780
|
+
return Boolean(e);
|
|
7192
5781
|
},
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
// Revive to an objectified Boolean
|
|
7196
|
-
return new Boolean(b);
|
|
5782
|
+
revive: function revive(e) {
|
|
5783
|
+
return new Boolean(e);
|
|
7197
5784
|
}
|
|
7198
5785
|
},
|
|
7199
|
-
// Number Object (not primitive number which need no type spec)
|
|
7200
5786
|
NumberObject: {
|
|
7201
|
-
test: function test(
|
|
7202
|
-
return
|
|
5787
|
+
test: function test(e) {
|
|
5788
|
+
return "Number" === toStringTag(e) && "object" == _typeof$2(e);
|
|
7203
5789
|
},
|
|
7204
|
-
replace: function replace(
|
|
7205
|
-
return Number(
|
|
5790
|
+
replace: function replace(e) {
|
|
5791
|
+
return Number(e);
|
|
7206
5792
|
},
|
|
7207
|
-
|
|
7208
|
-
|
|
7209
|
-
|
|
7210
|
-
} // Revive to an objectified number
|
|
7211
|
-
|
|
5793
|
+
revive: function revive(e) {
|
|
5794
|
+
return new Number(e);
|
|
5795
|
+
}
|
|
7212
5796
|
}
|
|
7213
|
-
}
|
|
7214
|
-
|
|
7215
|
-
var regexp = {
|
|
5797
|
+
},
|
|
5798
|
+
$ = {
|
|
7216
5799
|
regexp: {
|
|
7217
|
-
test: function test(
|
|
7218
|
-
return
|
|
5800
|
+
test: function test(e) {
|
|
5801
|
+
return "RegExp" === toStringTag(e);
|
|
7219
5802
|
},
|
|
7220
|
-
replace: function replace(
|
|
5803
|
+
replace: function replace(e) {
|
|
7221
5804
|
return {
|
|
7222
|
-
source:
|
|
7223
|
-
flags: (
|
|
5805
|
+
source: e.source,
|
|
5806
|
+
flags: (e.global ? "g" : "") + (e.ignoreCase ? "i" : "") + (e.multiline ? "m" : "") + (e.sticky ? "y" : "") + (e.unicode ? "u" : "")
|
|
7224
5807
|
};
|
|
7225
5808
|
},
|
|
7226
|
-
revive: function revive(
|
|
7227
|
-
var
|
|
7228
|
-
|
|
7229
|
-
return new RegExp(
|
|
7230
|
-
}
|
|
7231
|
-
}
|
|
7232
|
-
};
|
|
7233
|
-
|
|
7234
|
-
var resurrectableObjectsByUUID = {};
|
|
7235
|
-
var resurrectable = {
|
|
7236
|
-
resurrectable: {
|
|
7237
|
-
test: function test(x) {
|
|
7238
|
-
return x && !Array.isArray(x) && ['object', 'function', 'symbol'].includes(_typeof$1(x));
|
|
7239
|
-
},
|
|
7240
|
-
replace: function replace(rsrrctble) {
|
|
7241
|
-
var uuid = generateUUID();
|
|
7242
|
-
resurrectableObjectsByUUID[uuid] = rsrrctble;
|
|
7243
|
-
return uuid;
|
|
7244
|
-
},
|
|
7245
|
-
revive: function revive(serializedResurrectable) {
|
|
7246
|
-
return resurrectableObjectsByUUID[serializedResurrectable];
|
|
5809
|
+
revive: function revive(_ref9) {
|
|
5810
|
+
var e = _ref9.source,
|
|
5811
|
+
t = _ref9.flags;
|
|
5812
|
+
return new RegExp(e, t);
|
|
7247
5813
|
}
|
|
7248
5814
|
}
|
|
7249
|
-
}
|
|
7250
|
-
|
|
7251
|
-
var set = {
|
|
5815
|
+
},
|
|
5816
|
+
Y = {
|
|
7252
5817
|
set: {
|
|
7253
|
-
test: function test(
|
|
7254
|
-
return
|
|
5818
|
+
test: function test(e) {
|
|
5819
|
+
return "Set" === toStringTag(e);
|
|
7255
5820
|
},
|
|
7256
|
-
replace: function replace(
|
|
7257
|
-
return _toConsumableArray(
|
|
5821
|
+
replace: function replace(e) {
|
|
5822
|
+
return _toConsumableArray(e.values());
|
|
7258
5823
|
},
|
|
7259
|
-
revive: function revive(
|
|
7260
|
-
return new Set(
|
|
7261
|
-
}
|
|
7262
|
-
}
|
|
7263
|
-
}
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
|
|
7271
|
-
|
|
7272
|
-
var arrType = typeName;
|
|
7273
|
-
var TypedArray = _global$1[typeName];
|
|
7274
|
-
/* istanbul ignore if */
|
|
7275
|
-
|
|
7276
|
-
if (!TypedArray) {
|
|
7277
|
-
return;
|
|
7278
|
-
}
|
|
7279
|
-
|
|
7280
|
-
typedArraysSocketIO[typeName.toLowerCase()] = {
|
|
7281
|
-
test: function test(x) {
|
|
7282
|
-
return Typeson.toStringTag(x) === arrType;
|
|
5824
|
+
revive: function revive(e) {
|
|
5825
|
+
return new Set(e);
|
|
5826
|
+
}
|
|
5827
|
+
}
|
|
5828
|
+
},
|
|
5829
|
+
q = "undefined" == typeof self ? global : self,
|
|
5830
|
+
W = {};
|
|
5831
|
+
["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"].forEach(function (e) {
|
|
5832
|
+
var t = e,
|
|
5833
|
+
r = q[e];
|
|
5834
|
+
r && (W[e.toLowerCase()] = {
|
|
5835
|
+
test: function test(e) {
|
|
5836
|
+
return toStringTag(e) === t;
|
|
7283
5837
|
},
|
|
7284
|
-
replace: function replace(
|
|
7285
|
-
return (
|
|
7286
|
-
// If we have a typed array representing a portion
|
|
7287
|
-
// of the buffer, we need to clone
|
|
7288
|
-
// the buffer before leaving it to socket.io.
|
|
7289
|
-
: a.slice(0)).buffer;
|
|
5838
|
+
replace: function replace(e) {
|
|
5839
|
+
return (0 === e.byteOffset && e.byteLength === e.buffer.byteLength ? e : e.slice(0)).buffer;
|
|
7290
5840
|
},
|
|
7291
|
-
revive: function revive(
|
|
7292
|
-
|
|
7293
|
-
// Buffer or Blob.
|
|
7294
|
-
// We should therefore not rely on that the instance we
|
|
7295
|
-
// get here is an ArrayBuffer
|
|
7296
|
-
// If not, let's assume user wants to receive it as
|
|
7297
|
-
// configured with socket.io.
|
|
7298
|
-
return Typeson.toStringTag(buf) === 'ArrayBuffer' ? new TypedArray(buf) : buf;
|
|
5841
|
+
revive: function revive(e) {
|
|
5842
|
+
return "ArrayBuffer" === toStringTag(e) ? new r(e) : e;
|
|
7299
5843
|
}
|
|
7300
|
-
};
|
|
5844
|
+
});
|
|
7301
5845
|
});
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
|
|
7309
|
-
|
|
7310
|
-
var TypedArray = _global[arrType];
|
|
7311
|
-
/* istanbul ignore if */
|
|
7312
|
-
|
|
7313
|
-
if (!TypedArray) {
|
|
7314
|
-
return;
|
|
7315
|
-
}
|
|
7316
|
-
|
|
7317
|
-
typedArrays[typeName.toLowerCase()] = {
|
|
7318
|
-
test: function test(x) {
|
|
7319
|
-
return Typeson.toStringTag(x) === arrType;
|
|
5846
|
+
var G = "undefined" == typeof self ? global : self,
|
|
5847
|
+
H = {};
|
|
5848
|
+
["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"].forEach(function (e) {
|
|
5849
|
+
var t = e,
|
|
5850
|
+
r = G[t];
|
|
5851
|
+
r && (H[e.toLowerCase()] = {
|
|
5852
|
+
test: function test(e) {
|
|
5853
|
+
return toStringTag(e) === t;
|
|
7320
5854
|
},
|
|
7321
|
-
replace: function replace(
|
|
7322
|
-
var
|
|
7323
|
-
|
|
7324
|
-
|
|
7325
|
-
|
|
7326
|
-
|
|
7327
|
-
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
length: l
|
|
7337
|
-
};
|
|
7338
|
-
}
|
|
7339
|
-
|
|
7340
|
-
stateObj.buffers.push(buffer);
|
|
7341
|
-
return {
|
|
7342
|
-
encoded: encode$1(buffer),
|
|
7343
|
-
byteOffset: byteOffset,
|
|
7344
|
-
length: l
|
|
7345
|
-
};
|
|
5855
|
+
replace: function replace(_ref10, n) {
|
|
5856
|
+
var e = _ref10.buffer,
|
|
5857
|
+
t = _ref10.byteOffset,
|
|
5858
|
+
r = _ref10.length;
|
|
5859
|
+
n.buffers || (n.buffers = []);
|
|
5860
|
+
var a = n.buffers.indexOf(e);
|
|
5861
|
+
return a > -1 ? {
|
|
5862
|
+
index: a,
|
|
5863
|
+
byteOffset: t,
|
|
5864
|
+
length: r
|
|
5865
|
+
} : (n.buffers.push(e), {
|
|
5866
|
+
encoded: v(e),
|
|
5867
|
+
byteOffset: t,
|
|
5868
|
+
length: r
|
|
5869
|
+
});
|
|
7346
5870
|
},
|
|
7347
|
-
revive: function revive(
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
index = b64Obj.index;
|
|
7356
|
-
var buffer;
|
|
7357
|
-
|
|
7358
|
-
if ('index' in b64Obj) {
|
|
7359
|
-
buffer = stateObj.buffers[index];
|
|
7360
|
-
} else {
|
|
7361
|
-
buffer = decode$1(encoded);
|
|
7362
|
-
stateObj.buffers.push(buffer);
|
|
7363
|
-
}
|
|
7364
|
-
|
|
7365
|
-
return new TypedArray(buffer, byteOffset, len);
|
|
5871
|
+
revive: function revive(e, t) {
|
|
5872
|
+
t.buffers || (t.buffers = []);
|
|
5873
|
+
var n = e.byteOffset,
|
|
5874
|
+
a = e.length,
|
|
5875
|
+
o = e.encoded,
|
|
5876
|
+
i = e.index;
|
|
5877
|
+
var s;
|
|
5878
|
+
return "index" in e ? s = t.buffers[i] : (s = b(o), t.buffers.push(s)), new r(s, n, a);
|
|
7366
5879
|
}
|
|
7367
|
-
};
|
|
5880
|
+
});
|
|
7368
5881
|
});
|
|
7369
|
-
|
|
7370
|
-
// This does not preserve `undefined` in sparse arrays; see the `undefined`
|
|
7371
|
-
var undef$1 = {
|
|
5882
|
+
var X = {
|
|
7372
5883
|
undef: {
|
|
7373
|
-
test: function test(
|
|
7374
|
-
return
|
|
5884
|
+
test: function test(e, t) {
|
|
5885
|
+
return void 0 === e && (t.ownKeys || !("ownKeys" in t));
|
|
7375
5886
|
},
|
|
7376
|
-
replace: function replace(
|
|
5887
|
+
replace: function replace(e) {
|
|
7377
5888
|
return 0;
|
|
7378
5889
|
},
|
|
7379
|
-
revive: function revive(
|
|
7380
|
-
|
|
7381
|
-
// avoid explicitly setting)
|
|
7382
|
-
return new Typeson.Undefined();
|
|
5890
|
+
revive: function revive(e) {
|
|
5891
|
+
return new l();
|
|
7383
5892
|
}
|
|
7384
5893
|
}
|
|
7385
|
-
}
|
|
7386
|
-
|
|
7387
|
-
var userObject = {
|
|
5894
|
+
},
|
|
5895
|
+
z = {
|
|
7388
5896
|
userObject: {
|
|
7389
|
-
test: function test(
|
|
7390
|
-
return
|
|
5897
|
+
test: function test(e, t) {
|
|
5898
|
+
return isUserObject(e);
|
|
7391
5899
|
},
|
|
7392
|
-
replace: function replace(
|
|
7393
|
-
return _objectSpread2({},
|
|
5900
|
+
replace: function replace(e) {
|
|
5901
|
+
return _objectSpread2$1({}, e);
|
|
7394
5902
|
},
|
|
7395
|
-
revive: function revive(
|
|
7396
|
-
return
|
|
5903
|
+
revive: function revive(e) {
|
|
5904
|
+
return e;
|
|
7397
5905
|
}
|
|
7398
5906
|
}
|
|
7399
|
-
}
|
|
7400
|
-
|
|
7401
|
-
var arrayNonindexKeys = [{
|
|
5907
|
+
},
|
|
5908
|
+
Q = [{
|
|
7402
5909
|
arrayNonindexKeys: {
|
|
7403
|
-
testPlainObjects:
|
|
7404
|
-
test: function test(
|
|
7405
|
-
|
|
7406
|
-
|
|
7407
|
-
|
|
7408
|
-
// size and improve revival performance; arrays with
|
|
7409
|
-
// non-index keys will be larger however
|
|
7410
|
-
Object.keys(x).some(function (k) {
|
|
7411
|
-
// No need to check for `isNaN` or
|
|
7412
|
-
// `isNaN(Number.parseInt())` as `NaN` will be
|
|
7413
|
-
// treated as a string.
|
|
7414
|
-
// No need to do check as
|
|
7415
|
-
// `Number.parseInt(Number())` since scientific
|
|
7416
|
-
// notation will be pre-resolved if a number
|
|
7417
|
-
// was given, and it will otherwise be a string
|
|
7418
|
-
return String(Number.parseInt(k)) !== k;
|
|
7419
|
-
})) {
|
|
7420
|
-
stateObj.iterateIn = 'object';
|
|
7421
|
-
stateObj.addLength = true;
|
|
7422
|
-
}
|
|
7423
|
-
|
|
7424
|
-
return true;
|
|
7425
|
-
}
|
|
7426
|
-
|
|
7427
|
-
return false;
|
|
5910
|
+
testPlainObjects: !0,
|
|
5911
|
+
test: function test(e, t) {
|
|
5912
|
+
return !!Array.isArray(e) && (Object.keys(e).some(function (e) {
|
|
5913
|
+
return String(Number.parseInt(e)) !== e;
|
|
5914
|
+
}) && (t.iterateIn = "object", t.addLength = !0), !0);
|
|
7428
5915
|
},
|
|
7429
|
-
replace: function replace(
|
|
7430
|
-
|
|
7431
|
-
stateObj.iterateUnsetNumeric = true;
|
|
7432
|
-
return a;
|
|
5916
|
+
replace: function replace(e, t) {
|
|
5917
|
+
return t.iterateUnsetNumeric = !0, e;
|
|
7433
5918
|
},
|
|
7434
|
-
revive: function revive(
|
|
7435
|
-
if (Array.isArray(
|
|
7436
|
-
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
|
|
7441
|
-
// Todo: Reenable when Node `engines` >= 7
|
|
7442
|
-
// Object.entries(o).forEach(([key, val]) => {
|
|
7443
|
-
|
|
7444
|
-
Object.keys(o).forEach(function (key) {
|
|
7445
|
-
var val = o[key];
|
|
7446
|
-
arr[key] = val;
|
|
7447
|
-
});
|
|
7448
|
-
return arr;
|
|
5919
|
+
revive: function revive(e) {
|
|
5920
|
+
if (Array.isArray(e)) return e;
|
|
5921
|
+
var t = [];
|
|
5922
|
+
return Object.keys(e).forEach(function (r) {
|
|
5923
|
+
var n = e[r];
|
|
5924
|
+
t[r] = n;
|
|
5925
|
+
}), t;
|
|
7449
5926
|
}
|
|
7450
5927
|
}
|
|
7451
5928
|
}, {
|
|
7452
5929
|
sparseUndefined: {
|
|
7453
|
-
test: function test(
|
|
7454
|
-
return
|
|
5930
|
+
test: function test(e, t) {
|
|
5931
|
+
return void 0 === e && !1 === t.ownKeys;
|
|
7455
5932
|
},
|
|
7456
|
-
replace: function replace(
|
|
5933
|
+
replace: function replace(e) {
|
|
7457
5934
|
return 0;
|
|
7458
5935
|
},
|
|
7459
|
-
revive: function revive(
|
|
7460
|
-
return undefined;
|
|
7461
|
-
} // Will avoid adding anything
|
|
7462
|
-
|
|
7463
|
-
}
|
|
7464
|
-
}];
|
|
7465
|
-
|
|
7466
|
-
var specialNumbers = [nan, infinity, negativeInfinity];
|
|
7467
|
-
|
|
7468
|
-
/* This preset includes types that are built-in into the JavaScript
|
|
7469
|
-
language itself, this should work universally.
|
|
7470
|
-
|
|
7471
|
-
Types that were added in ES6 or beyond will be checked before inclusion
|
|
7472
|
-
so that this module can be consumed by both ES5 and ES6 environments.
|
|
7473
|
-
|
|
7474
|
-
Some types cannot be encapsulated because their inner state is private:
|
|
7475
|
-
`WeakMap`, `WeakSet`.
|
|
7476
|
-
|
|
7477
|
-
The Function type is not included because their closures would not be
|
|
7478
|
-
serialized, so a revived Function that uses closures would not behave
|
|
7479
|
-
as expected.
|
|
7480
|
-
|
|
7481
|
-
Symbols are similarly not included.
|
|
7482
|
-
*/
|
|
7483
|
-
var expObj$1 = [undef$1, // ES5
|
|
7484
|
-
arrayNonindexKeys, primitiveObjects, specialNumbers, date, error, errors, regexp].concat( // ES2015 (ES6)
|
|
7485
|
-
|
|
7486
|
-
/* istanbul ignore next */
|
|
7487
|
-
typeof Map === 'function' ? map : [],
|
|
7488
|
-
/* istanbul ignore next */
|
|
7489
|
-
typeof Set === 'function' ? set : [],
|
|
7490
|
-
/* istanbul ignore next */
|
|
7491
|
-
typeof ArrayBuffer === 'function' ? arraybuffer : [],
|
|
7492
|
-
/* istanbul ignore next */
|
|
7493
|
-
typeof Uint8Array === 'function' ? typedArrays : [],
|
|
7494
|
-
/* istanbul ignore next */
|
|
7495
|
-
typeof DataView === 'function' ? dataview : [],
|
|
7496
|
-
/* istanbul ignore next */
|
|
7497
|
-
typeof Intl !== 'undefined' ? intlTypes : [],
|
|
7498
|
-
/* istanbul ignore next */
|
|
7499
|
-
typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []);
|
|
7500
|
-
|
|
7501
|
-
/*
|
|
7502
|
-
When communicating via `postMessage()` (`Worker.postMessage()` or
|
|
7503
|
-
`window.postMessage()`), the browser will use a similar algorithm as Typeson
|
|
7504
|
-
does to encapsulate and revive all items in the structure (aka the structured
|
|
7505
|
-
clone algorithm). This algorithm supports all built-in types as well as many
|
|
7506
|
-
DOM types. Therefore, only types that are not included in the structured clone
|
|
7507
|
-
algorithm need to be registered, which is:
|
|
7508
|
-
|
|
7509
|
-
* Error
|
|
7510
|
-
* Specific Errors like SyntaxError, TypeError, etc.
|
|
7511
|
-
* Any custom type you want to send across window- or worker boundraries
|
|
7512
|
-
|
|
7513
|
-
This preset will only include the Error types and you can register your
|
|
7514
|
-
custom types after having registered these.
|
|
7515
|
-
*/
|
|
7516
|
-
var postmessage = [error, errors];
|
|
7517
|
-
|
|
7518
|
-
var socketio = [expObj$1, // Leave ArrayBuffer as is, and let socket.io stream it instead.
|
|
7519
|
-
{
|
|
7520
|
-
arraybuffer: null
|
|
7521
|
-
}, // Encapsulate TypedArrays in ArrayBuffers instead of base64 strings.
|
|
7522
|
-
typedArraysSocketIO];
|
|
7523
|
-
|
|
7524
|
-
var sparseUndefined = [{
|
|
7525
|
-
sparseArrays: {
|
|
7526
|
-
testPlainObjects: true,
|
|
7527
|
-
test: function test(x) {
|
|
7528
|
-
return Array.isArray(x);
|
|
7529
|
-
},
|
|
7530
|
-
replace: function replace(a, stateObj) {
|
|
7531
|
-
stateObj.iterateUnsetNumeric = true;
|
|
7532
|
-
return a;
|
|
7533
|
-
}
|
|
5936
|
+
revive: function revive(e) {}
|
|
7534
5937
|
}
|
|
7535
|
-
},
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
},
|
|
7540
|
-
replace: function replace(n) {
|
|
7541
|
-
return 0;
|
|
7542
|
-
},
|
|
7543
|
-
revive: function revive(s) {
|
|
7544
|
-
return undefined;
|
|
7545
|
-
} // Will avoid adding anything
|
|
7546
|
-
|
|
7547
|
-
}
|
|
7548
|
-
}];
|
|
7549
|
-
|
|
7550
|
-
/* This preset includes types for the Structured Cloning Algorithm. */
|
|
7551
|
-
var expObj = [// Todo: Might also register synchronous `ImageBitmap` and
|
|
7552
|
-
// `Blob`/`File`/`FileList`?
|
|
7553
|
-
// ES5
|
|
7554
|
-
userObject, // Processed last (non-builtin)
|
|
7555
|
-
undef$1, arrayNonindexKeys, primitiveObjects, specialNumbers, date, regexp, // Non-built-ins
|
|
7556
|
-
imagedata, imagebitmap, // Async return
|
|
7557
|
-
file, filelist, blob].concat( // ES2015 (ES6)
|
|
7558
|
-
|
|
7559
|
-
/* istanbul ignore next */
|
|
7560
|
-
typeof Map === 'function' ? map : [],
|
|
7561
|
-
/* istanbul ignore next */
|
|
7562
|
-
typeof Set === 'function' ? set : [],
|
|
7563
|
-
/* istanbul ignore next */
|
|
7564
|
-
typeof ArrayBuffer === 'function' ? arraybuffer : [],
|
|
7565
|
-
/* istanbul ignore next */
|
|
7566
|
-
typeof Uint8Array === 'function' ? typedArrays : [],
|
|
7567
|
-
/* istanbul ignore next */
|
|
7568
|
-
typeof DataView === 'function' ? dataview : [],
|
|
7569
|
-
/* istanbul ignore next */
|
|
7570
|
-
typeof Intl !== 'undefined' ? intlTypes : [],
|
|
7571
|
-
/* istanbul ignore next */
|
|
7572
|
-
typeof crypto !== 'undefined' ? cryptokey : [],
|
|
7573
|
-
/* istanbul ignore next */
|
|
7574
|
-
typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []);
|
|
7575
|
-
|
|
7576
|
-
var structuredCloningThrowing = expObj.concat({
|
|
5938
|
+
}],
|
|
5939
|
+
Z = [L, k, F],
|
|
5940
|
+
ae = [z, X, Q, M, Z, j, $, x, E, N, C, O].concat("function" == typeof Map ? K : [], "function" == typeof Set ? Y : [], "function" == typeof ArrayBuffer ? h : [], "function" == typeof Uint8Array ? H : [], "function" == typeof DataView ? A : [], "undefined" != typeof Intl ? U : [], "undefined" != typeof crypto ? w : [], "undefined" != typeof BigInt ? [m, g] : []);
|
|
5941
|
+
var oe = ae.concat({
|
|
7577
5942
|
checkDataCloneException: {
|
|
7578
|
-
test: function test(
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
// 2. `IsCallable` (covered by `typeof === 'function'` or a
|
|
7583
|
-
// function's `toStringTag`)
|
|
7584
|
-
// 3. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
|
|
7585
|
-
// [[PromiseState]] or [[WeakMapData]])
|
|
7586
|
-
// 4. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
|
|
7587
|
-
// intrinsic object) (which does not have default
|
|
7588
|
-
// behavior for one or more of the essential internal methods
|
|
7589
|
-
// that are limited to the following for non-function objects
|
|
7590
|
-
// (we auto-exclude functions):
|
|
7591
|
-
// [[GetPrototypeOf]],[[SetPrototypeOf]],[[IsExtensible]],
|
|
7592
|
-
// [[PreventExtensions]],[[GetOwnProperty]],
|
|
7593
|
-
// [[DefineOwnProperty]],[[HasProperty]],
|
|
7594
|
-
// [[Get]],[[Set]],[[Delete]],[[OwnPropertyKeys]]);
|
|
7595
|
-
// except for the standard, built-in exotic objects, we'd need
|
|
7596
|
-
// to know whether these methods had distinct behaviors
|
|
7597
|
-
// Note: There is no apparent way for us to detect a `Proxy` and
|
|
7598
|
-
// reject (Chrome at least is not rejecting anyways)
|
|
7599
|
-
var stringTag = {}.toString.call(val).slice(8, -1);
|
|
7600
|
-
|
|
7601
|
-
if ([// Symbol's `toStringTag` is only "Symbol" for its initial
|
|
7602
|
-
// value, so we check `typeof`
|
|
7603
|
-
'symbol', // All functions including bound function exotic objects
|
|
7604
|
-
'function'].includes(_typeof$1(val)) || [// A non-array exotic object
|
|
7605
|
-
'Arguments', // A non-array exotic object
|
|
7606
|
-
'Module', // `Error` and other errors have the [[ErrorData]] internal
|
|
7607
|
-
// slot and give "Error"
|
|
7608
|
-
'Error', // Promise instances have an extra slot ([[PromiseState]])
|
|
7609
|
-
// but not throwing in Chrome `postMessage`
|
|
7610
|
-
'Promise', // WeakMap instances have an extra slot ([[WeakMapData]])
|
|
7611
|
-
// but not throwing in Chrome `postMessage`
|
|
7612
|
-
'WeakMap', // WeakSet instances have an extra slot ([[WeakSetData]])
|
|
7613
|
-
// but not throwing in Chrome `postMessage`
|
|
7614
|
-
'WeakSet', // HTML-SPECIFIC
|
|
7615
|
-
'Event', // Also in Node `worker_threads` (currently experimental)
|
|
7616
|
-
'MessageChannel'].includes(stringTag) ||
|
|
7617
|
-
/*
|
|
7618
|
-
// isClosed is no longer documented
|
|
7619
|
-
((stringTag === 'Blob' || stringTag === 'File') &&
|
|
7620
|
-
val.isClosed) ||
|
|
7621
|
-
*/
|
|
7622
|
-
val && _typeof$1(val) === 'object' && // Duck-type DOM node objects (non-array exotic?
|
|
7623
|
-
// objects which cannot be cloned by the SCA)
|
|
7624
|
-
typeof val.nodeType === 'number' && typeof val.insertBefore === 'function') {
|
|
7625
|
-
throw new DOMException('The object cannot be cloned.', 'DataCloneError');
|
|
7626
|
-
}
|
|
7627
|
-
|
|
7628
|
-
return false;
|
|
5943
|
+
test: function test(e) {
|
|
5944
|
+
var t = {}.toString.call(e).slice(8, -1);
|
|
5945
|
+
if (["symbol", "function"].includes(_typeof$2(e)) || ["Arguments", "Module", "Error", "Promise", "WeakMap", "WeakSet", "Event", "MessageChannel"].includes(t) || e && "object" == _typeof$2(e) && "number" == typeof e.nodeType && "function" == typeof e.insertBefore) throw new DOMException("The object cannot be cloned.", "DataCloneError");
|
|
5946
|
+
return !1;
|
|
7629
5947
|
}
|
|
7630
5948
|
}
|
|
7631
5949
|
});
|
|
7632
5950
|
|
|
7633
|
-
var
|
|
7634
|
-
|
|
7635
|
-
var universal = [expObj$1 // TODO: Add types that are de-facto universal even though not
|
|
7636
|
-
// built-in into ecmasript standard.
|
|
7637
|
-
];
|
|
7638
|
-
|
|
7639
|
-
// This file is auto-generated from `build.js`
|
|
7640
|
-
Typeson.types = {
|
|
7641
|
-
arraybuffer: arraybuffer,
|
|
7642
|
-
bigintObject: bigintObject,
|
|
7643
|
-
bigint: bigint,
|
|
7644
|
-
blob: blob,
|
|
7645
|
-
cloneable: cloneable,
|
|
7646
|
-
cryptokey: cryptokey,
|
|
7647
|
-
dataview: dataview,
|
|
7648
|
-
date: date,
|
|
7649
|
-
error: error,
|
|
7650
|
-
errors: errors,
|
|
7651
|
-
file: file,
|
|
7652
|
-
filelist: filelist,
|
|
7653
|
-
imagebitmap: imagebitmap,
|
|
7654
|
-
imagedata: imagedata,
|
|
7655
|
-
infinity: infinity,
|
|
7656
|
-
intlTypes: intlTypes,
|
|
7657
|
-
map: map,
|
|
7658
|
-
nan: nan,
|
|
7659
|
-
negativeInfinity: negativeInfinity,
|
|
7660
|
-
nonbuiltinIgnore: nonbuiltinIgnore,
|
|
7661
|
-
primitiveObjects: primitiveObjects,
|
|
7662
|
-
regexp: regexp,
|
|
7663
|
-
resurrectable: resurrectable,
|
|
7664
|
-
set: set,
|
|
7665
|
-
typedArraysSocketio: typedArraysSocketIO,
|
|
7666
|
-
typedArrays: typedArrays,
|
|
7667
|
-
undef: undef$1,
|
|
7668
|
-
userObject: userObject
|
|
7669
|
-
};
|
|
7670
|
-
Typeson.presets = {
|
|
7671
|
-
arrayNonindexKeys: arrayNonindexKeys,
|
|
7672
|
-
builtin: expObj$1,
|
|
7673
|
-
postmessage: postmessage,
|
|
7674
|
-
socketio: socketio,
|
|
7675
|
-
sparseUndefined: sparseUndefined,
|
|
7676
|
-
specialNumbers: specialNumbers,
|
|
7677
|
-
structuredCloningThrowing: structuredCloningThrowing,
|
|
7678
|
-
structuredCloning: expObj,
|
|
7679
|
-
undef: undef,
|
|
7680
|
-
universal: universal
|
|
7681
|
-
};
|
|
7682
|
-
|
|
7683
|
-
var typeson = new Typeson().register(Typeson.presets.structuredCloningThrowing);
|
|
5951
|
+
var typeson = new u().register(oe);
|
|
7684
5952
|
|
|
7685
5953
|
function register(func) {
|
|
7686
|
-
typeson = new
|
|
5954
|
+
typeson = new u().register(func(oe));
|
|
7687
5955
|
} // We are keeping the callback approach for now in case we wish to reexpose
|
|
7688
5956
|
// `Blob`, `File`, `FileList` asynchronously (though in such a case, we
|
|
7689
5957
|
// should probably refactor as a Promise)
|
|
@@ -7697,11 +5965,11 @@
|
|
|
7697
5965
|
ret = typeson.stringifySync(obj);
|
|
7698
5966
|
} catch (err) {
|
|
7699
5967
|
// SCA in typeson-registry using `DOMException` which is not defined (e.g., in Node)
|
|
7700
|
-
if (
|
|
5968
|
+
if (hasConstructorOf(err, ReferenceError) || // SCA in typeson-registry threw a cloning error and we are in a
|
|
7701
5969
|
// supporting environment (e.g., the browser) where `ShimDOMException` is
|
|
7702
5970
|
// an alias for `DOMException`; if typeson-registry ever uses our shim
|
|
7703
5971
|
// to throw, we can use this condition alone.
|
|
7704
|
-
|
|
5972
|
+
hasConstructorOf(err, ShimDOMException)) {
|
|
7705
5973
|
throw createDOMException('DataCloneError', 'The object cannot be cloned.');
|
|
7706
5974
|
} // We should rethrow non-cloning exceptions like from
|
|
7707
5975
|
// throwing getters (as in the W3C test, key-conversion-exceptions.htm)
|
|
@@ -8903,7 +7171,7 @@
|
|
|
8903
7171
|
}
|
|
8904
7172
|
|
|
8905
7173
|
Object.entries(paramMap).forEach(function (_ref) {
|
|
8906
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
7174
|
+
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
8907
7175
|
key = _ref2[0],
|
|
8908
7176
|
stmt = _ref2[1];
|
|
8909
7177
|
|
|
@@ -8964,7 +7232,7 @@
|
|
|
8964
7232
|
var request = me.transaction.__createRequest(me);
|
|
8965
7233
|
|
|
8966
7234
|
var _me$__validateKeyAndV = me.__validateKeyAndValueAndCloneValue(value, key, false),
|
|
8967
|
-
_me$__validateKeyAndV2 = _slicedToArray(_me$__validateKeyAndV, 2),
|
|
7235
|
+
_me$__validateKeyAndV2 = _slicedToArray$1(_me$__validateKeyAndV, 2),
|
|
8968
7236
|
ky = _me$__validateKeyAndV2[0],
|
|
8969
7237
|
clonedValue = _me$__validateKeyAndV2[1];
|
|
8970
7238
|
|
|
@@ -8997,7 +7265,7 @@
|
|
|
8997
7265
|
var request = me.transaction.__createRequest(me);
|
|
8998
7266
|
|
|
8999
7267
|
var _me$__validateKeyAndV3 = me.__validateKeyAndValueAndCloneValue(value, key, false),
|
|
9000
|
-
_me$__validateKeyAndV4 = _slicedToArray(_me$__validateKeyAndV3, 2),
|
|
7268
|
+
_me$__validateKeyAndV4 = _slicedToArray$1(_me$__validateKeyAndV3, 2),
|
|
9001
7269
|
ky = _me$__validateKeyAndV4[0],
|
|
9002
7270
|
clonedValue = _me$__validateKeyAndV4[1];
|
|
9003
7271
|
|
|
@@ -9771,7 +8039,7 @@
|
|
|
9771
8039
|
|
|
9772
8040
|
IDBTransaction.__assertActive(this.__versionTransaction);
|
|
9773
8041
|
|
|
9774
|
-
createOptions = _objectSpread2({}, createOptions);
|
|
8042
|
+
createOptions = _objectSpread2$1({}, createOptions);
|
|
9775
8043
|
var _createOptions = createOptions,
|
|
9776
8044
|
keyPath = _createOptions.keyPath;
|
|
9777
8045
|
keyPath = keyPath === undefined ? null : convertToSequenceDOMString(keyPath);
|
|
@@ -9976,7 +8244,7 @@
|
|
|
9976
8244
|
};
|
|
9977
8245
|
|
|
9978
8246
|
var getOrigin = function getOrigin() {
|
|
9979
|
-
return (typeof location === "undefined" ? "undefined" : _typeof$
|
|
8247
|
+
return (typeof location === "undefined" ? "undefined" : _typeof$2(location)) !== 'object' || !location ? 'null' : location.origin;
|
|
9980
8248
|
};
|
|
9981
8249
|
|
|
9982
8250
|
var hasNullOrigin = function hasNullOrigin() {
|
|
@@ -11448,7 +9716,7 @@
|
|
|
11448
9716
|
|
|
11449
9717
|
if (me.__store.keyPath !== null) {
|
|
11450
9718
|
var _me$__store$__validat = me.__store.__validateKeyAndValueAndCloneValue(valueToUpdate, undefined, true),
|
|
11451
|
-
_me$__store$__validat2 = _slicedToArray(_me$__store$__validat, 2),
|
|
9719
|
+
_me$__store$__validat2 = _slicedToArray$1(_me$__store$__validat, 2),
|
|
11452
9720
|
evaluatedKey = _me$__store$__validat2[0],
|
|
11453
9721
|
clonedValue = _me$__store$__validat2[1];
|
|
11454
9722
|
|
|
@@ -11547,9 +9815,9 @@
|
|
|
11547
9815
|
});
|
|
11548
9816
|
|
|
11549
9817
|
function setConfig(prop, val) {
|
|
11550
|
-
if (prop && _typeof$
|
|
9818
|
+
if (prop && _typeof$2(prop) === 'object') {
|
|
11551
9819
|
Object.entries(prop).forEach(function (_ref) {
|
|
11552
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
9820
|
+
var _ref2 = _slicedToArray$1(_ref, 2),
|
|
11553
9821
|
p = _ref2[0],
|
|
11554
9822
|
val = _ref2[1];
|
|
11555
9823
|
|
|
@@ -11574,7 +9842,7 @@
|
|
|
11574
9842
|
setConfig(initialConfig);
|
|
11575
9843
|
}
|
|
11576
9844
|
|
|
11577
|
-
var IDB = idb || (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : typeof global
|
|
9845
|
+
var IDB = idb || (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : typeof global !== 'undefined' ? global : {});
|
|
11578
9846
|
|
|
11579
9847
|
function shim(name, value, propDesc) {
|
|
11580
9848
|
if (!propDesc || !Object.defineProperty) {
|
|
@@ -11677,7 +9945,7 @@
|
|
|
11677
9945
|
}
|
|
11678
9946
|
});
|
|
11679
9947
|
[['IDBFactory', shimIDBFactory], ['IDBDatabase', IDBDatabase], ['IDBObjectStore', IDBObjectStore], ['IDBIndex', IDBIndex], ['IDBTransaction', IDBTransaction], ['IDBCursor', IDBCursor], ['IDBCursorWithValue', IDBCursorWithValue], ['IDBKeyRange', IDBKeyRange], ['IDBRequest', IDBRequest], ['IDBOpenDBRequest', IDBOpenDBRequest], ['IDBVersionChangeEvent', IDBVersionChangeEvent]].forEach(function (_ref3) {
|
|
11680
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
9948
|
+
var _ref4 = _slicedToArray$1(_ref3, 2),
|
|
11681
9949
|
prop = _ref4[0],
|
|
11682
9950
|
obj = _ref4[1];
|
|
11683
9951
|
|