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