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,4 +1,4 @@
1
- /*! indexeddbshim - v9.0.0 - 1/5/2022 */
1
+ /*! indexeddbshim - v9.0.0 - 2/26/2022 */
2
2
 
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -11,7 +11,7 @@
11
11
 
12
12
  var UnicodeIDContinue = "(?:[$0-9A-Z_a-z\\xAA\\xB5\\xB7\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B4\\u08B6-\\u08BD\\u08D4-\\u08E1\\u08E3-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0AF9\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58-\\u0C5A\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C80-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D54-\\u0D57\\u0D5F-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1369-\\u1371\\u1380-\\u138F\\u13A0-\\u13F5\\u13F8-\\u13FD\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19DA\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1C80-\\u1C88\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFB-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2118-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FD5\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA7AE\\uA7B0-\\uA7B7\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C5\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA8FD\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB65\\uAB70-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2F\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]|\\uD800[\\uDC00-\\uDC0B\\uDC0D-\\uDC26\\uDC28-\\uDC3A\\uDC3C\\uDC3D\\uDC3F-\\uDC4D\\uDC50-\\uDC5D\\uDC80-\\uDCFA\\uDD40-\\uDD74\\uDDFD\\uDE80-\\uDE9C\\uDEA0-\\uDED0\\uDEE0\\uDF00-\\uDF1F\\uDF30-\\uDF4A\\uDF50-\\uDF7A\\uDF80-\\uDF9D\\uDFA0-\\uDFC3\\uDFC8-\\uDFCF\\uDFD1-\\uDFD5]|\\uD801[\\uDC00-\\uDC9D\\uDCA0-\\uDCA9\\uDCB0-\\uDCD3\\uDCD8-\\uDCFB\\uDD00-\\uDD27\\uDD30-\\uDD63\\uDE00-\\uDF36\\uDF40-\\uDF55\\uDF60-\\uDF67]|\\uD802[\\uDC00-\\uDC05\\uDC08\\uDC0A-\\uDC35\\uDC37\\uDC38\\uDC3C\\uDC3F-\\uDC55\\uDC60-\\uDC76\\uDC80-\\uDC9E\\uDCE0-\\uDCF2\\uDCF4\\uDCF5\\uDD00-\\uDD15\\uDD20-\\uDD39\\uDD80-\\uDDB7\\uDDBE\\uDDBF\\uDE00-\\uDE03\\uDE05\\uDE06\\uDE0C-\\uDE13\\uDE15-\\uDE17\\uDE19-\\uDE33\\uDE38-\\uDE3A\\uDE3F\\uDE60-\\uDE7C\\uDE80-\\uDE9C\\uDEC0-\\uDEC7\\uDEC9-\\uDEE6\\uDF00-\\uDF35\\uDF40-\\uDF55\\uDF60-\\uDF72\\uDF80-\\uDF91]|\\uD803[\\uDC00-\\uDC48\\uDC80-\\uDCB2\\uDCC0-\\uDCF2]|\\uD804[\\uDC00-\\uDC46\\uDC66-\\uDC6F\\uDC7F-\\uDCBA\\uDCD0-\\uDCE8\\uDCF0-\\uDCF9\\uDD00-\\uDD34\\uDD36-\\uDD3F\\uDD50-\\uDD73\\uDD76\\uDD80-\\uDDC4\\uDDCA-\\uDDCC\\uDDD0-\\uDDDA\\uDDDC\\uDE00-\\uDE11\\uDE13-\\uDE37\\uDE3E\\uDE80-\\uDE86\\uDE88\\uDE8A-\\uDE8D\\uDE8F-\\uDE9D\\uDE9F-\\uDEA8\\uDEB0-\\uDEEA\\uDEF0-\\uDEF9\\uDF00-\\uDF03\\uDF05-\\uDF0C\\uDF0F\\uDF10\\uDF13-\\uDF28\\uDF2A-\\uDF30\\uDF32\\uDF33\\uDF35-\\uDF39\\uDF3C-\\uDF44\\uDF47\\uDF48\\uDF4B-\\uDF4D\\uDF50\\uDF57\\uDF5D-\\uDF63\\uDF66-\\uDF6C\\uDF70-\\uDF74]|\\uD805[\\uDC00-\\uDC4A\\uDC50-\\uDC59\\uDC80-\\uDCC5\\uDCC7\\uDCD0-\\uDCD9\\uDD80-\\uDDB5\\uDDB8-\\uDDC0\\uDDD8-\\uDDDD\\uDE00-\\uDE40\\uDE44\\uDE50-\\uDE59\\uDE80-\\uDEB7\\uDEC0-\\uDEC9\\uDF00-\\uDF19\\uDF1D-\\uDF2B\\uDF30-\\uDF39]|\\uD806[\\uDCA0-\\uDCE9\\uDCFF\\uDEC0-\\uDEF8]|\\uD807[\\uDC00-\\uDC08\\uDC0A-\\uDC36\\uDC38-\\uDC40\\uDC50-\\uDC59\\uDC72-\\uDC8F\\uDC92-\\uDCA7\\uDCA9-\\uDCB6]|\\uD808[\\uDC00-\\uDF99]|\\uD809[\\uDC00-\\uDC6E\\uDC80-\\uDD43]|[\\uD80C\\uD81C-\\uD820\\uD840-\\uD868\\uD86A-\\uD86C\\uD86F-\\uD872][\\uDC00-\\uDFFF]|\\uD80D[\\uDC00-\\uDC2E]|\\uD811[\\uDC00-\\uDE46]|\\uD81A[\\uDC00-\\uDE38\\uDE40-\\uDE5E\\uDE60-\\uDE69\\uDED0-\\uDEED\\uDEF0-\\uDEF4\\uDF00-\\uDF36\\uDF40-\\uDF43\\uDF50-\\uDF59\\uDF63-\\uDF77\\uDF7D-\\uDF8F]|\\uD81B[\\uDF00-\\uDF44\\uDF50-\\uDF7E\\uDF8F-\\uDF9F\\uDFE0]|\\uD821[\\uDC00-\\uDFEC]|\\uD822[\\uDC00-\\uDEF2]|\\uD82C[\\uDC00\\uDC01]|\\uD82F[\\uDC00-\\uDC6A\\uDC70-\\uDC7C\\uDC80-\\uDC88\\uDC90-\\uDC99\\uDC9D\\uDC9E]|\\uD834[\\uDD65-\\uDD69\\uDD6D-\\uDD72\\uDD7B-\\uDD82\\uDD85-\\uDD8B\\uDDAA-\\uDDAD\\uDE42-\\uDE44]|\\uD835[\\uDC00-\\uDC54\\uDC56-\\uDC9C\\uDC9E\\uDC9F\\uDCA2\\uDCA5\\uDCA6\\uDCA9-\\uDCAC\\uDCAE-\\uDCB9\\uDCBB\\uDCBD-\\uDCC3\\uDCC5-\\uDD05\\uDD07-\\uDD0A\\uDD0D-\\uDD14\\uDD16-\\uDD1C\\uDD1E-\\uDD39\\uDD3B-\\uDD3E\\uDD40-\\uDD44\\uDD46\\uDD4A-\\uDD50\\uDD52-\\uDEA5\\uDEA8-\\uDEC0\\uDEC2-\\uDEDA\\uDEDC-\\uDEFA\\uDEFC-\\uDF14\\uDF16-\\uDF34\\uDF36-\\uDF4E\\uDF50-\\uDF6E\\uDF70-\\uDF88\\uDF8A-\\uDFA8\\uDFAA-\\uDFC2\\uDFC4-\\uDFCB\\uDFCE-\\uDFFF]|\\uD836[\\uDE00-\\uDE36\\uDE3B-\\uDE6C\\uDE75\\uDE84\\uDE9B-\\uDE9F\\uDEA1-\\uDEAF]|\\uD838[\\uDC00-\\uDC06\\uDC08-\\uDC18\\uDC1B-\\uDC21\\uDC23\\uDC24\\uDC26-\\uDC2A]|\\uD83A[\\uDC00-\\uDCC4\\uDCD0-\\uDCD6\\uDD00-\\uDD4A\\uDD50-\\uDD59]|\\uD83B[\\uDE00-\\uDE03\\uDE05-\\uDE1F\\uDE21\\uDE22\\uDE24\\uDE27\\uDE29-\\uDE32\\uDE34-\\uDE37\\uDE39\\uDE3B\\uDE42\\uDE47\\uDE49\\uDE4B\\uDE4D-\\uDE4F\\uDE51\\uDE52\\uDE54\\uDE57\\uDE59\\uDE5B\\uDE5D\\uDE5F\\uDE61\\uDE62\\uDE64\\uDE67-\\uDE6A\\uDE6C-\\uDE72\\uDE74-\\uDE77\\uDE79-\\uDE7C\\uDE7E\\uDE80-\\uDE89\\uDE8B-\\uDE9B\\uDEA1-\\uDEA3\\uDEA5-\\uDEA9\\uDEAB-\\uDEBB]|\\uD869[\\uDC00-\\uDED6\\uDF00-\\uDFFF]|\\uD86D[\\uDC00-\\uDF34\\uDF40-\\uDFFF]|\\uD86E[\\uDC00-\\uDC1D\\uDC20-\\uDFFF]|\\uD873[\\uDC00-\\uDEA1]|\\uD87E[\\uDC00-\\uDE1D]|\\uDB40[\\uDD00-\\uDDEF])";
13
13
 
14
- function ownKeys(object, enumerableOnly) {
14
+ function ownKeys$1(object, enumerableOnly) {
15
15
  var keys = Object.keys(object);
16
16
 
17
17
  if (Object.getOwnPropertySymbols) {
@@ -24,12 +24,12 @@
24
24
  return keys;
25
25
  }
26
26
 
27
- function _objectSpread2(target) {
27
+ function _objectSpread2$1(target) {
28
28
  for (var i = 1; i < arguments.length; i++) {
29
29
  var source = null != arguments[i] ? arguments[i] : {};
30
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
31
- _defineProperty(target, key, source[key]);
32
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
30
+ i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
31
+ _defineProperty$1(target, key, source[key]);
32
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
33
33
  Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
34
34
  });
35
35
  }
@@ -37,23 +37,59 @@
37
37
  return target;
38
38
  }
39
39
 
40
- function _typeof$1(obj) {
40
+ function _typeof$2(obj) {
41
41
  "@babel/helpers - typeof";
42
42
 
43
- return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
43
+ return _typeof$2 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
44
44
  return typeof obj;
45
45
  } : function (obj) {
46
46
  return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
47
- }, _typeof$1(obj);
47
+ }, _typeof$2(obj);
48
+ }
49
+
50
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
51
+ try {
52
+ var info = gen[key](arg);
53
+ var value = info.value;
54
+ } catch (error) {
55
+ reject(error);
56
+ return;
57
+ }
58
+
59
+ if (info.done) {
60
+ resolve(value);
61
+ } else {
62
+ Promise.resolve(value).then(_next, _throw);
63
+ }
64
+ }
65
+
66
+ function _asyncToGenerator(fn) {
67
+ return function () {
68
+ var self = this,
69
+ args = arguments;
70
+ return new Promise(function (resolve, reject) {
71
+ var gen = fn.apply(self, args);
72
+
73
+ function _next(value) {
74
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
75
+ }
76
+
77
+ function _throw(err) {
78
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
79
+ }
80
+
81
+ _next(undefined);
82
+ });
83
+ };
48
84
  }
49
85
 
50
- function _classCallCheck(instance, Constructor) {
86
+ function _classCallCheck$1(instance, Constructor) {
51
87
  if (!(instance instanceof Constructor)) {
52
88
  throw new TypeError("Cannot call a class as a function");
53
89
  }
54
90
  }
55
91
 
56
- function _defineProperties(target, props) {
92
+ function _defineProperties$1(target, props) {
57
93
  for (var i = 0; i < props.length; i++) {
58
94
  var descriptor = props[i];
59
95
  descriptor.enumerable = descriptor.enumerable || false;
@@ -63,9 +99,9 @@
63
99
  }
64
100
  }
65
101
 
66
- function _createClass(Constructor, protoProps, staticProps) {
67
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
68
- if (staticProps) _defineProperties(Constructor, staticProps);
102
+ function _createClass$1(Constructor, protoProps, staticProps) {
103
+ if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
104
+ if (staticProps) _defineProperties$1(Constructor, staticProps);
69
105
  Object.defineProperty(Constructor, "prototype", {
70
106
  writable: false
71
107
  });
@@ -95,7 +131,7 @@
95
131
  return obj;
96
132
  }
97
133
 
98
- function _defineProperty(obj, key, value) {
134
+ function _defineProperty$1(obj, key, value) {
99
135
  if (key in obj) {
100
136
  Object.defineProperty(obj, key, {
101
137
  value: value,
@@ -149,16 +185,16 @@
149
185
  return _construct.apply(null, arguments);
150
186
  }
151
187
 
152
- function _slicedToArray(arr, i) {
153
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
188
+ function _slicedToArray$1(arr, i) {
189
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest();
154
190
  }
155
191
 
156
192
  function _toConsumableArray(arr) {
157
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
193
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread();
158
194
  }
159
195
 
160
196
  function _arrayWithoutHoles(arr) {
161
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
197
+ if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
162
198
  }
163
199
 
164
200
  function _arrayWithHoles(arr) {
@@ -199,16 +235,16 @@
199
235
  return _arr;
200
236
  }
201
237
 
202
- function _unsupportedIterableToArray(o, minLen) {
238
+ function _unsupportedIterableToArray$1(o, minLen) {
203
239
  if (!o) return;
204
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
240
+ if (typeof o === "string") return _arrayLikeToArray$1(o, minLen);
205
241
  var n = Object.prototype.toString.call(o).slice(8, -1);
206
242
  if (n === "Object" && o.constructor) n = o.constructor.name;
207
243
  if (n === "Map" || n === "Set") return Array.from(o);
208
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
244
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen);
209
245
  }
210
246
 
211
- function _arrayLikeToArray(arr, len) {
247
+ function _arrayLikeToArray$1(arr, len) {
212
248
  if (len == null || len > arr.length) len = arr.length;
213
249
 
214
250
  for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
@@ -228,7 +264,7 @@
228
264
  var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
229
265
 
230
266
  if (!it) {
231
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
267
+ if (Array.isArray(o) || (it = _unsupportedIterableToArray$1(o)) || allowArrayLike && o && typeof o.length === "number") {
232
268
  if (it) o = it;
233
269
  var i = 0;
234
270
 
@@ -281,24 +317,24 @@
281
317
  };
282
318
  }
283
319
 
284
- var global$2 = typeof global$1 !== "undefined" ? global$1 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
320
+ var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
285
321
 
286
- var global$1 = typeof global$2 !== "undefined" ? global$2 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
322
+ var global = typeof global$1 !== "undefined" ? global$1 : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
287
323
 
288
- function _typeof(obj) {
324
+ function _typeof$1(obj) {
289
325
  "@babel/helpers - typeof";
290
326
 
291
327
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
292
- _typeof = function _typeof(obj) {
328
+ _typeof$1 = function _typeof(obj) {
293
329
  return typeof obj;
294
330
  };
295
331
  } else {
296
- _typeof = function _typeof(obj) {
332
+ _typeof$1 = function _typeof(obj) {
297
333
  return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
298
334
  };
299
335
  }
300
336
 
301
- return _typeof(obj);
337
+ return _typeof$1(obj);
302
338
  }
303
339
  /* eslint-disable no-sync, no-restricted-syntax */
304
340
  // Todo: Switch to ES6 classes
@@ -997,7 +1033,7 @@
997
1033
  var triggerGlobalErrorEvent;
998
1034
  var useNodeImpl = false;
999
1035
 
1000
- if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && !window.dispatchEvent) {
1036
+ if (typeof window === 'undefined' || typeof ErrorEvent === 'undefined' || window && (typeof window === "undefined" ? "undefined" : _typeof$1(window)) === 'object' && !window.dispatchEvent) {
1001
1037
  useNodeImpl = true;
1002
1038
 
1003
1039
  triggerGlobalErrorEvent = function triggerGlobalErrorEvent() {
@@ -1079,7 +1115,7 @@
1079
1115
  Object.setPrototypeOf(ShimCustomEvent.prototype, ShimEvent.prototype);
1080
1116
  } // Todo: Move to own library (but allowing WeakMaps to be passed in for sharing here)
1081
1117
 
1082
- var map$1 = {};
1118
+ var map = {};
1083
1119
  var CFG = {};
1084
1120
  [// Boolean for verbose reporting
1085
1121
  'DEBUG', // Effectively defaults to false (ignored unless `true`)
@@ -1181,7 +1217,7 @@
1181
1217
  if (Array.isArray(prop)) {
1182
1218
  var _prop = prop;
1183
1219
 
1184
- var _prop2 = _slicedToArray(_prop, 2);
1220
+ var _prop2 = _slicedToArray$1(_prop, 2);
1185
1221
 
1186
1222
  prop = _prop2[0];
1187
1223
  validator = _prop2[1];
@@ -1189,14 +1225,14 @@
1189
1225
 
1190
1226
  Object.defineProperty(CFG, prop, {
1191
1227
  get: function get() {
1192
- return map$1[prop];
1228
+ return map[prop];
1193
1229
  },
1194
1230
  set: function set(val) {
1195
1231
  if (validator) {
1196
1232
  validator(val);
1197
1233
  }
1198
1234
 
1199
- map$1[prop] = val;
1235
+ map[prop] = val;
1200
1236
  }
1201
1237
  });
1202
1238
  });
@@ -1317,7 +1353,7 @@
1317
1353
  }
1318
1354
 
1319
1355
  function isObj(obj) {
1320
- return obj && _typeof$1(obj) === 'object';
1356
+ return obj && _typeof$2(obj) === 'object';
1321
1357
  }
1322
1358
 
1323
1359
  function isDate(obj) {
@@ -1792,7 +1828,7 @@
1792
1828
  }
1793
1829
 
1794
1830
  function isErrorOrDOMErrorOrDOMException(obj) {
1795
- return obj && _typeof$1(obj) === 'object' && // We don't use util.isObj here as mutual dependency causing problems in Babel with browser
1831
+ return obj && _typeof$2(obj) === 'object' && // We don't use util.isObj here as mutual dependency causing problems in Babel with browser
1796
1832
  typeof obj.name === 'string';
1797
1833
  }
1798
1834
  /**
@@ -2032,8 +2068,6 @@
2032
2068
  writable: false
2033
2069
  });
2034
2070
 
2035
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2036
-
2037
2071
  // not doing the trick for our WebSQL transactions (at least in Node),
2038
2072
  // we are forced to make the promises run fully synchronously.
2039
2073
 
@@ -2220,12 +2254,12 @@
2220
2254
  var decodedKey1 = _decode(encodedKey1);
2221
2255
  var decodedKey2 = _decode(encodedKey2);
2222
2256
 
2223
- if (_typeof$1(first) === 'object') {
2257
+ if (_typeof$2(first) === 'object') {
2224
2258
  first = JSON.stringify(first);
2225
2259
  decodedKey1 = JSON.stringify(decodedKey1);
2226
2260
  }
2227
2261
 
2228
- if (_typeof$1(second) === 'object') {
2262
+ if (_typeof$2(second) === 'object') {
2229
2263
  second = JSON.stringify(second);
2230
2264
  decodedKey2 = JSON.stringify(decodedKey2);
2231
2265
  } // Encoding/decoding mismatches are usually due to a loss of
@@ -2428,7 +2462,7 @@
2428
2462
 
2429
2463
  try {
2430
2464
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
2431
- var _step$value = _slicedToArray(_step.value, 2),
2465
+ var _step$value = _slicedToArray$1(_step.value, 2),
2432
2466
  i = _step$value[0],
2433
2467
  item = _step$value[1];
2434
2468
 
@@ -2617,7 +2651,7 @@
2617
2651
  if (isDate(key)) return 'date';
2618
2652
  if (isBinary(key)) return 'binary';
2619
2653
 
2620
- var keyType = _typeof$1(key);
2654
+ var keyType = _typeof$2(key);
2621
2655
 
2622
2656
  return ['string', 'number'].includes(keyType) ? keyType : 'invalid';
2623
2657
  }
@@ -2792,7 +2826,7 @@
2792
2826
  }();
2793
2827
 
2794
2828
  if (_ret === "continue") continue;
2795
- if (_typeof$1(_ret) === "object") return _ret.v;
2829
+ if (_typeof$2(_ret) === "object") return _ret.v;
2796
2830
  } catch (err) {
2797
2831
  if (!multiEntry) {
2798
2832
  throw err;
@@ -2830,7 +2864,7 @@
2830
2864
  {
2831
2865
  // Other `typeof` types which are not valid keys:
2832
2866
  // 'undefined', 'boolean', 'object' (including `null`), 'symbol', 'function
2833
- var _type = input === null ? 'null' : _typeof$1(input); // Convert `null` for convenience of consumers in reporting errors
2867
+ var _type = input === null ? 'null' : _typeof$2(input); // Convert `null` for convenience of consumers in reporting errors
2834
2868
 
2835
2869
 
2836
2870
  return {
@@ -3776,7 +3810,7 @@
3776
3810
 
3777
3811
  this.sortList();
3778
3812
  }
3779
- }, _defineProperty(_DOMStringList$protot, Symbol.toStringTag, 'DOMStringListPrototype'), _defineProperty(_DOMStringList$protot, Symbol.iterator, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
3813
+ }, _defineProperty$1(_DOMStringList$protot, Symbol.toStringTag, 'DOMStringListPrototype'), _defineProperty$1(_DOMStringList$protot, Symbol.iterator, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
3780
3814
  var i;
3781
3815
  return regeneratorRuntime.wrap(function _callee$(_context) {
3782
3816
  while (1) {
@@ -4498,3187 +4532,1421 @@
4498
4532
  writable: false
4499
4533
  });
4500
4534
 
4501
- var typeson$1 = {exports: {}};
4502
-
4503
- (function (module, exports) {
4504
- (function (global, factory) {
4505
- module.exports = factory() ;
4506
- })(commonjsGlobal, function () {
4507
-
4508
- function _typeof(obj) {
4509
- "@babel/helpers - typeof";
4510
-
4511
- if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
4512
- _typeof = function _typeof(obj) {
4513
- return typeof obj;
4514
- };
4515
- } else {
4516
- _typeof = function _typeof(obj) {
4517
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
4518
- };
4519
- }
4520
-
4521
- return _typeof(obj);
4522
- }
4523
-
4524
- function _classCallCheck(instance, Constructor) {
4525
- if (!(instance instanceof Constructor)) {
4526
- throw new TypeError("Cannot call a class as a function");
4527
- }
4528
- }
4529
-
4530
- function _defineProperties(target, props) {
4531
- for (var i = 0; i < props.length; i++) {
4532
- var descriptor = props[i];
4533
- descriptor.enumerable = descriptor.enumerable || false;
4534
- descriptor.configurable = true;
4535
- if ("value" in descriptor) descriptor.writable = true;
4536
- Object.defineProperty(target, descriptor.key, descriptor);
4537
- }
4538
- }
4539
-
4540
- function _createClass(Constructor, protoProps, staticProps) {
4541
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
4542
- if (staticProps) _defineProperties(Constructor, staticProps);
4543
- return Constructor;
4544
- }
4545
-
4546
- function _defineProperty(obj, key, value) {
4547
- if (key in obj) {
4548
- Object.defineProperty(obj, key, {
4549
- value: value,
4550
- enumerable: true,
4551
- configurable: true,
4552
- writable: true
4553
- });
4554
- } else {
4555
- obj[key] = value;
4556
- }
4557
-
4558
- return obj;
4559
- }
4560
-
4561
- function ownKeys(object, enumerableOnly) {
4562
- var keys = Object.keys(object);
4535
+ function ownKeys(e, t) {
4536
+ var r = Object.keys(e);
4563
4537
 
4564
- if (Object.getOwnPropertySymbols) {
4565
- var symbols = Object.getOwnPropertySymbols(object);
4566
- if (enumerableOnly) symbols = symbols.filter(function (sym) {
4567
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
4568
- });
4569
- keys.push.apply(keys, symbols);
4570
- }
4538
+ if (Object.getOwnPropertySymbols) {
4539
+ var n = Object.getOwnPropertySymbols(e);
4540
+ t && (n = n.filter(function (t) {
4541
+ return Object.getOwnPropertyDescriptor(e, t).enumerable;
4542
+ })), r.push.apply(r, n);
4543
+ }
4571
4544
 
4572
- return keys;
4573
- }
4545
+ return r;
4546
+ }
4574
4547
 
4575
- function _objectSpread2(target) {
4576
- for (var i = 1; i < arguments.length; i++) {
4577
- var source = arguments[i] != null ? arguments[i] : {};
4548
+ function _objectSpread2(e) {
4549
+ for (var t = 1; t < arguments.length; t++) {
4550
+ var r = null != arguments[t] ? arguments[t] : {};
4551
+ t % 2 ? ownKeys(Object(r), !0).forEach(function (t) {
4552
+ _defineProperty(e, t, r[t]);
4553
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ownKeys(Object(r)).forEach(function (t) {
4554
+ Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(r, t));
4555
+ });
4556
+ }
4578
4557
 
4579
- if (i % 2) {
4580
- ownKeys(Object(source), true).forEach(function (key) {
4581
- _defineProperty(target, key, source[key]);
4582
- });
4583
- } else if (Object.getOwnPropertyDescriptors) {
4584
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
4585
- } else {
4586
- ownKeys(Object(source)).forEach(function (key) {
4587
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
4588
- });
4589
- }
4590
- }
4558
+ return e;
4559
+ }
4591
4560
 
4592
- return target;
4593
- }
4561
+ function _typeof(e) {
4562
+ return (_typeof = "function" == typeof Symbol && "symbol" == _typeof$2(Symbol.iterator) ? function (e) {
4563
+ return _typeof$2(e);
4564
+ } : function (e) {
4565
+ return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : _typeof$2(e);
4566
+ })(e);
4567
+ }
4594
4568
 
4595
- function _slicedToArray(arr, i) {
4596
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
4597
- }
4569
+ function _classCallCheck(e, t) {
4570
+ if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function");
4571
+ }
4598
4572
 
4599
- function _toConsumableArray(arr) {
4600
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
4601
- }
4573
+ function _defineProperties(e, t) {
4574
+ for (var r = 0; r < t.length; r++) {
4575
+ var n = t[r];
4576
+ n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(e, n.key, n);
4577
+ }
4578
+ }
4602
4579
 
4603
- function _arrayWithoutHoles(arr) {
4604
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
4605
- }
4580
+ function _createClass(e, t, r) {
4581
+ return t && _defineProperties(e.prototype, t), r && _defineProperties(e, r), Object.defineProperty(e, "prototype", {
4582
+ writable: !1
4583
+ }), e;
4584
+ }
4606
4585
 
4607
- function _arrayWithHoles(arr) {
4608
- if (Array.isArray(arr)) return arr;
4609
- }
4586
+ function _defineProperty(e, t, r) {
4587
+ return t in e ? Object.defineProperty(e, t, {
4588
+ value: r,
4589
+ enumerable: !0,
4590
+ configurable: !0,
4591
+ writable: !0
4592
+ }) : e[t] = r, e;
4593
+ }
4610
4594
 
4611
- function _iterableToArray(iter) {
4612
- if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
4613
- }
4595
+ function _slicedToArray(e, t) {
4596
+ return function _arrayWithHoles(e) {
4597
+ if (Array.isArray(e)) return e;
4598
+ }(e) || function _iterableToArrayLimit(e, t) {
4599
+ var r = null == e ? null : "undefined" != typeof Symbol && e[Symbol.iterator] || e["@@iterator"];
4614
4600
 
4615
- function _iterableToArrayLimit(arr, i) {
4616
- if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
4617
- var _arr = [];
4618
- var _n = true;
4619
- var _d = false;
4620
- var _e = undefined;
4601
+ if (null != r) {
4602
+ var n,
4603
+ a,
4604
+ o = [],
4605
+ i = !0,
4606
+ s = !1;
4621
4607
 
4622
4608
  try {
4623
- for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
4624
- _arr.push(_s.value);
4625
-
4626
- if (i && _arr.length === i) break;
4609
+ for (r = r.call(e); !(i = (n = r.next()).done) && (o.push(n.value), !t || o.length !== t); i = !0) {
4610
+ ;
4627
4611
  }
4628
- } catch (err) {
4629
- _d = true;
4630
- _e = err;
4612
+ } catch (e) {
4613
+ s = !0, a = e;
4631
4614
  } finally {
4632
4615
  try {
4633
- if (!_n && _i["return"] != null) _i["return"]();
4616
+ i || null == r["return"] || r["return"]();
4634
4617
  } finally {
4635
- if (_d) throw _e;
4618
+ if (s) throw a;
4636
4619
  }
4637
4620
  }
4638
4621
 
4639
- return _arr;
4622
+ return o;
4640
4623
  }
4624
+ }(e, t) || _unsupportedIterableToArray(e, t) || function _nonIterableRest() {
4625
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4626
+ }();
4627
+ }
4641
4628
 
4642
- function _unsupportedIterableToArray(o, minLen) {
4643
- if (!o) return;
4644
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
4645
- var n = Object.prototype.toString.call(o).slice(8, -1);
4646
- if (n === "Object" && o.constructor) n = o.constructor.name;
4647
- if (n === "Map" || n === "Set") return Array.from(o);
4648
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
4649
- }
4629
+ function _unsupportedIterableToArray(e, t) {
4630
+ if (e) {
4631
+ if ("string" == typeof e) return _arrayLikeToArray(e, t);
4632
+ var r = Object.prototype.toString.call(e).slice(8, -1);
4633
+ 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;
4634
+ }
4635
+ }
4650
4636
 
4651
- function _arrayLikeToArray(arr, len) {
4652
- if (len == null || len > arr.length) len = arr.length;
4637
+ function _arrayLikeToArray(e, t) {
4638
+ (null == t || t > e.length) && (t = e.length);
4653
4639
 
4654
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
4655
- arr2[i] = arr[i];
4656
- }
4640
+ for (var r = 0, n = new Array(t); r < t; r++) {
4641
+ n[r] = e[r];
4642
+ }
4657
4643
 
4658
- return arr2;
4659
- }
4644
+ return n;
4645
+ }
4660
4646
 
4661
- function _nonIterableSpread() {
4662
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4663
- }
4647
+ var e = _createClass(function TypesonPromise(e) {
4648
+ _classCallCheck(this, TypesonPromise), this.p = new Promise(e);
4649
+ });
4664
4650
 
4665
- function _nonIterableRest() {
4666
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4667
- }
4668
- /**
4669
- * @callback TypesonFulfilled
4670
- * @returns {Promise<any>|any}
4671
- */
4651
+ e.__typeson__type__ = "TypesonPromise", "undefined" != typeof Symbol && (e.prototype[Symbol.toStringTag] = "TypesonPromise"), e.prototype.then = function (t, r) {
4652
+ var n = this;
4653
+ return new e(function (e, a) {
4654
+ n.p.then(function (r) {
4655
+ e(t ? t(r) : r);
4656
+ })["catch"](function (e) {
4657
+ return r ? r(e) : Promise.reject(e);
4658
+ }).then(e, a);
4659
+ });
4660
+ }, e.prototype["catch"] = function (e) {
4661
+ return this.then(null, e);
4662
+ }, e.resolve = function (t) {
4663
+ return new e(function (e) {
4664
+ e(t);
4665
+ });
4666
+ }, e.reject = function (t) {
4667
+ return new e(function (e, r) {
4668
+ r(t);
4669
+ });
4670
+ }, ["all", "race", "allSettled"].forEach(function (t) {
4671
+ e[t] = function (r) {
4672
+ return new e(function (e, n) {
4673
+ Promise[t](r.map(function (e) {
4674
+ return e && e.constructor && "TypesonPromise" === e.constructor.__typeson__type__ ? e.p : e;
4675
+ })).then(e, n);
4676
+ });
4677
+ };
4678
+ });
4679
+ var t = {}.toString,
4680
+ r = {}.hasOwnProperty,
4681
+ n = Object.getPrototypeOf,
4682
+ a = r.toString;
4672
4683
 
4673
- /**
4674
- * @callback TypesonRejected
4675
- * @returns {Promise<any>|any}
4676
- */
4684
+ function isThenable(e, t) {
4685
+ return isObject(e) && "function" == typeof e.then && (!t || "function" == typeof e["catch"]);
4686
+ }
4677
4687
 
4678
- /**
4679
- * @callback TypesonResolve
4680
- * @param {any} value
4681
- * @returns {Promise<any>}
4682
- */
4688
+ function toStringTag(e) {
4689
+ return t.call(e).slice(8, -1);
4690
+ }
4683
4691
 
4684
- /**
4685
- * @callback TypesonReject
4686
- * @param {Error|any} error
4687
- * @returns {Promise<any>}
4688
- */
4692
+ function hasConstructorOf(e, t) {
4693
+ if (!e || "object" !== _typeof(e)) return !1;
4694
+ var o = n(e);
4695
+ if (!o) return null === t;
4696
+ var i = r.call(o, "constructor") && o.constructor;
4697
+ 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__;
4698
+ }
4689
4699
 
4690
- /**
4691
- * @callback TypesonResolveReject
4692
- * @param {TypesonResolve} typesonResolve
4693
- * @param {TypesonReject} typesonReject
4694
- * @returns {Promise<any>}
4695
- */
4700
+ function isPlainObject(e) {
4701
+ return !(!e || "Object" !== toStringTag(e)) && (!n(e) || hasConstructorOf(e, Object));
4702
+ }
4696
4703
 
4697
- /* eslint-disable block-spacing, space-before-function-paren,
4698
- space-before-blocks, space-infix-ops, semi, promise/avoid-new,
4699
- jsdoc/require-jsdoc */
4704
+ function isUserObject(e) {
4705
+ if (!e || "Object" !== toStringTag(e)) return !1;
4706
+ var t = n(e);
4707
+ return !t || hasConstructorOf(e, Object) || isUserObject(t);
4708
+ }
4700
4709
 
4701
- /**
4702
- * We keep this function minimized so if using two instances of this
4703
- * library, where one is minimized and one is not, it will still work
4704
- * with `hasConstructorOf`.
4705
- * With ES6 classes, we may be able to simply use `class TypesonPromise
4706
- * extends Promise` and add a string tag for detection.
4707
- * @param {TypesonResolveReject} f
4708
- */
4710
+ function isObject(e) {
4711
+ return e && "object" === _typeof(e);
4712
+ }
4709
4713
 
4714
+ function escapeKeyPathComponent(e) {
4715
+ return e.replace(/~/g, "~0").replace(/\./g, "~1");
4716
+ }
4710
4717
 
4711
- var TypesonPromise = function TypesonPromise(f) {
4712
- _classCallCheck(this, TypesonPromise);
4718
+ function unescapeKeyPathComponent(e) {
4719
+ return e.replace(/~1/g, ".").replace(/~0/g, "~");
4720
+ }
4713
4721
 
4714
- this.p = new Promise(f);
4715
- };
4716
- /* eslint-enable block-spacing, space-before-function-paren,
4717
- space-before-blocks, space-infix-ops, semi, promise/avoid-new,
4718
- jsdoc/require-jsdoc */
4719
- // eslint-disable-next-line max-len
4720
- // class TypesonPromise extends Promise {get[Symbol.toStringTag](){return 'TypesonPromise'};} // eslint-disable-line keyword-spacing, space-before-function-paren, space-before-blocks, block-spacing, semi
4722
+ function getByKeyPath(e, t) {
4723
+ if ("" === t) return e;
4724
+ var r = t.indexOf(".");
4721
4725
 
4726
+ if (r > -1) {
4727
+ var n = e[unescapeKeyPathComponent(t.slice(0, r))];
4728
+ return void 0 === n ? void 0 : getByKeyPath(n, t.slice(r + 1));
4729
+ }
4722
4730
 
4723
- TypesonPromise.__typeson__type__ = 'TypesonPromise'; // Note: core-js-bundle provides a `Symbol` polyfill
4731
+ return e[unescapeKeyPathComponent(t)];
4732
+ }
4724
4733
 
4725
- /* istanbul ignore else */
4734
+ function setAtKeyPath(e, t, r) {
4735
+ if ("" === t) return r;
4736
+ var n = t.indexOf(".");
4737
+ return n > -1 ? setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0, n))], t.slice(n + 1), r) : (e[unescapeKeyPathComponent(t)] = r, e);
4738
+ }
4726
4739
 
4727
- if (typeof Symbol !== 'undefined') {
4728
- // Ensure `isUserObject` will return `false` for `TypesonPromise`
4729
- TypesonPromise.prototype[Symbol.toStringTag] = 'TypesonPromise';
4730
- }
4731
- /**
4732
- *
4733
- * @param {TypesonFulfilled} [onFulfilled]
4734
- * @param {TypesonRejected} [onRejected]
4735
- * @returns {TypesonPromise}
4736
- */
4740
+ function getJSONType(e) {
4741
+ return null === e ? "null" : Array.isArray(e) ? "array" : _typeof(e);
4742
+ }
4737
4743
 
4744
+ function _await(e, t, r) {
4745
+ return r ? t ? t(e) : e : (e && e.then || (e = Promise.resolve(e)), t ? e.then(t) : e);
4746
+ }
4738
4747
 
4739
- TypesonPromise.prototype.then = function (onFulfilled, onRejected) {
4740
- var _this = this;
4748
+ var o = Object.keys,
4749
+ i = Array.isArray,
4750
+ s = {}.hasOwnProperty,
4751
+ c = ["type", "replaced", "iterateIn", "iterateUnsetNumeric"];
4741
4752
 
4742
- return new TypesonPromise(function (typesonResolve, typesonReject) {
4743
- // eslint-disable-next-line promise/catch-or-return
4744
- _this.p.then(function (res) {
4745
- // eslint-disable-next-line promise/always-return
4746
- typesonResolve(onFulfilled ? onFulfilled(res) : res);
4747
- })["catch"](function (res) {
4748
- return onRejected ? onRejected(res) : Promise.reject(res);
4749
- }).then(typesonResolve, typesonReject);
4750
- });
4751
- };
4752
- /**
4753
- *
4754
- * @param {TypesonRejected} onRejected
4755
- * @returns {TypesonPromise}
4756
- */
4753
+ function _async(e) {
4754
+ return function () {
4755
+ for (var t = [], r = 0; r < arguments.length; r++) {
4756
+ t[r] = arguments[r];
4757
+ }
4757
4758
 
4759
+ try {
4760
+ return Promise.resolve(e.apply(this, t));
4761
+ } catch (e) {
4762
+ return Promise.reject(e);
4763
+ }
4764
+ };
4765
+ }
4758
4766
 
4759
- TypesonPromise.prototype["catch"] = function (onRejected) {
4760
- return this.then(null, onRejected);
4761
- };
4762
- /**
4763
- *
4764
- * @param {any} v
4765
- * @returns {TypesonPromise}
4766
- */
4767
+ function nestedPathsFirst(e, t) {
4768
+ if ("" === e.keypath) return -1;
4769
+ var r = e.keypath.match(/\./g) || 0,
4770
+ n = t.keypath.match(/\./g) || 0;
4771
+ return r && (r = r.length), n && (n = n.length), r > n ? -1 : r < n ? 1 : e.keypath < t.keypath ? -1 : e.keypath > t.keypath;
4772
+ }
4767
4773
 
4774
+ var u = function () {
4775
+ function Typeson(e) {
4776
+ _classCallCheck(this, Typeson), this.options = e, this.plainObjectReplacers = [], this.nonplainObjectReplacers = [], this.revivers = {}, this.types = {};
4777
+ }
4768
4778
 
4769
- TypesonPromise.resolve = function (v) {
4770
- return new TypesonPromise(function (typesonResolve) {
4771
- typesonResolve(v);
4779
+ return _createClass(Typeson, [{
4780
+ key: "stringify",
4781
+ value: function stringify(e, t, r, n) {
4782
+ n = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), n), {}, {
4783
+ stringification: !0
4772
4784
  });
4773
- };
4774
- /**
4775
- *
4776
- * @param {any} v
4777
- * @returns {TypesonPromise}
4778
- */
4779
-
4780
-
4781
- TypesonPromise.reject = function (v) {
4782
- return new TypesonPromise(function (typesonResolve, typesonReject) {
4783
- typesonReject(v);
4785
+ var a = this.encapsulate(e, null, n);
4786
+ return i(a) ? JSON.stringify(a[0], t, r) : a.then(function (e) {
4787
+ return JSON.stringify(e, t, r);
4784
4788
  });
4785
- };
4786
-
4787
- ['all', 'race', 'allSettled'].forEach(function (meth) {
4788
- /**
4789
- *
4790
- * @param {Promise<any>[]} promArr
4791
- * @returns {TypesonPromise}
4792
- */
4793
- TypesonPromise[meth] = function (promArr) {
4794
- return new TypesonPromise(function (typesonResolve, typesonReject) {
4795
- // eslint-disable-next-line promise/catch-or-return
4796
- Promise[meth](promArr.map(function (prom) {
4797
- return prom && prom.constructor && prom.constructor.__typeson__type__ === 'TypesonPromise' ? prom.p : prom;
4798
- })).then(typesonResolve, typesonReject);
4789
+ }
4790
+ }, {
4791
+ key: "stringifySync",
4792
+ value: function stringifySync(e, t, r, n) {
4793
+ return this.stringify(e, t, r, _objectSpread2(_objectSpread2({
4794
+ throwOnBadSyncType: !0
4795
+ }, n), {}, {
4796
+ sync: !0
4797
+ }));
4798
+ }
4799
+ }, {
4800
+ key: "stringifyAsync",
4801
+ value: function stringifyAsync(e, t, r, n) {
4802
+ return this.stringify(e, t, r, _objectSpread2(_objectSpread2({
4803
+ throwOnBadSyncType: !0
4804
+ }, n), {}, {
4805
+ sync: !1
4806
+ }));
4807
+ }
4808
+ }, {
4809
+ key: "parse",
4810
+ value: function parse(e, t, r) {
4811
+ return r = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), r), {}, {
4812
+ parse: !0
4813
+ }), this.revive(JSON.parse(e, t), r);
4814
+ }
4815
+ }, {
4816
+ key: "parseSync",
4817
+ value: function parseSync(e, t, r) {
4818
+ return this.parse(e, t, _objectSpread2(_objectSpread2({
4819
+ throwOnBadSyncType: !0
4820
+ }, r), {}, {
4821
+ sync: !0
4822
+ }));
4823
+ }
4824
+ }, {
4825
+ key: "parseAsync",
4826
+ value: function parseAsync(e, t, r) {
4827
+ return this.parse(e, t, _objectSpread2(_objectSpread2({
4828
+ throwOnBadSyncType: !0
4829
+ }, r), {}, {
4830
+ sync: !1
4831
+ }));
4832
+ }
4833
+ }, {
4834
+ key: "specialTypeNames",
4835
+ value: function specialTypeNames(e, t) {
4836
+ var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
4837
+ return r.returnTypeNames = !0, this.encapsulate(e, t, r);
4838
+ }
4839
+ }, {
4840
+ key: "rootTypeName",
4841
+ value: function rootTypeName(e, t) {
4842
+ var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {};
4843
+ return r.iterateNone = !0, this.encapsulate(e, t, r);
4844
+ }
4845
+ }, {
4846
+ key: "encapsulate",
4847
+ value: function encapsulate(t, r, n) {
4848
+ var a = _async(function (t, r) {
4849
+ return _await(Promise.all(r.map(function (e) {
4850
+ return e[1].p;
4851
+ })), function (n) {
4852
+ return _await(Promise.all(n.map(_async(function (n) {
4853
+ var o = !1,
4854
+ i = [],
4855
+ s = _slicedToArray(r.splice(0, 1), 1),
4856
+ c = _slicedToArray(s[0], 7),
4857
+ u = c[0],
4858
+ l = c[2],
4859
+ f = c[3],
4860
+ y = c[4],
4861
+ p = c[5],
4862
+ d = c[6],
4863
+ v = _encapsulate(u, n, l, f, i, !0, d),
4864
+ b = hasConstructorOf(v, e);
4865
+
4866
+ return function _invoke(e, t) {
4867
+ var r = e();
4868
+ return r && r.then ? r.then(t) : t(r);
4869
+ }(function () {
4870
+ if (u && b) return _await(v.p, function (e) {
4871
+ y[p] = e;
4872
+ var r = a(t, i);
4873
+ return o = !0, r;
4874
+ });
4875
+ }, function (e) {
4876
+ return o ? e : (u ? y[p] = v : t = b ? v.p : v, a(t, i));
4877
+ });
4878
+ }))), function () {
4879
+ return t;
4880
+ });
4881
+ });
4882
+ }),
4883
+ u = (n = _objectSpread2(_objectSpread2({
4884
+ sync: !0
4885
+ }, this.options), n)).sync,
4886
+ l = this,
4887
+ f = {},
4888
+ y = [],
4889
+ p = [],
4890
+ d = [],
4891
+ v = !("cyclic" in n) || n.cyclic,
4892
+ b = n.encapsulateObserver,
4893
+ h = _encapsulate("", t, v, r || {}, d);
4894
+
4895
+ function finish(e) {
4896
+ var t = Object.values(f);
4897
+ if (n.iterateNone) return t.length ? t[0] : getJSONType(e);
4898
+
4899
+ if (t.length) {
4900
+ if (n.returnTypeNames) return function _toConsumableArray(e) {
4901
+ return function _arrayWithoutHoles(e) {
4902
+ if (Array.isArray(e)) return _arrayLikeToArray(e);
4903
+ }(e) || function _iterableToArray(e) {
4904
+ if ("undefined" != typeof Symbol && null != e[Symbol.iterator] || null != e["@@iterator"]) return Array.from(e);
4905
+ }(e) || _unsupportedIterableToArray(e) || function _nonIterableSpread() {
4906
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
4907
+ }();
4908
+ }(new Set(t));
4909
+ e && isPlainObject(e) && !s.call(e, "$types") ? e.$types = f : e = {
4910
+ $: e,
4911
+ $types: {
4912
+ $: f
4913
+ }
4914
+ };
4915
+ } else isObject(e) && s.call(e, "$types") && (e = {
4916
+ $: e,
4917
+ $types: !0
4799
4918
  });
4800
- };
4801
- });
4802
- var _ref = {},
4803
- toStr = _ref.toString,
4804
- hasOwn$1 = {}.hasOwnProperty,
4805
- getProto = Object.getPrototypeOf,
4806
- fnToString = hasOwn$1.toString;
4807
- /**
4808
- * Second argument not in use internally, but provided for utility.
4809
- * @param {any} v
4810
- * @param {boolean} catchCheck
4811
- * @returns {boolean}
4812
- */
4813
4919
 
4814
- function isThenable(v, catchCheck) {
4815
- return isObject(v) && typeof v.then === 'function' && (!catchCheck || typeof v["catch"] === 'function');
4816
- }
4817
- /**
4818
- *
4819
- * @param {any} val
4820
- * @returns {string}
4821
- */
4920
+ return !n.returnTypeNames && e;
4921
+ }
4822
4922
 
4923
+ function _adaptBuiltinStateObjectProperties(e, t, r) {
4924
+ Object.assign(e, t);
4925
+ var n = c.map(function (t) {
4926
+ var r = e[t];
4927
+ return delete e[t], r;
4928
+ });
4929
+ r(), c.forEach(function (t, r) {
4930
+ e[t] = n[r];
4931
+ });
4932
+ }
4823
4933
 
4824
- function toStringTag(val) {
4825
- return toStr.call(val).slice(8, -1);
4826
- }
4827
- /**
4828
- * This function is dependent on both constructors
4829
- * being identical so any minimization is expected of both.
4830
- * @param {any} a
4831
- * @param {GenericFunction} b
4832
- * @returns {boolean}
4833
- */
4934
+ function _encapsulate(t, r, a, c, u, d, v) {
4935
+ var h,
4936
+ g = {},
4937
+ m = _typeof(r),
4938
+ O = b ? function (n) {
4939
+ var o = v || c.type || getJSONType(r);
4940
+ b(Object.assign(n || g, {
4941
+ keypath: t,
4942
+ value: r,
4943
+ cyclic: a,
4944
+ stateObj: c,
4945
+ promisesData: u,
4946
+ resolvingTypesonPromise: d,
4947
+ awaitingTypesonPromise: hasConstructorOf(r, e)
4948
+ }, {
4949
+ type: o
4950
+ }));
4951
+ } : null;
4952
+
4953
+ 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 = {
4954
+ replaced: h
4955
+ }) : h = r, O && O(), h;
4956
+ if (null === r) return O && O(), r;
4957
+
4958
+ if (a && !c.iterateIn && !c.iterateUnsetNumeric && r && "object" === _typeof(r)) {
4959
+ var S = y.indexOf(r);
4960
+ if (!(S < 0)) return f[t] = "#", O && O({
4961
+ cyclicKeypath: p[S]
4962
+ }), "#" + p[S];
4963
+ !0 === a && (y.push(r), p.push(t));
4964
+ }
4834
4965
 
4966
+ var _,
4967
+ w = isPlainObject(r),
4968
+ A = i(r),
4969
+ j = (w || A) && (!l.plainObjectReplacers.length || c.replaced) || c.iterateIn ? r : replace(t, r, c, u, w || A, null, O);
4970
+
4971
+ if (j !== r ? (h = j, g = {
4972
+ replaced: j
4973
+ }) : "" === 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 = {
4974
+ clone: _
4975
+ }) : (["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 = {
4976
+ clone: _
4977
+ }), O && O(), n.iterateNone) return _ || h;
4978
+ if (!_) return h;
4979
+
4980
+ if (c.iterateIn) {
4981
+ var T = function _loop(n) {
4982
+ var o = {
4983
+ ownKeys: s.call(r, n)
4984
+ };
4835
4985
 
4836
- function hasConstructorOf(a, b) {
4837
- if (!a || _typeof(a) !== 'object') {
4838
- return false;
4839
- }
4986
+ _adaptBuiltinStateObjectProperties(c, o, function () {
4987
+ var o = t + (t ? "." : "") + escapeKeyPathComponent(n),
4988
+ i = _encapsulate(o, r[n], Boolean(a), c, u, d);
4840
4989
 
4841
- var proto = getProto(a);
4990
+ hasConstructorOf(i, e) ? u.push([o, i, Boolean(a), c, _, n, c.type]) : void 0 !== i && (_[n] = i);
4991
+ });
4992
+ };
4842
4993
 
4843
- if (!proto) {
4844
- return b === null;
4845
- }
4994
+ for (var I in r) {
4995
+ T(I);
4996
+ }
4846
4997
 
4847
- var Ctor = hasOwn$1.call(proto, 'constructor') && proto.constructor;
4998
+ O && O({
4999
+ endIterateIn: !0,
5000
+ end: !0
5001
+ });
5002
+ } else o(r).forEach(function (n) {
5003
+ var o = t + (t ? "." : "") + escapeKeyPathComponent(n);
4848
5004
 
4849
- if (typeof Ctor !== 'function') {
4850
- return b === null;
4851
- }
5005
+ _adaptBuiltinStateObjectProperties(c, {
5006
+ ownKeys: !0
5007
+ }, function () {
5008
+ var t = _encapsulate(o, r[n], Boolean(a), c, u, d);
4852
5009
 
4853
- if (b === Ctor) {
4854
- return true;
4855
- }
5010
+ hasConstructorOf(t, e) ? u.push([o, t, Boolean(a), c, _, n, c.type]) : void 0 !== t && (_[n] = t);
5011
+ });
5012
+ }), O && O({
5013
+ endIterateOwn: !0,
5014
+ end: !0
5015
+ });
4856
5016
 
4857
- if (b !== null && fnToString.call(Ctor) === fnToString.call(b)) {
4858
- return true;
4859
- }
5017
+ if (c.iterateUnsetNumeric) {
5018
+ for (var P = r.length, N = function _loop2(n) {
5019
+ if (!(n in r)) {
5020
+ var o = t + (t ? "." : "") + n;
4860
5021
 
4861
- if (typeof b === 'function' && typeof Ctor.__typeson__type__ === 'string' && Ctor.__typeson__type__ === b.__typeson__type__) {
4862
- return true;
4863
- }
5022
+ _adaptBuiltinStateObjectProperties(c, {
5023
+ ownKeys: !1
5024
+ }, function () {
5025
+ var t = _encapsulate(o, void 0, Boolean(a), c, u, d);
4864
5026
 
4865
- return false;
4866
- }
4867
- /**
4868
- *
4869
- * @param {any} val
4870
- * @returns {boolean}
4871
- */
5027
+ hasConstructorOf(t, e) ? u.push([o, t, Boolean(a), c, _, n, c.type]) : void 0 !== t && (_[n] = t);
5028
+ });
5029
+ }
5030
+ }, C = 0; C < P; C++) {
5031
+ N(C);
5032
+ }
4872
5033
 
5034
+ O && O({
5035
+ endIterateUnsetNumeric: !0,
5036
+ end: !0
5037
+ });
5038
+ }
4873
5039
 
4874
- function isPlainObject(val) {
4875
- // Mirrors jQuery's
4876
- if (!val || toStringTag(val) !== 'Object') {
4877
- return false;
5040
+ return _;
4878
5041
  }
4879
5042
 
4880
- var proto = getProto(val);
5043
+ function replace(e, t, r, n, a, o, i) {
5044
+ for (var s = a ? l.plainObjectReplacers : l.nonplainObjectReplacers, c = s.length; c--;) {
5045
+ var y = s[c];
4881
5046
 
4882
- if (!proto) {
4883
- // `Object.create(null)`
4884
- return true;
4885
- }
5047
+ if (y.test(t, r)) {
5048
+ var p = y.type;
4886
5049
 
4887
- return hasConstructorOf(val, Object);
4888
- }
4889
- /**
4890
- *
4891
- * @param {any} val
4892
- * @returns {boolean}
4893
- */
5050
+ if (l.revivers[p]) {
5051
+ var d = f[e];
5052
+ f[e] = d ? [p].concat(d) : p;
5053
+ }
4894
5054
 
5055
+ return Object.assign(r, {
5056
+ type: p,
5057
+ replaced: !0
5058
+ }), !u && y.replaceAsync || y.replace ? (i && i({
5059
+ replacing: !0
5060
+ }), _encapsulate(e, y[u || !y.replaceAsync ? "replace" : "replaceAsync"](t, r), v && "readonly", r, n, o, p)) : (i && i({
5061
+ typeDetected: !0
5062
+ }), _encapsulate(e, t, v && "readonly", r, n, o, p));
5063
+ }
5064
+ }
4895
5065
 
4896
- function isUserObject(val) {
4897
- if (!val || toStringTag(val) !== 'Object') {
4898
- return false;
4899
- }
5066
+ return t;
5067
+ }
5068
+
5069
+ return d.length ? u && n.throwOnBadSyncType ? function () {
5070
+ throw new TypeError("Sync method requested but async result obtained");
5071
+ }() : Promise.resolve(a(h, d)).then(finish) : !u && n.throwOnBadSyncType ? function () {
5072
+ throw new TypeError("Async method requested but sync result obtained");
5073
+ }() : n.stringification && u ? [finish(h)] : u ? finish(h) : Promise.resolve(finish(h));
5074
+ }
5075
+ }, {
5076
+ key: "encapsulateSync",
5077
+ value: function encapsulateSync(e, t, r) {
5078
+ return this.encapsulate(e, t, _objectSpread2(_objectSpread2({
5079
+ throwOnBadSyncType: !0
5080
+ }, r), {}, {
5081
+ sync: !0
5082
+ }));
5083
+ }
5084
+ }, {
5085
+ key: "encapsulateAsync",
5086
+ value: function encapsulateAsync(e, t, r) {
5087
+ return this.encapsulate(e, t, _objectSpread2(_objectSpread2({
5088
+ throwOnBadSyncType: !0
5089
+ }, r), {}, {
5090
+ sync: !1
5091
+ }));
5092
+ }
5093
+ }, {
5094
+ key: "revive",
5095
+ value: function revive(t, r) {
5096
+ var n = t && t.$types;
5097
+ if (!n) return t;
5098
+ if (!0 === n) return t.$;
5099
+
5100
+ var a = (r = _objectSpread2(_objectSpread2({
5101
+ sync: !0
5102
+ }, this.options), r)).sync,
5103
+ s = [],
5104
+ c = {},
5105
+ u = !0;
5106
+
5107
+ n.$ && isPlainObject(n.$) && (t = t.$, n = n.$, u = !1);
5108
+ var f = this;
5109
+
5110
+ function executeReviver(e, t) {
5111
+ var r = _slicedToArray(f.revivers[e] || [], 1)[0];
5112
+
5113
+ if (!r) throw new Error("Unregistered type: " + e);
5114
+ return a && !("revive" in r) ? t : r[a && r.revive ? "revive" : !a && r.reviveAsync ? "reviveAsync" : "revive"](t, c);
5115
+ }
5116
+
5117
+ var y = [];
5118
+
5119
+ function checkUndefined(e) {
5120
+ return hasConstructorOf(e, l) ? void 0 : e;
5121
+ }
5122
+
5123
+ var p,
5124
+ d = function revivePlainObjects() {
5125
+ var r = [];
5126
+ if (Object.entries(n).forEach(function (e) {
5127
+ var t = _slicedToArray(e, 2),
5128
+ a = t[0],
5129
+ o = t[1];
5130
+
5131
+ "#" !== o && [].concat(o).forEach(function (e) {
5132
+ _slicedToArray(f.revivers[e] || [null, {}], 2)[1].plain && (r.push({
5133
+ keypath: a,
5134
+ type: e
5135
+ }), delete n[a]);
5136
+ });
5137
+ }), r.length) return r.sort(nestedPathsFirst).reduce(function reducer(r, n) {
5138
+ var a = n.keypath,
5139
+ o = n.type;
5140
+ if (isThenable(r)) return r.then(function (e) {
5141
+ return reducer(e, {
5142
+ keypath: a,
5143
+ type: o
5144
+ });
5145
+ });
5146
+ var i = getByKeyPath(t, a);
5147
+ if (hasConstructorOf(i = executeReviver(o, i), e)) return i.then(function (e) {
5148
+ var r = setAtKeyPath(t, a, e);
5149
+ r === e && (t = r);
5150
+ });
5151
+ var s = setAtKeyPath(t, a, i);
5152
+ s === i && (t = s);
5153
+ }, void 0);
5154
+ }();
5155
+
5156
+ return hasConstructorOf(d, e) ? p = d.then(function () {
5157
+ return t;
5158
+ }) : (p = function _revive(t, r, a, c, f) {
5159
+ if (!u || "$types" !== t) {
5160
+ var p = n[t],
5161
+ d = i(r);
5162
+
5163
+ if (d || isPlainObject(r)) {
5164
+ var v = d ? new Array(r.length) : {};
5165
+
5166
+ for (o(r).forEach(function (n) {
5167
+ var o = _revive(t + (t ? "." : "") + escapeKeyPathComponent(n), r[n], a || v, v, n),
5168
+ i = function set(e) {
5169
+ return hasConstructorOf(e, l) ? v[n] = void 0 : void 0 !== e && (v[n] = e), e;
5170
+ };
4900
5171
 
4901
- var proto = getProto(val);
5172
+ hasConstructorOf(o, e) ? y.push(o.then(function (e) {
5173
+ return i(e);
5174
+ })) : i(o);
5175
+ }), r = v; s.length;) {
5176
+ var b = _slicedToArray(s[0], 4),
5177
+ h = b[0],
5178
+ g = b[1],
5179
+ m = b[2],
5180
+ O = b[3],
5181
+ S = getByKeyPath(h, g);
5182
+
5183
+ if (void 0 === S) break;
5184
+ m[O] = S, s.splice(0, 1);
5185
+ }
5186
+ }
4902
5187
 
4903
- if (!proto) {
4904
- // `Object.create(null)`
4905
- return true;
4906
- }
5188
+ if (!p) return r;
4907
5189
 
4908
- return hasConstructorOf(val, Object) || isUserObject(proto);
4909
- }
4910
- /**
4911
- *
4912
- * @param {any} v
4913
- * @returns {boolean}
4914
- */
5190
+ if ("#" === p) {
5191
+ var _ = getByKeyPath(a, r.slice(1));
4915
5192
 
5193
+ return void 0 === _ && s.push([a, r.slice(1), c, f]), _;
5194
+ }
4916
5195
 
4917
- function isObject(v) {
4918
- return v && _typeof(v) === 'object';
4919
- }
4920
- /**
4921
- *
4922
- * @param {string} keyPathComponent
4923
- * @returns {string}
4924
- */
5196
+ return [].concat(p).reduce(function reducer(t, r) {
5197
+ return hasConstructorOf(t, e) ? t.then(function (e) {
5198
+ return reducer(e, r);
5199
+ }) : executeReviver(r, t);
5200
+ }, r);
5201
+ }
5202
+ }("", t, null), y.length && (p = e.resolve(p).then(function (t) {
5203
+ return e.all([t].concat(y));
5204
+ }).then(function (e) {
5205
+ return _slicedToArray(e, 1)[0];
5206
+ }))), isThenable(p) ? a && r.throwOnBadSyncType ? function () {
5207
+ throw new TypeError("Sync method requested but async result obtained");
5208
+ }() : hasConstructorOf(p, e) ? p.p.then(checkUndefined) : p : !a && r.throwOnBadSyncType ? function () {
5209
+ throw new TypeError("Async method requested but sync result obtained");
5210
+ }() : a ? checkUndefined(p) : Promise.resolve(checkUndefined(p));
5211
+ }
5212
+ }, {
5213
+ key: "reviveSync",
5214
+ value: function reviveSync(e, t) {
5215
+ return this.revive(e, _objectSpread2(_objectSpread2({
5216
+ throwOnBadSyncType: !0
5217
+ }, t), {}, {
5218
+ sync: !0
5219
+ }));
5220
+ }
5221
+ }, {
5222
+ key: "reviveAsync",
5223
+ value: function reviveAsync(e, t) {
5224
+ return this.revive(e, _objectSpread2(_objectSpread2({
5225
+ throwOnBadSyncType: !0
5226
+ }, t), {}, {
5227
+ sync: !1
5228
+ }));
5229
+ }
5230
+ }, {
5231
+ key: "register",
5232
+ value: function register(e, t) {
5233
+ var r = this;
5234
+ t = t || {};
5235
+
5236
+ var n = function R(e) {
5237
+ i(e) ? e.forEach(function (e) {
5238
+ return R(e);
5239
+ }) : e && o(e).forEach(function (n) {
5240
+ if ("#" === n) throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");
5241
+ if (f.includes(n)) throw new TypeError("Plain JSON object types are reserved as type names");
5242
+ var a = e[n],
5243
+ o = a && a.testPlainObjects ? r.plainObjectReplacers : r.nonplainObjectReplacers,
5244
+ s = o.filter(function (e) {
5245
+ return e.type === n;
5246
+ });
5247
+
5248
+ if (s.length && (o.splice(o.indexOf(s[0]), 1), delete r.revivers[n], delete r.types[n]), "function" == typeof a) {
5249
+ var c = a;
5250
+ a = {
5251
+ test: function test(e) {
5252
+ return e && e.constructor === c;
5253
+ },
5254
+ replace: function replace(e) {
5255
+ return _objectSpread2({}, e);
5256
+ },
5257
+ revive: function revive(e) {
5258
+ return Object.assign(Object.create(c.prototype), e);
5259
+ }
5260
+ };
5261
+ } else if (i(a)) {
5262
+ var u = _slicedToArray(a, 3);
4925
5263
 
5264
+ a = {
5265
+ test: u[0],
5266
+ replace: u[1],
5267
+ revive: u[2]
5268
+ };
5269
+ }
4926
5270
 
4927
- function escapeKeyPathComponent(keyPathComponent) {
4928
- return keyPathComponent.replace(/~/g, '~0').replace(/\./g, '~1');
4929
- }
4930
- /**
4931
- *
4932
- * @param {string} keyPathComponent
4933
- * @returns {string}
4934
- */
5271
+ if (a && a.test) {
5272
+ var l = {
5273
+ type: n,
5274
+ test: a.test.bind(a)
5275
+ };
5276
+ a.replace && (l.replace = a.replace.bind(a)), a.replaceAsync && (l.replaceAsync = a.replaceAsync.bind(a));
5277
+ var y = "number" == typeof t.fallback ? t.fallback : t.fallback ? 0 : Number.POSITIVE_INFINITY;
5278
+
5279
+ if (a.testPlainObjects ? r.plainObjectReplacers.splice(y, 0, l) : r.nonplainObjectReplacers.splice(y, 0, l), a.revive || a.reviveAsync) {
5280
+ var p = {};
5281
+ a.revive && (p.revive = a.revive.bind(a)), a.reviveAsync && (p.reviveAsync = a.reviveAsync.bind(a)), r.revivers[n] = [p, {
5282
+ plain: a.testPlainObjects
5283
+ }];
5284
+ }
4935
5285
 
5286
+ r.types[n] = a;
5287
+ }
5288
+ });
5289
+ };
4936
5290
 
4937
- function unescapeKeyPathComponent(keyPathComponent) {
4938
- return keyPathComponent.replace(/~1/g, '.').replace(/~0/g, '~');
5291
+ return [].concat(e).forEach(function (e) {
5292
+ return n(e);
5293
+ }), this;
4939
5294
  }
4940
- /**
4941
- * @param {PlainObject|GenericArray} obj
4942
- * @param {string} keyPath
4943
- * @returns {any}
4944
- */
5295
+ }]), Typeson;
5296
+ }(),
5297
+ l = _createClass(function Undefined() {
5298
+ _classCallCheck(this, Undefined);
5299
+ });
4945
5300
 
5301
+ l.__typeson__type__ = "TypesonUndefined";
4946
5302
 
4947
- function getByKeyPath(obj, keyPath) {
4948
- if (keyPath === '') {
4949
- return obj;
4950
- }
5303
+ for (var f = ["null", "boolean", "number", "string", "array", "object"], y = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", p = new Uint8Array(256), d = 0; d < y.length; d++) {
5304
+ p[y.codePointAt(d)] = d;
5305
+ }
4951
5306
 
4952
- var period = keyPath.indexOf('.');
5307
+ var v = function encode(e, t, r) {
5308
+ null == r && (r = e.byteLength);
4953
5309
 
4954
- if (period > -1) {
4955
- var innerObj = obj[unescapeKeyPathComponent(keyPath.slice(0, period))];
4956
- return innerObj === undefined ? undefined : getByKeyPath(innerObj, keyPath.slice(period + 1));
4957
- }
5310
+ for (var n = new Uint8Array(e, t || 0, r), a = n.length, o = "", i = 0; i < a; i += 3) {
5311
+ 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]];
5312
+ }
4958
5313
 
4959
- return obj[unescapeKeyPathComponent(keyPath)];
4960
- }
4961
- /**
4962
- *
4963
- * @param {PlainObject} obj
4964
- * @param {string} keyPath
4965
- * @param {any} value
4966
- * @returns {any}
4967
- */
5314
+ return a % 3 == 2 ? o = o.slice(0, -1) + "=" : a % 3 == 1 && (o = o.slice(0, -2) + "=="), o;
5315
+ },
5316
+ b = function decode(e) {
5317
+ var t,
5318
+ r,
5319
+ n,
5320
+ a,
5321
+ o = e.length,
5322
+ i = .75 * e.length,
5323
+ s = 0;
5324
+ "=" === e[e.length - 1] && (i--, "=" === e[e.length - 2] && i--);
4968
5325
 
4969
-
4970
- function setAtKeyPath(obj, keyPath, value) {
4971
- if (keyPath === '') {
4972
- return value;
4973
- }
4974
-
4975
- var period = keyPath.indexOf('.');
4976
-
4977
- if (period > -1) {
4978
- var innerObj = obj[unescapeKeyPathComponent(keyPath.slice(0, period))];
4979
- return setAtKeyPath(innerObj, keyPath.slice(period + 1), value);
4980
- }
4981
-
4982
- obj[unescapeKeyPathComponent(keyPath)] = value;
4983
- return obj;
4984
- }
4985
- /**
4986
- *
4987
- * @param {external:JSON} value
4988
- * @returns {"null"|"array"|"undefined"|"boolean"|"number"|"string"|
4989
- * "object"|"symbol"}
4990
- */
4991
-
4992
-
4993
- function getJSONType(value) {
4994
- return value === null ? 'null' : Array.isArray(value) ? 'array' : _typeof(value);
4995
- }
4996
-
4997
- function _await(value, then, direct) {
4998
- if (direct) {
4999
- return then ? then(value) : value;
5000
- }
5001
-
5002
- if (!value || !value.then) {
5003
- value = Promise.resolve(value);
5004
- }
5005
-
5006
- return then ? value.then(then) : value;
5007
- }
5008
-
5009
- var keys = Object.keys,
5010
- isArray = Array.isArray,
5011
- hasOwn = {}.hasOwnProperty,
5012
- internalStateObjPropsToIgnore = ['type', 'replaced', 'iterateIn', 'iterateUnsetNumeric'];
5013
- /**
5014
- * Handle plain object revivers first so reference setting can use
5015
- * revived type (e.g., array instead of object); assumes revived
5016
- * has same structure or will otherwise break subsequent references.
5017
- * @param {PlainObjectType} a
5018
- * @param {PlainObjectType} b
5019
- * @returns {1|-1|boolean}
5020
- */
5021
-
5022
- function _async(f) {
5023
- return function () {
5024
- for (var args = [], i = 0; i < arguments.length; i++) {
5025
- args[i] = arguments[i];
5026
- }
5027
-
5028
- try {
5029
- return Promise.resolve(f.apply(this, args));
5030
- } catch (e) {
5031
- return Promise.reject(e);
5032
- }
5033
- };
5034
- }
5035
- /**
5036
- * @callback Tester
5037
- * @param {any} value
5038
- * @param {StateObject} stateobj
5039
- * @returns {boolean}
5040
- */
5041
-
5042
- /**
5043
- * @callback Replacer
5044
- * @param {any} value
5045
- * @param {StateObject} stateObj
5046
- * @returns {any} Should be JSON-stringifiable
5047
- */
5048
-
5049
- /**
5050
- * @callback Reviver
5051
- * @param {JSON} value
5052
- * @param {StateObject} stateObj
5053
- * @returns {any}
5054
- */
5055
-
5056
- /**
5057
- * @typedef {PlainObject} TypesonOptions
5058
- * @property {boolean} stringification Auto-set by `stringify`
5059
- */
5060
-
5061
- /**
5062
- * An instance of this class can be used to call `stringify()` and `parse()`.
5063
- * Typeson resolves cyclic references by default. Can also be extended to
5064
- * support custom types using the register() method.
5065
- *
5066
- * @class
5067
- * @param {{cyclic: boolean}} [options] - if cyclic (default true),
5068
- * cyclic references will be handled gracefully.
5069
- */
5070
-
5071
-
5072
- function _invoke(body, then) {
5073
- var result = body();
5074
-
5075
- if (result && result.then) {
5076
- return result.then(then);
5077
- }
5078
-
5079
- return then(result);
5080
- }
5081
-
5082
- function nestedPathsFirst(a, b) {
5083
- if (a.keypath === '') {
5084
- return -1;
5085
- }
5086
-
5087
- var as = a.keypath.match(/\./g) || 0;
5088
- var bs = b.keypath.match(/\./g) || 0;
5089
-
5090
- if (as) {
5091
- as = as.length;
5092
- }
5093
-
5094
- if (bs) {
5095
- bs = bs.length;
5096
- }
5097
-
5098
- return as > bs ? -1 : as < bs ? 1 : a.keypath < b.keypath ? -1 : a.keypath > b.keypath;
5099
- }
5100
-
5101
- var Typeson = /*#__PURE__*/function () {
5102
- /**
5103
- * @param {TypesonOptions} options
5104
- */
5105
- function Typeson(options) {
5106
- _classCallCheck(this, Typeson);
5107
-
5108
- this.options = options; // Replacers signature: replace (value). Returns falsy if not
5109
- // replacing. Otherwise ['Date', value.getTime()]
5110
-
5111
- this.plainObjectReplacers = [];
5112
- this.nonplainObjectReplacers = []; // Revivers: [{type => reviver}, {plain: boolean}].
5113
- // Sample: [{'Date': value => new Date(value)}, {plain: false}]
5114
-
5115
- this.revivers = {};
5116
- /** Types registered via `register()`. */
5117
-
5118
- this.types = {};
5119
- }
5120
- /**
5121
- * @typedef {null|boolean|number|string|GenericArray|PlainObject} JSON
5122
- */
5123
-
5124
- /**
5125
- * @callback JSONReplacer
5126
- * @param {""|string} key
5127
- * @param {JSON} value
5128
- * @returns {number|string|boolean|null|PlainObject|undefined}
5129
- * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The%20replacer%20parameter
5130
- */
5131
-
5132
- /**
5133
- * Serialize given object to Typeson.
5134
- * Initial arguments work identical to those of `JSON.stringify`.
5135
- * The `replacer` argument has nothing to do with our replacers.
5136
- * @param {any} obj
5137
- * @param {JSONReplacer|string[]} replacer
5138
- * @param {number|string} space
5139
- * @param {TypesonOptions} opts
5140
- * @returns {string|Promise<string>} Promise resolves to a string
5141
- */
5142
-
5143
-
5144
- _createClass(Typeson, [{
5145
- key: "stringify",
5146
- value: function stringify(obj, replacer, space, opts) {
5147
- opts = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), opts), {}, {
5148
- stringification: true
5149
- });
5150
- var encapsulated = this.encapsulate(obj, null, opts);
5151
-
5152
- if (isArray(encapsulated)) {
5153
- return JSON.stringify(encapsulated[0], replacer, space);
5154
- }
5155
-
5156
- return encapsulated.then(function (res) {
5157
- return JSON.stringify(res, replacer, space);
5158
- });
5159
- }
5160
- /**
5161
- * Also sync but throws on non-sync result.
5162
- * @param {any} obj
5163
- * @param {JSONReplacer|string[]} replacer
5164
- * @param {number|string} space
5165
- * @param {TypesonOptions} opts
5166
- * @returns {string}
5167
- */
5168
-
5169
- }, {
5170
- key: "stringifySync",
5171
- value: function stringifySync(obj, replacer, space, opts) {
5172
- return this.stringify(obj, replacer, space, _objectSpread2(_objectSpread2({
5173
- throwOnBadSyncType: true
5174
- }, opts), {}, {
5175
- sync: true
5176
- }));
5177
- }
5178
- /**
5179
- *
5180
- * @param {any} obj
5181
- * @param {JSONReplacer|string[]} replacer
5182
- * @param {number|string} space
5183
- * @param {TypesonOptions} opts
5184
- * @returns {Promise<string>}
5185
- */
5186
-
5187
- }, {
5188
- key: "stringifyAsync",
5189
- value: function stringifyAsync(obj, replacer, space, opts) {
5190
- return this.stringify(obj, replacer, space, _objectSpread2(_objectSpread2({
5191
- throwOnBadSyncType: true
5192
- }, opts), {}, {
5193
- sync: false
5194
- }));
5195
- }
5196
- /**
5197
- * @callback JSONReviver
5198
- * @param {string} key
5199
- * @param {JSON} value
5200
- * @returns {JSON}
5201
- */
5202
-
5203
- /**
5204
- * Parse Typeson back into an obejct.
5205
- * Initial arguments works identical to those of `JSON.parse()`.
5206
- * @param {string} text
5207
- * @param {JSONReviver} reviver This JSON reviver has nothing to do with
5208
- * our revivers.
5209
- * @param {TypesonOptions} opts
5210
- * @returns {external:JSON}
5211
- */
5212
-
5213
- }, {
5214
- key: "parse",
5215
- value: function parse(text, reviver, opts) {
5216
- opts = _objectSpread2(_objectSpread2(_objectSpread2({}, this.options), opts), {}, {
5217
- parse: true
5218
- });
5219
- return this.revive(JSON.parse(text, reviver), opts);
5220
- }
5221
- /**
5222
- * Also sync but throws on non-sync result.
5223
- * @param {string} text
5224
- * @param {JSONReviver} reviver This JSON reviver has nothing to do with
5225
- * our revivers.
5226
- * @param {TypesonOptions} opts
5227
- * @returns {external:JSON}
5228
- */
5229
-
5230
- }, {
5231
- key: "parseSync",
5232
- value: function parseSync(text, reviver, opts) {
5233
- return this.parse(text, reviver, _objectSpread2(_objectSpread2({
5234
- throwOnBadSyncType: true
5235
- }, opts), {}, {
5236
- sync: true
5237
- }));
5238
- }
5239
- /**
5240
- * @param {string} text
5241
- * @param {JSONReviver} reviver This JSON reviver has nothing to do with
5242
- * our revivers.
5243
- * @param {TypesonOptions} opts
5244
- * @returns {Promise<external:JSON>} Resolves to `external:JSON`
5245
- */
5246
-
5247
- }, {
5248
- key: "parseAsync",
5249
- value: function parseAsync(text, reviver, opts) {
5250
- return this.parse(text, reviver, _objectSpread2(_objectSpread2({
5251
- throwOnBadSyncType: true
5252
- }, opts), {}, {
5253
- sync: false
5254
- }));
5255
- }
5256
- /**
5257
- * @typedef {} StateObject
5258
- */
5259
-
5260
- /**
5261
- *
5262
- * @param {any} obj
5263
- * @param {StateObject} stateObj
5264
- * @param {TypesonOptions} [opts={}]
5265
- * @returns {string[]|false}
5266
- */
5267
-
5268
- }, {
5269
- key: "specialTypeNames",
5270
- value: function specialTypeNames(obj, stateObj) {
5271
- var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5272
- opts.returnTypeNames = true;
5273
- return this.encapsulate(obj, stateObj, opts);
5274
- }
5275
- /**
5276
- *
5277
- * @param {any} obj
5278
- * @param {PlainObject} stateObj
5279
- * @param {PlainObject} [opts={}]
5280
- * @returns {Promise<any>|GenericArray|PlainObject|string|false}
5281
- */
5282
-
5283
- }, {
5284
- key: "rootTypeName",
5285
- value: function rootTypeName(obj, stateObj) {
5286
- var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
5287
- opts.iterateNone = true;
5288
- return this.encapsulate(obj, stateObj, opts);
5289
- }
5290
- /**
5291
- * Encapsulate a complex object into a plain Object by replacing
5292
- * registered types with plain objects representing the types data.
5293
- *
5294
- * This method is used internally by `Typeson.stringify()`.
5295
- * @param {any} obj - Object to encapsulate.
5296
- * @param {PlainObject} stateObj
5297
- * @param {PlainObject} opts
5298
- * @returns {Promise<any>|GenericArray|PlainObject|string|false}
5299
- */
5300
-
5301
- }, {
5302
- key: "encapsulate",
5303
- value: function encapsulate(obj, stateObj, opts) {
5304
- /**
5305
- *
5306
- * @param {any} ret
5307
- * @param {GenericArray} promisesData
5308
- * @returns {Promise<any>}
5309
- */
5310
- var checkPromises = _async(function (ret, promisesData) {
5311
- return _await(Promise.all(promisesData.map(function (pd) {
5312
- return pd[1].p;
5313
- })), function (promResults) {
5314
- return _await(Promise.all(promResults.map(_async(function (promResult) {
5315
- var _exit = false;
5316
- var newPromisesData = [];
5317
-
5318
- var _promisesData$splice = promisesData.splice(0, 1),
5319
- _promisesData$splice2 = _slicedToArray(_promisesData$splice, 1),
5320
- prData = _promisesData$splice2[0];
5321
-
5322
- var _prData = _slicedToArray(prData, 7),
5323
- keyPath = _prData[0],
5324
- cyclic = _prData[2],
5325
- stateObj = _prData[3],
5326
- parentObj = _prData[4],
5327
- key = _prData[5],
5328
- detectedType = _prData[6];
5329
-
5330
- var encaps = _encapsulate(keyPath, promResult, cyclic, stateObj, newPromisesData, true, detectedType);
5331
-
5332
- var isTypesonPromise = hasConstructorOf(encaps, TypesonPromise); // Handle case where an embedded custom type itself
5333
- // returns a `Typeson.Promise`
5334
-
5335
- return _invoke(function () {
5336
- if (keyPath && isTypesonPromise) {
5337
- return _await(encaps.p, function (encaps2) {
5338
- parentObj[key] = encaps2;
5339
- _exit = true;
5340
- return checkPromises(ret, newPromisesData);
5341
- });
5342
- }
5343
- }, function (_result) {
5344
- if (_exit) return _result;
5345
-
5346
- if (keyPath) {
5347
- parentObj[key] = encaps;
5348
- } else if (isTypesonPromise) {
5349
- ret = encaps.p;
5350
- } else {
5351
- // If this is itself a `Typeson.Promise` (because the
5352
- // original value supplied was a `Promise` or
5353
- // because the supplied custom type value resolved
5354
- // to one), returning it below will be fine since
5355
- // a `Promise` is expected anyways given current
5356
- // config (and if not a `Promise`, it will be ready
5357
- // as the resolve value)
5358
- ret = encaps;
5359
- }
5360
-
5361
- return checkPromises(ret, newPromisesData);
5362
- });
5363
- }))), function () {
5364
- return ret;
5365
- });
5366
- });
5367
- });
5368
- /**
5369
- * @typedef {PlainObject} OwnKeysObject
5370
- * @property {boolean} ownKeys
5371
- */
5372
-
5373
- /**
5374
- * @callback BuiltinStateObjectPropertiesCallback
5375
- * @returns {void}
5376
- */
5377
-
5378
- /**
5379
- *
5380
- * @param {StateObject} stateObj
5381
- * @param {OwnKeysObject} ownKeysObj
5382
- * @param {BuiltinStateObjectPropertiesCallback} cb
5383
- * @returns {undefined}
5384
- */
5385
-
5386
-
5387
- opts = _objectSpread2(_objectSpread2({
5388
- sync: true
5389
- }, this.options), opts);
5390
- var _opts = opts,
5391
- sync = _opts.sync;
5392
- var that = this,
5393
- types = {},
5394
- refObjs = [],
5395
- // For checking cyclic references
5396
- refKeys = [],
5397
- // For checking cyclic references
5398
- promisesDataRoot = []; // Clone the object deeply while at the same time replacing any
5399
- // special types or cyclic reference:
5400
-
5401
- var cyclic = 'cyclic' in opts ? opts.cyclic : true;
5402
- var _opts2 = opts,
5403
- encapsulateObserver = _opts2.encapsulateObserver;
5404
-
5405
- var ret = _encapsulate('', obj, cyclic, stateObj || {}, promisesDataRoot);
5406
- /**
5407
- *
5408
- * @param {any} ret
5409
- * @returns {GenericArray|PlainObject|string|false}
5410
- */
5411
-
5412
-
5413
- function finish(ret) {
5414
- // Add `$types` to result only if we ever bumped into a
5415
- // special type (or special case where object has own `$types`)
5416
- var typeNames = Object.values(types);
5417
-
5418
- if (opts.iterateNone) {
5419
- if (typeNames.length) {
5420
- return typeNames[0];
5421
- }
5422
-
5423
- return Typeson.getJSONType(ret);
5424
- }
5425
-
5426
- if (typeNames.length) {
5427
- if (opts.returnTypeNames) {
5428
- return _toConsumableArray(new Set(typeNames));
5429
- } // Special if array (or a primitive) was serialized
5430
- // because JSON would ignore custom `$types` prop on it
5431
-
5432
-
5433
- if (!ret || !isPlainObject(ret) || // Also need to handle if this is an object with its
5434
- // own `$types` property (to avoid ambiguity)
5435
- hasOwn.call(ret, '$types')) {
5436
- ret = {
5437
- $: ret,
5438
- $types: {
5439
- $: types
5440
- }
5441
- };
5442
- } else {
5443
- ret.$types = types;
5444
- } // No special types
5445
-
5446
- } else if (isObject(ret) && hasOwn.call(ret, '$types')) {
5447
- ret = {
5448
- $: ret,
5449
- $types: true
5450
- };
5451
- }
5452
-
5453
- if (opts.returnTypeNames) {
5454
- return false;
5455
- }
5456
-
5457
- return ret;
5458
- }
5459
-
5460
- function _adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, cb) {
5461
- Object.assign(stateObj, ownKeysObj);
5462
- var vals = internalStateObjPropsToIgnore.map(function (prop) {
5463
- var tmp = stateObj[prop];
5464
- delete stateObj[prop];
5465
- return tmp;
5466
- }); // eslint-disable-next-line node/callback-return
5467
-
5468
- cb();
5469
- internalStateObjPropsToIgnore.forEach(function (prop, i) {
5470
- stateObj[prop] = vals[i];
5471
- });
5472
- }
5473
- /**
5474
- *
5475
- * @param {string} keypath
5476
- * @param {any} value
5477
- * @param {boolean} cyclic
5478
- * @param {PlainObject} stateObj
5479
- * @param {boolean} promisesData
5480
- * @param {boolean} resolvingTypesonPromise
5481
- * @param {string} detectedType
5482
- * @returns {any}
5483
- */
5484
-
5485
-
5486
- function _encapsulate(keypath, value, cyclic, stateObj, promisesData, resolvingTypesonPromise, detectedType) {
5487
- var ret;
5488
- var observerData = {};
5489
-
5490
- var $typeof = _typeof(value);
5491
-
5492
- var runObserver = encapsulateObserver ? function (obj) {
5493
- var type = detectedType || stateObj.type || Typeson.getJSONType(value);
5494
- encapsulateObserver(Object.assign(obj || observerData, {
5495
- keypath: keypath,
5496
- value: value,
5497
- cyclic: cyclic,
5498
- stateObj: stateObj,
5499
- promisesData: promisesData,
5500
- resolvingTypesonPromise: resolvingTypesonPromise,
5501
- awaitingTypesonPromise: hasConstructorOf(value, TypesonPromise)
5502
- }, {
5503
- type: type
5504
- }));
5505
- } : null;
5506
-
5507
- if (['string', 'boolean', 'number', 'undefined'].includes($typeof)) {
5508
- if (value === undefined || Number.isNaN(value) || value === Number.NEGATIVE_INFINITY || value === Number.POSITIVE_INFINITY) {
5509
- ret = stateObj.replaced ? value : replace(keypath, value, stateObj, promisesData, false, resolvingTypesonPromise, runObserver);
5510
-
5511
- if (ret !== value) {
5512
- observerData = {
5513
- replaced: ret
5514
- };
5515
- }
5516
- } else {
5517
- ret = value;
5518
- }
5519
-
5520
- if (runObserver) {
5521
- runObserver();
5522
- }
5523
-
5524
- return ret;
5525
- }
5526
-
5527
- if (value === null) {
5528
- if (runObserver) {
5529
- runObserver();
5530
- }
5531
-
5532
- return value;
5533
- }
5534
-
5535
- if (cyclic && !stateObj.iterateIn && !stateObj.iterateUnsetNumeric && value && _typeof(value) === 'object') {
5536
- // Options set to detect cyclic references and be able
5537
- // to rewrite them.
5538
- var refIndex = refObjs.indexOf(value);
5539
-
5540
- if (refIndex < 0) {
5541
- if (cyclic === true) {
5542
- refObjs.push(value);
5543
- refKeys.push(keypath);
5544
- }
5545
- } else {
5546
- types[keypath] = '#';
5547
-
5548
- if (runObserver) {
5549
- runObserver({
5550
- cyclicKeypath: refKeys[refIndex]
5551
- });
5552
- }
5553
-
5554
- return '#' + refKeys[refIndex];
5555
- }
5556
- }
5557
-
5558
- var isPlainObj = isPlainObject(value);
5559
- var isArr = isArray(value);
5560
- var replaced = // Running replace will cause infinite loop as will test
5561
- // positive again
5562
- (isPlainObj || isArr) && (!that.plainObjectReplacers.length || stateObj.replaced) || stateObj.iterateIn ? // Optimization: if plain object and no plain-object
5563
- // replacers, don't try finding a replacer
5564
- value : replace(keypath, value, stateObj, promisesData, isPlainObj || isArr, null, runObserver);
5565
- var clone;
5566
-
5567
- if (replaced !== value) {
5568
- ret = replaced;
5569
- observerData = {
5570
- replaced: replaced
5571
- };
5572
- } else {
5573
- // eslint-disable-next-line no-lonely-if
5574
- if (keypath === '' && hasConstructorOf(value, TypesonPromise)) {
5575
- promisesData.push([keypath, value, cyclic, stateObj, undefined, undefined, stateObj.type]);
5576
- ret = value;
5577
- } else if (isArr && stateObj.iterateIn !== 'object' || stateObj.iterateIn === 'array') {
5578
- // eslint-disable-next-line unicorn/no-new-array -- Sparse
5579
- clone = new Array(value.length);
5580
- observerData = {
5581
- clone: clone
5582
- };
5583
- } else if (!['function', 'symbol'].includes(_typeof(value)) && !('toJSON' in value) && !hasConstructorOf(value, TypesonPromise) && !hasConstructorOf(value, Promise) && !hasConstructorOf(value, ArrayBuffer) || isPlainObj || stateObj.iterateIn === 'object') {
5584
- clone = {};
5585
-
5586
- if (stateObj.addLength) {
5587
- clone.length = value.length;
5588
- }
5589
-
5590
- observerData = {
5591
- clone: clone
5592
- };
5593
- } else {
5594
- ret = value; // Only clone vanilla objects and arrays
5595
- }
5596
- }
5597
-
5598
- if (runObserver) {
5599
- runObserver();
5600
- }
5601
-
5602
- if (opts.iterateNone) {
5603
- return clone || ret;
5604
- }
5605
-
5606
- if (!clone) {
5607
- return ret;
5608
- } // Iterate object or array
5609
-
5610
-
5611
- if (stateObj.iterateIn) {
5612
- var _loop = function _loop(key) {
5613
- var ownKeysObj = {
5614
- ownKeys: hasOwn.call(value, key)
5615
- };
5616
-
5617
- _adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, function () {
5618
- var kp = keypath + (keypath ? '.' : '') + escapeKeyPathComponent(key);
5619
-
5620
- var val = _encapsulate(kp, value[key], Boolean(cyclic), stateObj, promisesData, resolvingTypesonPromise);
5621
-
5622
- if (hasConstructorOf(val, TypesonPromise)) {
5623
- promisesData.push([kp, val, Boolean(cyclic), stateObj, clone, key, stateObj.type]);
5624
- } else if (val !== undefined) {
5625
- clone[key] = val;
5626
- }
5627
- });
5628
- }; // eslint-disable-next-line guard-for-in
5629
-
5630
-
5631
- for (var key in value) {
5632
- _loop(key);
5633
- }
5634
-
5635
- if (runObserver) {
5636
- runObserver({
5637
- endIterateIn: true,
5638
- end: true
5639
- });
5640
- }
5641
- } else {
5642
- // Note: Non-indexes on arrays won't survive stringify so
5643
- // somewhat wasteful for arrays, but so too is iterating
5644
- // all numeric indexes on sparse arrays when not wanted
5645
- // or filtering own keys for positive integers
5646
- keys(value).forEach(function (key) {
5647
- var kp = keypath + (keypath ? '.' : '') + escapeKeyPathComponent(key);
5648
- var ownKeysObj = {
5649
- ownKeys: true
5650
- };
5651
-
5652
- _adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, function () {
5653
- var val = _encapsulate(kp, value[key], Boolean(cyclic), stateObj, promisesData, resolvingTypesonPromise);
5654
-
5655
- if (hasConstructorOf(val, TypesonPromise)) {
5656
- promisesData.push([kp, val, Boolean(cyclic), stateObj, clone, key, stateObj.type]);
5657
- } else if (val !== undefined) {
5658
- clone[key] = val;
5659
- }
5660
- });
5661
- });
5662
-
5663
- if (runObserver) {
5664
- runObserver({
5665
- endIterateOwn: true,
5666
- end: true
5667
- });
5668
- }
5669
- } // Iterate array for non-own numeric properties (we can't
5670
- // replace the prior loop though as it iterates non-integer
5671
- // keys)
5672
-
5673
-
5674
- if (stateObj.iterateUnsetNumeric) {
5675
- var vl = value.length;
5676
-
5677
- var _loop2 = function _loop2(i) {
5678
- if (!(i in value)) {
5679
- // No need to escape numeric
5680
- var kp = keypath + (keypath ? '.' : '') + i;
5681
- var ownKeysObj = {
5682
- ownKeys: false
5683
- };
5684
-
5685
- _adaptBuiltinStateObjectProperties(stateObj, ownKeysObj, function () {
5686
- var val = _encapsulate(kp, undefined, Boolean(cyclic), stateObj, promisesData, resolvingTypesonPromise);
5687
-
5688
- if (hasConstructorOf(val, TypesonPromise)) {
5689
- promisesData.push([kp, val, Boolean(cyclic), stateObj, clone, i, stateObj.type]);
5690
- } else if (val !== undefined) {
5691
- clone[i] = val;
5692
- }
5693
- });
5694
- }
5695
- };
5696
-
5697
- for (var i = 0; i < vl; i++) {
5698
- _loop2(i);
5699
- }
5700
-
5701
- if (runObserver) {
5702
- runObserver({
5703
- endIterateUnsetNumeric: true,
5704
- end: true
5705
- });
5706
- }
5707
- }
5708
-
5709
- return clone;
5710
- }
5711
- /**
5712
- * @typedef {PlainObject} KeyPathEvent
5713
- * @property {string} cyclicKeypath
5714
- */
5715
-
5716
- /**
5717
- * @typedef {PlainObject} EndIterateInEvent
5718
- * @property {boolean} endIterateIn
5719
- * @property {boolean} end
5720
- */
5721
-
5722
- /**
5723
- * @typedef {PlainObject} EndIterateUnsetNumericEvent
5724
- * @property {boolean} endIterateUnsetNumeric
5725
- * @property {boolean} end
5726
- */
5727
-
5728
- /**
5729
- * @typedef {PlainObject} TypeDetectedEvent
5730
- * @property {boolean} typeDetected
5731
- */
5732
-
5733
- /**
5734
- * @typedef {PlainObject} ReplacingEvent
5735
- * @property {boolean} replacing
5736
- */
5737
-
5738
- /**
5739
- * @callback Observer
5740
- * @param {KeyPathEvent|EndIterateInEvent|EndIterateUnsetNumericEvent|
5741
- * TypeDetectedEvent|ReplacingEvent} [event]
5742
- * @returns {void}
5743
- */
5744
-
5745
- /**
5746
- *
5747
- * @param {string} keypath
5748
- * @param {any} value
5749
- * @param {PlainObject} stateObj
5750
- * @param {GenericArray} promisesData
5751
- * @param {boolean} plainObject
5752
- * @param {boolean} resolvingTypesonPromise
5753
- * @param {Observer} [runObserver]
5754
- * @returns {any}
5755
- */
5756
-
5757
-
5758
- function replace(keypath, value, stateObj, promisesData, plainObject, resolvingTypesonPromise, runObserver) {
5759
- // Encapsulate registered types
5760
- var replacers = plainObject ? that.plainObjectReplacers : that.nonplainObjectReplacers;
5761
- var i = replacers.length;
5762
-
5763
- while (i--) {
5764
- var replacer = replacers[i];
5765
-
5766
- if (replacer.test(value, stateObj)) {
5767
- var type = replacer.type;
5768
-
5769
- if (that.revivers[type]) {
5770
- // Record the type only if a corresponding reviver
5771
- // exists. This is to support specs where only
5772
- // replacement is done.
5773
- // For example, ensuring deep cloning of the object,
5774
- // or replacing a type to its equivalent without
5775
- // the need to revive it.
5776
- var existing = types[keypath]; // type can comprise an array of types (see test
5777
- // "should support intermediate types")
5778
-
5779
- types[keypath] = existing ? [type].concat(existing) : type;
5780
- }
5781
-
5782
- Object.assign(stateObj, {
5783
- type: type,
5784
- replaced: true
5785
- });
5786
-
5787
- if ((sync || !replacer.replaceAsync) && !replacer.replace) {
5788
- if (runObserver) {
5789
- runObserver({
5790
- typeDetected: true
5791
- });
5792
- }
5793
-
5794
- return _encapsulate(keypath, value, cyclic && 'readonly', stateObj, promisesData, resolvingTypesonPromise, type);
5795
- }
5796
-
5797
- if (runObserver) {
5798
- runObserver({
5799
- replacing: true
5800
- });
5801
- } // Now, also traverse the result in case it contains its
5802
- // own types to replace
5803
-
5804
-
5805
- var replaceMethod = sync || !replacer.replaceAsync ? 'replace' : 'replaceAsync';
5806
- return _encapsulate(keypath, replacer[replaceMethod](value, stateObj), cyclic && 'readonly', stateObj, promisesData, resolvingTypesonPromise, type);
5807
- }
5808
- }
5809
-
5810
- return value;
5811
- }
5812
-
5813
- return promisesDataRoot.length ? sync && opts.throwOnBadSyncType ? function () {
5814
- throw new TypeError('Sync method requested but async result obtained');
5815
- }() : Promise.resolve(checkPromises(ret, promisesDataRoot)).then(finish) : !sync && opts.throwOnBadSyncType ? function () {
5816
- throw new TypeError('Async method requested but sync result obtained');
5817
- }() // If this is a synchronous request for stringification, yet
5818
- // a promise is the result, we don't want to resolve leading
5819
- // to an async result, so we return an array to avoid
5820
- // ambiguity
5821
- : opts.stringification && sync ? [finish(ret)] : sync ? finish(ret) : Promise.resolve(finish(ret));
5822
- }
5823
- /**
5824
- * Also sync but throws on non-sync result.
5825
- * @param {any} obj
5826
- * @param {StateObject} stateObj
5827
- * @param {TypesonOptions} opts
5828
- * @returns {any}
5829
- */
5830
-
5831
- }, {
5832
- key: "encapsulateSync",
5833
- value: function encapsulateSync(obj, stateObj, opts) {
5834
- return this.encapsulate(obj, stateObj, _objectSpread2(_objectSpread2({
5835
- throwOnBadSyncType: true
5836
- }, opts), {}, {
5837
- sync: true
5838
- }));
5839
- }
5840
- /**
5841
- * @param {any} obj
5842
- * @param {StateObject} stateObj
5843
- * @param {TypesonOptions} opts
5844
- * @returns {any}
5845
- */
5846
-
5847
- }, {
5848
- key: "encapsulateAsync",
5849
- value: function encapsulateAsync(obj, stateObj, opts) {
5850
- return this.encapsulate(obj, stateObj, _objectSpread2(_objectSpread2({
5851
- throwOnBadSyncType: true
5852
- }, opts), {}, {
5853
- sync: false
5854
- }));
5855
- }
5856
- /**
5857
- * Revive an encapsulated object.
5858
- * This method is used internally by `Typeson.parse()`.
5859
- * @param {PlainObject} obj - Object to revive. If it has `$types` member,
5860
- * the properties that are listed there will be replaced with its true
5861
- * type instead of just plain objects.
5862
- * @param {TypesonOptions} opts
5863
- * @throws TypeError If mismatch between sync/async type and result
5864
- * @returns {Promise<any>|any} If async, returns a Promise that resolves
5865
- * to `any`.
5866
- */
5867
-
5868
- }, {
5869
- key: "revive",
5870
- value: function revive(obj, opts) {
5871
- var types = obj && obj.$types; // No type info added. Revival not needed.
5872
-
5873
- if (!types) {
5874
- return obj;
5875
- } // Object happened to have own `$types` property but with
5876
- // no actual types, so we unescape and return that object
5877
-
5878
-
5879
- if (types === true) {
5880
- return obj.$;
5881
- }
5882
-
5883
- opts = _objectSpread2(_objectSpread2({
5884
- sync: true
5885
- }, this.options), opts);
5886
- var _opts3 = opts,
5887
- sync = _opts3.sync;
5888
- var keyPathResolutions = [];
5889
- var stateObj = {};
5890
- var ignore$Types = true; // Special when root object is not a trivial Object, it will
5891
- // be encapsulated in `$`. It will also be encapsulated in
5892
- // `$` if it has its own `$` property to avoid ambiguity
5893
-
5894
- if (types.$ && isPlainObject(types.$)) {
5895
- obj = obj.$;
5896
- types = types.$;
5897
- ignore$Types = false;
5898
- }
5899
-
5900
- var that = this;
5901
- /**
5902
- * @callback RevivalReducer
5903
- * @param {any} value
5904
- * @param {string} type
5905
- * @returns {any}
5906
- */
5907
-
5908
- /**
5909
- *
5910
- * @param {string} type
5911
- * @param {any} val
5912
- * @throws {Error}
5913
- * @returns {any}
5914
- */
5915
-
5916
- function executeReviver(type, val) {
5917
- var _ref = that.revivers[type] || [],
5918
- _ref2 = _slicedToArray(_ref, 1),
5919
- reviver = _ref2[0];
5920
-
5921
- if (!reviver) {
5922
- throw new Error('Unregistered type: ' + type);
5923
- } // Only `sync` expected here, as problematic async would
5924
- // be missing both `reviver` and `reviverAsync`, and
5925
- // encapsulation shouldn't have added types, so
5926
- // should have made an early exit
5927
-
5928
-
5929
- if (sync && !('revive' in reviver)) {
5930
- // Just return value as is
5931
- return val;
5932
- }
5933
-
5934
- return reviver[sync && reviver.revive ? 'revive' : !sync && reviver.reviveAsync ? 'reviveAsync' : 'revive'](val, stateObj);
5935
- }
5936
- /**
5937
- *
5938
- * @returns {void|TypesonPromise<void>}
5939
- */
5940
-
5941
-
5942
- function revivePlainObjects() {
5943
- // const references = [];
5944
- // const reviveTypes = [];
5945
- var plainObjectTypes = [];
5946
- Object.entries(types).forEach(function (_ref3) {
5947
- var _ref4 = _slicedToArray(_ref3, 2),
5948
- keypath = _ref4[0],
5949
- type = _ref4[1];
5950
-
5951
- if (type === '#') {
5952
- /*
5953
- references.push({
5954
- keypath,
5955
- reference: getByKeyPath(obj, keypath)
5956
- });
5957
- */
5958
- return;
5959
- }
5960
-
5961
- [].concat(type).forEach(function (type) {
5962
- var _ref5 = that.revivers[type] || [null, {}],
5963
- _ref6 = _slicedToArray(_ref5, 2),
5964
- plain = _ref6[1].plain;
5965
-
5966
- if (!plain) {
5967
- // reviveTypes.push({keypath, type});
5968
- return;
5969
- }
5970
-
5971
- plainObjectTypes.push({
5972
- keypath: keypath,
5973
- type: type
5974
- });
5975
- delete types[keypath]; // Avoid repeating
5976
- });
5977
- });
5978
-
5979
- if (!plainObjectTypes.length) {
5980
- return undefined;
5981
- } // console.log(plainObjectTypes.sort(nestedPathsFirst));
5982
-
5983
- /**
5984
- * @typedef {PlainObject} PlainObjectType
5985
- * @property {string} keypath
5986
- * @property {string} type
5987
- */
5988
-
5989
-
5990
- return plainObjectTypes.sort(nestedPathsFirst).reduce(function reducer(possibleTypesonPromise, _ref7) {
5991
- var keypath = _ref7.keypath,
5992
- type = _ref7.type;
5993
-
5994
- if (isThenable(possibleTypesonPromise)) {
5995
- return possibleTypesonPromise.then(function (val) {
5996
- return reducer(val, {
5997
- keypath: keypath,
5998
- type: type
5999
- });
6000
- });
6001
- } // console.log('obj', JSON.stringify(keypath), obj);
6002
-
6003
-
6004
- var val = getByKeyPath(obj, keypath);
6005
- val = executeReviver(type, val);
6006
-
6007
- if (hasConstructorOf(val, TypesonPromise)) {
6008
- return val.then(function (v) {
6009
- var newVal = setAtKeyPath(obj, keypath, v);
6010
-
6011
- if (newVal === v) {
6012
- obj = newVal;
6013
- }
6014
-
6015
- return undefined;
6016
- });
6017
- }
6018
-
6019
- var newVal = setAtKeyPath(obj, keypath, val);
6020
-
6021
- if (newVal === val) {
6022
- obj = newVal;
6023
- }
6024
-
6025
- return undefined;
6026
- }, undefined // This argument must be explicit
6027
- ); // references.forEach(({keypath, reference}) => {});
6028
- // reviveTypes.sort(nestedPathsFirst).forEach(() => {});
6029
- }
6030
-
6031
- var revivalPromises = [];
6032
- /**
6033
- *
6034
- * @param {string} keypath
6035
- * @param {any} value
6036
- * @param {?(GenericArray|PlainObject)} target
6037
- * @param {GenericArray|PlainObject} [clone]
6038
- * @param {string} [key]
6039
- * @returns {any}
6040
- */
6041
-
6042
- function _revive(keypath, value, target, clone, key) {
6043
- if (ignore$Types && keypath === '$types') {
6044
- return undefined;
6045
- }
6046
-
6047
- var type = types[keypath];
6048
- var isArr = isArray(value);
6049
-
6050
- if (isArr || isPlainObject(value)) {
6051
- // eslint-disable-next-line unicorn/no-new-array -- Sparse
6052
- var _clone = isArr ? new Array(value.length) : {}; // Iterate object or array
6053
-
6054
-
6055
- keys(value).forEach(function (k) {
6056
- var val = _revive(keypath + (keypath ? '.' : '') + escapeKeyPathComponent(k), value[k], target || _clone, _clone, k);
6057
-
6058
- var set = function set(v) {
6059
- if (hasConstructorOf(v, Undefined)) {
6060
- _clone[k] = undefined;
6061
- } else if (v !== undefined) {
6062
- _clone[k] = v;
6063
- }
6064
-
6065
- return v;
6066
- };
6067
-
6068
- if (hasConstructorOf(val, TypesonPromise)) {
6069
- revivalPromises.push(val.then(function (ret) {
6070
- return set(ret);
6071
- }));
6072
- } else {
6073
- set(val);
6074
- }
6075
- });
6076
- value = _clone; // Try to resolve cyclic reference as soon as available
6077
-
6078
- while (keyPathResolutions.length) {
6079
- var _keyPathResolutions$ = _slicedToArray(keyPathResolutions[0], 4),
6080
- _target = _keyPathResolutions$[0],
6081
- keyPath = _keyPathResolutions$[1],
6082
- _clone2 = _keyPathResolutions$[2],
6083
- k = _keyPathResolutions$[3];
6084
-
6085
- var val = getByKeyPath(_target, keyPath); // Typeson.Undefined not expected here as not cyclic or
6086
- // `undefined`
6087
-
6088
- if (val !== undefined) {
6089
- _clone2[k] = val;
6090
- } else {
6091
- break;
6092
- }
6093
-
6094
- keyPathResolutions.splice(0, 1);
6095
- }
6096
- }
6097
-
6098
- if (!type) {
6099
- return value;
6100
- }
6101
-
6102
- if (type === '#') {
6103
- var _ret = getByKeyPath(target, value.slice(1));
6104
-
6105
- if (_ret === undefined) {
6106
- // Cyclic reference not yet available
6107
- keyPathResolutions.push([target, value.slice(1), clone, key]);
6108
- }
6109
-
6110
- return _ret;
6111
- } // `type` can be an array here
6112
-
6113
-
6114
- return [].concat(type).reduce(function reducer(val, typ) {
6115
- if (hasConstructorOf(val, TypesonPromise)) {
6116
- return val.then(function (v) {
6117
- // TypesonPromise here too
6118
- return reducer(v, typ);
6119
- });
6120
- }
6121
-
6122
- return executeReviver(typ, val);
6123
- }, value);
6124
- }
6125
- /**
6126
- *
6127
- * @param {any} retrn
6128
- * @returns {undefined|any}
6129
- */
6130
-
6131
-
6132
- function checkUndefined(retrn) {
6133
- return hasConstructorOf(retrn, Undefined) ? undefined : retrn;
6134
- }
6135
-
6136
- var possibleTypesonPromise = revivePlainObjects();
6137
- var ret;
6138
-
6139
- if (hasConstructorOf(possibleTypesonPromise, TypesonPromise)) {
6140
- ret = possibleTypesonPromise.then(function () {
6141
- return obj;
6142
- });
6143
- } else {
6144
- ret = _revive('', obj, null);
6145
-
6146
- if (revivalPromises.length) {
6147
- // Ensure children resolved
6148
- ret = TypesonPromise.resolve(ret).then(function (r) {
6149
- return TypesonPromise.all([// May be a TypesonPromise or not
6150
- r].concat(revivalPromises));
6151
- }).then(function (_ref8) {
6152
- var _ref9 = _slicedToArray(_ref8, 1),
6153
- r = _ref9[0];
6154
-
6155
- return r;
6156
- });
6157
- }
6158
- }
6159
-
6160
- return isThenable(ret) ? sync && opts.throwOnBadSyncType ? function () {
6161
- throw new TypeError('Sync method requested but async result obtained');
6162
- }() : hasConstructorOf(ret, TypesonPromise) ? ret.p.then(checkUndefined) : ret : !sync && opts.throwOnBadSyncType ? function () {
6163
- throw new TypeError('Async method requested but sync result obtained');
6164
- }() : sync ? checkUndefined(ret) : Promise.resolve(checkUndefined(ret));
6165
- }
6166
- /**
6167
- * Also sync but throws on non-sync result.
6168
- * @param {any} obj
6169
- * @param {TypesonOptions} opts
6170
- * @returns {any}
6171
- */
6172
-
6173
- }, {
6174
- key: "reviveSync",
6175
- value: function reviveSync(obj, opts) {
6176
- return this.revive(obj, _objectSpread2(_objectSpread2({
6177
- throwOnBadSyncType: true
6178
- }, opts), {}, {
6179
- sync: true
6180
- }));
6181
- }
6182
- /**
6183
- * @param {any} obj
6184
- * @param {TypesonOptions} opts
6185
- * @returns {Promise<any>}
6186
- */
6187
-
6188
- }, {
6189
- key: "reviveAsync",
6190
- value: function reviveAsync(obj, opts) {
6191
- return this.revive(obj, _objectSpread2(_objectSpread2({
6192
- throwOnBadSyncType: true
6193
- }, opts), {}, {
6194
- sync: false
6195
- }));
6196
- }
6197
- /**
6198
- * @typedef {Tester|Replacer|Reviver} Spec
6199
- */
6200
-
6201
- /**
6202
- * Register types.
6203
- * For examples on how to use this method, see
6204
- * {@link https://github.com/dfahlander/typeson-registry/tree/master/types}.
6205
- * @param {object<string,Spec[]>[]} typeSpecSets -
6206
- * Types and their functions [test, encapsulate, revive];
6207
- * @param {TypesonOptions} opts
6208
- * @returns {Typeson}
6209
- */
6210
-
6211
- }, {
6212
- key: "register",
6213
- value: function register(typeSpecSets, opts) {
6214
- opts = opts || {};
6215
- [].concat(typeSpecSets).forEach(function R(typeSpec) {
6216
- var _this = this; // Allow arrays of arrays of arrays...
6217
-
6218
-
6219
- if (isArray(typeSpec)) {
6220
- return typeSpec.map(function (typSpec) {
6221
- return R.call(_this, typSpec);
6222
- });
6223
- }
6224
-
6225
- typeSpec && keys(typeSpec).forEach(function (typeId) {
6226
- if (typeId === '#') {
6227
- throw new TypeError('# cannot be used as a type name as it is reserved ' + 'for cyclic objects');
6228
- } else if (Typeson.JSON_TYPES.includes(typeId)) {
6229
- throw new TypeError('Plain JSON object types are reserved as type names');
6230
- }
6231
-
6232
- var spec = typeSpec[typeId];
6233
- var replacers = spec && spec.testPlainObjects ? this.plainObjectReplacers : this.nonplainObjectReplacers;
6234
- var existingReplacer = replacers.filter(function (r) {
6235
- return r.type === typeId;
6236
- });
6237
-
6238
- if (existingReplacer.length) {
6239
- // Remove existing spec and replace with this one.
6240
- replacers.splice(replacers.indexOf(existingReplacer[0]), 1);
6241
- delete this.revivers[typeId];
6242
- delete this.types[typeId];
6243
- }
6244
-
6245
- if (typeof spec === 'function') {
6246
- // Support registering just a class without replacer/reviver
6247
- var Class = spec;
6248
- spec = {
6249
- test: function test(x) {
6250
- return x && x.constructor === Class;
6251
- },
6252
- replace: function replace(x) {
6253
- return _objectSpread2({}, x);
6254
- },
6255
- revive: function revive(x) {
6256
- return Object.assign(Object.create(Class.prototype), x);
6257
- }
6258
- };
6259
- } else if (isArray(spec)) {
6260
- var _spec = spec,
6261
- _spec2 = _slicedToArray(_spec, 3),
6262
- test = _spec2[0],
6263
- replace = _spec2[1],
6264
- revive = _spec2[2];
6265
-
6266
- spec = {
6267
- test: test,
6268
- replace: replace,
6269
- revive: revive
6270
- };
6271
- }
6272
-
6273
- if (!spec || !spec.test) {
6274
- return;
6275
- }
6276
-
6277
- var replacerObj = {
6278
- type: typeId,
6279
- test: spec.test.bind(spec)
6280
- };
6281
-
6282
- if (spec.replace) {
6283
- replacerObj.replace = spec.replace.bind(spec);
6284
- }
6285
-
6286
- if (spec.replaceAsync) {
6287
- replacerObj.replaceAsync = spec.replaceAsync.bind(spec);
6288
- }
6289
-
6290
- var start = typeof opts.fallback === 'number' ? opts.fallback : opts.fallback ? 0 : Number.POSITIVE_INFINITY;
6291
-
6292
- if (spec.testPlainObjects) {
6293
- this.plainObjectReplacers.splice(start, 0, replacerObj);
6294
- } else {
6295
- this.nonplainObjectReplacers.splice(start, 0, replacerObj);
6296
- } // Todo: We might consider a testAsync type
6297
-
6298
-
6299
- if (spec.revive || spec.reviveAsync) {
6300
- var reviverObj = {};
6301
-
6302
- if (spec.revive) {
6303
- reviverObj.revive = spec.revive.bind(spec);
6304
- }
6305
-
6306
- if (spec.reviveAsync) {
6307
- reviverObj.reviveAsync = spec.reviveAsync.bind(spec);
6308
- }
6309
-
6310
- this.revivers[typeId] = [reviverObj, {
6311
- plain: spec.testPlainObjects
6312
- }];
6313
- } // Record to be retrieved via public types property.
6314
-
6315
-
6316
- this.types[typeId] = spec;
6317
- }, this);
6318
- }, this);
6319
- return this;
6320
- }
6321
- }]);
6322
-
6323
- return Typeson;
6324
- }();
6325
- /**
6326
- * We keep this function minimized so if using two instances of this
6327
- * library, where one is minimized and one is not, it will still work
6328
- * with `hasConstructorOf`.
6329
- * @class
6330
- */
6331
-
6332
-
6333
- var Undefined = function Undefined() {
6334
- _classCallCheck(this, Undefined);
6335
- }; // eslint-disable-line space-before-blocks
6336
-
6337
-
6338
- Undefined.__typeson__type__ = 'TypesonUndefined'; // The following provide classes meant to avoid clashes with other values
6339
- // To insist `undefined` should be added
6340
-
6341
- Typeson.Undefined = Undefined; // To support async encapsulation/stringification
6342
-
6343
- Typeson.Promise = TypesonPromise; // Some fundamental type-checking utilities
6344
-
6345
- Typeson.isThenable = isThenable;
6346
- Typeson.toStringTag = toStringTag;
6347
- Typeson.hasConstructorOf = hasConstructorOf;
6348
- Typeson.isObject = isObject;
6349
- Typeson.isPlainObject = isPlainObject;
6350
- Typeson.isUserObject = isUserObject;
6351
- Typeson.escapeKeyPathComponent = escapeKeyPathComponent;
6352
- Typeson.unescapeKeyPathComponent = unescapeKeyPathComponent;
6353
- Typeson.getByKeyPath = getByKeyPath;
6354
- Typeson.getJSONType = getJSONType;
6355
- Typeson.JSON_TYPES = ['null', 'boolean', 'number', 'string', 'array', 'object'];
6356
- return Typeson;
6357
- });
6358
- })(typeson$1);
6359
-
6360
- var Typeson = typeson$1.exports;
6361
-
6362
- /*
6363
- * base64-arraybuffer
6364
- * https://github.com/niklasvh/base64-arraybuffer
6365
- *
6366
- * Copyright (c) 2017 Brett Zamir, 2012 Niklas von Hertzen
6367
- * Licensed under the MIT license.
6368
- */
6369
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; // Use a lookup table to find the index.
6370
-
6371
- var lookup = new Uint8Array(256);
6372
-
6373
- for (var i = 0; i < chars.length; i++) {
6374
- lookup[chars.charCodeAt(i)] = i;
6375
- }
6376
- /**
6377
- * @param {ArrayBuffer} arraybuffer
6378
- * @param {Integer} byteOffset
6379
- * @param {Integer} lngth
6380
- * @returns {string}
6381
- */
6382
-
6383
-
6384
- var encode$1 = function encode(arraybuffer, byteOffset, lngth) {
6385
- if (lngth === null || lngth === undefined) {
6386
- lngth = arraybuffer.byteLength; // Needed for Safari
5326
+ for (var c = new ArrayBuffer(i), u = new Uint8Array(c), l = 0; l < o; l += 4) {
5327
+ 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;
6387
5328
  }
6388
5329
 
6389
- var bytes = new Uint8Array(arraybuffer, byteOffset || 0, // Default needed for Safari
6390
- lngth);
6391
- var len = bytes.length;
6392
- var base64 = '';
6393
-
6394
- for (var _i = 0; _i < len; _i += 3) {
6395
- base64 += chars[bytes[_i] >> 2];
6396
- base64 += chars[(bytes[_i] & 3) << 4 | bytes[_i + 1] >> 4];
6397
- base64 += chars[(bytes[_i + 1] & 15) << 2 | bytes[_i + 2] >> 6];
6398
- base64 += chars[bytes[_i + 2] & 63];
6399
- }
6400
-
6401
- if (len % 3 === 2) {
6402
- base64 = base64.slice(0, -1) + '=';
6403
- } else if (len % 3 === 1) {
6404
- base64 = base64.slice(0, -2) + '==';
6405
- }
6406
-
6407
- return base64;
6408
- };
6409
- /**
6410
- * @param {string} base64
6411
- * @returns {ArrayBuffer}
6412
- */
6413
-
6414
-
6415
- var decode$1 = function decode(base64) {
6416
- var len = base64.length;
6417
- var bufferLength = base64.length * 0.75;
6418
- var p = 0;
6419
- var encoded1, encoded2, encoded3, encoded4;
6420
-
6421
- if (base64[base64.length - 1] === '=') {
6422
- bufferLength--;
6423
-
6424
- if (base64[base64.length - 2] === '=') {
6425
- bufferLength--;
6426
- }
6427
- }
6428
-
6429
- var arraybuffer = new ArrayBuffer(bufferLength),
6430
- bytes = new Uint8Array(arraybuffer);
6431
-
6432
- for (var _i2 = 0; _i2 < len; _i2 += 4) {
6433
- encoded1 = lookup[base64.charCodeAt(_i2)];
6434
- encoded2 = lookup[base64.charCodeAt(_i2 + 1)];
6435
- encoded3 = lookup[base64.charCodeAt(_i2 + 2)];
6436
- encoded4 = lookup[base64.charCodeAt(_i2 + 3)];
6437
- bytes[p++] = encoded1 << 2 | encoded2 >> 4;
6438
- bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
6439
- bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
6440
- }
6441
-
6442
- return arraybuffer;
6443
- };
6444
-
6445
- var arraybuffer = {
6446
- arraybuffer: {
6447
- test: function test(x) {
6448
- return Typeson.toStringTag(x) === 'ArrayBuffer';
6449
- },
6450
- replace: function replace(b, stateObj) {
6451
- if (!stateObj.buffers) {
6452
- stateObj.buffers = [];
6453
- }
6454
-
6455
- var index = stateObj.buffers.indexOf(b);
6456
-
6457
- if (index > -1) {
6458
- return {
6459
- index: index
6460
- };
6461
- }
6462
-
6463
- stateObj.buffers.push(b);
6464
- return encode$1(b);
6465
- },
6466
- revive: function revive(b64, stateObj) {
6467
- if (!stateObj.buffers) {
6468
- stateObj.buffers = [];
6469
- }
6470
-
6471
- if (_typeof$1(b64) === 'object') {
6472
- return stateObj.buffers[b64.index];
6473
- }
6474
-
6475
- var buffer = decode$1(b64);
6476
- stateObj.buffers.push(buffer);
6477
- return buffer;
6478
- }
6479
- }
5330
+ return c;
6480
5331
  };
6481
- // See also typed-arrays!
6482
5332
 
6483
- var bigintObject = {
5333
+ var h = {
5334
+ arraybuffer: {
5335
+ test: function test(e) {
5336
+ return "ArrayBuffer" === toStringTag(e);
5337
+ },
5338
+ replace: function replace(e, t) {
5339
+ t.buffers || (t.buffers = []);
5340
+ var r = t.buffers.indexOf(e);
5341
+ return r > -1 ? {
5342
+ index: r
5343
+ } : (t.buffers.push(e), v(e));
5344
+ },
5345
+ revive: function revive(e, t) {
5346
+ if (t.buffers || (t.buffers = []), "object" == _typeof$2(e)) return t.buffers[e.index];
5347
+ var r = b(e);
5348
+ return t.buffers.push(r), r;
5349
+ }
5350
+ }
5351
+ },
5352
+ g = {
6484
5353
  bigintObject: {
6485
- test: function test(x) {
6486
- return _typeof$1(x) === 'object' && Typeson.hasConstructorOf(x, BigInt);
5354
+ test: function test(e) {
5355
+ return "object" == _typeof$2(e) && hasConstructorOf(e, BigInt);
6487
5356
  },
6488
- replace: function replace(n) {
6489
- return String(n);
5357
+ replace: function replace(e) {
5358
+ return String(e);
6490
5359
  },
6491
- revive: function revive(s) {
6492
- // Filed this to avoid error: https://github.com/eslint/eslint/issues/11810
6493
- // eslint-disable-next-line no-new-object
6494
- return new Object(BigInt(s));
5360
+ revive: function revive(e) {
5361
+ return new Object(BigInt(e));
6495
5362
  }
6496
5363
  }
6497
- };
6498
-
6499
- /* globals BigInt */
6500
- var bigint = {
5364
+ },
5365
+ m = {
6501
5366
  bigint: {
6502
- test: function test(x) {
6503
- return typeof x === 'bigint';
5367
+ test: function test(e) {
5368
+ return "bigint" == typeof e;
6504
5369
  },
6505
- replace: function replace(n) {
6506
- return String(n);
5370
+ replace: function replace(e) {
5371
+ return String(e);
6507
5372
  },
6508
- revive: function revive(s) {
6509
- return BigInt(s);
5373
+ revive: function revive(e) {
5374
+ return BigInt(e);
6510
5375
  }
6511
5376
  }
6512
5377
  };
6513
5378
 
6514
- /**
6515
- * Not currently in use internally, but provided for parity.
6516
- * @param {ArrayBuffer} buf
6517
- * @returns {Uint8Array}
6518
- */
6519
- /**
6520
- *
6521
- * @param {string} str
6522
- * @returns {ArrayBuffer}
6523
- */
6524
-
6525
-
6526
- function string2arraybuffer(str) {
6527
- /*
6528
- // UTF-8 approaches
6529
- const utf8 = unescape(encodeURIComponent(str));
6530
- const arr = new Uint8Array(utf8.length);
6531
- for (let i = 0; i < utf8.length; i++) {
6532
- arr[i] = utf8.charCodeAt(i);
6533
- }
6534
- return arr.buffer;
6535
- const utf8 = [];
6536
- for (let i = 0; i < str.length; i++) {
6537
- let charcode = str.charCodeAt(i);
6538
- if (charcode < 0x80) utf8.push(charcode);
6539
- else if (charcode < 0x800) {
6540
- utf8.push(0xc0 | (charcode >> 6),
6541
- 0x80 | (charcode & 0x3f));
6542
- } else if (charcode < 0xd800 || charcode >= 0xe000) {
6543
- utf8.push(0xe0 | (charcode >> 12),
6544
- 0x80 | ((charcode >> 6) & 0x3f),
6545
- 0x80 | (charcode & 0x3f));
6546
- // surrogate pair
6547
- } else {
6548
- i++;
6549
- // UTF-16 encodes 0x10000-0x10FFFF by
6550
- // subtracting 0x10000 and splitting the
6551
- // 20 bits of 0x0-0xFFFFF into two halves
6552
- charcode = 0x10000 + (((charcode & 0x3ff) << 10) |
6553
- (str.charCodeAt(i) & 0x3ff));
6554
- utf8.push(0xf0 | (charcode >> 18),
6555
- 0x80 | ((charcode >> 12) & 0x3f),
6556
- 0x80 | ((charcode >> 6) & 0x3f),
6557
- 0x80 | (charcode & 0x3f));
6558
- }
6559
- }
6560
- return utf8;
6561
- */
6562
-
6563
- /*
6564
- // Working UTF-16 options (equivalents)
6565
- const buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
6566
- const bufView = new Uint16Array(buf);
6567
- for (let i = 0, strLen = str.length; i < strLen; i++) {
6568
- bufView[i] = str.charCodeAt(i);
6569
- }
6570
- return buf;
6571
- */
6572
- var array = new Uint8Array(str.length);
5379
+ function string2arraybuffer(e) {
5380
+ var t = new Uint8Array(e.length);
6573
5381
 
6574
- for (var i = 0; i < str.length; i++) {
6575
- array[i] = str.charCodeAt(i); // & 0xff;
5382
+ for (var _r = 0; _r < e.length; _r++) {
5383
+ t[_r] = e.charCodeAt(_r);
6576
5384
  }
6577
5385
 
6578
- return array.buffer;
5386
+ return t.buffer;
6579
5387
  }
6580
5388
 
6581
- /* globals XMLHttpRequest, Blob, FileReader */
6582
- var blob = {
5389
+ var O = {
6583
5390
  blob: {
6584
- test: function test(x) {
6585
- return Typeson.toStringTag(x) === 'Blob';
5391
+ test: function test(e) {
5392
+ return "Blob" === toStringTag(e);
6586
5393
  },
6587
- replace: function replace(b) {
6588
- // Sync
6589
- var req = new XMLHttpRequest();
6590
- req.overrideMimeType('text/plain; charset=x-user-defined');
6591
- req.open('GET', URL.createObjectURL(b), false); // Sync
6592
-
6593
- req.send(); // Seems not feasible to accurately simulate
6594
-
6595
- /* istanbul ignore next */
6596
-
6597
- if (req.status !== 200 && req.status !== 0) {
6598
- throw new Error('Bad Blob access: ' + req.status);
6599
- }
6600
-
5394
+ replace: function replace(e) {
5395
+ var t = new XMLHttpRequest();
5396
+ 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);
6601
5397
  return {
6602
- type: b.type,
6603
- stringContents: req.responseText
5398
+ type: e.type,
5399
+ stringContents: t.responseText
6604
5400
  };
6605
5401
  },
6606
5402
  revive: function revive(_ref) {
6607
- var type = _ref.type,
6608
- stringContents = _ref.stringContents;
6609
- return new Blob([string2arraybuffer(stringContents)], {
6610
- type: type
5403
+ var e = _ref.type,
5404
+ t = _ref.stringContents;
5405
+ return new Blob([string2arraybuffer(t)], {
5406
+ type: e
6611
5407
  });
6612
5408
  },
6613
- replaceAsync: function replaceAsync(b) {
6614
- return new Typeson.Promise(function (resolve, reject) {
6615
- /*
6616
- if (b.isClosed) { // On MDN, but not in https://w3c.github.io/FileAPI/#dfn-Blob
6617
- reject(new Error('The Blob is closed'));
6618
- return;
6619
- }
6620
- */
6621
- var reader = new FileReader();
6622
- reader.addEventListener('load', function () {
6623
- resolve({
6624
- type: b.type,
6625
- stringContents: reader.result
5409
+ replaceAsync: function replaceAsync(t) {
5410
+ return new e(function (e, r) {
5411
+ var n = new FileReader();
5412
+ n.addEventListener("load", function () {
5413
+ e({
5414
+ type: t.type,
5415
+ stringContents: n.result
6626
5416
  });
6627
- }); // Seems not feasible to accurately simulate
6628
-
6629
- /* istanbul ignore next */
6630
-
6631
- reader.addEventListener('error', function () {
6632
- reject(reader.error);
6633
- });
6634
- reader.readAsBinaryString(b);
5417
+ }), n.addEventListener("error", function () {
5418
+ r(n.error);
5419
+ }), n.readAsBinaryString(t);
6635
5420
  });
6636
5421
  }
6637
5422
  }
6638
5423
  };
6639
5424
 
6640
- /* globals performance */
6641
- // The `performance` global is optional
6642
-
6643
- /**
6644
- * @todo We could use `import generateUUID from 'uuid/v4';` (but it needs
6645
- * crypto library, etc.; `rollup-plugin-node-builtins` doesn't recommend
6646
- * using its own version and though there is <https://www.npmjs.com/package/crypto-browserify>,
6647
- * it may be troublesome to bundle and not strongly needed)
6648
- * @returns {string}
6649
- */
6650
- function generateUUID() {
6651
- // Adapted from original: public domain/MIT: http://stackoverflow.com/a/8809472/271577
6652
-
6653
- /* istanbul ignore next */
6654
- var d = Date.now() + ( // use high-precision timer if available
6655
- // istanbul ignore next
6656
- typeof performance !== 'undefined' && typeof performance.now === 'function' ? performance.now() : 0);
6657
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
6658
- /* eslint-disable no-bitwise */
6659
- var r = Math.trunc((d + Math.random() * 16) % 16);
6660
- d = Math.floor(d / 16);
6661
- return (c === 'x' ? r : r & 0x3 | 0x8).toString(16);
6662
- /* eslint-enable no-bitwise */
6663
- });
6664
- }
6665
-
6666
- var cloneableObjectsByUUID = {};
6667
- var cloneable = {
6668
- cloneable: {
6669
- test: function test(x) {
6670
- return x && _typeof$1(x) === 'object' && typeof x[Symbol["for"]('cloneEncapsulate')] === 'function';
6671
- },
6672
- replace: function replace(clonable) {
6673
- var encapsulated = clonable[Symbol["for"]('cloneEncapsulate')]();
6674
- var uuid = generateUUID();
6675
- cloneableObjectsByUUID[uuid] = clonable;
6676
- return {
6677
- uuid: uuid,
6678
- encapsulated: encapsulated
6679
- };
6680
- },
6681
- revive: function revive(_ref) {
6682
- var uuid = _ref.uuid,
6683
- encapsulated = _ref.encapsulated;
6684
- return cloneableObjectsByUUID[uuid][Symbol["for"]('cloneRevive')](encapsulated);
6685
- }
6686
- }
6687
- };
6688
-
6689
- /* globals crypto */
6690
- var cryptokey = {
5425
+ var w = {
6691
5426
  cryptokey: {
6692
- test: function test(x) {
6693
- return Typeson.toStringTag(x) === 'CryptoKey' && x.extractable;
6694
- },
6695
- replaceAsync: function replaceAsync(key) {
6696
- return new Typeson.Promise(function (resolve, reject) {
6697
- // eslint-disable-next-line promise/catch-or-return
6698
- crypto.subtle.exportKey('jwk', key)["catch"](
6699
- /* eslint-disable promise/prefer-await-to-callbacks */
6700
- // istanbul ignore next
6701
- function (err) {
6702
- /* eslint-enable promise/prefer-await-to-callbacks */
6703
- // eslint-disable-next-line max-len
6704
- // istanbul ignore next -- Our format should be valid and our key extractable
6705
- reject(err);
6706
- } // eslint-disable-next-line max-len
6707
- // eslint-disable-next-line promise/always-return, promise/prefer-await-to-then
6708
- ).then(function (jwk) {
6709
- resolve({
6710
- jwk: jwk,
6711
- algorithm: key.algorithm,
6712
- usages: key.usages
6713
- });
6714
- });
6715
- });
5427
+ test: function test(e) {
5428
+ return "CryptoKey" === toStringTag(e) && e.extractable;
6716
5429
  },
6717
- revive: function revive(_ref) {
6718
- var jwk = _ref.jwk,
6719
- algorithm = _ref.algorithm,
6720
- usages = _ref.usages;
6721
- return crypto.subtle.importKey('jwk', jwk, algorithm, true, usages);
6722
- }
6723
- }
6724
- };
5430
+ replaceAsync: function replaceAsync(t) {
5431
+ return new e( /*#__PURE__*/function () {
5432
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(e, r) {
5433
+ var n;
5434
+ return regeneratorRuntime.wrap(function _callee$(_context) {
5435
+ while (1) {
5436
+ switch (_context.prev = _context.next) {
5437
+ case 0:
5438
+ _context.prev = 0;
5439
+ _context.next = 3;
5440
+ return crypto.subtle.exportKey("jwk", t);
5441
+
5442
+ case 3:
5443
+ n = _context.sent;
5444
+ _context.next = 9;
5445
+ break;
6725
5446
 
6726
- var dataview = {
6727
- dataview: {
6728
- test: function test(x) {
6729
- return Typeson.toStringTag(x) === 'DataView';
6730
- },
6731
- replace: function replace(_ref, stateObj) {
6732
- var buffer = _ref.buffer,
6733
- byteOffset = _ref.byteOffset,
6734
- byteLength = _ref.byteLength;
5447
+ case 6:
5448
+ _context.prev = 6;
5449
+ _context.t0 = _context["catch"](0);
5450
+ return _context.abrupt("return", void r(_context.t0));
6735
5451
 
6736
- if (!stateObj.buffers) {
6737
- stateObj.buffers = [];
6738
- }
5452
+ case 9:
5453
+ e({
5454
+ jwk: n,
5455
+ algorithm: t.algorithm,
5456
+ usages: t.usages
5457
+ });
6739
5458
 
6740
- var index = stateObj.buffers.indexOf(buffer);
5459
+ case 10:
5460
+ case "end":
5461
+ return _context.stop();
5462
+ }
5463
+ }
5464
+ }, _callee, null, [[0, 6]]);
5465
+ }));
6741
5466
 
6742
- if (index > -1) {
6743
- return {
6744
- index: index,
6745
- byteOffset: byteOffset,
6746
- byteLength: byteLength
5467
+ return function (_x, _x2) {
5468
+ return _ref3.apply(this, arguments);
6747
5469
  };
6748
- }
6749
-
6750
- stateObj.buffers.push(buffer);
6751
- return {
6752
- encoded: encode$1(buffer),
6753
- byteOffset: byteOffset,
6754
- byteLength: byteLength
6755
- };
5470
+ }());
6756
5471
  },
6757
- revive: function revive(b64Obj, stateObj) {
6758
- if (!stateObj.buffers) {
6759
- stateObj.buffers = [];
6760
- }
6761
-
6762
- var byteOffset = b64Obj.byteOffset,
6763
- byteLength = b64Obj.byteLength,
6764
- encoded = b64Obj.encoded,
6765
- index = b64Obj.index;
6766
- var buffer;
6767
-
6768
- if ('index' in b64Obj) {
6769
- buffer = stateObj.buffers[index];
6770
- } else {
6771
- buffer = decode$1(encoded);
6772
- stateObj.buffers.push(buffer);
6773
- }
6774
-
6775
- return new DataView(buffer, byteOffset, byteLength);
5472
+ revive: function revive(_ref4) {
5473
+ var e = _ref4.jwk,
5474
+ t = _ref4.algorithm,
5475
+ r = _ref4.usages;
5476
+ return crypto.subtle.importKey("jwk", e, t, !0, r);
6776
5477
  }
6777
5478
  }
6778
- };
6779
-
6780
- var date = {
5479
+ },
5480
+ A = {
5481
+ dataview: {
5482
+ test: function test(e) {
5483
+ return "DataView" === toStringTag(e);
5484
+ },
5485
+ replace: function replace(_ref5, n) {
5486
+ var e = _ref5.buffer,
5487
+ t = _ref5.byteOffset,
5488
+ r = _ref5.byteLength;
5489
+ n.buffers || (n.buffers = []);
5490
+ var a = n.buffers.indexOf(e);
5491
+ return a > -1 ? {
5492
+ index: a,
5493
+ byteOffset: t,
5494
+ byteLength: r
5495
+ } : (n.buffers.push(e), {
5496
+ encoded: v(e),
5497
+ byteOffset: t,
5498
+ byteLength: r
5499
+ });
5500
+ },
5501
+ revive: function revive(e, t) {
5502
+ t.buffers || (t.buffers = []);
5503
+ var r = e.byteOffset,
5504
+ n = e.byteLength,
5505
+ a = e.encoded,
5506
+ o = e.index;
5507
+ var i;
5508
+ return "index" in e ? i = t.buffers[o] : (i = b(a), t.buffers.push(i)), new DataView(i, r, n);
5509
+ }
5510
+ }
5511
+ },
5512
+ j = {
6781
5513
  date: {
6782
- test: function test(x) {
6783
- return Typeson.toStringTag(x) === 'Date';
5514
+ test: function test(e) {
5515
+ return "Date" === toStringTag(e);
6784
5516
  },
6785
- replace: function replace(dt) {
6786
- var time = dt.getTime();
6787
-
6788
- if (Number.isNaN(time)) {
6789
- return 'NaN';
6790
- }
6791
-
6792
- return time;
5517
+ replace: function replace(e) {
5518
+ var t = e.getTime();
5519
+ return Number.isNaN(t) ? "NaN" : t;
6793
5520
  },
6794
- revive: function revive(time) {
6795
- if (time === 'NaN') {
6796
- return new Date(Number.NaN);
6797
- }
6798
-
6799
- return new Date(time);
6800
- }
6801
- }
6802
- };
6803
-
6804
- var error = {
6805
- error: {
6806
- test: function test(x) {
6807
- return Typeson.toStringTag(x) === 'Error';
5521
+ revive: function revive(e) {
5522
+ return "NaN" === e ? new Date(Number.NaN) : new Date(e);
5523
+ }
5524
+ }
5525
+ },
5526
+ I = "undefined" == typeof self ? global : self,
5527
+ P = {};
5528
+ ["TypeError", "RangeError", "SyntaxError", "ReferenceError", "EvalError", "URIError", "InternalError"].forEach(function (e) {
5529
+ var t = I[e];
5530
+ t && (P[e.toLowerCase()] = {
5531
+ test: function test(e) {
5532
+ return hasConstructorOf(e, t);
6808
5533
  },
6809
- replace: function replace(_ref) {
6810
- var name = _ref.name,
6811
- message = _ref.message;
6812
- return {
6813
- name: name,
6814
- message: message
6815
- };
5534
+ replace: function replace(e) {
5535
+ return e.message;
6816
5536
  },
6817
- revive: function revive(_ref2) {
6818
- var name = _ref2.name,
6819
- message = _ref2.message;
6820
- var e = new Error(message);
6821
- e.name = name;
6822
- return e;
5537
+ revive: function revive(e) {
5538
+ return new t(e);
6823
5539
  }
6824
- }
6825
- }; // See also errors.js that may be registered after having registered this type.
6826
-
6827
- /* istanbul ignore next */
6828
-
6829
- var _global$2 = typeof self === 'undefined' ? global$1 : self;
6830
-
6831
- var errors = {}; // Comprises all built-in errors.
6832
-
6833
- ['TypeError', 'RangeError', 'SyntaxError', 'ReferenceError', 'EvalError', 'URIError', 'InternalError' // non-standard
6834
- ].forEach(function (errName) {
6835
- var Cnstrctr = _global$2[errName];
6836
-
6837
- if (Cnstrctr) {
6838
- errors[errName.toLowerCase()] = {
6839
- test: function test(x) {
6840
- return Typeson.hasConstructorOf(x, Cnstrctr);
6841
- },
6842
- replace: function replace(e) {
6843
- return e.message;
6844
- },
6845
- revive: function revive(message) {
6846
- return new Cnstrctr(message);
6847
- }
6848
- };
6849
- }
5540
+ });
6850
5541
  });
6851
-
6852
- /* globals XMLHttpRequest, File, FileReader */
6853
- var file = {
5542
+ var N = {
6854
5543
  file: {
6855
- test: function test(x) {
6856
- return Typeson.toStringTag(x) === 'File';
5544
+ test: function test(e) {
5545
+ return "File" === toStringTag(e);
6857
5546
  },
6858
- replace: function replace(f) {
6859
- // Sync
6860
- var req = new XMLHttpRequest();
6861
- req.overrideMimeType('text/plain; charset=x-user-defined');
6862
- req.open('GET', URL.createObjectURL(f), false); // Sync
6863
-
6864
- req.send(); // Seems not feasible to accurately simulate
6865
-
6866
- /* istanbul ignore next */
6867
-
6868
- if (req.status !== 200 && req.status !== 0) {
6869
- throw new Error('Bad File access: ' + req.status);
6870
- }
6871
-
5547
+ replace: function replace(e) {
5548
+ var t = new XMLHttpRequest();
5549
+ 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);
6872
5550
  return {
6873
- type: f.type,
6874
- stringContents: req.responseText,
6875
- name: f.name,
6876
- lastModified: f.lastModified
5551
+ type: e.type,
5552
+ stringContents: t.responseText,
5553
+ name: e.name,
5554
+ lastModified: e.lastModified
6877
5555
  };
6878
5556
  },
6879
- revive: function revive(_ref) {
6880
- var name = _ref.name,
6881
- type = _ref.type,
6882
- stringContents = _ref.stringContents,
6883
- lastModified = _ref.lastModified;
6884
- return new File([string2arraybuffer(stringContents)], name, {
6885
- type: type,
6886
- lastModified: lastModified
5557
+ revive: function revive(_ref8) {
5558
+ var e = _ref8.name,
5559
+ t = _ref8.type,
5560
+ r = _ref8.stringContents,
5561
+ n = _ref8.lastModified;
5562
+ return new File([string2arraybuffer(r)], e, {
5563
+ type: t,
5564
+ lastModified: n
6887
5565
  });
6888
5566
  },
6889
- replaceAsync: function replaceAsync(f) {
6890
- return new Typeson.Promise(function (resolve, reject) {
6891
- /*
6892
- if (f.isClosed) { // On MDN, but not in https://w3c.github.io/FileAPI/#dfn-Blob
6893
- reject(new Error('The File is closed'));
6894
- return;
6895
- }
6896
- */
6897
- var reader = new FileReader();
6898
- reader.addEventListener('load', function () {
6899
- resolve({
6900
- type: f.type,
6901
- stringContents: reader.result,
6902
- name: f.name,
6903
- lastModified: f.lastModified
5567
+ replaceAsync: function replaceAsync(t) {
5568
+ return new e(function (e, r) {
5569
+ var n = new FileReader();
5570
+ n.addEventListener("load", function () {
5571
+ e({
5572
+ type: t.type,
5573
+ stringContents: n.result,
5574
+ name: t.name,
5575
+ lastModified: t.lastModified
6904
5576
  });
6905
- }); // Seems not feasible to accurately simulate
6906
-
6907
- /* istanbul ignore next */
6908
-
6909
- reader.addEventListener('error', function () {
6910
- reject(reader.error);
6911
- });
6912
- reader.readAsBinaryString(f);
5577
+ }), n.addEventListener("error", function () {
5578
+ r(n.error);
5579
+ }), n.readAsBinaryString(t);
6913
5580
  });
6914
5581
  }
6915
5582
  }
6916
- };
6917
-
6918
- var filelist = {
6919
- file: file.file,
5583
+ },
5584
+ C = {
5585
+ file: N.file,
6920
5586
  filelist: {
6921
- test: function test(x) {
6922
- return Typeson.toStringTag(x) === 'FileList';
5587
+ test: function test(e) {
5588
+ return "FileList" === toStringTag(e);
6923
5589
  },
6924
- replace: function replace(fl) {
6925
- var arr = [];
5590
+ replace: function replace(e) {
5591
+ var t = [];
6926
5592
 
6927
- for (var i = 0; i < fl.length; i++) {
6928
- arr[i] = fl.item(i);
5593
+ for (var _r2 = 0; _r2 < e.length; _r2++) {
5594
+ t[_r2] = e.item(_r2);
6929
5595
  }
6930
5596
 
6931
- return arr;
5597
+ return t;
6932
5598
  },
6933
- revive: function revive(o) {
6934
- /**
6935
- * `FileList` polyfill.
6936
- */
5599
+ revive: function revive(e) {
6937
5600
  var FileList = /*#__PURE__*/function (_Symbol$toStringTag) {
6938
- /**
6939
- * Set private properties and length.
6940
- */
6941
5601
  function FileList() {
6942
- _classCallCheck(this, FileList);
5602
+ _classCallCheck$1(this, FileList);
6943
5603
 
6944
- // eslint-disable-next-line prefer-rest-params
6945
- this._files = arguments[0];
6946
- this.length = this._files.length;
5604
+ this._files = arguments[0], this.length = this._files.length;
6947
5605
  }
6948
- /**
6949
- * @param {Integer} index
6950
- * @returns {File}
6951
- */
6952
-
6953
5606
 
6954
- _createClass(FileList, [{
5607
+ _createClass$1(FileList, [{
6955
5608
  key: "item",
6956
- value: function item(index) {
6957
- return this._files[index];
5609
+ value: function item(e) {
5610
+ return this._files[e];
6958
5611
  }
6959
- /* eslint-disable class-methods-use-this */
6960
-
6961
- /**
6962
- * @returns {"FileList"}
6963
- */
6964
-
6965
5612
  }, {
6966
5613
  key: _Symbol$toStringTag,
6967
5614
  get: function get() {
6968
- /* eslint-enable class-methods-use-this */
6969
- return 'FileList';
5615
+ return "FileList";
6970
5616
  }
6971
5617
  }]);
6972
5618
 
6973
5619
  return FileList;
6974
5620
  }(Symbol.toStringTag);
6975
5621
 
6976
- return new FileList(o);
5622
+ return new FileList(e);
6977
5623
  }
6978
5624
  }
6979
- };
6980
-
6981
- /* globals createImageBitmap */
6982
- var imagebitmap = {
5625
+ },
5626
+ E = {
6983
5627
  imagebitmap: {
6984
- test: function test(x) {
6985
- return Typeson.toStringTag(x) === 'ImageBitmap' || // In Node, our polyfill sets the dataset on a canvas
6986
- // element as JSDom no longer allows overriding toStringTag
6987
- x && x.dataset && x.dataset.toStringTag === 'ImageBitmap';
5628
+ test: function test(e) {
5629
+ return "ImageBitmap" === toStringTag(e) || e && e.dataset && "ImageBitmap" === e.dataset.toStringTag;
6988
5630
  },
6989
- replace: function replace(bm) {
6990
- var canvas = document.createElement('canvas');
6991
- var ctx = canvas.getContext('2d');
6992
- ctx.drawImage(bm, 0, 0); // Although `width` and `height` are part of `ImageBitMap`,
6993
- // these will be auto-created for us when reviving with the
6994
- // data URL (and they are not settable even if they weren't)
6995
- // return {
6996
- // width: bm.width, height: bm.height, dataURL: canvas.toDataURL()
6997
- // };
6998
-
6999
- return canvas.toDataURL();
5631
+ replace: function replace(e) {
5632
+ var t = document.createElement("canvas");
5633
+ return t.getContext("2d").drawImage(e, 0, 0), t.toDataURL();
7000
5634
  },
7001
- revive: function revive(o) {
7002
- /*
7003
- var req = new XMLHttpRequest();
7004
- req.open('GET', o, false); // Sync
7005
- if (req.status !== 200 && req.status !== 0) {
7006
- throw new Error('Bad ImageBitmap access: ' + req.status);
7007
- }
7008
- req.send();
7009
- return req.responseText;
7010
- */
7011
- var canvas = document.createElement('canvas');
7012
- var ctx = canvas.getContext('2d');
7013
- var img = document.createElement('img'); // The onload is needed by some browsers per http://stackoverflow.com/a/4776378/271577
7014
-
7015
- img.addEventListener('load', function () {
7016
- ctx.drawImage(img, 0, 0);
7017
- });
7018
- img.src = o; // Works in contexts allowing an `ImageBitmap` (We might use
7019
- // `OffscreenCanvas.transferToBitmap` when supported)
7020
-
7021
- return canvas;
5635
+ revive: function revive(e) {
5636
+ var t = document.createElement("canvas"),
5637
+ r = t.getContext("2d"),
5638
+ n = document.createElement("img");
5639
+ return n.addEventListener("load", function () {
5640
+ r.drawImage(n, 0, 0);
5641
+ }), n.src = e, t;
7022
5642
  },
7023
- reviveAsync: function reviveAsync(o) {
7024
- var canvas = document.createElement('canvas');
7025
- var ctx = canvas.getContext('2d');
7026
- var img = document.createElement('img'); // The onload is needed by some browsers per http://stackoverflow.com/a/4776378/271577
7027
-
7028
- img.addEventListener('load', function () {
7029
- ctx.drawImage(img, 0, 0);
7030
- });
7031
- img.src = o; // o.dataURL;
7032
-
7033
- return createImageBitmap(canvas); // Returns a promise
5643
+ reviveAsync: function reviveAsync(e) {
5644
+ var t = document.createElement("canvas"),
5645
+ r = t.getContext("2d"),
5646
+ n = document.createElement("img");
5647
+ return n.addEventListener("load", function () {
5648
+ r.drawImage(n, 0, 0);
5649
+ }), n.src = e, createImageBitmap(t);
7034
5650
  }
7035
5651
  }
7036
- };
7037
-
7038
- var imagedata = {
5652
+ },
5653
+ x = {
7039
5654
  imagedata: {
7040
- test: function test(x) {
7041
- return Typeson.toStringTag(x) === 'ImageData';
5655
+ test: function test(e) {
5656
+ return "ImageData" === toStringTag(e);
7042
5657
  },
7043
- replace: function replace(d) {
5658
+ replace: function replace(e) {
7044
5659
  return {
7045
- // Ensure `length` gets preserved for revival
7046
- array: _toConsumableArray(d.data),
7047
- width: d.width,
7048
- height: d.height
5660
+ array: _toConsumableArray(e.data),
5661
+ width: e.width,
5662
+ height: e.height
7049
5663
  };
7050
5664
  },
7051
- revive: function revive(o) {
7052
- return new ImageData(new Uint8ClampedArray(o.array), o.width, o.height);
5665
+ revive: function revive(e) {
5666
+ return new ImageData(new Uint8ClampedArray(e.array), e.width, e.height);
7053
5667
  }
7054
5668
  }
7055
- };
7056
-
7057
- var infinity = {
5669
+ },
5670
+ k = {
7058
5671
  infinity: {
7059
- test: function test(x) {
7060
- return x === Number.POSITIVE_INFINITY;
5672
+ test: function test(e) {
5673
+ return e === Number.POSITIVE_INFINITY;
7061
5674
  },
7062
- replace: function replace(n) {
7063
- return 'Infinity';
5675
+ replace: function replace(e) {
5676
+ return "Infinity";
7064
5677
  },
7065
- revive: function revive(s) {
5678
+ revive: function revive(e) {
7066
5679
  return Number.POSITIVE_INFINITY;
7067
5680
  }
7068
5681
  }
7069
- };
7070
-
7071
- var IntlCollator = {
7072
- test: function test(x) {
7073
- return Typeson.hasConstructorOf(x, Intl.Collator);
7074
- },
7075
- replace: function replace(c) {
7076
- return c.resolvedOptions();
7077
- },
7078
- revive: function revive(options) {
7079
- return new Intl.Collator(options.locale, options);
7080
- }
7081
- };
7082
- var IntlDateTimeFormat = {
7083
- test: function test(x) {
7084
- return Typeson.hasConstructorOf(x, Intl.DateTimeFormat);
5682
+ },
5683
+ B = {
5684
+ test: function test(e) {
5685
+ return hasConstructorOf(e, Intl.Collator);
7085
5686
  },
7086
- replace: function replace(dtf) {
7087
- return dtf.resolvedOptions();
7088
- },
7089
- revive: function revive(options) {
7090
- return new Intl.DateTimeFormat(options.locale, options);
7091
- }
7092
- };
7093
- var IntlNumberFormat = {
7094
- test: function test(x) {
7095
- return Typeson.hasConstructorOf(x, Intl.NumberFormat);
5687
+ replace: function replace(e) {
5688
+ return e.resolvedOptions();
7096
5689
  },
7097
- replace: function replace(nf) {
7098
- return nf.resolvedOptions();
5690
+ revive: function revive(e) {
5691
+ return new Intl.Collator(e.locale, e);
5692
+ }
5693
+ },
5694
+ U = {
5695
+ IntlCollator: B,
5696
+ IntlDateTimeFormat: {
5697
+ test: function test(e) {
5698
+ return hasConstructorOf(e, Intl.DateTimeFormat);
5699
+ },
5700
+ replace: function replace(e) {
5701
+ return e.resolvedOptions();
5702
+ },
5703
+ revive: function revive(e) {
5704
+ return new Intl.DateTimeFormat(e.locale, e);
5705
+ }
7099
5706
  },
7100
- revive: function revive(options) {
7101
- return new Intl.NumberFormat(options.locale, options);
5707
+ IntlNumberFormat: {
5708
+ test: function test(e) {
5709
+ return hasConstructorOf(e, Intl.NumberFormat);
5710
+ },
5711
+ replace: function replace(e) {
5712
+ return e.resolvedOptions();
5713
+ },
5714
+ revive: function revive(e) {
5715
+ return new Intl.NumberFormat(e.locale, e);
5716
+ }
7102
5717
  }
7103
- };
7104
- var intlTypes = {
7105
- IntlCollator: IntlCollator,
7106
- IntlDateTimeFormat: IntlDateTimeFormat,
7107
- IntlNumberFormat: IntlNumberFormat
7108
- };
7109
-
7110
- var map = {
5718
+ },
5719
+ K = {
7111
5720
  map: {
7112
- test: function test(x) {
7113
- return Typeson.toStringTag(x) === 'Map';
5721
+ test: function test(e) {
5722
+ return "Map" === toStringTag(e);
7114
5723
  },
7115
- replace: function replace(mp) {
7116
- return _toConsumableArray(mp.entries());
5724
+ replace: function replace(e) {
5725
+ return _toConsumableArray(e.entries());
7117
5726
  },
7118
- revive: function revive(entries) {
7119
- return new Map(entries);
5727
+ revive: function revive(e) {
5728
+ return new Map(e);
7120
5729
  }
7121
5730
  }
7122
- };
7123
-
7124
- var nan = {
5731
+ },
5732
+ L = {
7125
5733
  nan: {
7126
- test: function test(x) {
7127
- return Number.isNaN(x);
5734
+ test: function test(e) {
5735
+ return Number.isNaN(e);
7128
5736
  },
7129
- replace: function replace(n) {
7130
- return 'NaN';
5737
+ replace: function replace(e) {
5738
+ return "NaN";
7131
5739
  },
7132
- revive: function revive(s) {
5740
+ revive: function revive(e) {
7133
5741
  return Number.NaN;
7134
5742
  }
7135
5743
  }
7136
- };
7137
-
7138
- var negativeInfinity = {
5744
+ },
5745
+ F = {
7139
5746
  negativeInfinity: {
7140
- test: function test(x) {
7141
- return x === Number.NEGATIVE_INFINITY;
5747
+ test: function test(e) {
5748
+ return e === Number.NEGATIVE_INFINITY;
7142
5749
  },
7143
- replace: function replace(n) {
7144
- return '-Infinity';
5750
+ replace: function replace(e) {
5751
+ return "-Infinity";
7145
5752
  },
7146
- revive: function revive(s) {
5753
+ revive: function revive(e) {
7147
5754
  return Number.NEGATIVE_INFINITY;
7148
5755
  }
7149
5756
  }
7150
- };
7151
-
7152
- var nonbuiltinIgnore = {
7153
- nonbuiltinIgnore: {
7154
- test: function test(x) {
7155
- return x && _typeof$1(x) === 'object' && !Array.isArray(x) && !['Object', // `Proxy` and `Reflect`, two other built-in objects, will also
7156
- // have a `toStringTag` of `Object`; we don't want built-in
7157
- // function objects, however
7158
- '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));
7159
- },
7160
- replace: function replace(rexp) {// Not in use
7161
- }
7162
- }
7163
- };
7164
-
7165
- var primitiveObjects = {
7166
- // String Object (not primitive string which need no type spec)
5757
+ },
5758
+ M = {
7167
5759
  StringObject: {
7168
- test: function test(x) {
7169
- return Typeson.toStringTag(x) === 'String' && _typeof$1(x) === 'object';
5760
+ test: function test(e) {
5761
+ return "String" === toStringTag(e) && "object" == _typeof$2(e);
7170
5762
  },
7171
- replace: function replace(s) {
7172
- return String(s);
5763
+ replace: function replace(e) {
5764
+ return String(e);
7173
5765
  },
7174
- // convert to primitive string
7175
- revive: function revive(s) {
7176
- return new String(s);
7177
- } // Revive to an objectified string
7178
-
5766
+ revive: function revive(e) {
5767
+ return new String(e);
5768
+ }
7179
5769
  },
7180
- // Boolean Object (not primitive boolean which need no type spec)
7181
5770
  BooleanObject: {
7182
- test: function test(x) {
7183
- return Typeson.toStringTag(x) === 'Boolean' && _typeof$1(x) === 'object';
5771
+ test: function test(e) {
5772
+ return "Boolean" === toStringTag(e) && "object" == _typeof$2(e);
7184
5773
  },
7185
- replace: function replace(b) {
7186
- return Boolean(b);
5774
+ replace: function replace(e) {
5775
+ return Boolean(e);
7187
5776
  },
7188
- // convert to primitive boolean
7189
- revive: function revive(b) {
7190
- // Revive to an objectified Boolean
7191
- return new Boolean(b);
5777
+ revive: function revive(e) {
5778
+ return new Boolean(e);
7192
5779
  }
7193
5780
  },
7194
- // Number Object (not primitive number which need no type spec)
7195
5781
  NumberObject: {
7196
- test: function test(x) {
7197
- return Typeson.toStringTag(x) === 'Number' && _typeof$1(x) === 'object';
5782
+ test: function test(e) {
5783
+ return "Number" === toStringTag(e) && "object" == _typeof$2(e);
7198
5784
  },
7199
- replace: function replace(n) {
7200
- return Number(n);
5785
+ replace: function replace(e) {
5786
+ return Number(e);
7201
5787
  },
7202
- // convert to primitive number
7203
- revive: function revive(n) {
7204
- return new Number(n);
7205
- } // Revive to an objectified number
7206
-
5788
+ revive: function revive(e) {
5789
+ return new Number(e);
5790
+ }
7207
5791
  }
7208
- };
7209
-
7210
- var regexp = {
5792
+ },
5793
+ $ = {
7211
5794
  regexp: {
7212
- test: function test(x) {
7213
- return Typeson.toStringTag(x) === 'RegExp';
5795
+ test: function test(e) {
5796
+ return "RegExp" === toStringTag(e);
7214
5797
  },
7215
- replace: function replace(rexp) {
5798
+ replace: function replace(e) {
7216
5799
  return {
7217
- source: rexp.source,
7218
- flags: (rexp.global ? 'g' : '') + (rexp.ignoreCase ? 'i' : '') + (rexp.multiline ? 'm' : '') + (rexp.sticky ? 'y' : '') + (rexp.unicode ? 'u' : '')
5800
+ source: e.source,
5801
+ flags: (e.global ? "g" : "") + (e.ignoreCase ? "i" : "") + (e.multiline ? "m" : "") + (e.sticky ? "y" : "") + (e.unicode ? "u" : "")
7219
5802
  };
7220
5803
  },
7221
- revive: function revive(_ref) {
7222
- var source = _ref.source,
7223
- flags = _ref.flags;
7224
- return new RegExp(source, flags);
7225
- }
7226
- }
7227
- };
7228
-
7229
- var resurrectableObjectsByUUID = {};
7230
- var resurrectable = {
7231
- resurrectable: {
7232
- test: function test(x) {
7233
- return x && !Array.isArray(x) && ['object', 'function', 'symbol'].includes(_typeof$1(x));
7234
- },
7235
- replace: function replace(rsrrctble) {
7236
- var uuid = generateUUID();
7237
- resurrectableObjectsByUUID[uuid] = rsrrctble;
7238
- return uuid;
7239
- },
7240
- revive: function revive(serializedResurrectable) {
7241
- return resurrectableObjectsByUUID[serializedResurrectable];
5804
+ revive: function revive(_ref9) {
5805
+ var e = _ref9.source,
5806
+ t = _ref9.flags;
5807
+ return new RegExp(e, t);
7242
5808
  }
7243
5809
  }
7244
- };
7245
-
7246
- var set = {
5810
+ },
5811
+ Y = {
7247
5812
  set: {
7248
- test: function test(x) {
7249
- return Typeson.toStringTag(x) === 'Set';
5813
+ test: function test(e) {
5814
+ return "Set" === toStringTag(e);
7250
5815
  },
7251
- replace: function replace(st) {
7252
- return _toConsumableArray(st.values());
5816
+ replace: function replace(e) {
5817
+ return _toConsumableArray(e.values());
7253
5818
  },
7254
- revive: function revive(values) {
7255
- return new Set(values);
7256
- }
7257
- }
7258
- };
7259
-
7260
- /* istanbul ignore next */
7261
-
7262
- var _global$1 = typeof self === 'undefined' ? global$1 : self; // Support all kinds of typed arrays (views of ArrayBuffers)
7263
-
7264
-
7265
- var typedArraysSocketIO = {};
7266
- ['Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array'].forEach(function (typeName) {
7267
- var arrType = typeName;
7268
- var TypedArray = _global$1[typeName];
7269
- /* istanbul ignore if */
7270
-
7271
- if (!TypedArray) {
7272
- return;
7273
- }
7274
-
7275
- typedArraysSocketIO[typeName.toLowerCase()] = {
7276
- test: function test(x) {
7277
- return Typeson.toStringTag(x) === arrType;
5819
+ revive: function revive(e) {
5820
+ return new Set(e);
5821
+ }
5822
+ }
5823
+ },
5824
+ q = "undefined" == typeof self ? global : self,
5825
+ W = {};
5826
+ ["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"].forEach(function (e) {
5827
+ var t = e,
5828
+ r = q[e];
5829
+ r && (W[e.toLowerCase()] = {
5830
+ test: function test(e) {
5831
+ return toStringTag(e) === t;
7278
5832
  },
7279
- replace: function replace(a) {
7280
- return (a.byteOffset === 0 && a.byteLength === a.buffer.byteLength ? a // socket.io supports streaming ArrayBuffers.
7281
- // If we have a typed array representing a portion
7282
- // of the buffer, we need to clone
7283
- // the buffer before leaving it to socket.io.
7284
- : a.slice(0)).buffer;
5833
+ replace: function replace(e) {
5834
+ return (0 === e.byteOffset && e.byteLength === e.buffer.byteLength ? e : e.slice(0)).buffer;
7285
5835
  },
7286
- revive: function revive(buf) {
7287
- // One may configure socket.io to revive binary data as
7288
- // Buffer or Blob.
7289
- // We should therefore not rely on that the instance we
7290
- // get here is an ArrayBuffer
7291
- // If not, let's assume user wants to receive it as
7292
- // configured with socket.io.
7293
- return Typeson.toStringTag(buf) === 'ArrayBuffer' ? new TypedArray(buf) : buf;
5836
+ revive: function revive(e) {
5837
+ return "ArrayBuffer" === toStringTag(e) ? new r(e) : e;
7294
5838
  }
7295
- };
5839
+ });
7296
5840
  });
7297
-
7298
- /* istanbul ignore next */
7299
-
7300
- var _global = typeof self === 'undefined' ? global$1 : self;
7301
-
7302
- var typedArrays = {};
7303
- ['Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array', 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', 'Float64Array'].forEach(function (typeName) {
7304
- var arrType = typeName;
7305
- var TypedArray = _global[arrType];
7306
- /* istanbul ignore if */
7307
-
7308
- if (!TypedArray) {
7309
- return;
7310
- }
7311
-
7312
- typedArrays[typeName.toLowerCase()] = {
7313
- test: function test(x) {
7314
- return Typeson.toStringTag(x) === arrType;
5841
+ var G = "undefined" == typeof self ? global : self,
5842
+ H = {};
5843
+ ["Int8Array", "Uint8Array", "Uint8ClampedArray", "Int16Array", "Uint16Array", "Int32Array", "Uint32Array", "Float32Array", "Float64Array"].forEach(function (e) {
5844
+ var t = e,
5845
+ r = G[t];
5846
+ r && (H[e.toLowerCase()] = {
5847
+ test: function test(e) {
5848
+ return toStringTag(e) === t;
7315
5849
  },
7316
- replace: function replace(_ref, stateObj) {
7317
- var buffer = _ref.buffer,
7318
- byteOffset = _ref.byteOffset,
7319
- l = _ref.length;
7320
-
7321
- if (!stateObj.buffers) {
7322
- stateObj.buffers = [];
7323
- }
7324
-
7325
- var index = stateObj.buffers.indexOf(buffer);
7326
-
7327
- if (index > -1) {
7328
- return {
7329
- index: index,
7330
- byteOffset: byteOffset,
7331
- length: l
7332
- };
7333
- }
7334
-
7335
- stateObj.buffers.push(buffer);
7336
- return {
7337
- encoded: encode$1(buffer),
7338
- byteOffset: byteOffset,
7339
- length: l
7340
- };
5850
+ replace: function replace(_ref10, n) {
5851
+ var e = _ref10.buffer,
5852
+ t = _ref10.byteOffset,
5853
+ r = _ref10.length;
5854
+ n.buffers || (n.buffers = []);
5855
+ var a = n.buffers.indexOf(e);
5856
+ return a > -1 ? {
5857
+ index: a,
5858
+ byteOffset: t,
5859
+ length: r
5860
+ } : (n.buffers.push(e), {
5861
+ encoded: v(e),
5862
+ byteOffset: t,
5863
+ length: r
5864
+ });
7341
5865
  },
7342
- revive: function revive(b64Obj, stateObj) {
7343
- if (!stateObj.buffers) {
7344
- stateObj.buffers = [];
7345
- }
7346
-
7347
- var byteOffset = b64Obj.byteOffset,
7348
- len = b64Obj.length,
7349
- encoded = b64Obj.encoded,
7350
- index = b64Obj.index;
7351
- var buffer;
7352
-
7353
- if ('index' in b64Obj) {
7354
- buffer = stateObj.buffers[index];
7355
- } else {
7356
- buffer = decode$1(encoded);
7357
- stateObj.buffers.push(buffer);
7358
- }
7359
-
7360
- return new TypedArray(buffer, byteOffset, len);
5866
+ revive: function revive(e, t) {
5867
+ t.buffers || (t.buffers = []);
5868
+ var n = e.byteOffset,
5869
+ a = e.length,
5870
+ o = e.encoded,
5871
+ i = e.index;
5872
+ var s;
5873
+ return "index" in e ? s = t.buffers[i] : (s = b(o), t.buffers.push(s)), new r(s, n, a);
7361
5874
  }
7362
- };
5875
+ });
7363
5876
  });
7364
-
7365
- // This does not preserve `undefined` in sparse arrays; see the `undefined`
7366
- var undef$1 = {
5877
+ var X = {
7367
5878
  undef: {
7368
- test: function test(x, stateObj) {
7369
- return typeof x === 'undefined' && (stateObj.ownKeys || !('ownKeys' in stateObj));
5879
+ test: function test(e, t) {
5880
+ return void 0 === e && (t.ownKeys || !("ownKeys" in t));
7370
5881
  },
7371
- replace: function replace(n) {
5882
+ replace: function replace(e) {
7372
5883
  return 0;
7373
5884
  },
7374
- revive: function revive(s) {
7375
- // Will add `undefined` (returning `undefined` would instead
7376
- // avoid explicitly setting)
7377
- return new Typeson.Undefined();
5885
+ revive: function revive(e) {
5886
+ return new l();
7378
5887
  }
7379
5888
  }
7380
- };
7381
-
7382
- var userObject = {
5889
+ },
5890
+ z = {
7383
5891
  userObject: {
7384
- test: function test(x, stateObj) {
7385
- return Typeson.isUserObject(x);
5892
+ test: function test(e, t) {
5893
+ return isUserObject(e);
7386
5894
  },
7387
- replace: function replace(n) {
7388
- return _objectSpread2({}, n);
5895
+ replace: function replace(e) {
5896
+ return _objectSpread2$1({}, e);
7389
5897
  },
7390
- revive: function revive(s) {
7391
- return s;
5898
+ revive: function revive(e) {
5899
+ return e;
7392
5900
  }
7393
5901
  }
7394
- };
7395
-
7396
- var arrayNonindexKeys = [{
5902
+ },
5903
+ Q = [{
7397
5904
  arrayNonindexKeys: {
7398
- testPlainObjects: true,
7399
- test: function test(x, stateObj) {
7400
- if (Array.isArray(x)) {
7401
- if ( // By avoiding serializing arrays into objects which
7402
- // have only positive-integer keys, we reduce
7403
- // size and improve revival performance; arrays with
7404
- // non-index keys will be larger however
7405
- Object.keys(x).some(function (k) {
7406
- // No need to check for `isNaN` or
7407
- // `isNaN(Number.parseInt())` as `NaN` will be
7408
- // treated as a string.
7409
- // No need to do check as
7410
- // `Number.parseInt(Number())` since scientific
7411
- // notation will be pre-resolved if a number
7412
- // was given, and it will otherwise be a string
7413
- return String(Number.parseInt(k)) !== k;
7414
- })) {
7415
- stateObj.iterateIn = 'object';
7416
- stateObj.addLength = true;
7417
- }
7418
-
7419
- return true;
7420
- }
7421
-
7422
- return false;
5905
+ testPlainObjects: !0,
5906
+ test: function test(e, t) {
5907
+ return !!Array.isArray(e) && (Object.keys(e).some(function (e) {
5908
+ return String(Number.parseInt(e)) !== e;
5909
+ }) && (t.iterateIn = "object", t.addLength = !0), !0);
7423
5910
  },
7424
- replace: function replace(a, stateObj) {
7425
- // Catch sparse undefined
7426
- stateObj.iterateUnsetNumeric = true;
7427
- return a;
5911
+ replace: function replace(e, t) {
5912
+ return t.iterateUnsetNumeric = !0, e;
7428
5913
  },
7429
- revive: function revive(o) {
7430
- if (Array.isArray(o)) {
7431
- return o;
7432
- }
7433
-
7434
- var arr = []; // No map here as may be a sparse array (including
7435
- // with `length` set)
7436
- // Todo: Reenable when Node `engines` >= 7
7437
- // Object.entries(o).forEach(([key, val]) => {
7438
-
7439
- Object.keys(o).forEach(function (key) {
7440
- var val = o[key];
7441
- arr[key] = val;
7442
- });
7443
- return arr;
5914
+ revive: function revive(e) {
5915
+ if (Array.isArray(e)) return e;
5916
+ var t = [];
5917
+ return Object.keys(e).forEach(function (r) {
5918
+ var n = e[r];
5919
+ t[r] = n;
5920
+ }), t;
7444
5921
  }
7445
5922
  }
7446
5923
  }, {
7447
5924
  sparseUndefined: {
7448
- test: function test(x, stateObj) {
7449
- return typeof x === 'undefined' && stateObj.ownKeys === false;
5925
+ test: function test(e, t) {
5926
+ return void 0 === e && !1 === t.ownKeys;
7450
5927
  },
7451
- replace: function replace(n) {
5928
+ replace: function replace(e) {
7452
5929
  return 0;
7453
5930
  },
7454
- revive: function revive(s) {
7455
- return undefined;
7456
- } // Will avoid adding anything
7457
-
7458
- }
7459
- }];
7460
-
7461
- var specialNumbers = [nan, infinity, negativeInfinity];
7462
-
7463
- /* This preset includes types that are built-in into the JavaScript
7464
- language itself, this should work universally.
7465
-
7466
- Types that were added in ES6 or beyond will be checked before inclusion
7467
- so that this module can be consumed by both ES5 and ES6 environments.
7468
-
7469
- Some types cannot be encapsulated because their inner state is private:
7470
- `WeakMap`, `WeakSet`.
7471
-
7472
- The Function type is not included because their closures would not be
7473
- serialized, so a revived Function that uses closures would not behave
7474
- as expected.
7475
-
7476
- Symbols are similarly not included.
7477
- */
7478
- var expObj$1 = [undef$1, // ES5
7479
- arrayNonindexKeys, primitiveObjects, specialNumbers, date, error, errors, regexp].concat( // ES2015 (ES6)
7480
-
7481
- /* istanbul ignore next */
7482
- typeof Map === 'function' ? map : [],
7483
- /* istanbul ignore next */
7484
- typeof Set === 'function' ? set : [],
7485
- /* istanbul ignore next */
7486
- typeof ArrayBuffer === 'function' ? arraybuffer : [],
7487
- /* istanbul ignore next */
7488
- typeof Uint8Array === 'function' ? typedArrays : [],
7489
- /* istanbul ignore next */
7490
- typeof DataView === 'function' ? dataview : [],
7491
- /* istanbul ignore next */
7492
- typeof Intl !== 'undefined' ? intlTypes : [],
7493
- /* istanbul ignore next */
7494
- typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []);
7495
-
7496
- /*
7497
- When communicating via `postMessage()` (`Worker.postMessage()` or
7498
- `window.postMessage()`), the browser will use a similar algorithm as Typeson
7499
- does to encapsulate and revive all items in the structure (aka the structured
7500
- clone algorithm). This algorithm supports all built-in types as well as many
7501
- DOM types. Therefore, only types that are not included in the structured clone
7502
- algorithm need to be registered, which is:
7503
-
7504
- * Error
7505
- * Specific Errors like SyntaxError, TypeError, etc.
7506
- * Any custom type you want to send across window- or worker boundraries
7507
-
7508
- This preset will only include the Error types and you can register your
7509
- custom types after having registered these.
7510
- */
7511
- var postmessage = [error, errors];
7512
-
7513
- var socketio = [expObj$1, // Leave ArrayBuffer as is, and let socket.io stream it instead.
7514
- {
7515
- arraybuffer: null
7516
- }, // Encapsulate TypedArrays in ArrayBuffers instead of base64 strings.
7517
- typedArraysSocketIO];
7518
-
7519
- var sparseUndefined = [{
7520
- sparseArrays: {
7521
- testPlainObjects: true,
7522
- test: function test(x) {
7523
- return Array.isArray(x);
7524
- },
7525
- replace: function replace(a, stateObj) {
7526
- stateObj.iterateUnsetNumeric = true;
7527
- return a;
7528
- }
5931
+ revive: function revive(e) {}
7529
5932
  }
7530
- }, {
7531
- sparseUndefined: {
7532
- test: function test(x, stateObj) {
7533
- return typeof x === 'undefined' && stateObj.ownKeys === false;
7534
- },
7535
- replace: function replace(n) {
7536
- return 0;
7537
- },
7538
- revive: function revive(s) {
7539
- return undefined;
7540
- } // Will avoid adding anything
7541
-
7542
- }
7543
- }];
7544
-
7545
- /* This preset includes types for the Structured Cloning Algorithm. */
7546
- var expObj = [// Todo: Might also register synchronous `ImageBitmap` and
7547
- // `Blob`/`File`/`FileList`?
7548
- // ES5
7549
- userObject, // Processed last (non-builtin)
7550
- undef$1, arrayNonindexKeys, primitiveObjects, specialNumbers, date, regexp, // Non-built-ins
7551
- imagedata, imagebitmap, // Async return
7552
- file, filelist, blob].concat( // ES2015 (ES6)
7553
-
7554
- /* istanbul ignore next */
7555
- typeof Map === 'function' ? map : [],
7556
- /* istanbul ignore next */
7557
- typeof Set === 'function' ? set : [],
7558
- /* istanbul ignore next */
7559
- typeof ArrayBuffer === 'function' ? arraybuffer : [],
7560
- /* istanbul ignore next */
7561
- typeof Uint8Array === 'function' ? typedArrays : [],
7562
- /* istanbul ignore next */
7563
- typeof DataView === 'function' ? dataview : [],
7564
- /* istanbul ignore next */
7565
- typeof Intl !== 'undefined' ? intlTypes : [],
7566
- /* istanbul ignore next */
7567
- typeof crypto !== 'undefined' ? cryptokey : [],
7568
- /* istanbul ignore next */
7569
- typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []);
7570
-
7571
- var structuredCloningThrowing = expObj.concat({
5933
+ }],
5934
+ Z = [L, k, F],
5935
+ 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] : []);
5936
+ var oe = ae.concat({
7572
5937
  checkDataCloneException: {
7573
- test: function test(val) {
7574
- // Should also throw with:
7575
- // 1. `IsDetachedBuffer` (a process not called within the
7576
- // ECMAScript spec)
7577
- // 2. `IsCallable` (covered by `typeof === 'function'` or a
7578
- // function's `toStringTag`)
7579
- // 3. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
7580
- // [[PromiseState]] or [[WeakMapData]])
7581
- // 4. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
7582
- // intrinsic object) (which does not have default
7583
- // behavior for one or more of the essential internal methods
7584
- // that are limited to the following for non-function objects
7585
- // (we auto-exclude functions):
7586
- // [[GetPrototypeOf]],[[SetPrototypeOf]],[[IsExtensible]],
7587
- // [[PreventExtensions]],[[GetOwnProperty]],
7588
- // [[DefineOwnProperty]],[[HasProperty]],
7589
- // [[Get]],[[Set]],[[Delete]],[[OwnPropertyKeys]]);
7590
- // except for the standard, built-in exotic objects, we'd need
7591
- // to know whether these methods had distinct behaviors
7592
- // Note: There is no apparent way for us to detect a `Proxy` and
7593
- // reject (Chrome at least is not rejecting anyways)
7594
- var stringTag = {}.toString.call(val).slice(8, -1);
7595
-
7596
- if ([// Symbol's `toStringTag` is only "Symbol" for its initial
7597
- // value, so we check `typeof`
7598
- 'symbol', // All functions including bound function exotic objects
7599
- 'function'].includes(_typeof$1(val)) || [// A non-array exotic object
7600
- 'Arguments', // A non-array exotic object
7601
- 'Module', // `Error` and other errors have the [[ErrorData]] internal
7602
- // slot and give "Error"
7603
- 'Error', // Promise instances have an extra slot ([[PromiseState]])
7604
- // but not throwing in Chrome `postMessage`
7605
- 'Promise', // WeakMap instances have an extra slot ([[WeakMapData]])
7606
- // but not throwing in Chrome `postMessage`
7607
- 'WeakMap', // WeakSet instances have an extra slot ([[WeakSetData]])
7608
- // but not throwing in Chrome `postMessage`
7609
- 'WeakSet', // HTML-SPECIFIC
7610
- 'Event', // Also in Node `worker_threads` (currently experimental)
7611
- 'MessageChannel'].includes(stringTag) ||
7612
- /*
7613
- // isClosed is no longer documented
7614
- ((stringTag === 'Blob' || stringTag === 'File') &&
7615
- val.isClosed) ||
7616
- */
7617
- val && _typeof$1(val) === 'object' && // Duck-type DOM node objects (non-array exotic?
7618
- // objects which cannot be cloned by the SCA)
7619
- typeof val.nodeType === 'number' && typeof val.insertBefore === 'function') {
7620
- throw new DOMException('The object cannot be cloned.', 'DataCloneError');
7621
- }
7622
-
7623
- return false;
5938
+ test: function test(e) {
5939
+ var t = {}.toString.call(e).slice(8, -1);
5940
+ 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");
5941
+ return !1;
7624
5942
  }
7625
5943
  }
7626
5944
  });
7627
5945
 
7628
- var undef = [sparseUndefined, undef$1];
7629
-
7630
- var universal = [expObj$1 // TODO: Add types that are de-facto universal even though not
7631
- // built-in into ecmasript standard.
7632
- ];
7633
-
7634
- // This file is auto-generated from `build.js`
7635
- Typeson.types = {
7636
- arraybuffer: arraybuffer,
7637
- bigintObject: bigintObject,
7638
- bigint: bigint,
7639
- blob: blob,
7640
- cloneable: cloneable,
7641
- cryptokey: cryptokey,
7642
- dataview: dataview,
7643
- date: date,
7644
- error: error,
7645
- errors: errors,
7646
- file: file,
7647
- filelist: filelist,
7648
- imagebitmap: imagebitmap,
7649
- imagedata: imagedata,
7650
- infinity: infinity,
7651
- intlTypes: intlTypes,
7652
- map: map,
7653
- nan: nan,
7654
- negativeInfinity: negativeInfinity,
7655
- nonbuiltinIgnore: nonbuiltinIgnore,
7656
- primitiveObjects: primitiveObjects,
7657
- regexp: regexp,
7658
- resurrectable: resurrectable,
7659
- set: set,
7660
- typedArraysSocketio: typedArraysSocketIO,
7661
- typedArrays: typedArrays,
7662
- undef: undef$1,
7663
- userObject: userObject
7664
- };
7665
- Typeson.presets = {
7666
- arrayNonindexKeys: arrayNonindexKeys,
7667
- builtin: expObj$1,
7668
- postmessage: postmessage,
7669
- socketio: socketio,
7670
- sparseUndefined: sparseUndefined,
7671
- specialNumbers: specialNumbers,
7672
- structuredCloningThrowing: structuredCloningThrowing,
7673
- structuredCloning: expObj,
7674
- undef: undef,
7675
- universal: universal
7676
- };
7677
-
7678
- var typeson = new Typeson().register(Typeson.presets.structuredCloningThrowing);
5946
+ var typeson = new u().register(oe);
7679
5947
 
7680
5948
  function register(func) {
7681
- typeson = new Typeson().register(func(Typeson.presets.structuredCloningThrowing));
5949
+ typeson = new u().register(func(oe));
7682
5950
  } // We are keeping the callback approach for now in case we wish to reexpose
7683
5951
  // `Blob`, `File`, `FileList` asynchronously (though in such a case, we
7684
5952
  // should probably refactor as a Promise)
@@ -7692,11 +5960,11 @@
7692
5960
  ret = typeson.stringifySync(obj);
7693
5961
  } catch (err) {
7694
5962
  // SCA in typeson-registry using `DOMException` which is not defined (e.g., in Node)
7695
- if (Typeson.hasConstructorOf(err, ReferenceError) || // SCA in typeson-registry threw a cloning error and we are in a
5963
+ if (hasConstructorOf(err, ReferenceError) || // SCA in typeson-registry threw a cloning error and we are in a
7696
5964
  // supporting environment (e.g., the browser) where `ShimDOMException` is
7697
5965
  // an alias for `DOMException`; if typeson-registry ever uses our shim
7698
5966
  // to throw, we can use this condition alone.
7699
- Typeson.hasConstructorOf(err, ShimDOMException)) {
5967
+ hasConstructorOf(err, ShimDOMException)) {
7700
5968
  throw createDOMException('DataCloneError', 'The object cannot be cloned.');
7701
5969
  } // We should rethrow non-cloning exceptions like from
7702
5970
  // throwing getters (as in the W3C test, key-conversion-exceptions.htm)
@@ -8898,7 +7166,7 @@
8898
7166
  }
8899
7167
 
8900
7168
  Object.entries(paramMap).forEach(function (_ref) {
8901
- var _ref2 = _slicedToArray(_ref, 2),
7169
+ var _ref2 = _slicedToArray$1(_ref, 2),
8902
7170
  key = _ref2[0],
8903
7171
  stmt = _ref2[1];
8904
7172
 
@@ -8959,7 +7227,7 @@
8959
7227
  var request = me.transaction.__createRequest(me);
8960
7228
 
8961
7229
  var _me$__validateKeyAndV = me.__validateKeyAndValueAndCloneValue(value, key, false),
8962
- _me$__validateKeyAndV2 = _slicedToArray(_me$__validateKeyAndV, 2),
7230
+ _me$__validateKeyAndV2 = _slicedToArray$1(_me$__validateKeyAndV, 2),
8963
7231
  ky = _me$__validateKeyAndV2[0],
8964
7232
  clonedValue = _me$__validateKeyAndV2[1];
8965
7233
 
@@ -8992,7 +7260,7 @@
8992
7260
  var request = me.transaction.__createRequest(me);
8993
7261
 
8994
7262
  var _me$__validateKeyAndV3 = me.__validateKeyAndValueAndCloneValue(value, key, false),
8995
- _me$__validateKeyAndV4 = _slicedToArray(_me$__validateKeyAndV3, 2),
7263
+ _me$__validateKeyAndV4 = _slicedToArray$1(_me$__validateKeyAndV3, 2),
8996
7264
  ky = _me$__validateKeyAndV4[0],
8997
7265
  clonedValue = _me$__validateKeyAndV4[1];
8998
7266
 
@@ -9766,7 +8034,7 @@
9766
8034
 
9767
8035
  IDBTransaction.__assertActive(this.__versionTransaction);
9768
8036
 
9769
- createOptions = _objectSpread2({}, createOptions);
8037
+ createOptions = _objectSpread2$1({}, createOptions);
9770
8038
  var _createOptions = createOptions,
9771
8039
  keyPath = _createOptions.keyPath;
9772
8040
  keyPath = keyPath === undefined ? null : convertToSequenceDOMString(keyPath);
@@ -9971,7 +8239,7 @@
9971
8239
  };
9972
8240
 
9973
8241
  var getOrigin = function getOrigin() {
9974
- return (typeof location === "undefined" ? "undefined" : _typeof$1(location)) !== 'object' || !location ? 'null' : location.origin;
8242
+ return (typeof location === "undefined" ? "undefined" : _typeof$2(location)) !== 'object' || !location ? 'null' : location.origin;
9975
8243
  };
9976
8244
 
9977
8245
  var hasNullOrigin = function hasNullOrigin() {
@@ -11443,7 +9711,7 @@
11443
9711
 
11444
9712
  if (me.__store.keyPath !== null) {
11445
9713
  var _me$__store$__validat = me.__store.__validateKeyAndValueAndCloneValue(valueToUpdate, undefined, true),
11446
- _me$__store$__validat2 = _slicedToArray(_me$__store$__validat, 2),
9714
+ _me$__store$__validat2 = _slicedToArray$1(_me$__store$__validat, 2),
11447
9715
  evaluatedKey = _me$__store$__validat2[0],
11448
9716
  clonedValue = _me$__store$__validat2[1];
11449
9717
 
@@ -11542,9 +9810,9 @@
11542
9810
  });
11543
9811
 
11544
9812
  function setConfig(prop, val) {
11545
- if (prop && _typeof$1(prop) === 'object') {
9813
+ if (prop && _typeof$2(prop) === 'object') {
11546
9814
  Object.entries(prop).forEach(function (_ref) {
11547
- var _ref2 = _slicedToArray(_ref, 2),
9815
+ var _ref2 = _slicedToArray$1(_ref, 2),
11548
9816
  p = _ref2[0],
11549
9817
  val = _ref2[1];
11550
9818
 
@@ -11569,7 +9837,7 @@
11569
9837
  setConfig(initialConfig);
11570
9838
  }
11571
9839
 
11572
- var IDB = idb || (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : typeof global$1 !== 'undefined' ? global$1 : {});
9840
+ var IDB = idb || (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : typeof global !== 'undefined' ? global : {});
11573
9841
 
11574
9842
  function shim(name, value, propDesc) {
11575
9843
  if (!propDesc || !Object.defineProperty) {
@@ -11672,7 +9940,7 @@
11672
9940
  }
11673
9941
  });
11674
9942
  [['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) {
11675
- var _ref4 = _slicedToArray(_ref3, 2),
9943
+ var _ref4 = _slicedToArray$1(_ref3, 2),
11676
9944
  prop = _ref4[0],
11677
9945
  obj = _ref4[1];
11678
9946