@es-joy/jsoe 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.eslintrc.cjs +2 -0
- package/.nyc_output/out.json +121296 -0
- package/CHANGES.md +10 -0
- package/README.md +47 -21
- package/cypress.config.ts +13 -0
- package/demo/index-instrumented.html +29 -0
- package/demo/index.html +10 -1
- package/demo/index.js +482 -126
- package/dist/formatAndTypeChoices.d.ts +10 -4
- package/dist/formatAndTypeChoices.d.ts.map +1 -1
- package/dist/formats/json.d.ts.map +1 -1
- package/dist/formats/structuredCloning.d.ts +2 -1
- package/dist/formats/structuredCloning.d.ts.map +1 -1
- package/dist/fundamentalTypes/arrayType.d.ts +6 -37
- package/dist/fundamentalTypes/arrayType.d.ts.map +1 -1
- package/dist/fundamentalTypes/dateType.d.ts.map +1 -1
- package/dist/fundamentalTypes/errorType.d.ts +6 -0
- package/dist/fundamentalTypes/errorType.d.ts.map +1 -0
- package/dist/fundamentalTypes/mapType.d.ts +6 -0
- package/dist/fundamentalTypes/mapType.d.ts.map +1 -0
- package/dist/fundamentalTypes/nullType.d.ts.map +1 -1
- package/dist/fundamentalTypes/objectReferenceType.d.ts.map +1 -1
- package/dist/fundamentalTypes/setType.d.ts +6 -0
- package/dist/fundamentalTypes/setType.d.ts.map +1 -0
- package/dist/fundamentalTypes/sparseUndefinedType.d.ts.map +1 -1
- package/dist/fundamentalTypes/undefinedType.d.ts.map +1 -1
- package/dist/subTypes/blobHTMLType.d.ts +12 -6
- package/dist/subTypes/blobHTMLType.d.ts.map +1 -1
- package/dist/superTypes/SpecialNumberType.d.ts +14 -0
- package/dist/superTypes/SpecialNumberType.d.ts.map +1 -0
- package/dist/superTypes/SpecialRealNumberType.d.ts +6 -0
- package/dist/superTypes/SpecialRealNumberType.d.ts.map +1 -0
- package/dist/superTypes/errorsSpecialType.d.ts +8 -0
- package/dist/superTypes/errorsSpecialType.d.ts.map +1 -0
- package/dist/typeChoices.d.ts +4 -2
- package/dist/typeChoices.d.ts.map +1 -1
- package/dist/types.d.ts +85 -233
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/dialogs.d.ts +22 -22
- package/dist/utils/dialogs.d.ts.map +1 -1
- package/dist/utils/templateUtils.d.ts +6 -6
- package/dist/utils/templateUtils.d.ts.map +1 -1
- package/dist/vendor-imports.d.ts +1 -1
- package/package.json +39 -34
- package/rollup.config.js +14 -2
- package/server.js +1 -1
- package/src/formatAndTypeChoices.js +14 -13
- package/src/formats/indexedDBKey.js +2 -2
- package/src/formats/json.js +1 -2
- package/src/formats/structuredCloning.js +104 -29
- package/src/formats.js +2 -2
- package/src/fundamentalTypes/arrayReferenceType.js +3 -3
- package/src/fundamentalTypes/arrayType.js +384 -79
- package/src/fundamentalTypes/dateType.js +4 -6
- package/src/fundamentalTypes/errorType.js +416 -0
- package/src/fundamentalTypes/mapType.js +34 -0
- package/src/fundamentalTypes/nullType.js +1 -2
- package/src/fundamentalTypes/objectReferenceType.js +2 -1
- package/src/fundamentalTypes/regexpType.js +2 -2
- package/src/fundamentalTypes/setType.js +34 -0
- package/src/fundamentalTypes/sparseUndefinedType.js +2 -3
- package/src/fundamentalTypes/undefinedType.js +2 -3
- package/src/jsoe.css +3 -0
- package/src/subTypes/blobHTMLType.js +37 -33
- package/src/subTypes/falseType.js +2 -2
- package/src/subTypes/trueType.js +2 -2
- package/src/superTypes/{SpecialNumberSuperType.js → SpecialNumberType.js} +1 -1
- package/src/superTypes/{SpecialRealNumberSuperType.js → SpecialRealNumberType.js} +3 -2
- package/src/superTypes/errorsSpecialType.js +768 -0
- package/src/typeChoices.js +27 -20
- package/src/types.js +72 -40
- package/src/utils/dialogs.js +11 -12
- package/src/utils/jsonPointer.js +3 -3
- package/src/utils/templateUtils.js +4 -4
- package/src/vendor-imports.js +2 -2
- package/tsconfig.json +1 -1
- package/typings/CypressPlugins.d.ts +10 -0
- package/vendor/jamilih/dist/jml-es.js +126 -106
- package/vendor/typeson-registry/dist/index.js +188 -44
|
@@ -1,4 +1,4 @@
|
|
|
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},_typeof(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,_toPropertyKey(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=_toPropertyKey(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){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1;}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,o=e;}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(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}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:String(t)}var e=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e);}));e.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function get(){return "TypesonPromise"}}),e.prototype.then=function(t,r){var n=this;return new e((function(e,o){n.p.then((function(r){e(t?t(r):r);})).catch((function(e){return r?r(e):Promise.reject(e)})).then(e,o);}))},e.prototype.catch=function(e){return this.then((function(){}),e)},e.resolve=function(t){return new e((function(e){e(t);}))},e.reject=function(t){return new e((function(e,r){r(t);}))},e.all=function(t){return new e((function(e,r){Promise.all(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.race=function(t){return new e((function(e,r){Promise.race(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.allSettled=function(t){return new e((function(e,r){Promise.allSettled(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))};var t=Object.hasOwn,r=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,n){if(!e||"object"!==_typeof(e))return !1;var o=r(e);if(!o)return null===n;var i=t(o,"constructor")&&o.constructor;return "function"!=typeof i?null===n:n===i||(null!==n&&Function.prototype.toString.call(i)===Function.prototype.toString.call(n)||"function"==typeof n&&"string"==typeof i.__typeson__type__&&i.__typeson__type__===n.__typeson__type__)}function isPlainObject(e){return !(!e||"Object"!==toStringTag(e))&&(!r(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return !1;var t=r(e);return !t||(hasConstructorOf(e,Object)||isUserObject(t))}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replace(/''/g,"''''").replace(/^$/,"''").replace(/~/g,"~0").replace(/\./g,"~1")}function unescapeKeyPathComponent(e){return e.replace(/~1/g,".").replace(/~0/g,"~").replace(/^''$/,"").replace(/''''/g,"''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");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;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");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 n=Object.keys,o=Object.hasOwn,i$1=Array.isArray,a=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];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){var r,n;if(""===e.keypath)return -1;var o=null!==(r=e.keypath.match(/\./g))&&void 0!==r?r:0,i=null!==(n=t.keypath.match(/\./g))&&void 0!==n?n:0;return o&&(o=o.length),i&&(i=i.length),o>i?-1:o<i?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var c=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 o=this.encapsulate(e,null,n);return i$1(o)?JSON.stringify(o[0],t,r):o.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,c){var s=this,u=_objectSpread2(_objectSpread2({sync:!0},this.options),c),y=u.sync,p={},l=[],f=[],v=[],h=!("cyclic"in u)||u.cyclic,d=u.encapsulateObserver,b=function finish(e){var t=Object.values(p);if(u.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(u.returnTypeNames)return _toConsumableArray(new Set(t));e&&isPlainObject(e)&&!o(e,"$types")?e.$types=p:e={$:e,$types:{$:p}};}else isObject(e)&&o(e,"$types")&&(e={$:e,$types:!0});return !u.returnTypeNames&&e},_=_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=[],a=_slicedToArray(r.splice(0,1),1),c=_slicedToArray(a[0],7),s=c[0],u=c[2],y=c[3],p=c[4],l=c[5],f=c[6],v=m(s,n,u,y,i,!0,f),h=hasConstructorOf(v,e);return function _invoke(e,t){var r=e();return r&&r.then?r.then(t):t(r)}((function(){if(s&&h)return _await(v.p,(function(e){p[l]=e;var r=_(t,i);return o=!0,r}))}),(function(e){return o?e:(s?p[l]=v:t=h?v.p:v,_(t,i))}))})))),(function(){return t}))}))})),O=function _adaptBuiltinStateObjectProperties(e,t,r){Object.assign(e,t);var n=a.map((function(t){var r=e[t];return delete e[t],r}));r(),a.forEach((function(t,r){e[t]=n[r];}));},m=function _encapsulate(t,r,a,c,y,v,h){var b,_={},m=_typeof(r),g=d?function(n){var o,i=null!==(o=null!=h?h:c.type)&&void 0!==o?o:getJSONType(r);d(Object.assign(null!=n?n:_,{keypath:t,value:r,cyclic:a,stateObj:c,promisesData:y,resolvingTypesonPromise:v,awaitingTypesonPromise:hasConstructorOf(r,e)},{type:i}));}:null;if(["string","boolean","number","undefined"].includes(m))return void 0===r||Number.isNaN(r)||r===Number.NEGATIVE_INFINITY||r===Number.POSITIVE_INFINITY||0===r?(b=c.replaced?r:j(t,r,c,y,!1,v,g))!==r&&(_={replaced:b}):b=r,g&&g(),b;if(null===r)return g&&g(),r;if(a&&!c.iterateIn&&!c.iterateUnsetNumeric&&r&&"object"===_typeof(r)){var S=l.indexOf(r);if(!(S<0))return p[t]="#",g&&g({cyclicKeypath:f[S]}),"#"+f[S];!0===a&&(l.push(r),f.push(t));}var P,T,w=isPlainObject(r),A=i$1(r),C=(w||A)&&(!s.plainObjectReplacers.length||c.replaced)||c.iterateIn?r:j(t,r,c,y,w||A,null,g);if(C!==r?(b=C,_={replaced:C}):""===t&&hasConstructorOf(r,e)?(y.push([t,r,a,c,void 0,void 0,c.type]),b=r):A&&"object"!==c.iterateIn||"array"===c.iterateIn?(P=new Array(r.length),_={clone:P}):(["function","symbol"].includes(_typeof(r))||"toJSON"in r||hasConstructorOf(r,e)||hasConstructorOf(r,Promise)||hasConstructorOf(r,ArrayBuffer))&&!w&&"object"!==c.iterateIn?b=r:(P={},c.addLength&&(P.length=r.length),_={clone:P}),g&&g(),u.iterateNone)return null!==(T=P)&&void 0!==T?T:b;if(!P)return b;if(c.iterateIn){var k=function _loop(n){var i={ownKeys:o(r,n)};O(c,i,(function(){var o=t+(t?".":"")+escapeKeyPathComponent(n),i=_encapsulate(o,r[n],Boolean(a),c,y,v);hasConstructorOf(i,e)?y.push([o,i,Boolean(a),c,P,n,c.type]):void 0!==i&&(P[n]=i);}));};for(var N in r)k(N);g&&g({endIterateIn:!0,end:!0});}else n(r).forEach((function(n){var o=t+(t?".":"")+escapeKeyPathComponent(n);O(c,{ownKeys:!0},(function(){var t=_encapsulate(o,r[n],Boolean(a),c,y,v);hasConstructorOf(t,e)?y.push([o,t,Boolean(a),c,P,n,c.type]):void 0!==t&&(P[n]=t);}));})),g&&g({endIterateOwn:!0,end:!0});if(c.iterateUnsetNumeric){for(var I=r.length,E=function _loop2(n){if(!(n in r)){var o="".concat(t).concat(t?".":"").concat(n);O(c,{ownKeys:!1},(function(){var t=_encapsulate(o,void 0,Boolean(a),c,y,v);hasConstructorOf(t,e)?y.push([o,t,Boolean(a),c,P,n,c.type]):void 0!==t&&(P[n]=t);}));}},K=0;K<I;K++)E(K);g&&g({endIterateUnsetNumeric:!0,end:!0});}return P},j=function replace(e,t,r,n,o,i,a){for(var c=o?s.plainObjectReplacers:s.nonplainObjectReplacers,u=c.length;u--;){var l=c[u];if(l.test(t,r)){var f=l.type;if(s.revivers[f]){var v=p[e];p[e]=v?[f].concat(v):f;}if(Object.assign(r,{type:f,replaced:!0}),(y||!l.replaceAsync)&&!l.replace)return a&&a({typeDetected:!0}),m(e,t,h&&"readonly",r,n,i,f);a&&a({replacing:!0});var d=void 0;if(y||!l.replaceAsync){if(void 0===l.replace)throw new TypeError("Missing replacer");d=l.replace(t,r);}else d=l.replaceAsync(t,r);return m(e,d,h&&"readonly",r,n,i,f)}}return t},g=m("",t,h,null!=r?r:{},v);if(v.length)return y&&u.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(_(g,v)).then(b);if(!y&&u.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return u.stringification&&y?[b(g)]:y?b(g):Promise.resolve(b(g))}},{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 o=this,a=_objectSpread2(_objectSpread2({sync:!0},this.options),r),c=a.sync;function finishRevival(e){if(c)return e;if(a.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!t||"object"!==_typeof(t)||Array.isArray(t))return finishRevival(t);var u=t.$types;if(!0===u)return finishRevival(t.$);if(!u||"object"!==_typeof(u)||Array.isArray(u))return finishRevival(t);var y=[],p={},l=!0;u.$&&isPlainObject(u.$)&&(t=t.$,u=u.$,l=!1);var f=function executeReviver(e,t){var r,n=_slicedToArray(null!==(r=o.revivers[e])&&void 0!==r?r:[],1)[0];if(!n)throw new Error("Unregistered type: "+e);if(c&&!("revive"in n))return t;if(!c&&n.reviveAsync)return n.reviveAsync(t,p);if(n.revive)return n.revive(t,p);throw new Error("Missing reviver")},v=[];function checkUndefined(e){return hasConstructorOf(e,s)?void 0:e}var h,d=function revivePlainObjects(){var r=[];if(!u)throw new Error("Found bad `types`");if(Object.entries(u).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],i=t[1];"#"!==i&&[].concat(i).forEach((function(e){var t;_slicedToArray(null!==(t=o.revivers[e])&&void 0!==t?t:[null,{}],2)[1].plain&&(r.push({keypath:n,type:e}),delete u[n]);}));})),r.length)return r.sort(nestedPathsFirst).reduce((function reducer(r,n){var o=n.keypath,i=n.type;if(isThenable(r))return r.then((function(e){return reducer(e,{keypath:o,type:i})}));var a=getByKeyPath(t,o);if(hasConstructorOf(a=f(i,a),e))return a.then((function(e){var r=setAtKeyPath(t,o,e);r===e&&(t=r);}));var c=setAtKeyPath(t,o,a);c===a&&(t=c);}),void 0)}();return hasConstructorOf(d,e)?h=d.then((function(){return t})):(h=function _revive(t,r,o,a,c){if(!l||"$types"!==t){var p=u[t],h=i$1(r);if(h||isPlainObject(r)){var d=h?new Array(r.length):{};for(n(r).forEach((function(n){var i=_revive(t+(t?".":"")+escapeKeyPathComponent(n),r[n],null!=o?o:d,d,n),a=function set(e){return hasConstructorOf(e,s)?d[n]=void 0:void 0!==e&&(d[n]=e),e};hasConstructorOf(i,e)?v.push(i.then((function(e){return a(e)}))):a(i);})),r=d;y.length;){var b=_slicedToArray(y[0],4),_=b[0],O=b[1],m=b[2],j=b[3],g=getByKeyPath(_,O);if(void 0===g)break;m[j]=g,y.splice(0,1);}}if(!p)return r;if("#"===p){var S=getByKeyPath(o,r.slice(1));return void 0===S&&y.push([o,r.slice(1),a,c]),S}return [].concat(p).reduce((function reducer(t,r){if(hasConstructorOf(t,e))return t.then((function(e){return reducer(e,r)}));if("string"!=typeof r)throw new TypeError("Bad type JSON");return f(r,t)}),r)}}("",t,null),v.length&&(h=e.resolve(h).then((function(t){return e.all([t].concat(v))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(h)?c&&a.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(h,e)?h.p.then(checkUndefined):h:!c&&a.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():c?checkUndefined(h):Promise.resolve(checkUndefined(h))}},{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,o=null!=t?t:{},a=function R(e){i$1(e)?e.forEach((function(e){return R(e)})):n(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(u.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var a=e[t],c=a&&"function"!=typeof a&&!Array.isArray(a)&&a.testPlainObjects?r.plainObjectReplacers:r.nonplainObjectReplacers,s=c.filter((function(e){return e.type===t}));if(s.length&&(c.splice(c.indexOf(s[0]),1),delete r.revivers[t],delete r.types[t]),"function"==typeof a){var y=a;a={test:function test(e){return e&&e.constructor===y},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(y.prototype),e)}};}else if(i$1(a)){var p=_slicedToArray(a,3);a={test:p[0],replace:p[1],revive:p[2]};}if(null!==(n=a)&&void 0!==n&&n.test){var l={type:t,test:a.test.bind(a)};a.replace&&(l.replace=a.replace.bind(a)),a.replaceAsync&&(l.replaceAsync=a.replaceAsync.bind(a));var f="number"==typeof o.fallback?o.fallback:o.fallback?0:Number.POSITIVE_INFINITY;if(a.testPlainObjects?r.plainObjectReplacers.splice(f,0,l):r.nonplainObjectReplacers.splice(f,0,l),a.revive||a.reviveAsync){var v={};a.revive&&(v.revive=a.revive.bind(a)),a.reviveAsync&&(v.reviveAsync=a.reviveAsync.bind(a)),r.revivers[t]=[v,{plain:a.testPlainObjects}];}r.types[t]=a;}}));};return [].concat(e).forEach((function(e){return a(e)})),this}}]),Typeson}(),s=_createClass((function Undefined(){_classCallCheck(this,Undefined);}));s.__typeson__type__="TypesonUndefined";var u=["null","boolean","number","string","array","object"];
|
|
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},_typeof(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,_toPropertyKey(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=_toPropertyKey(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){var n,o,i,a,c=[],s=!0,u=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1;}else for(;!(s=(n=i.call(r)).done)&&(c.push(n.value),c.length!==t);s=!0);}catch(e){u=!0,o=e;}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(u)throw o}}return c}}(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}function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(e,"string");return "symbol"==typeof t?t:String(t)}var e=_createClass((function TypesonPromise(e){_classCallCheck(this,TypesonPromise),this.p=new Promise(e);}));e.__typeson__type__="TypesonPromise","undefined"!=typeof Symbol&&Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function get(){return "TypesonPromise"}}),e.prototype.then=function(t,r){var n=this;return new e((function(e,o){n.p.then((function(r){e(t?t(r):r);})).catch((function(e){return r?r(e):Promise.reject(e)})).then(e,o);}))},e.prototype.catch=function(e){return this.then((function(){}),e)},e.resolve=function(t){return new e((function(e){e(t);}))},e.reject=function(t){return new e((function(e,r){r(t);}))},e.all=function(t){return new e((function(e,r){Promise.all(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.race=function(t){return new e((function(e,r){Promise.race(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))},e.allSettled=function(t){return new e((function(e,r){Promise.allSettled(t.map((function(e){return null!=e&&e.constructor&&"__typeson__type__"in e.constructor&&"TypesonPromise"===e.constructor.__typeson__type__?e.p:e}))).then(e,r);}))};var t=Object.hasOwn,r=Object.getPrototypeOf;function isThenable(e,t){return isObject(e)&&"function"==typeof e.then&&(!t||"function"==typeof e.catch)}function toStringTag(e){return Object.prototype.toString.call(e).slice(8,-1)}function hasConstructorOf(e,n){if(!e||"object"!==_typeof(e))return !1;var o=r(e);if(!o)return null===n;var i=t(o,"constructor")&&o.constructor;return "function"!=typeof i?null===n:n===i||(null!==n&&Function.prototype.toString.call(i)===Function.prototype.toString.call(n)||"function"==typeof n&&"string"==typeof i.__typeson__type__&&i.__typeson__type__===n.__typeson__type__)}function isPlainObject(e){return !(!e||"Object"!==toStringTag(e))&&(!r(e)||hasConstructorOf(e,Object))}function isUserObject(e){if(!e||"Object"!==toStringTag(e))return !1;var t=r(e);return !t||(hasConstructorOf(e,Object)||isUserObject(t))}function isObject(e){return null!==e&&"object"===_typeof(e)}function escapeKeyPathComponent(e){return e.replaceAll("''","''''").replace(/^$/,"''").replaceAll("~","~0").replaceAll(".","~1")}function unescapeKeyPathComponent(e){return e.replaceAll("~1",".").replaceAll("~0","~").replace(/^''$/,"").replaceAll("''''","''")}function getByKeyPath(e,t){if(""===t)return e;if(null===e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");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;if(!e||"object"!==_typeof(e))throw new TypeError("Unexpected non-object type");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 n=Object.keys,o=Object.hasOwn,i$1=Array.isArray,a=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];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){var r,n;if(""===e.keypath)return -1;var o=null!==(r=e.keypath.match(/\./g))&&void 0!==r?r:0,i=null!==(n=t.keypath.match(/\./g))&&void 0!==n?n:0;return o&&(o=o.length),i&&(i=i.length),o>i?-1:o<i?1:e.keypath<t.keypath?-1:e.keypath>t.keypath?1:0}var c=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 o=this.encapsulate(e,null,n);return i$1(o)?JSON.stringify(o[0],t,r):o.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,c){var s=this,u=_objectSpread2(_objectSpread2({sync:!0},this.options),c),l=u.sync,y={},p=[],f=[],v=[],h=!("cyclic"in u)||u.cyclic,d=u.encapsulateObserver,b=function finish(e){var t=Object.values(y);if(u.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(u.returnTypeNames)return _toConsumableArray(new Set(t));e&&isPlainObject(e)&&!o(e,"$types")?e.$types=y:e={$:e,$types:{$:y}};}else isObject(e)&&o(e,"$types")&&(e={$:e,$types:!0});return !u.returnTypeNames&&e},_=_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=[],a=_slicedToArray(r.splice(0,1),1),c=_slicedToArray(a[0],7),s=c[0],u=c[2],l=c[3],y=c[4],p=c[5],f=c[6],v=m(s,n,u,l,i,!0,f),h=hasConstructorOf(v,e);return function _invoke(e,t){var r=e();return r&&r.then?r.then(t):t(r)}((function(){if(s&&h)return _await(v.p,(function(e){y[p]=e;var r=_(t,i);return o=!0,r}))}),(function(e){return o?e:(s?y[p]=v:t=h?v.p:v,_(t,i))}))})))),(function(){return t}))}))})),O=function _adaptBuiltinStateObjectProperties(e,t,r){Object.assign(e,t);var n=a.map((function(t){var r=e[t];return delete e[t],r}));r(),a.forEach((function(t,r){e[t]=n[r];}));},m=function _encapsulate(t,r,a,c,l,v,h){var b,_={},m=_typeof(r),g=d?function(n){var o,i=null!==(o=null!=h?h:c.type)&&void 0!==o?o:getJSONType(r);d(Object.assign(null!=n?n:_,{keypath:t,value:r,cyclic:a,stateObj:c,promisesData:l,resolvingTypesonPromise:v,awaitingTypesonPromise:hasConstructorOf(r,e)},{type:i}));}:null;if(["string","boolean","number","undefined"].includes(m))return void 0===r||Number.isNaN(r)||r===Number.NEGATIVE_INFINITY||r===Number.POSITIVE_INFINITY||0===r?(b=c.replaced?r:j(t,r,c,l,!1,v,g))!==r&&(_={replaced:b}):b=r,g&&g(),b;if(null===r)return g&&g(),r;if(a&&!c.iterateIn&&!c.iterateUnsetNumeric&&r&&"object"===_typeof(r)){var S=p.indexOf(r);if(!(S<0))return y[t]="#",g&&g({cyclicKeypath:f[S]}),"#"+f[S];!0===a&&(p.push(r),f.push(t));}var P,T,w=isPlainObject(r),A=i$1(r),C=(w||A)&&(!s.plainObjectReplacers.length||c.replaced)||c.iterateIn?r:j(t,r,c,l,w||A,null,g);if(C!==r?(b=C,_={replaced:C}):""===t&&hasConstructorOf(r,e)?(l.push([t,r,a,c,void 0,void 0,c.type]),b=r):A&&"object"!==c.iterateIn||"array"===c.iterateIn?(P=new Array(r.length),_={clone:P}):(["function","symbol"].includes(_typeof(r))||"toJSON"in r||hasConstructorOf(r,e)||hasConstructorOf(r,Promise)||hasConstructorOf(r,ArrayBuffer))&&!w&&"object"!==c.iterateIn?b=r:(P={},c.addLength&&(P.length=r.length),_={clone:P}),g&&g(),u.iterateNone)return null!==(T=P)&&void 0!==T?T:b;if(!P)return b;if(c.iterateIn){var k=function _loop(n){var i={ownKeys:o(r,n)};O(c,i,(function(){var o=t+(t?".":"")+escapeKeyPathComponent(n),i=_encapsulate(o,r[n],Boolean(a),c,l,v);hasConstructorOf(i,e)?l.push([o,i,Boolean(a),c,P,n,c.type]):void 0!==i&&(P[n]=i);}));};for(var N in r)k(N);g&&g({endIterateIn:!0,end:!0});}else n(r).forEach((function(n){var o=t+(t?".":"")+escapeKeyPathComponent(n);O(c,{ownKeys:!0},(function(){var t=_encapsulate(o,r[n],Boolean(a),c,l,v);hasConstructorOf(t,e)?l.push([o,t,Boolean(a),c,P,n,c.type]):void 0!==t&&(P[n]=t);}));})),g&&g({endIterateOwn:!0,end:!0});if(c.iterateUnsetNumeric){for(var I=r.length,E=function _loop2(n){if(!(n in r)){var o="".concat(t).concat(t?".":"").concat(n);O(c,{ownKeys:!1},(function(){var t=_encapsulate(o,void 0,Boolean(a),c,l,v);hasConstructorOf(t,e)?l.push([o,t,Boolean(a),c,P,n,c.type]):void 0!==t&&(P[n]=t);}));}},K=0;K<I;K++)E(K);g&&g({endIterateUnsetNumeric:!0,end:!0});}return P},j=function replace(e,t,r,n,o,i,a){for(var c=o?s.plainObjectReplacers:s.nonplainObjectReplacers,u=c.length;u--;){var p=c[u];if(p.test(t,r)){var f=p.type;if(s.revivers[f]){var v=y[e];y[e]=v?[f].concat(v):f;}if(Object.assign(r,{type:f,replaced:!0}),(l||!p.replaceAsync)&&!p.replace)return a&&a({typeDetected:!0}),m(e,t,h&&"readonly",r,n,i,f);a&&a({replacing:!0});var d=void 0;if(l||!p.replaceAsync){if(void 0===p.replace)throw new TypeError("Missing replacer");d=p.replace(t,r);}else d=p.replaceAsync(t,r);return m(e,d,h&&"readonly",r,n,i,f)}}return t},g=m("",t,h,null!=r?r:{},v);if(v.length)return l&&u.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():Promise.resolve(_(g,v)).then(b);if(!l&&u.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return u.stringification&&l?[b(g)]:l?b(g):Promise.resolve(b(g))}},{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 o=this,a=_objectSpread2(_objectSpread2({sync:!0},this.options),r),c=a.sync;function finishRevival(e){if(c)return e;if(a.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!t||"object"!==_typeof(t)||Array.isArray(t))return finishRevival(t);var u=t.$types;if(!0===u)return finishRevival(t.$);if(!u||"object"!==_typeof(u)||Array.isArray(u))return finishRevival(t);var l=[],y={},p=!0;u.$&&isPlainObject(u.$)&&(t=t.$,u=u.$,p=!1);var f=function executeReviver(e,t){var r,n=_slicedToArray(null!==(r=o.revivers[e])&&void 0!==r?r:[],1)[0];if(!n)throw new Error("Unregistered type: "+e);if(c&&!("revive"in n))return t;if(!c&&n.reviveAsync)return n.reviveAsync(t,y);if(n.revive)return n.revive(t,y);throw new Error("Missing reviver")},v=[];function checkUndefined(e){return hasConstructorOf(e,s)?void 0:e}var h,d=function revivePlainObjects(){var r=[];if(!u)throw new Error("Found bad `types`");if(Object.entries(u).forEach((function(e){var t=_slicedToArray(e,2),n=t[0],i=t[1];"#"!==i&&[].concat(i).forEach((function(e){var t;_slicedToArray(null!==(t=o.revivers[e])&&void 0!==t?t:[null,{}],2)[1].plain&&(r.push({keypath:n,type:e}),delete u[n]);}));})),r.length)return r.sort(nestedPathsFirst).reduce((function reducer(r,n){var o=n.keypath,i=n.type;if(isThenable(r))return r.then((function(e){return reducer(e,{keypath:o,type:i})}));var a=getByKeyPath(t,o);if(hasConstructorOf(a=f(i,a),e))return a.then((function(e){var r=setAtKeyPath(t,o,e);r===e&&(t=r);}));var c=setAtKeyPath(t,o,a);c===a&&(t=c);}),void 0)}();return hasConstructorOf(d,e)?h=d.then((function(){return t})):(h=function _revive(t,r,o,a,c){if(!p||"$types"!==t){var y=u[t],h=i$1(r);if(h||isPlainObject(r)){var d=h?new Array(r.length):{};for(n(r).forEach((function(n){var i=_revive(t+(t?".":"")+escapeKeyPathComponent(n),r[n],null!=o?o:d,d,n),a=function set(e){return hasConstructorOf(e,s)?d[n]=void 0:void 0!==e&&(d[n]=e),e};hasConstructorOf(i,e)?v.push(i.then((function(e){return a(e)}))):a(i);})),r=d;l.length;){var b=_slicedToArray(l[0],4),_=b[0],O=b[1],m=b[2],j=b[3],g=getByKeyPath(_,O);if(void 0===g)break;m[j]=g,l.splice(0,1);}}if(!y)return r;if("#"===y){var S=getByKeyPath(o,r.slice(1));return void 0===S&&l.push([o,r.slice(1),a,c]),S}return [].concat(y).reduce((function reducer(t,r){if(hasConstructorOf(t,e))return t.then((function(e){return reducer(e,r)}));if("string"!=typeof r)throw new TypeError("Bad type JSON");return f(r,t)}),r)}}("",t,null),v.length&&(h=e.resolve(h).then((function(t){return e.all([t].concat(v))})).then((function(e){return _slicedToArray(e,1)[0]})))),isThenable(h)?c&&a.throwOnBadSyncType?function(){throw new TypeError("Sync method requested but async result obtained")}():hasConstructorOf(h,e)?h.p.then(checkUndefined):h:!c&&a.throwOnBadSyncType?function(){throw new TypeError("Async method requested but sync result obtained")}():c?checkUndefined(h):Promise.resolve(checkUndefined(h))}},{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,o=null!=t?t:{},a=function R(e){i$1(e)?e.forEach((function(e){return R(e)})):n(e).forEach((function(t){var n;if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(u.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");var a=e[t],c=a&&"function"!=typeof a&&!Array.isArray(a)&&a.testPlainObjects?r.plainObjectReplacers:r.nonplainObjectReplacers,s=c.filter((function(e){return e.type===t}));if(s.length&&(c.splice(c.indexOf(s[0]),1),delete r.revivers[t],delete r.types[t]),"function"==typeof a){var l=a;a={test:function test(e){return e&&e.constructor===l},replace:function replace(e){return _objectSpread2({},e)},revive:function revive(e){return Object.assign(Object.create(l.prototype),e)}};}else if(i$1(a)){var y=_slicedToArray(a,3);a={test:y[0],replace:y[1],revive:y[2]};}if(null!==(n=a)&&void 0!==n&&n.test){var p={type:t,test:a.test.bind(a)};a.replace&&(p.replace=a.replace.bind(a)),a.replaceAsync&&(p.replaceAsync=a.replaceAsync.bind(a));var f="number"==typeof o.fallback?o.fallback:o.fallback?0:Number.POSITIVE_INFINITY;if(a.testPlainObjects?r.plainObjectReplacers.splice(f,0,p):r.nonplainObjectReplacers.splice(f,0,p),a.revive||a.reviveAsync){var v={};a.revive&&(v.revive=a.revive.bind(a)),a.reviveAsync&&(v.reviveAsync=a.reviveAsync.bind(a)),r.revivers[t]=[v,{plain:a.testPlainObjects}];}r.types[t]=a;}}));};return [].concat(e).forEach((function(e){return a(e)})),this}}]),Typeson}(),s=_createClass((function Undefined(){_classCallCheck(this,Undefined);}));s.__typeson__type__="TypesonUndefined";var u=["null","boolean","number","string","array","object"];
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* base64-arraybuffer
|
|
@@ -136,8 +136,6 @@ const arraybuffer = {
|
|
|
136
136
|
|
|
137
137
|
// See also typed-arrays!
|
|
138
138
|
|
|
139
|
-
/* globals BigInt */
|
|
140
|
-
|
|
141
139
|
/**
|
|
142
140
|
* @type {import('typeson').TypeSpecSet}
|
|
143
141
|
*/
|
|
@@ -155,8 +153,6 @@ const bigintObject = {
|
|
|
155
153
|
}
|
|
156
154
|
};
|
|
157
155
|
|
|
158
|
-
/* globals BigInt */
|
|
159
|
-
|
|
160
156
|
/**
|
|
161
157
|
* @type {import('typeson').TypeSpecSet}
|
|
162
158
|
*/
|
|
@@ -233,7 +229,7 @@ function string2arraybuffer (str) {
|
|
|
233
229
|
|
|
234
230
|
const array = new Uint8Array(str.length);
|
|
235
231
|
for (let i = 0; i < str.length; i++) {
|
|
236
|
-
// eslint-disable-next-line max-len -- Long
|
|
232
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
237
233
|
// eslint-disable-next-line unicorn/prefer-code-point -- Iterating char. codes
|
|
238
234
|
array[i] = str.charCodeAt(i); // & 0xff;
|
|
239
235
|
}
|
|
@@ -296,8 +292,6 @@ const blob = {
|
|
|
296
292
|
}
|
|
297
293
|
};
|
|
298
294
|
|
|
299
|
-
/* globals performance */
|
|
300
|
-
|
|
301
295
|
// The `performance` global is optional
|
|
302
296
|
|
|
303
297
|
/**
|
|
@@ -317,11 +311,13 @@ function generateUUID () { // Adapted from original: public domain/MIT: http://
|
|
|
317
311
|
? performance.now()
|
|
318
312
|
: 0);
|
|
319
313
|
|
|
320
|
-
|
|
314
|
+
// eslint-disable-next-line @stylistic/max-len -- Long
|
|
315
|
+
// eslint-disable-next-line no-use-extend-native/no-use-extend-native -- Need to update plugin
|
|
316
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replaceAll(/[xy]/gu, function (c) {
|
|
321
317
|
/* eslint-disable no-bitwise */
|
|
322
|
-
const r = Math.trunc((d + Math.random() * 16) % 16);
|
|
318
|
+
const r = Math.trunc((d + (Math.random() * 16)) % 16);
|
|
323
319
|
d = Math.floor(d / 16);
|
|
324
|
-
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
|
320
|
+
return (c === 'x' ? r : ((r & 0x3) | 0x8)).toString(16);
|
|
325
321
|
/* eslint-enable no-bitwise */
|
|
326
322
|
});
|
|
327
323
|
}
|
|
@@ -484,6 +480,122 @@ const date = {
|
|
|
484
480
|
}
|
|
485
481
|
};
|
|
486
482
|
|
|
483
|
+
/**
|
|
484
|
+
* @type {import('typeson').TypeSpecSet}
|
|
485
|
+
*/
|
|
486
|
+
const domexception = {
|
|
487
|
+
domexception: {
|
|
488
|
+
test (x) { return toStringTag(x) === 'DOMException'; },
|
|
489
|
+
replace (de) {
|
|
490
|
+
// `code` is based on `name` and readonly, so no
|
|
491
|
+
// need to keep here
|
|
492
|
+
return {
|
|
493
|
+
name: de.name,
|
|
494
|
+
message: de.message
|
|
495
|
+
};
|
|
496
|
+
},
|
|
497
|
+
revive ({message, name}) {
|
|
498
|
+
return new DOMException(message, name);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
/* globals DOMMatrix */
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* @type {import('typeson').TypeSpecSet}
|
|
507
|
+
*/
|
|
508
|
+
const dommatrix = {
|
|
509
|
+
dommatrix: {
|
|
510
|
+
test (x) { return toStringTag(x) === 'DOMMatrix'; },
|
|
511
|
+
replace (dm) {
|
|
512
|
+
if (dm.is2D) {
|
|
513
|
+
return {
|
|
514
|
+
a: dm.a,
|
|
515
|
+
b: dm.b,
|
|
516
|
+
c: dm.c,
|
|
517
|
+
d: dm.d,
|
|
518
|
+
e: dm.e,
|
|
519
|
+
f: dm.f
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
return {
|
|
523
|
+
m11: dm.m11,
|
|
524
|
+
m12: dm.m12,
|
|
525
|
+
m13: dm.m13,
|
|
526
|
+
m14: dm.m14,
|
|
527
|
+
m21: dm.m21,
|
|
528
|
+
m22: dm.m22,
|
|
529
|
+
m23: dm.m23,
|
|
530
|
+
m24: dm.m24,
|
|
531
|
+
m31: dm.m31,
|
|
532
|
+
m32: dm.m32,
|
|
533
|
+
m33: dm.m33,
|
|
534
|
+
m34: dm.m34,
|
|
535
|
+
m41: dm.m41,
|
|
536
|
+
m42: dm.m42,
|
|
537
|
+
m43: dm.m43,
|
|
538
|
+
m44: dm.m44
|
|
539
|
+
};
|
|
540
|
+
},
|
|
541
|
+
revive (o) {
|
|
542
|
+
if (Object.hasOwn(o, 'a')) {
|
|
543
|
+
return new DOMMatrix([o.a, o.b, o.c, o.d, o.e, o.f]);
|
|
544
|
+
}
|
|
545
|
+
return new DOMMatrix([
|
|
546
|
+
o.m11, o.m12, o.m13, o.m14,
|
|
547
|
+
o.m21, o.m22, o.m23, o.m24,
|
|
548
|
+
o.m31, o.m32, o.m33, o.m34,
|
|
549
|
+
o.m41, o.m42, o.m43, o.m44
|
|
550
|
+
]);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
/* globals DOMPoint */
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @type {import('typeson').TypeSpecSet}
|
|
559
|
+
*/
|
|
560
|
+
const dompoint = {
|
|
561
|
+
dompoint: {
|
|
562
|
+
test (x) { return toStringTag(x) === 'DOMPoint'; },
|
|
563
|
+
replace (dp) {
|
|
564
|
+
return {
|
|
565
|
+
x: dp.x,
|
|
566
|
+
y: dp.y,
|
|
567
|
+
z: dp.z,
|
|
568
|
+
w: dp.w
|
|
569
|
+
};
|
|
570
|
+
},
|
|
571
|
+
revive ({x, y, z, w}) {
|
|
572
|
+
return new DOMPoint(x, y, z, w);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
|
|
577
|
+
/* globals DOMRect */
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* @type {import('typeson').TypeSpecSet}
|
|
581
|
+
*/
|
|
582
|
+
const domrect = {
|
|
583
|
+
domrect: {
|
|
584
|
+
test (x) { return toStringTag(x) === 'DOMRect'; },
|
|
585
|
+
replace (dr) {
|
|
586
|
+
return {
|
|
587
|
+
x: dr.x,
|
|
588
|
+
y: dr.y,
|
|
589
|
+
width: dr.width,
|
|
590
|
+
height: dr.height
|
|
591
|
+
};
|
|
592
|
+
},
|
|
593
|
+
revive ({x, y, width, height}) {
|
|
594
|
+
return new DOMRect(x, y, width, height);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
};
|
|
598
|
+
|
|
487
599
|
/**
|
|
488
600
|
* @type {import('typeson').TypeSpecSet}
|
|
489
601
|
*/
|
|
@@ -521,6 +633,7 @@ const error = {
|
|
|
521
633
|
};
|
|
522
634
|
|
|
523
635
|
/* globals InternalError */
|
|
636
|
+
/* eslint-env browser, node */
|
|
524
637
|
|
|
525
638
|
/**
|
|
526
639
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -538,9 +651,12 @@ if (typeof AggregateError !== 'undefined') {
|
|
|
538
651
|
create$2(AggregateError);
|
|
539
652
|
}
|
|
540
653
|
|
|
541
|
-
/* c8 ignore next
|
|
542
|
-
// @ts-
|
|
543
|
-
typeof InternalError === 'function'
|
|
654
|
+
/* c8 ignore next 5 */
|
|
655
|
+
// @ts-expect-error Non-standard
|
|
656
|
+
if (typeof InternalError === 'function') {
|
|
657
|
+
// @ts-expect-error Non-standard
|
|
658
|
+
create$2(InternalError);
|
|
659
|
+
}
|
|
544
660
|
|
|
545
661
|
/* eslint-disable jsdoc/valid-types -- https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131 */
|
|
546
662
|
/**
|
|
@@ -722,7 +838,10 @@ const filelist = {
|
|
|
722
838
|
}
|
|
723
839
|
};
|
|
724
840
|
|
|
725
|
-
/* globals createImageBitmap */
|
|
841
|
+
/* globals document, createImageBitmap */
|
|
842
|
+
// `ImageBitmap` is browser / DOM specific. It also can only work
|
|
843
|
+
// same-domain (or CORS)
|
|
844
|
+
|
|
726
845
|
|
|
727
846
|
/**
|
|
728
847
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -799,6 +918,9 @@ const imagebitmap = {
|
|
|
799
918
|
};
|
|
800
919
|
|
|
801
920
|
/* globals ImageData */
|
|
921
|
+
// `ImageData` is browser / DOM specific (though `node-canvas` has it
|
|
922
|
+
// available on `Canvas`).
|
|
923
|
+
|
|
802
924
|
|
|
803
925
|
/**
|
|
804
926
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -828,8 +950,8 @@ const imagedata = {
|
|
|
828
950
|
const infinity = {
|
|
829
951
|
infinity: {
|
|
830
952
|
test (x) { return x === Number.POSITIVE_INFINITY; },
|
|
831
|
-
replace (n) { return 'Infinity'; },
|
|
832
|
-
revive (s) { return Number.POSITIVE_INFINITY; }
|
|
953
|
+
replace (/* n */) { return 'Infinity'; },
|
|
954
|
+
revive (/* s */) { return Number.POSITIVE_INFINITY; }
|
|
833
955
|
}
|
|
834
956
|
};
|
|
835
957
|
|
|
@@ -885,8 +1007,8 @@ const map = {
|
|
|
885
1007
|
const nan = {
|
|
886
1008
|
nan: {
|
|
887
1009
|
test (x) { return Number.isNaN(x); },
|
|
888
|
-
replace (n) { return 'NaN'; },
|
|
889
|
-
revive (s) { return Number.NaN; }
|
|
1010
|
+
replace (/* n */) { return 'NaN'; },
|
|
1011
|
+
revive (/* s */) { return Number.NaN; }
|
|
890
1012
|
}
|
|
891
1013
|
};
|
|
892
1014
|
|
|
@@ -896,8 +1018,8 @@ const nan = {
|
|
|
896
1018
|
const negativeInfinity = {
|
|
897
1019
|
negativeInfinity: {
|
|
898
1020
|
test (x) { return x === Number.NEGATIVE_INFINITY; },
|
|
899
|
-
replace (n) { return '-Infinity'; },
|
|
900
|
-
revive (s) { return Number.NEGATIVE_INFINITY; }
|
|
1021
|
+
replace (/* n */) { return '-Infinity'; },
|
|
1022
|
+
revive (/* s */) { return Number.NEGATIVE_INFINITY; }
|
|
901
1023
|
}
|
|
902
1024
|
};
|
|
903
1025
|
|
|
@@ -909,11 +1031,11 @@ const negativeZero = {
|
|
|
909
1031
|
test (x) {
|
|
910
1032
|
return Object.is(x, -0);
|
|
911
1033
|
},
|
|
912
|
-
replace (n) {
|
|
1034
|
+
replace (/* n */) {
|
|
913
1035
|
// Just adding 0 here for minimized space; will still revive as -0
|
|
914
1036
|
return 0;
|
|
915
1037
|
},
|
|
916
|
-
revive (s) {
|
|
1038
|
+
revive (/* s */) {
|
|
917
1039
|
return -0;
|
|
918
1040
|
}
|
|
919
1041
|
}
|
|
@@ -945,13 +1067,15 @@ const nonbuiltinIgnore = {
|
|
|
945
1067
|
'Atomics', 'Module'
|
|
946
1068
|
].includes(toStringTag(x));
|
|
947
1069
|
},
|
|
948
|
-
replace (rexp) {
|
|
1070
|
+
replace (/* rexp */) {
|
|
949
1071
|
// Not in use
|
|
950
1072
|
}
|
|
951
1073
|
}
|
|
952
1074
|
};
|
|
953
1075
|
|
|
954
1076
|
// This module is for objectified primitives (such as `new Number(3)` or
|
|
1077
|
+
// `new String("foo")`)
|
|
1078
|
+
/* eslint-disable no-new-wrappers, unicorn/new-for-builtins */
|
|
955
1079
|
|
|
956
1080
|
/**
|
|
957
1081
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -1008,6 +1132,10 @@ const regexp = {
|
|
|
1008
1132
|
};
|
|
1009
1133
|
|
|
1010
1134
|
// Here we allow the exact same non-plain object, function, and symbol
|
|
1135
|
+
// instances to be resurrected (assuming the same session/environment);
|
|
1136
|
+
// plain objects are ignored by Typeson so not presently available and
|
|
1137
|
+
// we consciously exclude arrays
|
|
1138
|
+
|
|
1011
1139
|
|
|
1012
1140
|
/**
|
|
1013
1141
|
* @type {{[key: string]: any}}
|
|
@@ -1064,7 +1192,8 @@ const typedArraysSocketIO = {};
|
|
|
1064
1192
|
* Uint8ClampedArrayConstructor|Int16ArrayConstructor|
|
|
1065
1193
|
* Uint16ArrayConstructor|Int32ArrayConstructor|
|
|
1066
1194
|
* Uint32ArrayConstructor|Float32ArrayConstructor|
|
|
1067
|
-
* Float64ArrayConstructor
|
|
1195
|
+
* Float64ArrayConstructor|
|
|
1196
|
+
* BigInt64ArrayConstructor|BigUint64ArrayConstructor
|
|
1068
1197
|
* } TypedArray
|
|
1069
1198
|
* @returns {void}
|
|
1070
1199
|
*/
|
|
@@ -1109,7 +1238,11 @@ if (typeof Int8Array === 'function') {
|
|
|
1109
1238
|
Int32Array,
|
|
1110
1239
|
Uint32Array,
|
|
1111
1240
|
Float32Array,
|
|
1112
|
-
Float64Array
|
|
1241
|
+
Float64Array,
|
|
1242
|
+
...(typeof BigInt64Array === 'function'
|
|
1243
|
+
? [BigInt64Array, BigUint64Array]
|
|
1244
|
+
/* c8 ignore next */
|
|
1245
|
+
: [])
|
|
1113
1246
|
].forEach((TypedArray) => create$1(TypedArray));
|
|
1114
1247
|
}
|
|
1115
1248
|
|
|
@@ -1126,7 +1259,8 @@ const typedArrays = {};
|
|
|
1126
1259
|
* Int16ArrayConstructor|Uint16ArrayConstructor|
|
|
1127
1260
|
* Int32ArrayConstructor|Uint32ArrayConstructor|
|
|
1128
1261
|
* Float32ArrayConstructor|
|
|
1129
|
-
* Float64ArrayConstructor
|
|
1262
|
+
* Float64ArrayConstructor|
|
|
1263
|
+
* BigInt64ArrayConstructor|BigUint64ArrayConstructor} TypedArrayConstructor
|
|
1130
1264
|
*/
|
|
1131
1265
|
|
|
1132
1266
|
/**
|
|
@@ -1202,11 +1336,16 @@ if (typeof Int8Array === 'function') {
|
|
|
1202
1336
|
Int32Array,
|
|
1203
1337
|
Uint32Array,
|
|
1204
1338
|
Float32Array,
|
|
1205
|
-
Float64Array
|
|
1339
|
+
Float64Array,
|
|
1340
|
+
...(typeof BigInt64Array === 'function'
|
|
1341
|
+
? [BigInt64Array, BigUint64Array]
|
|
1342
|
+
/* c8 ignore next */
|
|
1343
|
+
: [])
|
|
1206
1344
|
].forEach((TypedArray) => create(TypedArray));
|
|
1207
1345
|
}
|
|
1208
1346
|
|
|
1209
1347
|
// This does not preserve `undefined` in sparse arrays; see the `undef`
|
|
1348
|
+
// or `sparse-undefined` preset
|
|
1210
1349
|
|
|
1211
1350
|
/**
|
|
1212
1351
|
* @type {import('typeson').TypeSpecSet}
|
|
@@ -1217,8 +1356,8 @@ const undef$1 = {
|
|
|
1217
1356
|
return typeof x === 'undefined' &&
|
|
1218
1357
|
(stateObj.ownKeys || !('ownKeys' in stateObj));
|
|
1219
1358
|
},
|
|
1220
|
-
replace (n) { return 0; },
|
|
1221
|
-
revive (s
|
|
1359
|
+
replace (/* n */) { return 0; },
|
|
1360
|
+
revive (/* s */) {
|
|
1222
1361
|
// Will add `undefined` (returning `undefined` would instead
|
|
1223
1362
|
// avoid explicitly setting)
|
|
1224
1363
|
return new s();
|
|
@@ -1231,7 +1370,7 @@ const undef$1 = {
|
|
|
1231
1370
|
*/
|
|
1232
1371
|
const userObject = {
|
|
1233
1372
|
userObject: {
|
|
1234
|
-
test (x, stateObj) { return isUserObject(x); },
|
|
1373
|
+
test (x /* , stateObj */) { return isUserObject(x); },
|
|
1235
1374
|
replace (n) { return {...n}; },
|
|
1236
1375
|
revive (s) { return s; }
|
|
1237
1376
|
}
|
|
@@ -1297,8 +1436,8 @@ const arrayNonindexKeys = [
|
|
|
1297
1436
|
test (x, stateObj) {
|
|
1298
1437
|
return typeof x === 'undefined' && stateObj.ownKeys === false;
|
|
1299
1438
|
},
|
|
1300
|
-
replace (n) { return 0; },
|
|
1301
|
-
revive (s) { return undefined; } // Will avoid adding anything
|
|
1439
|
+
replace (/* n */) { return 0; },
|
|
1440
|
+
revive (/* s */) { return undefined; } // Will avoid adding anything
|
|
1302
1441
|
}
|
|
1303
1442
|
}
|
|
1304
1443
|
];
|
|
@@ -1329,6 +1468,7 @@ const specialNumbers = [
|
|
|
1329
1468
|
Symbols are similarly not included.
|
|
1330
1469
|
*/
|
|
1331
1470
|
|
|
1471
|
+
|
|
1332
1472
|
/**
|
|
1333
1473
|
* @type {import('typeson').Preset}
|
|
1334
1474
|
*/
|
|
@@ -1372,6 +1512,7 @@ This preset will only include the Error types and you can register your
|
|
|
1372
1512
|
custom types after having registered these.
|
|
1373
1513
|
*/
|
|
1374
1514
|
|
|
1515
|
+
|
|
1375
1516
|
/**
|
|
1376
1517
|
* @type {import('typeson').Preset}
|
|
1377
1518
|
*/
|
|
@@ -1410,14 +1551,15 @@ const sparseUndefined = [
|
|
|
1410
1551
|
test (x, stateObj) {
|
|
1411
1552
|
return typeof x === 'undefined' && stateObj.ownKeys === false;
|
|
1412
1553
|
},
|
|
1413
|
-
replace (n) { return 0; },
|
|
1414
|
-
revive (s) { return undefined; } // Will avoid adding anything
|
|
1554
|
+
replace (/* n */) { return 0; },
|
|
1555
|
+
revive (/* s */) { return undefined; } // Will avoid adding anything
|
|
1415
1556
|
}
|
|
1416
1557
|
}
|
|
1417
1558
|
];
|
|
1418
1559
|
|
|
1419
1560
|
/* This preset includes types for the Structured Cloning Algorithm. */
|
|
1420
1561
|
|
|
1562
|
+
|
|
1421
1563
|
/**
|
|
1422
1564
|
* @type {import('typeson').Preset}
|
|
1423
1565
|
*/
|
|
@@ -1452,15 +1594,19 @@ const expObj = [
|
|
|
1452
1594
|
/* c8 ignore next */
|
|
1453
1595
|
typeof DataView === 'function' ? dataview : [],
|
|
1454
1596
|
/* c8 ignore next */
|
|
1455
|
-
typeof Intl !== 'undefined' ? intlTypes : [],
|
|
1456
|
-
/* c8 ignore next */
|
|
1457
1597
|
typeof crypto !== 'undefined' ? cryptokey : [],
|
|
1458
1598
|
/* c8 ignore next */
|
|
1459
|
-
typeof BigInt !== 'undefined' ? [bigint, bigintObject] : []
|
|
1599
|
+
typeof BigInt !== 'undefined' ? [bigint, bigintObject] : [],
|
|
1600
|
+
/* c8 ignore next */
|
|
1601
|
+
typeof DOMException !== 'undefined' ? domexception : [],
|
|
1602
|
+
/* c8 ignore next */
|
|
1603
|
+
typeof DOMRect !== 'undefined' ? domrect : [],
|
|
1604
|
+
/* c8 ignore next */
|
|
1605
|
+
typeof DOMPoint !== 'undefined' ? dompoint : [],
|
|
1606
|
+
/* c8 ignore next */
|
|
1607
|
+
typeof DOMMatrix !== 'undefined' ? dommatrix : []
|
|
1460
1608
|
);
|
|
1461
1609
|
|
|
1462
|
-
/* globals DOMException */
|
|
1463
|
-
|
|
1464
1610
|
/**
|
|
1465
1611
|
* @type {import('typeson').Preset}
|
|
1466
1612
|
*/
|
|
@@ -1501,9 +1647,6 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1501
1647
|
'Arguments',
|
|
1502
1648
|
// A non-array exotic object
|
|
1503
1649
|
'Module',
|
|
1504
|
-
// `Error` and other errors have the [[ErrorData]] internal
|
|
1505
|
-
// slot and give "Error"
|
|
1506
|
-
'Error',
|
|
1507
1650
|
// Promise instances have an extra slot ([[PromiseState]])
|
|
1508
1651
|
// but not throwing in Chrome `postMessage`
|
|
1509
1652
|
'Promise',
|
|
@@ -1530,6 +1673,7 @@ const structuredCloningThrowing = expObj.concat({
|
|
|
1530
1673
|
typeof val.nodeType === 'number' &&
|
|
1531
1674
|
typeof val.insertBefore === 'function')
|
|
1532
1675
|
) {
|
|
1676
|
+
alert(stringTag);
|
|
1533
1677
|
throw new DOMException(
|
|
1534
1678
|
'The object cannot be cloned.', 'DataCloneError'
|
|
1535
1679
|
);
|
|
@@ -1556,5 +1700,5 @@ const universal = [
|
|
|
1556
1700
|
// built-in into ecmasript standard.
|
|
1557
1701
|
];
|
|
1558
1702
|
|
|
1559
|
-
export { u as JSON_TYPES, c as Typeson, e as TypesonPromise, s 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, negativeZero, 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 };
|
|
1703
|
+
export { u as JSON_TYPES, c as Typeson, e as TypesonPromise, s as Undefined, arrayNonindexKeys, arraybuffer, bigint, bigintObject, blob, expObj$1 as builtin, cloneable, cryptokey, dataview, date, domexception, dommatrix, dompoint, domrect, error, errors, escapeKeyPathComponent, file, filelist, getByKeyPath, getJSONType, hasConstructorOf, imagebitmap, imagedata, infinity, intlTypes, isObject, isPlainObject, isThenable, isUserObject, map, nan, negativeInfinity, negativeZero, 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 };
|
|
1560
1704
|
//# sourceMappingURL=index.js.map
|