typeson-registry 1.0.0-alpha.7 → 2.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.
Files changed (215) hide show
  1. package/{LICENSE → LICENSE-MIT.txt} +0 -0
  2. package/README.md +189 -77
  3. package/dist/index.js +1205 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.min.js +2 -0
  6. package/dist/index.min.js.map +1 -0
  7. package/dist/index.umd.js +2274 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/index.umd.min.js +2 -0
  10. package/dist/index.umd.min.js.map +1 -0
  11. package/dist/presets/array-nonindex-keys.umd.js +2 -0
  12. package/dist/presets/array-nonindex-keys.umd.js.map +1 -0
  13. package/dist/presets/builtin.umd.js +2 -0
  14. package/dist/presets/builtin.umd.js.map +1 -0
  15. package/dist/presets/postmessage.umd.js +2 -0
  16. package/dist/presets/postmessage.umd.js.map +1 -0
  17. package/dist/presets/socketio.umd.js +2 -0
  18. package/dist/presets/socketio.umd.js.map +1 -0
  19. package/dist/presets/sparse-undefined.umd.js +2 -0
  20. package/dist/presets/sparse-undefined.umd.js.map +1 -0
  21. package/dist/presets/special-numbers.umd.js +2 -0
  22. package/dist/presets/special-numbers.umd.js.map +1 -0
  23. package/dist/presets/structured-cloning-throwing.umd.js +2 -0
  24. package/dist/presets/structured-cloning-throwing.umd.js.map +1 -0
  25. package/dist/presets/structured-cloning.umd.js +2 -0
  26. package/dist/presets/structured-cloning.umd.js.map +1 -0
  27. package/dist/presets/undef.umd.js +2 -0
  28. package/dist/presets/undef.umd.js.map +1 -0
  29. package/dist/presets/universal.umd.js +2 -0
  30. package/dist/presets/universal.umd.js.map +1 -0
  31. package/dist/types/arraybuffer.umd.js +2 -0
  32. package/dist/types/arraybuffer.umd.js.map +1 -0
  33. package/dist/types/bigint-object.umd.js +2 -0
  34. package/dist/types/bigint-object.umd.js.map +1 -0
  35. package/dist/types/bigint.umd.js +2 -0
  36. package/dist/types/bigint.umd.js.map +1 -0
  37. package/dist/types/blob.umd.js +2 -0
  38. package/dist/types/blob.umd.js.map +1 -0
  39. package/dist/types/cloneable.umd.js +2 -0
  40. package/dist/types/cloneable.umd.js.map +1 -0
  41. package/dist/types/cryptokey.umd.js +2 -0
  42. package/dist/types/cryptokey.umd.js.map +1 -0
  43. package/dist/types/dataview.umd.js +2 -0
  44. package/dist/types/dataview.umd.js.map +1 -0
  45. package/dist/types/date.umd.js +2 -0
  46. package/dist/types/date.umd.js.map +1 -0
  47. package/dist/types/error.umd.js +2 -0
  48. package/dist/types/error.umd.js.map +1 -0
  49. package/dist/types/errors.umd.js +2 -0
  50. package/dist/types/errors.umd.js.map +1 -0
  51. package/dist/types/file.umd.js +2 -0
  52. package/dist/types/file.umd.js.map +1 -0
  53. package/dist/types/filelist.umd.js +2 -0
  54. package/dist/types/filelist.umd.js.map +1 -0
  55. package/dist/types/imagebitmap.umd.js +2 -0
  56. package/dist/types/imagebitmap.umd.js.map +1 -0
  57. package/dist/types/imagedata.umd.js +2 -0
  58. package/dist/types/imagedata.umd.js.map +1 -0
  59. package/dist/types/infinity.umd.js +2 -0
  60. package/dist/types/infinity.umd.js.map +1 -0
  61. package/dist/types/intl-types.umd.js +2 -0
  62. package/dist/types/intl-types.umd.js.map +1 -0
  63. package/dist/types/map.umd.js +2 -0
  64. package/dist/types/map.umd.js.map +1 -0
  65. package/dist/types/nan.umd.js +2 -0
  66. package/dist/types/nan.umd.js.map +1 -0
  67. package/dist/types/negative-infinity.umd.js +2 -0
  68. package/dist/types/negative-infinity.umd.js.map +1 -0
  69. package/dist/types/nonbuiltin-ignore.umd.js +2 -0
  70. package/dist/types/nonbuiltin-ignore.umd.js.map +1 -0
  71. package/dist/types/primitive-objects.umd.js +2 -0
  72. package/dist/types/primitive-objects.umd.js.map +1 -0
  73. package/dist/types/regexp.umd.js +2 -0
  74. package/dist/types/regexp.umd.js.map +1 -0
  75. package/dist/types/resurrectable.umd.js +2 -0
  76. package/dist/types/resurrectable.umd.js.map +1 -0
  77. package/dist/types/set.umd.js +2 -0
  78. package/dist/types/set.umd.js.map +1 -0
  79. package/dist/types/typed-arrays-socketio.umd.js +2 -0
  80. package/dist/types/typed-arrays-socketio.umd.js.map +1 -0
  81. package/dist/types/typed-arrays.umd.js +2 -0
  82. package/dist/types/typed-arrays.umd.js.map +1 -0
  83. package/dist/types/undef.umd.js +2 -0
  84. package/dist/types/undef.umd.js.map +1 -0
  85. package/dist/types/user-object.umd.js +2 -0
  86. package/dist/types/user-object.umd.js.map +1 -0
  87. package/package.json +98 -27
  88. package/polyfills/createObjectURL.js +96 -0
  89. package/polyfills/createObjectURL.umd.js +2 -0
  90. package/polyfills/createObjectURL.umd.js.map +1 -0
  91. package/utils/generateUUID.js +29 -0
  92. package/utils/stringArrayBuffer.js +72 -0
  93. package/CHANGES +0 -126
  94. package/browser-test/index.html +0 -30
  95. package/browser-test/testLoading.js +0 -57
  96. package/browser-test/worker.html +0 -31
  97. package/browser-test/worker.js +0 -16
  98. package/build.js +0 -99
  99. package/dist/all.js +0 -126
  100. package/dist/all.js.map +0 -89
  101. package/dist/presets/builtin.js +0 -78
  102. package/dist/presets/builtin.js.map +0 -59
  103. package/dist/presets/post-message.js +0 -21
  104. package/dist/presets/post-message.js.map +0 -23
  105. package/dist/presets/socketio.js +0 -87
  106. package/dist/presets/socketio.js.map +0 -63
  107. package/dist/presets/sparse-undefined.js +0 -12
  108. package/dist/presets/sparse-undefined.js.map +0 -19
  109. package/dist/presets/special-numbers.js +0 -21
  110. package/dist/presets/special-numbers.js.map +0 -25
  111. package/dist/presets/structured-cloning-throwing.js +0 -90
  112. package/dist/presets/structured-cloning-throwing.js.map +0 -69
  113. package/dist/presets/structured-cloning.js +0 -87
  114. package/dist/presets/structured-cloning.js.map +0 -67
  115. package/dist/presets/undefined.js +0 -18
  116. package/dist/presets/undefined.js.map +0 -23
  117. package/dist/presets/universal.js +0 -81
  118. package/dist/presets/universal.js.map +0 -61
  119. package/dist/types/Infinity.js +0 -12
  120. package/dist/types/Infinity.js.map +0 -19
  121. package/dist/types/NaN.js +0 -12
  122. package/dist/types/NaN.js.map +0 -19
  123. package/dist/types/NegativeInfinity.js +0 -12
  124. package/dist/types/NegativeInfinity.js.map +0 -19
  125. package/dist/types/arraybuffer.js +0 -15
  126. package/dist/types/arraybuffer.js.map +0 -21
  127. package/dist/types/blob.js +0 -12
  128. package/dist/types/blob.js.map +0 -19
  129. package/dist/types/cloneable.js +0 -12
  130. package/dist/types/cloneable.js.map +0 -19
  131. package/dist/types/dataview.js +0 -15
  132. package/dist/types/dataview.js.map +0 -21
  133. package/dist/types/date.js +0 -12
  134. package/dist/types/date.js.map +0 -19
  135. package/dist/types/error.js +0 -12
  136. package/dist/types/error.js.map +0 -19
  137. package/dist/types/errors.js +0 -15
  138. package/dist/types/errors.js.map +0 -19
  139. package/dist/types/file.js +0 -12
  140. package/dist/types/file.js.map +0 -19
  141. package/dist/types/filelist.js +0 -15
  142. package/dist/types/filelist.js.map +0 -21
  143. package/dist/types/imagebitmap.js +0 -12
  144. package/dist/types/imagebitmap.js.map +0 -19
  145. package/dist/types/imagedata.js +0 -12
  146. package/dist/types/imagedata.js.map +0 -19
  147. package/dist/types/intl-types.js +0 -12
  148. package/dist/types/intl-types.js.map +0 -19
  149. package/dist/types/map.js +0 -15
  150. package/dist/types/map.js.map +0 -21
  151. package/dist/types/nonbuiltin-ignore.js +0 -12
  152. package/dist/types/nonbuiltin-ignore.js.map +0 -19
  153. package/dist/types/primitive-objects.js +0 -12
  154. package/dist/types/primitive-objects.js.map +0 -19
  155. package/dist/types/regexp.js +0 -12
  156. package/dist/types/regexp.js.map +0 -19
  157. package/dist/types/resurrectable.js +0 -12
  158. package/dist/types/resurrectable.js.map +0 -19
  159. package/dist/types/set.js +0 -15
  160. package/dist/types/set.js.map +0 -21
  161. package/dist/types/special-numbers.js +0 -12
  162. package/dist/types/special-numbers.js.map +0 -19
  163. package/dist/types/typed-arrays-socketio.js +0 -15
  164. package/dist/types/typed-arrays-socketio.js.map +0 -19
  165. package/dist/types/typed-arrays.js +0 -18
  166. package/dist/types/typed-arrays.js.map +0 -21
  167. package/dist/types/undefined.js +0 -12
  168. package/dist/types/undefined.js.map +0 -19
  169. package/dist/types/user-object.js +0 -12
  170. package/dist/types/user-object.js.map +0 -19
  171. package/index.js +0 -39
  172. package/presets/builtin.js +0 -24
  173. package/presets/post-message.js +0 -15
  174. package/presets/socketio.js +0 -5
  175. package/presets/sparse-undefined.js +0 -19
  176. package/presets/special-numbers.js +0 -5
  177. package/presets/structured-cloning-throwing.js +0 -32
  178. package/presets/structured-cloning.js +0 -24
  179. package/presets/undefined.js +0 -4
  180. package/presets/universal.js +0 -4
  181. package/server.js +0 -10
  182. package/test/Flag_of_the_United_Nations.png +0 -0
  183. package/test/createObjectURL.js +0 -28
  184. package/test/test-entry.js +0 -49
  185. package/test/test-environment.js +0 -119
  186. package/test/test-node.js +0 -56
  187. package/test/test-utils.js +0 -38
  188. package/test/test.js +0 -885
  189. package/types/Infinity.js +0 -5
  190. package/types/NaN.js +0 -5
  191. package/types/NegativeInfinity.js +0 -5
  192. package/types/arraybuffer.js +0 -9
  193. package/types/blob.js +0 -36
  194. package/types/cloneable.js +0 -30
  195. package/types/dataview.js +0 -7
  196. package/types/date.js +0 -17
  197. package/types/error.js +0 -11
  198. package/types/errors.js +0 -20
  199. package/types/file.js +0 -41
  200. package/types/filelist.js +0 -23
  201. package/types/imagebitmap.js +0 -49
  202. package/types/imagedata.js +0 -14
  203. package/types/intl-types.js +0 -18
  204. package/types/map.js +0 -7
  205. package/types/nonbuiltin-ignore.js +0 -16
  206. package/types/primitive-objects.js +0 -23
  207. package/types/regexp.js +0 -11
  208. package/types/resurrectable.js +0 -28
  209. package/types/set.js +0 -7
  210. package/types/typed-arrays-socketio.js +0 -32
  211. package/types/typed-arrays.js +0 -23
  212. package/types/undefined.js +0 -9
  213. package/types/user-object.js +0 -6
  214. package/utils/array-from-iterator.js +0 -7
  215. package/windows-devinstall.js +0 -41
package/dist/index.js ADDED
@@ -0,0 +1,1205 @@
1
+ function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n);}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t]);})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t));}));}return e}function _typeof(e){return (_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n);}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,a,o=[],i=!0,c=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){c=!0,a=e;}finally{try{i||null==r.return||r.return();}finally{if(c)throw a}}return o}(e,t)||_unsupportedIterableToArray(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _toConsumableArray(e){return function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}(e)||function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||_unsupportedIterableToArray(e)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);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}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var e=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e);}));e.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&(e.prototype[Symbol.toStringTag]="TypesonPromise"),e.prototype.then=function(t,r){var n=this;return new e((function(e,a){n.p.then((function(r){e(t?t(r):r);})).catch((function(e){return r?r(e):Promise.reject(e)})).then(e,a);}))},e.prototype.catch=function(e){return this.then(null,e)},e.resolve=function(t){return new e((function(e){e(t);}))},e.reject=function(t){return new e((function(e,r){r(t);}))},["all","race","allSettled"].forEach((function(t){e[t]=function(r){return new e((function(e,n){Promise[t](r.map((function(e){return e&&e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,n);}))};}));var t={}.toString,r={}.hasOwnProperty,n=Object.getPrototypeOf,a=r.toString;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return t.call(e).slice(8,-1)}function hasConstructorOf(e,t){if(!e||"object"!==_typeof(e))return !1;var o=n(e);if(!o)return null===t;var i=r.call(o,"constructor")&&o.constructor;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__)}function isPlainObject(e){return !(!e||"Object"!==toStringTag(e))&&(!n(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return !1;var t=n(e);return !t||(hasConstructorOf(e,Object)||isUserObject(t))}function isObject(e){return e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replace(/~/g,"~0").replace(/\./g,"~1")}function unescapeKeyPathComponent(e){return e.replace(/~1/g,".").replace(/~0/g,"~")}function getByKeyPath(e,t){if(""===t)return e;var r=t.indexOf(".");if(r>-1){var n=e[unescapeKeyPathComponent(t.slice(0,r))];return void 0===n?void 0:getByKeyPath(n,t.slice(r+1))}return e[unescapeKeyPathComponent(t)]}function setAtKeyPath(e,t,r){if(""===t)return r;var n=t.indexOf(".");return n>-1?setAtKeyPath(e[unescapeKeyPathComponent(t.slice(0,n))],t.slice(n+1),r):(e[unescapeKeyPathComponent(t)]=r,e)}function getJSONType(e){return null===e?"null":Array.isArray(e)?"array":_typeof(e)}function _await(e,t,r){return r?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var o=Object.keys,i$1=Array.isArray,c={}.hasOwnProperty,s=["type","replaced","iterateIn","iterateUnsetNumeric"];function _async(e){return function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function nestedPathsFirst(e,t){if(""===e.keypath)return -1;var r=e.keypath.match(/\./g)||0,n=t.keypath.match(/\./g)||0;return r&&(r=r.length),n&&(n=n.length),r>n?-1:r<n?1:e.keypath<t.keypath?-1:e.keypath>t.keypath}var u=function(){function Typeson(e){_classCallCheck(this,Typeson),this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={};}return _createClass(Typeson,[{key:"stringify",value:function stringify(e,t,r,n){n=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),n),{},{stringification:!0});var a=this.encapsulate(e,null,n);return i$1(a)?JSON.stringify(a[0],t,r):a.then((function(e){return JSON.stringify(e,t,r)}))}},{key:"stringifySync",value:function stringifySync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!0}))}},{key:"stringifyAsync",value:function stringifyAsync(e,t,r,n){return this.stringify(e,t,r,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},n),{},{sync:!1}))}},{key:"parse",value:function parse(e,t,r){return r=_objectSpread2(_objectSpread2(_objectSpread2({},this.options),r),{},{parse:!0}),this.revive(JSON.parse(e,t),r)}},{key:"parseSync",value:function parseSync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"parseAsync",value:function parseAsync(e,t,r){return this.parse(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"specialTypeNames",value:function specialTypeNames(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.returnTypeNames=!0,this.encapsulate(e,t,r)}},{key:"rootTypeName",value:function rootTypeName(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return r.iterateNone=!0,this.encapsulate(e,t,r)}},{key:"encapsulate",value:function encapsulate(t,r,n){var a=_async((function(t,r){return _await(Promise.all(r.map((function(e){return e[1].p}))),(function(n){return _await(Promise.all(n.map(_async((function(n){var o=!1,i=[],c=_slicedToArray(r.splice(0,1),1),s=_slicedToArray(c[0],7),u=s[0],p=s[2],y=s[3],l=s[4],f=s[5],h=s[6],v=_encapsulate(u,n,p,y,i,!0,h),d=hasConstructorOf(v,e);return function _invoke(e,t){var r=e();return r&&r.then?r.then(t):t(r)}((function(){if(u&&d)return _await(v.p,(function(e){l[f]=e;var r=a(t,i);return o=!0,r}))}),(function(e){return o?e:(u?l[f]=v:t=d?v.p:v,a(t,i))}))})))),(function(){return t}))}))})),u=(n=_objectSpread2(_objectSpread2({sync:!0},this.options),n)).sync,p=this,y={},l=[],f=[],h=[],v=!("cyclic"in n)||n.cyclic,d=n.encapsulateObserver,b=_encapsulate("",t,v,r||{},h);function finish(e){var t=Object.values(y);if(n.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(n.returnTypeNames)return _toConsumableArray(new Set(t));e&&isPlainObject(e)&&!c.call(e,"$types")?e.$types=y:e={$:e,$types:{$:y}};}else isObject(e)&&c.call(e,"$types")&&(e={$:e,$types:!0});return !n.returnTypeNames&&e}function _adaptBuiltinStateObjectProperties(e,t,r){Object.assign(e,t);var n=s.map((function(t){var r=e[t];return delete e[t],r}));r(),s.forEach((function(t,r){e[t]=n[r];}));}function _encapsulate(t,r,a,s,u,h,v){var b,_={},O=_typeof(r),j=d?function(n){var o=v||s.type||getJSONType(r);d(Object.assign(n||_,{keypath:t,value:r,cyclic:a,stateObj:s,promisesData:u,resolvingTypesonPromise:h,awaitingTypesonPromise:hasConstructorOf(r,e)},{type:o}));}:null;if(["string","boolean","number","undefined"].includes(O))return void 0===r||Number.isNaN(r)||r===Number.NEGATIVE_INFINITY||r===Number.POSITIVE_INFINITY?(b=s.replaced?r:replace(t,r,s,u,!1,h,j))!==r&&(_={replaced:b}):b=r,j&&j(),b;if(null===r)return j&&j(),r;if(a&&!s.iterateIn&&!s.iterateUnsetNumeric&&r&&"object"===_typeof(r)){var m=l.indexOf(r);if(!(m<0))return y[t]="#",j&&j({cyclicKeypath:f[m]}),"#"+f[m];!0===a&&(l.push(r),f.push(t));}var S,g=isPlainObject(r),P=i$1(r),T=(g||P)&&(!p.plainObjectReplacers.length||s.replaced)||s.iterateIn?r:replace(t,r,s,u,g||P,null,j);if(T!==r?(b=T,_={replaced:T}):""===t&&hasConstructorOf(r,e)?(u.push([t,r,a,s,void 0,void 0,s.type]),b=r):P&&"object"!==s.iterateIn||"array"===s.iterateIn?(S=new Array(r.length),_={clone:S}):(["function","symbol"].includes(_typeof(r))||"toJSON"in r||hasConstructorOf(r,e)||hasConstructorOf(r,Promise)||hasConstructorOf(r,ArrayBuffer))&&!g&&"object"!==s.iterateIn?b=r:(S={},s.addLength&&(S.length=r.length),_={clone:S}),j&&j(),n.iterateNone)return S||b;if(!S)return b;if(s.iterateIn){var w=function _loop(n){var o={ownKeys:c.call(r,n)};_adaptBuiltinStateObjectProperties(s,o,(function(){var o=t+(t?".":"")+escapeKeyPathComponent(n),i=_encapsulate(o,r[n],Boolean(a),s,u,h);hasConstructorOf(i,e)?u.push([o,i,Boolean(a),s,S,n,s.type]):void 0!==i&&(S[n]=i);}));};for(var A in r)w(A);j&&j({endIterateIn:!0,end:!0});}else o(r).forEach((function(n){var o=t+(t?".":"")+escapeKeyPathComponent(n);_adaptBuiltinStateObjectProperties(s,{ownKeys:!0},(function(){var t=_encapsulate(o,r[n],Boolean(a),s,u,h);hasConstructorOf(t,e)?u.push([o,t,Boolean(a),s,S,n,s.type]):void 0!==t&&(S[n]=t);}));})),j&&j({endIterateOwn:!0,end:!0});if(s.iterateUnsetNumeric){for(var C=r.length,k=function _loop2(n){if(!(n in r)){var o=t+(t?".":"")+n;_adaptBuiltinStateObjectProperties(s,{ownKeys:!1},(function(){var t=_encapsulate(o,void 0,Boolean(a),s,u,h);hasConstructorOf(t,e)?u.push([o,t,Boolean(a),s,S,n,s.type]):void 0!==t&&(S[n]=t);}));}},N=0;N<C;N++)k(N);j&&j({endIterateUnsetNumeric:!0,end:!0});}return S}function replace(e,t,r,n,a,o,i){for(var c=a?p.plainObjectReplacers:p.nonplainObjectReplacers,s=c.length;s--;){var l=c[s];if(l.test(t,r)){var f=l.type;if(p.revivers[f]){var h=y[e];y[e]=h?[f].concat(h):f;}return Object.assign(r,{type:f,replaced:!0}),!u&&l.replaceAsync||l.replace?(i&&i({replacing:!0}),_encapsulate(e,l[u||!l.replaceAsync?"replace":"replaceAsync"](t,r),v&&"readonly",r,n,o,f)):(i&&i({typeDetected:!0}),_encapsulate(e,t,v&&"readonly",r,n,o,f))}}return t}return h.length?u&&n.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(a(b,h)).then(finish):!u&&n.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():n.stringification&&u?[finish(b)]:u?finish(b):Promise.resolve(finish(b))}},{key:"encapsulateSync",value:function encapsulateSync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!0}))}},{key:"encapsulateAsync",value:function encapsulateAsync(e,t,r){return this.encapsulate(e,t,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},r),{},{sync:!1}))}},{key:"revive",value:function revive(t,r){var n=t&&t.$types;if(!n)return t;if(!0===n)return t.$;var a=(r=_objectSpread2(_objectSpread2({sync:!0},this.options),r)).sync,c=[],s={},u=!0;n.$&&isPlainObject(n.$)&&(t=t.$,n=n.$,u=!1);var y=this;function executeReviver(e,t){var r=_slicedToArray(y.revivers[e]||[],1)[0];if(!r)throw new Error("Unregistered type: "+e);return a&&!("revive"in r)?t:r[a&&r.revive?"revive":!a&&r.reviveAsync?"reviveAsync":"revive"](t,s)}var l=[];function checkUndefined(e){return hasConstructorOf(e,p)?void 0:e}var f,h=function revivePlainObjects(){var r=[];if(Object.entries(n).forEach((function(e){var t=_slicedToArray(e,2),a=t[0],o=t[1];"#"!==o&&[].concat(o).forEach((function(e){_slicedToArray(y.revivers[e]||[null,{}],2)[1].plain&&(r.push({keypath:a,type:e}),delete n[a]);}));})),r.length)return r.sort(nestedPathsFirst).reduce((function reducer(r,n){var a=n.keypath,o=n.type;if(isThenable(r))return r.then((function(e){return reducer(e,{keypath:a,type:o})}));var i=getByKeyPath(t,a);if(hasConstructorOf(i=executeReviver(o,i),e))return i.then((function(e){var r=setAtKeyPath(t,a,e);r===e&&(t=r);}));var c=setAtKeyPath(t,a,i);c===i&&(t=c);}),void 0)}();return hasConstructorOf(h,e)?f=h.then((function(){return t})):(f=function _revive(t,r,a,s,y){if(!u||"$types"!==t){var f=n[t],h=i$1(r);if(h||isPlainObject(r)){var v=h?new Array(r.length):{};for(o(r).forEach((function(n){var o=_revive(t+(t?".":"")+escapeKeyPathComponent(n),r[n],a||v,v,n),i=function set(e){return hasConstructorOf(e,p)?v[n]=void 0:void 0!==e&&(v[n]=e),e};hasConstructorOf(o,e)?l.push(o.then((function(e){return i(e)}))):i(o);})),r=v;c.length;){var d=_slicedToArray(c[0],4),b=d[0],_=d[1],O=d[2],j=d[3],m=getByKeyPath(b,_);if(void 0===m)break;O[j]=m,c.splice(0,1);}}if(!f)return r;if("#"===f){var S=getByKeyPath(a,r.slice(1));return void 0===S&&c.push([a,r.slice(1),s,y]),S}return [].concat(f).reduce((function reducer(t,r){return hasConstructorOf(t,e)?t.then((function(e){return reducer(e,r)})):executeReviver(r,t)}),r)}}("",t,null),l.length&&(f=e.resolve(f).then((function(t){return e.all([t].concat(l))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(f)?a&&r.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(f,e)?f.p.then(checkUndefined):f:!a&&r.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():a?checkUndefined(f):Promise.resolve(checkUndefined(f))}},{key:"reviveSync",value:function reviveSync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!0}))}},{key:"reviveAsync",value:function reviveAsync(e,t){return this.revive(e,_objectSpread2(_objectSpread2({throwOnBadSyncType:!0},t),{},{sync:!1}))}},{key:"register",value:function register(e,t){var r=this;t=t||{};var n=function R(e){i$1(e)?e.forEach((function(e){return R(e)})):e&&o(e).forEach((function(n){if("#"===n)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(y.includes(n))throw new TypeError("Plain JSON object types are reserved as type names");var a=e[n],o=a&&a.testPlainObjects?r.plainObjectReplacers:r.nonplainObjectReplacers,c=o.filter((function(e){return e.type===n}));if(c.length&&(o.splice(o.indexOf(c[0]),1),delete r.revivers[n],delete r.types[n]),"function"==typeof a){var s=a;a={test:function test(e){return e&&e.constructor===s},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(s.prototype),e)}};}else if(i$1(a)){var u=_slicedToArray(a,3);a={test:u[0],replace:u[1],revive:u[2]};}if(a&&a.test){var p={type:n,test:a.test.bind(a)};a.replace&&(p.replace=a.replace.bind(a)),a.replaceAsync&&(p.replaceAsync=a.replaceAsync.bind(a));var l="number"==typeof t.fallback?t.fallback:t.fallback?0:Number.POSITIVE_INFINITY;if(a.testPlainObjects?r.plainObjectReplacers.splice(l,0,p):r.nonplainObjectReplacers.splice(l,0,p),a.revive||a.reviveAsync){var f={};a.revive&&(f.revive=a.revive.bind(a)),a.reviveAsync&&(f.reviveAsync=a.reviveAsync.bind(a)),r.revivers[n]=[f,{plain:a.testPlainObjects}];}r.types[n]=a;}}));};return [].concat(e).forEach((function(e){return n(e)})),this}}]),Typeson}(),p=_createClass((function Undefined(){_classCallCheck(this,Undefined);}));p.__typeson__type__="TypesonUndefined";var y=["null","boolean","number","string","array","object"];
2
+
3
+ /*
4
+ * base64-arraybuffer
5
+ * https://github.com/niklasvh/base64-arraybuffer
6
+ *
7
+ * Copyright (c) 2017 Brett Zamir, 2012 Niklas von Hertzen
8
+ * Licensed under the MIT license.
9
+ */
10
+ var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; // Use a lookup table to find the index.
11
+
12
+ var lookup = new Uint8Array(256);
13
+
14
+ for (var i = 0; i < chars.length; i++) {
15
+ lookup[chars.codePointAt(i)] = i;
16
+ }
17
+ /**
18
+ * @param {ArrayBuffer} arraybuffer
19
+ * @param {Integer} byteOffset
20
+ * @param {Integer} lngth
21
+ * @returns {string}
22
+ */
23
+
24
+
25
+ var encode = function encode(arraybuffer, byteOffset, lngth) {
26
+ if (lngth === null || lngth === undefined) {
27
+ lngth = arraybuffer.byteLength; // Needed for Safari
28
+ }
29
+
30
+ var bytes = new Uint8Array(arraybuffer, byteOffset || 0, // Default needed for Safari
31
+ lngth);
32
+ var len = bytes.length;
33
+ var base64 = '';
34
+
35
+ for (var _i = 0; _i < len; _i += 3) {
36
+ base64 += chars[bytes[_i] >> 2];
37
+ base64 += chars[(bytes[_i] & 3) << 4 | bytes[_i + 1] >> 4];
38
+ base64 += chars[(bytes[_i + 1] & 15) << 2 | bytes[_i + 2] >> 6];
39
+ base64 += chars[bytes[_i + 2] & 63];
40
+ }
41
+
42
+ if (len % 3 === 2) {
43
+ base64 = base64.slice(0, -1) + '=';
44
+ } else if (len % 3 === 1) {
45
+ base64 = base64.slice(0, -2) + '==';
46
+ }
47
+
48
+ return base64;
49
+ };
50
+ /**
51
+ * @param {string} base64
52
+ * @returns {ArrayBuffer}
53
+ */
54
+
55
+ var decode = function decode(base64) {
56
+ var len = base64.length;
57
+ var bufferLength = base64.length * 0.75;
58
+ var p = 0;
59
+ var encoded1, encoded2, encoded3, encoded4;
60
+
61
+ if (base64[base64.length - 1] === '=') {
62
+ bufferLength--;
63
+
64
+ if (base64[base64.length - 2] === '=') {
65
+ bufferLength--;
66
+ }
67
+ }
68
+
69
+ var arraybuffer = new ArrayBuffer(bufferLength),
70
+ bytes = new Uint8Array(arraybuffer);
71
+
72
+ for (var _i2 = 0; _i2 < len; _i2 += 4) {
73
+ encoded1 = lookup[base64.codePointAt(_i2)];
74
+ encoded2 = lookup[base64.codePointAt(_i2 + 1)];
75
+ encoded3 = lookup[base64.codePointAt(_i2 + 2)];
76
+ encoded4 = lookup[base64.codePointAt(_i2 + 3)];
77
+ bytes[p++] = encoded1 << 2 | encoded2 >> 4;
78
+ bytes[p++] = (encoded2 & 15) << 4 | encoded3 >> 2;
79
+ bytes[p++] = (encoded3 & 3) << 6 | encoded4 & 63;
80
+ }
81
+
82
+ return arraybuffer;
83
+ };
84
+
85
+ const arraybuffer = {
86
+ arraybuffer: {
87
+ test (x) { return toStringTag(x) === 'ArrayBuffer'; },
88
+ replace (b, stateObj) {
89
+ if (!stateObj.buffers) {
90
+ stateObj.buffers = [];
91
+ }
92
+ const index = stateObj.buffers.indexOf(b);
93
+ if (index > -1) {
94
+ return {index};
95
+ }
96
+ stateObj.buffers.push(b);
97
+ return encode(b);
98
+ },
99
+ revive (b64, stateObj) {
100
+ if (!stateObj.buffers) {
101
+ stateObj.buffers = [];
102
+ }
103
+ if (typeof b64 === 'object') {
104
+ return stateObj.buffers[b64.index];
105
+ }
106
+ const buffer = decode(b64);
107
+ stateObj.buffers.push(buffer);
108
+ return buffer;
109
+ }
110
+ }
111
+ };
112
+
113
+ // See also typed-arrays!
114
+
115
+ /* globals BigInt */
116
+
117
+ const bigintObject = {
118
+ bigintObject: {
119
+ test (x) {
120
+ return typeof x === 'object' && hasConstructorOf(x, BigInt);
121
+ },
122
+ replace (n) { return String(n); },
123
+ revive (s) {
124
+ // Filed this to avoid error: https://github.com/eslint/eslint/issues/11810
125
+ // eslint-disable-next-line no-new-object
126
+ return new Object(BigInt(s));
127
+ }
128
+ }
129
+ };
130
+
131
+ /* globals BigInt */
132
+
133
+ const bigint = {
134
+ bigint: {
135
+ test (x) {
136
+ return typeof x === 'bigint';
137
+ },
138
+ replace (n) { return String(n); },
139
+ revive (s) { return BigInt(s); }
140
+ }
141
+ };
142
+
143
+ /**
144
+ * Not currently in use internally, but provided for parity.
145
+ * @param {ArrayBuffer} buf
146
+ * @returns {Uint8Array}
147
+ */
148
+
149
+ /**
150
+ *
151
+ * @param {string} str
152
+ * @returns {ArrayBuffer}
153
+ */
154
+ function string2arraybuffer (str) {
155
+ /*
156
+ // UTF-8 approaches
157
+ const utf8 = unescape(encodeURIComponent(str));
158
+ const arr = new Uint8Array(utf8.length);
159
+ for (let i = 0; i < utf8.length; i++) {
160
+ arr[i] = utf8.charCodeAt(i);
161
+ }
162
+ return arr.buffer;
163
+
164
+ const utf8 = [];
165
+ for (let i = 0; i < str.length; i++) {
166
+ let charcode = str.charCodeAt(i);
167
+ if (charcode < 0x80) utf8.push(charcode);
168
+ else if (charcode < 0x800) {
169
+ utf8.push(0xc0 | (charcode >> 6),
170
+ 0x80 | (charcode & 0x3f));
171
+ } else if (charcode < 0xd800 || charcode >= 0xe000) {
172
+ utf8.push(0xe0 | (charcode >> 12),
173
+ 0x80 | ((charcode >> 6) & 0x3f),
174
+ 0x80 | (charcode & 0x3f));
175
+ // surrogate pair
176
+ } else {
177
+ i++;
178
+ // UTF-16 encodes 0x10000-0x10FFFF by
179
+ // subtracting 0x10000 and splitting the
180
+ // 20 bits of 0x0-0xFFFFF into two halves
181
+ charcode = 0x10000 + (((charcode & 0x3ff) << 10) |
182
+ (str.charCodeAt(i) & 0x3ff));
183
+ utf8.push(0xf0 | (charcode >> 18),
184
+ 0x80 | ((charcode >> 12) & 0x3f),
185
+ 0x80 | ((charcode >> 6) & 0x3f),
186
+ 0x80 | (charcode & 0x3f));
187
+ }
188
+ }
189
+ return utf8;
190
+ */
191
+ /*
192
+ // Working UTF-16 options (equivalents)
193
+ const buf = new ArrayBuffer(str.length * 2); // 2 bytes for each char
194
+ const bufView = new Uint16Array(buf);
195
+ for (let i = 0, strLen = str.length; i < strLen; i++) {
196
+ bufView[i] = str.charCodeAt(i);
197
+ }
198
+ return buf;
199
+ */
200
+
201
+ const array = new Uint8Array(str.length);
202
+ for (let i = 0; i < str.length; i++) {
203
+ // eslint-disable-next-line max-len -- Long
204
+ // eslint-disable-next-line unicorn/prefer-code-point -- Iterating char. codes
205
+ array[i] = str.charCodeAt(i); // & 0xff;
206
+ }
207
+ return array.buffer;
208
+ }
209
+
210
+ /* globals XMLHttpRequest, Blob, FileReader */
211
+
212
+ const blob = {
213
+ blob: {
214
+ test (x) { return toStringTag(x) === 'Blob'; },
215
+ replace (b) { // Sync
216
+ const req = new XMLHttpRequest();
217
+ req.overrideMimeType('text/plain; charset=x-user-defined');
218
+ req.open('GET', URL.createObjectURL(b), false); // Sync
219
+ req.send();
220
+
221
+ // Seems not feasible to accurately simulate
222
+ /* c8 ignore next 3 */
223
+ if (req.status !== 200 && req.status !== 0) {
224
+ throw new Error('Bad Blob access: ' + req.status);
225
+ }
226
+ return {
227
+ type: b.type,
228
+ stringContents: req.responseText
229
+ };
230
+ },
231
+ revive ({type, stringContents}) {
232
+ return new Blob([string2arraybuffer(stringContents)], {type});
233
+ },
234
+ replaceAsync (b) {
235
+ return new e((resolve, reject) => {
236
+ /*
237
+ if (b.isClosed) { // On MDN, but not in https://w3c.github.io/FileAPI/#dfn-Blob
238
+ reject(new Error('The Blob is closed'));
239
+ return;
240
+ }
241
+ */
242
+ const reader = new FileReader();
243
+ reader.addEventListener('load', () => {
244
+ resolve({
245
+ type: b.type,
246
+ stringContents: reader.result
247
+ });
248
+ });
249
+ // Seems not feasible to accurately simulate
250
+ /* c8 ignore next 3 */
251
+ reader.addEventListener('error', () => {
252
+ reject(reader.error);
253
+ });
254
+ reader.readAsBinaryString(b);
255
+ });
256
+ }
257
+ }
258
+ };
259
+
260
+ /* globals performance */
261
+
262
+ // The `performance` global is optional
263
+
264
+ /**
265
+ * @todo We could use `import generateUUID from 'uuid/v4';` (but it needs
266
+ * crypto library, etc.; `rollup-plugin-node-builtins` doesn't recommend
267
+ * using its own version and though there is <https://www.npmjs.com/package/crypto-browserify>,
268
+ * it may be troublesome to bundle and not strongly needed)
269
+ * @returns {string}
270
+ */
271
+ function generateUUID () { // Adapted from original: public domain/MIT: http://stackoverflow.com/a/8809472/271577
272
+ /* c8 ignore next */
273
+ let d = Date.now() +
274
+ // use high-precision timer if available
275
+ /* c8 ignore next 4 */
276
+ (typeof performance !== 'undefined' &&
277
+ typeof performance.now === 'function'
278
+ ? performance.now()
279
+ : 0);
280
+
281
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/gu, function (c) {
282
+ /* eslint-disable no-bitwise */
283
+ const r = Math.trunc((d + Math.random() * 16) % 16);
284
+ d = Math.floor(d / 16);
285
+ return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
286
+ /* eslint-enable no-bitwise */
287
+ });
288
+ }
289
+
290
+ const cloneableObjectsByUUID = {};
291
+
292
+ const cloneable = {
293
+ cloneable: {
294
+ test (x) {
295
+ return x && typeof x === 'object' &&
296
+ typeof x[Symbol.for('cloneEncapsulate')] === 'function';
297
+ },
298
+ replace (clonable) {
299
+ const encapsulated = clonable[Symbol.for('cloneEncapsulate')]();
300
+ const uuid = generateUUID();
301
+ cloneableObjectsByUUID[uuid] = clonable;
302
+ return {uuid, encapsulated};
303
+ },
304
+ revive ({uuid, encapsulated}) {
305
+ return cloneableObjectsByUUID[uuid][Symbol.for('cloneRevive')](
306
+ encapsulated
307
+ );
308
+ }
309
+ }
310
+ };
311
+
312
+ /* globals crypto */
313
+
314
+ const cryptokey = {
315
+ cryptokey: {
316
+ test (x) {
317
+ return toStringTag(x) === 'CryptoKey' && x.extractable;
318
+ },
319
+ replaceAsync (key) {
320
+ return new e(async (resolve, reject) => {
321
+ let jwk;
322
+ try {
323
+ jwk = await crypto.subtle.exportKey('jwk', key);
324
+ // Our format should be valid and our key extractable
325
+ /* c8 ignore next 4 */
326
+ } catch (err) {
327
+ reject(err);
328
+ return;
329
+ }
330
+ resolve({
331
+ jwk,
332
+ algorithm: key.algorithm,
333
+ usages: key.usages
334
+ });
335
+ });
336
+ },
337
+ revive ({jwk, algorithm, usages}) {
338
+ return crypto.subtle.importKey('jwk', jwk, algorithm, true, usages);
339
+ }
340
+ }
341
+ };
342
+
343
+ const dataview = {
344
+ dataview: {
345
+ test (x) { return toStringTag(x) === 'DataView'; },
346
+ replace ({buffer, byteOffset, byteLength}, stateObj) {
347
+ if (!stateObj.buffers) {
348
+ stateObj.buffers = [];
349
+ }
350
+ const index = stateObj.buffers.indexOf(buffer);
351
+ if (index > -1) {
352
+ return {index, byteOffset, byteLength};
353
+ }
354
+ stateObj.buffers.push(buffer);
355
+ return {
356
+ encoded: encode(buffer),
357
+ byteOffset,
358
+ byteLength
359
+ };
360
+ },
361
+ revive (b64Obj, stateObj) {
362
+ if (!stateObj.buffers) {
363
+ stateObj.buffers = [];
364
+ }
365
+ const {byteOffset, byteLength, encoded, index} = b64Obj;
366
+ let buffer;
367
+ if ('index' in b64Obj) {
368
+ buffer = stateObj.buffers[index];
369
+ } else {
370
+ buffer = decode(encoded);
371
+ stateObj.buffers.push(buffer);
372
+ }
373
+ return new DataView(buffer, byteOffset, byteLength);
374
+ }
375
+ }
376
+ };
377
+
378
+ const date = {
379
+ date: {
380
+ test (x) { return toStringTag(x) === 'Date'; },
381
+ replace (dt) {
382
+ const time = dt.getTime();
383
+ if (Number.isNaN(time)) {
384
+ return 'NaN';
385
+ }
386
+ return time;
387
+ },
388
+ revive (time) {
389
+ if (time === 'NaN') {
390
+ return new Date(Number.NaN);
391
+ }
392
+ return new Date(time);
393
+ }
394
+ }
395
+ };
396
+
397
+ const error = {
398
+ error: {
399
+ test (x) { return toStringTag(x) === 'Error'; },
400
+ replace ({name, message}) {
401
+ return {name, message};
402
+ },
403
+ revive ({name, message}) {
404
+ const e = new Error(message);
405
+ e.name = name;
406
+ return e;
407
+ }
408
+ }
409
+ };
410
+
411
+ /* eslint-env browser, node */
412
+
413
+ /* c8 ignore next */
414
+ const _global$2 = typeof self === 'undefined' ? global : self;
415
+
416
+ const errors = {};
417
+ // Comprises all built-in errors.
418
+ [
419
+ 'TypeError',
420
+ 'RangeError',
421
+ 'SyntaxError',
422
+ 'ReferenceError',
423
+ 'EvalError',
424
+ 'URIError',
425
+ 'InternalError' // non-standard
426
+ ].forEach((errName) => {
427
+ const Cnstrctr = _global$2[errName];
428
+ if (Cnstrctr) {
429
+ errors[errName.toLowerCase()] = {
430
+ test (x) { return hasConstructorOf(x, Cnstrctr); },
431
+ replace (e) { return e.message; },
432
+ revive (message) { return new Cnstrctr(message); }
433
+ };
434
+ }
435
+ });
436
+
437
+ /* globals XMLHttpRequest, File, FileReader */
438
+
439
+ const file = {
440
+ file: {
441
+ test (x) { return toStringTag(x) === 'File'; },
442
+ replace (f) { // Sync
443
+ const req = new XMLHttpRequest();
444
+ req.overrideMimeType('text/plain; charset=x-user-defined');
445
+ req.open('GET', URL.createObjectURL(f), false); // Sync
446
+ req.send();
447
+
448
+ // Seems not feasible to accurately simulate
449
+ /* c8 ignore next 3 */
450
+ if (req.status !== 200 && req.status !== 0) {
451
+ throw new Error('Bad File access: ' + req.status);
452
+ }
453
+ return {
454
+ type: f.type,
455
+ stringContents: req.responseText,
456
+ name: f.name,
457
+ lastModified: f.lastModified
458
+ };
459
+ },
460
+ revive ({name, type, stringContents, lastModified}) {
461
+ return new File([string2arraybuffer(stringContents)], name, {
462
+ type,
463
+ lastModified
464
+ });
465
+ },
466
+ replaceAsync (f) {
467
+ return new e(function (resolve, reject) {
468
+ /*
469
+ if (f.isClosed) { // On MDN, but not in https://w3c.github.io/FileAPI/#dfn-Blob
470
+ reject(new Error('The File is closed'));
471
+ return;
472
+ }
473
+ */
474
+ const reader = new FileReader();
475
+ reader.addEventListener('load', function () {
476
+ resolve({
477
+ type: f.type,
478
+ stringContents: reader.result,
479
+ name: f.name,
480
+ lastModified: f.lastModified
481
+ });
482
+ });
483
+ // Seems not feasible to accurately simulate
484
+ /* c8 ignore next 3 */
485
+ reader.addEventListener('error', function () {
486
+ reject(reader.error);
487
+ });
488
+ reader.readAsBinaryString(f);
489
+ });
490
+ }
491
+ }
492
+ };
493
+
494
+ const filelist = {
495
+ file: file.file,
496
+ filelist: {
497
+ test (x) { return toStringTag(x) === 'FileList'; },
498
+ replace (fl) {
499
+ const arr = [];
500
+ for (let i = 0; i < fl.length; i++) {
501
+ arr[i] = fl.item(i);
502
+ }
503
+ return arr;
504
+ },
505
+ revive (o) {
506
+ /**
507
+ * `FileList` polyfill.
508
+ */
509
+ class FileList {
510
+ /**
511
+ * Set private properties and length.
512
+ */
513
+ constructor () {
514
+ // eslint-disable-next-line prefer-rest-params
515
+ this._files = arguments[0];
516
+ this.length = this._files.length;
517
+ }
518
+ /**
519
+ * @param {Integer} index
520
+ * @returns {File}
521
+ */
522
+ item (index) {
523
+ return this._files[index];
524
+ }
525
+ /* eslint-disable class-methods-use-this */
526
+ /**
527
+ * @returns {"FileList"}
528
+ */
529
+ get [Symbol.toStringTag] () {
530
+ /* eslint-enable class-methods-use-this */
531
+ return 'FileList';
532
+ }
533
+ }
534
+ return new FileList(o);
535
+ }
536
+ }
537
+ };
538
+
539
+ /* globals createImageBitmap */
540
+
541
+ const imagebitmap = {
542
+ imagebitmap: {
543
+ test (x) {
544
+ return toStringTag(x) === 'ImageBitmap' ||
545
+ // In Node, our polyfill sets the dataset on a canvas
546
+ // element as JSDom no longer allows overriding toStringTag
547
+ (x && x.dataset && x.dataset.toStringTag === 'ImageBitmap');
548
+ },
549
+ replace (bm) {
550
+ const canvas = document.createElement('canvas');
551
+ const ctx = canvas.getContext('2d');
552
+ ctx.drawImage(bm, 0, 0);
553
+ // Although `width` and `height` are part of `ImageBitMap`,
554
+ // these will be auto-created for us when reviving with the
555
+ // data URL (and they are not settable even if they weren't)
556
+ // return {
557
+ // width: bm.width, height: bm.height, dataURL: canvas.toDataURL()
558
+ // };
559
+ return canvas.toDataURL();
560
+ },
561
+ revive (o) {
562
+ /*
563
+ var req = new XMLHttpRequest();
564
+ req.open('GET', o, false); // Sync
565
+ if (req.status !== 200 && req.status !== 0) {
566
+ throw new Error('Bad ImageBitmap access: ' + req.status);
567
+ }
568
+ req.send();
569
+ return req.responseText;
570
+ */
571
+ const canvas = document.createElement('canvas');
572
+ const ctx = canvas.getContext('2d');
573
+ const img = document.createElement('img');
574
+ // The onload is needed by some browsers per http://stackoverflow.com/a/4776378/271577
575
+ img.addEventListener('load', function () {
576
+ ctx.drawImage(img, 0, 0);
577
+ });
578
+ img.src = o;
579
+ // Works in contexts allowing an `ImageBitmap` (We might use
580
+ // `OffscreenCanvas.transferToBitmap` when supported)
581
+ return canvas;
582
+ },
583
+ reviveAsync (o) {
584
+ const canvas = document.createElement('canvas');
585
+ const ctx = canvas.getContext('2d');
586
+ const img = document.createElement('img');
587
+ // The onload is needed by some browsers per http://stackoverflow.com/a/4776378/271577
588
+ img.addEventListener('load', function () {
589
+ ctx.drawImage(img, 0, 0);
590
+ });
591
+ img.src = o; // o.dataURL;
592
+ return createImageBitmap(canvas); // Returns a promise
593
+ }
594
+ }
595
+ };
596
+
597
+ /* globals ImageData */
598
+
599
+ const imagedata = {
600
+ imagedata: {
601
+ test (x) { return toStringTag(x) === 'ImageData'; },
602
+ replace (d) {
603
+ return {
604
+ // Ensure `length` gets preserved for revival
605
+ array: [...d.data],
606
+ width: d.width,
607
+ height: d.height
608
+ };
609
+ },
610
+ revive (o) {
611
+ return new ImageData(
612
+ new Uint8ClampedArray(o.array), o.width, o.height
613
+ );
614
+ }
615
+ }
616
+ };
617
+
618
+ const infinity = {
619
+ infinity: {
620
+ test (x) { return x === Number.POSITIVE_INFINITY; },
621
+ replace (n) { return 'Infinity'; },
622
+ revive (s) { return Number.POSITIVE_INFINITY; }
623
+ }
624
+ };
625
+
626
+ const IntlCollator = {
627
+ test (x) { return hasConstructorOf(x, Intl.Collator); },
628
+ replace (c) { return c.resolvedOptions(); },
629
+ revive (options) { return new Intl.Collator(options.locale, options); }
630
+ };
631
+
632
+ const IntlDateTimeFormat = {
633
+ test (x) { return hasConstructorOf(x, Intl.DateTimeFormat); },
634
+ replace (dtf) { return dtf.resolvedOptions(); },
635
+ revive (options) {
636
+ return new Intl.DateTimeFormat(options.locale, options);
637
+ }
638
+ };
639
+
640
+ const IntlNumberFormat = {
641
+ test (x) { return hasConstructorOf(x, Intl.NumberFormat); },
642
+ replace (nf) { return nf.resolvedOptions(); },
643
+ revive (options) { return new Intl.NumberFormat(options.locale, options); }
644
+ };
645
+
646
+ const intlTypes = {
647
+ IntlCollator,
648
+ IntlDateTimeFormat,
649
+ IntlNumberFormat
650
+ };
651
+
652
+ const map = {
653
+ map: {
654
+ test (x) { return toStringTag(x) === 'Map'; },
655
+ replace (mp) { return [...mp.entries()]; },
656
+ revive (entries) { return new Map(entries); }
657
+ }
658
+ };
659
+
660
+ const nan = {
661
+ nan: {
662
+ test (x) { return Number.isNaN(x); },
663
+ replace (n) { return 'NaN'; },
664
+ revive (s) { return Number.NaN; }
665
+ }
666
+ };
667
+
668
+ const negativeInfinity = {
669
+ negativeInfinity: {
670
+ test (x) { return x === Number.NEGATIVE_INFINITY; },
671
+ replace (n) { return '-Infinity'; },
672
+ revive (s) { return Number.NEGATIVE_INFINITY; }
673
+ }
674
+ };
675
+
676
+ const nonbuiltinIgnore = {
677
+ nonbuiltinIgnore: {
678
+ test (x) {
679
+ return x && typeof x === 'object' && !Array.isArray(x) && ![
680
+ 'Object',
681
+ // `Proxy` and `Reflect`, two other built-in objects, will also
682
+ // have a `toStringTag` of `Object`; we don't want built-in
683
+ // function objects, however
684
+ 'Boolean', 'Number', 'String',
685
+ 'Error', 'RegExp', 'Math', 'Date',
686
+ 'Map', 'Set',
687
+ 'JSON',
688
+ 'ArrayBuffer', 'SharedArrayBuffer', 'DataView',
689
+ 'Int8Array', 'Uint8Array', 'Uint8ClampedArray', 'Int16Array',
690
+ 'Uint16Array', 'Int32Array', 'Uint32Array',
691
+ 'Float32Array', 'Float64Array',
692
+ 'Promise',
693
+ 'String Iterator', 'Array Iterator',
694
+ 'Map Iterator', 'Set Iterator',
695
+ 'WeakMap', 'WeakSet',
696
+ 'Atomics', 'Module'
697
+ ].includes(toStringTag(x));
698
+ },
699
+ replace (rexp) {
700
+ // Not in use
701
+ }
702
+ }
703
+ };
704
+
705
+ // This module is for objectified primitives (such as `new Number(3)` or
706
+
707
+ const primitiveObjects = {
708
+ // String Object (not primitive string which need no type spec)
709
+ StringObject: {
710
+ test (x) {
711
+ return toStringTag(x) === 'String' && typeof x === 'object';
712
+ },
713
+ replace (s) { return String(s); }, // convert to primitive string
714
+ revive (s) { return new String(s); } // Revive to an objectified string
715
+ },
716
+ // Boolean Object (not primitive boolean which need no type spec)
717
+ BooleanObject: {
718
+ test (x) {
719
+ return toStringTag(x) === 'Boolean' &&
720
+ typeof x === 'object';
721
+ },
722
+ replace (b) { return Boolean(b); }, // convert to primitive boolean
723
+ revive (b) {
724
+ // Revive to an objectified Boolean
725
+ return new Boolean(b);
726
+ }
727
+ },
728
+ // Number Object (not primitive number which need no type spec)
729
+ NumberObject: {
730
+ test (x) {
731
+ return toStringTag(x) === 'Number' && typeof x === 'object';
732
+ },
733
+ replace (n) { return Number(n); }, // convert to primitive number
734
+ revive (n) { return new Number(n); } // Revive to an objectified number
735
+ }
736
+ };
737
+
738
+ const regexp = {
739
+ regexp: {
740
+ test (x) { return toStringTag(x) === 'RegExp'; },
741
+ replace (rexp) {
742
+ return {
743
+ source: rexp.source,
744
+ flags: (rexp.global ? 'g' : '') +
745
+ (rexp.ignoreCase ? 'i' : '') +
746
+ (rexp.multiline ? 'm' : '') +
747
+ (rexp.sticky ? 'y' : '') +
748
+ (rexp.unicode ? 'u' : '')
749
+ };
750
+ },
751
+ revive ({source, flags}) { return new RegExp(source, flags); }
752
+ }
753
+ };
754
+
755
+ // Here we allow the exact same non-plain object, function, and symbol
756
+
757
+ const resurrectableObjectsByUUID = {};
758
+
759
+ const resurrectable = {
760
+ resurrectable: {
761
+ test (x) {
762
+ return x &&
763
+ !Array.isArray(x) &&
764
+ ['object', 'function', 'symbol'].includes(typeof x);
765
+ },
766
+ replace (rsrrctble) {
767
+ const uuid = generateUUID();
768
+ resurrectableObjectsByUUID[uuid] = rsrrctble;
769
+ return uuid;
770
+ },
771
+ revive (serializedResurrectable) {
772
+ return resurrectableObjectsByUUID[serializedResurrectable];
773
+ }
774
+ }
775
+ };
776
+
777
+ const set = {
778
+ set: {
779
+ test (x) { return toStringTag(x) === 'Set'; },
780
+ replace (st) {
781
+ return [...st.values()];
782
+ },
783
+ revive (values) { return new Set(values); }
784
+ }
785
+ };
786
+
787
+ /* eslint-env browser, node */
788
+
789
+ /* c8 ignore next */
790
+ const _global$1 = typeof self === 'undefined' ? global : self;
791
+
792
+ // Support all kinds of typed arrays (views of ArrayBuffers)
793
+ const typedArraysSocketIO = {};
794
+ [
795
+ 'Int8Array',
796
+ 'Uint8Array',
797
+ 'Uint8ClampedArray',
798
+ 'Int16Array',
799
+ 'Uint16Array',
800
+ 'Int32Array',
801
+ 'Uint32Array',
802
+ 'Float32Array',
803
+ 'Float64Array'
804
+ ].forEach(function (typeName) {
805
+ const arrType = typeName;
806
+ const TypedArray = _global$1[typeName];
807
+ /* c8 ignore next 3 */
808
+ if (!TypedArray) {
809
+ return;
810
+ }
811
+ typedArraysSocketIO[typeName.toLowerCase()] = {
812
+ test (x) { return toStringTag(x) === arrType; },
813
+ replace (a) {
814
+ return (a.byteOffset === 0 &&
815
+ a.byteLength === a.buffer.byteLength
816
+ ? a
817
+ // socket.io supports streaming ArrayBuffers.
818
+ // If we have a typed array representing a portion
819
+ // of the buffer, we need to clone
820
+ // the buffer before leaving it to socket.io.
821
+ : a.slice(0)).buffer;
822
+ },
823
+ revive (buf) {
824
+ // One may configure socket.io to revive binary data as
825
+ // Buffer or Blob.
826
+ // We should therefore not rely on that the instance we
827
+ // get here is an ArrayBuffer
828
+ // If not, let's assume user wants to receive it as
829
+ // configured with socket.io.
830
+ return toStringTag(buf) === 'ArrayBuffer'
831
+ ? new TypedArray(buf)
832
+ : buf;
833
+ }
834
+ };
835
+ });
836
+
837
+ /* eslint-env browser, node */
838
+
839
+ /* c8 ignore next */
840
+ const _global = typeof self === 'undefined' ? global : self;
841
+
842
+ const typedArrays = {};
843
+ [
844
+ 'Int8Array',
845
+ 'Uint8Array',
846
+ 'Uint8ClampedArray',
847
+ 'Int16Array',
848
+ 'Uint16Array',
849
+ 'Int32Array',
850
+ 'Uint32Array',
851
+ 'Float32Array',
852
+ 'Float64Array'
853
+ ].forEach(function (typeName) {
854
+ const arrType = typeName;
855
+ const TypedArray = _global[arrType];
856
+ /* c8 ignore next 3 */
857
+ if (!TypedArray) {
858
+ return;
859
+ }
860
+ typedArrays[typeName.toLowerCase()] = {
861
+ test (x) { return toStringTag(x) === arrType; },
862
+ replace ({buffer, byteOffset, length: l}, stateObj) {
863
+ if (!stateObj.buffers) {
864
+ stateObj.buffers = [];
865
+ }
866
+ const index = stateObj.buffers.indexOf(buffer);
867
+ if (index > -1) {
868
+ return {index, byteOffset, length: l};
869
+ }
870
+ stateObj.buffers.push(buffer);
871
+ return {
872
+ encoded: encode(buffer),
873
+ byteOffset,
874
+ length: l
875
+ };
876
+ },
877
+ revive (b64Obj, stateObj) {
878
+ if (!stateObj.buffers) {
879
+ stateObj.buffers = [];
880
+ }
881
+ const {byteOffset, length: len, encoded, index} = b64Obj;
882
+ let buffer;
883
+ if ('index' in b64Obj) {
884
+ buffer = stateObj.buffers[index];
885
+ } else {
886
+ buffer = decode(encoded);
887
+ stateObj.buffers.push(buffer);
888
+ }
889
+ return new TypedArray(buffer, byteOffset, len);
890
+ }
891
+ };
892
+ });
893
+
894
+ // This does not preserve `undefined` in sparse arrays; see the `undef`
895
+
896
+ const undef$1 = {
897
+ undef: {
898
+ test (x, stateObj) {
899
+ return typeof x === 'undefined' &&
900
+ (stateObj.ownKeys || !('ownKeys' in stateObj));
901
+ },
902
+ replace (n) { return 0; },
903
+ revive (s) {
904
+ // Will add `undefined` (returning `undefined` would instead
905
+ // avoid explicitly setting)
906
+ return new p();
907
+ }
908
+ }
909
+ };
910
+
911
+ const userObject = {
912
+ userObject: {
913
+ test (x, stateObj) { return isUserObject(x); },
914
+ replace (n) { return {...n}; },
915
+ revive (s) { return s; }
916
+ }
917
+ };
918
+
919
+ const arrayNonindexKeys = [
920
+ {
921
+ arrayNonindexKeys: {
922
+ testPlainObjects: true,
923
+ test (x, stateObj) {
924
+ if (Array.isArray(x)) {
925
+ if (
926
+ // By avoiding serializing arrays into objects which
927
+ // have only positive-integer keys, we reduce
928
+ // size and improve revival performance; arrays with
929
+ // non-index keys will be larger however
930
+ Object.keys(x).some((k) => {
931
+ // No need to check for `isNaN` or
932
+ // `isNaN(Number.parseInt())` as `NaN` will be
933
+ // treated as a string.
934
+ // No need to do check as
935
+ // `Number.parseInt(Number())` since scientific
936
+ // notation will be pre-resolved if a number
937
+ // was given, and it will otherwise be a string
938
+ return String(Number.parseInt(k)) !== k;
939
+ })
940
+ ) {
941
+ stateObj.iterateIn = 'object';
942
+ stateObj.addLength = true;
943
+ }
944
+ return true;
945
+ }
946
+ return false;
947
+ },
948
+ replace (a, stateObj) {
949
+ // Catch sparse undefined
950
+ stateObj.iterateUnsetNumeric = true;
951
+ return a;
952
+ },
953
+ revive (o) {
954
+ if (Array.isArray(o)) {
955
+ return o;
956
+ }
957
+ const arr = [];
958
+ // No map here as may be a sparse array (including
959
+ // with `length` set)
960
+ // Todo: Reenable when Node `engines` >= 7
961
+ // Object.entries(o).forEach(([key, val]) => {
962
+ Object.keys(o).forEach((key) => {
963
+ const val = o[key];
964
+ arr[key] = val;
965
+ });
966
+ return arr;
967
+ }
968
+ }
969
+ },
970
+ {
971
+ sparseUndefined: {
972
+ test (x, stateObj) {
973
+ return typeof x === 'undefined' && stateObj.ownKeys === false;
974
+ },
975
+ replace (n) { return 0; },
976
+ revive (s) { return undefined; } // Will avoid adding anything
977
+ }
978
+ }
979
+ ];
980
+
981
+ const specialNumbers = [
982
+ nan,
983
+ infinity,
984
+ negativeInfinity
985
+ ];
986
+
987
+ /* This preset includes types that are built-in into the JavaScript
988
+ language itself, this should work universally.
989
+
990
+ Types that were added in ES6 or beyond will be checked before inclusion
991
+ so that this module can be consumed by both ES5 and ES6 environments.
992
+
993
+ Some types cannot be encapsulated because their inner state is private:
994
+ `WeakMap`, `WeakSet`.
995
+
996
+ The Function type is not included because their closures would not be
997
+ serialized, so a revived Function that uses closures would not behave
998
+ as expected.
999
+
1000
+ Symbols are similarly not included.
1001
+ */
1002
+
1003
+ const expObj$1 = [
1004
+ undef$1,
1005
+ // ES5
1006
+ arrayNonindexKeys, primitiveObjects, specialNumbers,
1007
+ date, error, errors, regexp
1008
+ ].concat(
1009
+ // ES2015 (ES6)
1010
+ /* c8 ignore next */
1011
+ typeof Map === 'function' ? map : [],
1012
+ /* c8 ignore next */
1013
+ typeof Set === 'function' ? set : [],
1014
+ /* c8 ignore next */
1015
+ typeof ArrayBuffer === 'function' ? arraybuffer : [],
1016
+ /* c8 ignore next */
1017
+ typeof Uint8Array === 'function' ? typedArrays : [],
1018
+ /* c8 ignore next */
1019
+ typeof DataView === 'function' ? dataview : [],
1020
+ /* c8 ignore next */
1021
+ typeof Intl !== 'undefined' ? intlTypes : [],
1022
+
1023
+ /* c8 ignore next */
1024
+ typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []
1025
+ );
1026
+
1027
+ /*
1028
+ When communicating via `postMessage()` (`Worker.postMessage()` or
1029
+ `window.postMessage()`), the browser will use a similar algorithm as Typeson
1030
+ does to encapsulate and revive all items in the structure (aka the structured
1031
+ clone algorithm). This algorithm supports all built-in types as well as many
1032
+ DOM types. Therefore, only types that are not included in the structured clone
1033
+ algorithm need to be registered, which is:
1034
+
1035
+ * Error
1036
+ * Specific Errors like SyntaxError, TypeError, etc.
1037
+ * Any custom type you want to send across window- or worker boundraries
1038
+
1039
+ This preset will only include the Error types and you can register your
1040
+ custom types after having registered these.
1041
+ */
1042
+
1043
+ const postmessage = [
1044
+ error,
1045
+ errors
1046
+ ];
1047
+
1048
+ const socketio = [
1049
+ expObj$1,
1050
+ // Leave ArrayBuffer as is, and let socket.io stream it instead.
1051
+ {arraybuffer: null},
1052
+ // Encapsulate TypedArrays in ArrayBuffers instead of base64 strings.
1053
+ typedArraysSocketIO
1054
+ ];
1055
+
1056
+ const sparseUndefined = [
1057
+ {
1058
+ sparseArrays: {
1059
+ testPlainObjects: true,
1060
+ test (x) { return Array.isArray(x); },
1061
+ replace (a, stateObj) {
1062
+ stateObj.iterateUnsetNumeric = true;
1063
+ return a;
1064
+ }
1065
+ }
1066
+ },
1067
+ {
1068
+ sparseUndefined: {
1069
+ test (x, stateObj) {
1070
+ return typeof x === 'undefined' && stateObj.ownKeys === false;
1071
+ },
1072
+ replace (n) { return 0; },
1073
+ revive (s) { return undefined; } // Will avoid adding anything
1074
+ }
1075
+ }
1076
+ ];
1077
+
1078
+ /* This preset includes types for the Structured Cloning Algorithm. */
1079
+
1080
+ const expObj = [
1081
+ // Todo: Might also register synchronous `ImageBitmap` and
1082
+ // `Blob`/`File`/`FileList`?
1083
+ // ES5
1084
+ userObject, // Processed last (non-builtin)
1085
+
1086
+ undef$1,
1087
+ arrayNonindexKeys, primitiveObjects, specialNumbers,
1088
+ date, regexp,
1089
+
1090
+ // Non-built-ins
1091
+ imagedata,
1092
+ imagebitmap, // Async return
1093
+ file,
1094
+ filelist,
1095
+ blob
1096
+ ].concat(
1097
+ // ES2015 (ES6)
1098
+ /* c8 ignore next */
1099
+ typeof Map === 'function' ? map : [],
1100
+ /* c8 ignore next */
1101
+ typeof Set === 'function' ? set : [],
1102
+ /* c8 ignore next */
1103
+ typeof ArrayBuffer === 'function' ? arraybuffer : [],
1104
+ /* c8 ignore next */
1105
+ typeof Uint8Array === 'function' ? typedArrays : [],
1106
+ /* c8 ignore next */
1107
+ typeof DataView === 'function' ? dataview : [],
1108
+ /* c8 ignore next */
1109
+ typeof Intl !== 'undefined' ? intlTypes : [],
1110
+ /* c8 ignore next */
1111
+ typeof crypto !== 'undefined' ? cryptokey : [],
1112
+ /* c8 ignore next */
1113
+ typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []
1114
+ );
1115
+
1116
+ /* globals DOMException */
1117
+
1118
+ var structuredCloningThrowing = expObj.concat({
1119
+ checkDataCloneException: {
1120
+ test (val) {
1121
+ // Should also throw with:
1122
+ // 1. `IsDetachedBuffer` (a process not called within the
1123
+ // ECMAScript spec)
1124
+ // 2. `IsCallable` (covered by `typeof === 'function'` or a
1125
+ // function's `toStringTag`)
1126
+ // 3. internal slots besides [[Prototype]] or [[Extensible]] (e.g.,
1127
+ // [[PromiseState]] or [[WeakMapData]])
1128
+ // 4. exotic object (e.g., `Proxy`) (unless an `%ObjectPrototype%`
1129
+ // intrinsic object) (which does not have default
1130
+ // behavior for one or more of the essential internal methods
1131
+ // that are limited to the following for non-function objects
1132
+ // (we auto-exclude functions):
1133
+ // [[GetPrototypeOf]],[[SetPrototypeOf]],[[IsExtensible]],
1134
+ // [[PreventExtensions]],[[GetOwnProperty]],
1135
+ // [[DefineOwnProperty]],[[HasProperty]],
1136
+ // [[Get]],[[Set]],[[Delete]],[[OwnPropertyKeys]]);
1137
+ // except for the standard, built-in exotic objects, we'd need
1138
+ // to know whether these methods had distinct behaviors
1139
+ // Note: There is no apparent way for us to detect a `Proxy` and
1140
+ // reject (Chrome at least is not rejecting anyways)
1141
+ const stringTag = ({}.toString.call(val).slice(8, -1));
1142
+ if (
1143
+ [
1144
+ // Symbol's `toStringTag` is only "Symbol" for its initial
1145
+ // value, so we check `typeof`
1146
+ 'symbol',
1147
+ // All functions including bound function exotic objects
1148
+ 'function'
1149
+ ].includes(typeof val) ||
1150
+ [
1151
+ // A non-array exotic object
1152
+ 'Arguments',
1153
+ // A non-array exotic object
1154
+ 'Module',
1155
+ // `Error` and other errors have the [[ErrorData]] internal
1156
+ // slot and give "Error"
1157
+ 'Error',
1158
+ // Promise instances have an extra slot ([[PromiseState]])
1159
+ // but not throwing in Chrome `postMessage`
1160
+ 'Promise',
1161
+ // WeakMap instances have an extra slot ([[WeakMapData]])
1162
+ // but not throwing in Chrome `postMessage`
1163
+ 'WeakMap',
1164
+ // WeakSet instances have an extra slot ([[WeakSetData]])
1165
+ // but not throwing in Chrome `postMessage`
1166
+ 'WeakSet',
1167
+
1168
+ // HTML-SPECIFIC
1169
+ 'Event',
1170
+ // Also in Node `worker_threads` (currently experimental)
1171
+ 'MessageChannel'
1172
+ ].includes(stringTag) ||
1173
+ /*
1174
+ // isClosed is no longer documented
1175
+ ((stringTag === 'Blob' || stringTag === 'File') &&
1176
+ val.isClosed) ||
1177
+ */
1178
+ (val && typeof val === 'object' &&
1179
+ // Duck-type DOM node objects (non-array exotic?
1180
+ // objects which cannot be cloned by the SCA)
1181
+ typeof val.nodeType === 'number' &&
1182
+ typeof val.insertBefore === 'function')
1183
+ ) {
1184
+ throw new DOMException(
1185
+ 'The object cannot be cloned.', 'DataCloneError'
1186
+ );
1187
+ }
1188
+ return false;
1189
+ }
1190
+ }
1191
+ });
1192
+
1193
+ const undef = [
1194
+ sparseUndefined,
1195
+ undef$1
1196
+ ];
1197
+
1198
+ const universal = [
1199
+ expObj$1
1200
+ // TODO: Add types that are de-facto universal even though not
1201
+ // built-in into ecmasript standard.
1202
+ ];
1203
+
1204
+ export { y as JSON_TYPES, u as Typeson, e as TypesonPromise, p as Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, nonbuiltinIgnore, postmessage, primitiveObjects, regexp, resurrectable, set, setAtKeyPath, socketio, sparseUndefined, specialNumbers, expObj as structuredCloning, structuredCloningThrowing, toStringTag, typedArrays, typedArraysSocketIO as typedArraysSocketio, undef$1 as undef, undef as undefPreset, unescapeKeyPathComponent, universal, userObject };
1205
+ //# sourceMappingURL=index.js.map