typeson-registry 14.2.1 → 14.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.cjs +15 -1
- package/dist/index.umd.cjs.map +1 -1
- package/dist/index.umd.min.cjs +1 -1
- package/dist/index.umd.min.cjs.map +1 -1
- package/dist/presets/structured-cloning-throwing.d.ts.map +1 -1
- package/dist/presets/structured-cloning-throwing.umd.cjs +1 -1
- package/dist/presets/structured-cloning-throwing.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.min.js
CHANGED
|
@@ -3,5 +3,5 @@ class TypesonPromise{constructor(e){this.p=new Promise(e)}}TypesonPromise.__type
|
|
|
3
3
|
* @file Typeson - JSON with types.
|
|
4
4
|
* @license The MIT License (MIT)
|
|
5
5
|
* @copyright (c) 2016-2018 David Fahlander, Brett Zamir
|
|
6
|
-
*/const{keys:r,hasOwn:n}=Object,{isArray:a}=Array,o=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function setOwnEnumerable(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0})}function nestedPathsFirst(e,t){if(""===e.keypath)return-1;let r=e.keypath.match(/\./gu)??0,n=t.keypath.match(/\./gu)??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?1:0}class Typeson{constructor(e){this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}stringify(e,t,r,n){n={...this.options,...n,stringification:!0};const o=this.encapsulate(e,null,n);return a(o)?JSON.stringify(o[0],t,r):o.then(e=>JSON.stringify(e,t,r))}stringifySync(e,t,r,n){return this.stringify(e,t,r,{throwOnBadSyncType:!0,...n,sync:!0})}stringifyAsync(e,t,r,n){return this.stringify(e,t,r,{throwOnBadSyncType:!0,...n,sync:!1})}parse(e,t,r){return r={...this.options,...r,parse:!0},this.revive(JSON.parse(e,t),r)}parseSync(e,t,r){return this.parse(e,t,{throwOnBadSyncType:!0,...r,sync:!0})}parseAsync(e,t,r){return this.parse(e,t,{throwOnBadSyncType:!0,...r,sync:!1})}specialTypeNames(e,t,r={}){return this.encapsulate(e,t,{...r,returnTypeNames:!0})}rootTypeName(e,t,r={}){return this.encapsulate(e,t,{...r,iterateNone:!0})}encapsulate(e,t,s){const i={sync:!0,...this.options,...s},{sync:c}=i,y={},u=[],l=[],p=[],f=!("cyclic"in i)||i.cyclic,{encapsulateObserver:d,encapsulateError:m}=i,finish=e=>{const t=Object.values(y);if(i.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(i.returnTypeNames)return[...new Set(t)];e&&isPlainObject(e)&&!n(e,"$types")?e.$types=y:e={$:e,$types:{$:y}}}else isObject(e)&&n(e,"$types")&&(e={$:e,$types:!0});return!i.returnTypeNames&&e},checkPromises=async(e,t)=>{const r=await Promise.all(t.map(e=>e[1].p));return await Promise.all(r.map(async function(r){const n=[],[a]=t.splice(0,1),[o,,s,i,c,y,u]=a,l=_encapsulate(o,r,s,i,n,!0,u),p=hasConstructorOf(l,TypesonPromise);return o&&p?(setOwnEnumerable(c,y,await l.p),checkPromises(e,n)):(o?setOwnEnumerable(c,y,l):e=p?l.p:l,checkPromises(e,n))})),e},_adaptBuiltinStateObjectProperties=(e,t,r)=>{Object.assign(e,t);const n=o.map(t=>{const r=e[t];return delete e[t],r});r(),o.forEach((t,r)=>{e[t]=n[r]})},_encapsulate=(e,t,o,s,c,p,f)=>{let h,g={};const b=d?function(r){const n=f??s.type??getJSONType(t);d(Object.assign(r??g,{keypath:e,value:t,cyclic:o,stateObj:s,promisesData:c,resolvingTypesonPromise:p,awaitingTypesonPromise:hasConstructorOf(t,TypesonPromise)},{type:n}))}:null,getEncapsulatedValue=(e,t,r)=>{try{return{value:_encapsulate(e,t[r],Boolean(o),s,c,p)}}catch(n){if(!m)throw n;const a=f??s.type??getJSONType(t),o=m({keypath:e,error:n,parent:t,key:r,stateObj:s,type:a});if(!o)throw n;if("substitute"in o)return{value:o.substitute,substitute:!0};if(o.ignore)return;throw n}};if(["string","boolean","number","undefined"].includes(typeof t))return void 0===t||t===1/0||0===t||t===-1/0||Number.isNaN(t)?(h=s.replaced?t:replace(e,t,s,c,!1,p,b),h!==t&&(g={replaced:h})):h=t,b&&b(),h;if(null===t)return b&&b(),t;if(o&&t&&"object"==typeof t&&!s.iterateIn&&!s.iterateUnsetNumeric){const r=u.indexOf(t);if(-1!==r)return y[e]="#",b&&b({cyclicKeypath:l[r]}),"#"+l[r];!0===o&&(u.push(t),l.push(e))}const v=isPlainObject(t),w=a(t),O=(v||w)&&(!this.plainObjectReplacers.length||s.replaced)||s.iterateIn?t:replace(e,t,s,c,v||w,null,b);let A;if(O!==t?(h=O,g={replaced:O}):""===e&&hasConstructorOf(t,TypesonPromise)?(c.push([e,t,o,s,void 0,void 0,s.type]),h=t):w&&"object"!==s.iterateIn||"array"===s.iterateIn?(A=new Array(t.length),g={clone:A}):!v&&("object"!=typeof t||"toJSON"in t||hasConstructorOf(t,TypesonPromise)||hasConstructorOf(t,Promise)||hasConstructorOf(t,ArrayBuffer))&&"object"!==s.iterateIn?h=t:(A={},s.addLength&&(A.length=t.length),g={clone:A}),b&&b(),i.iterateNone)return A??h;if(!A)return h;if(s.iterateIn){for(const r in t){const a={ownKeys:n(t,r)};_adaptBuiltinStateObjectProperties(s,a,()=>{const n=e+(e?".":"")+escapeKeyPathComponent(r),a=getEncapsulatedValue(n,t,r),i=a&&a.value;hasConstructorOf(i,TypesonPromise)?c.push([n,i,Boolean(o),s,A,r,s.type]):a&&(void 0!==i||"substitute"in a)&&setOwnEnumerable(A,r,i)})}b&&b({endIterateIn:!0,end:!0})}else r(t).forEach(function(r){const n=e+(e?".":"")+escapeKeyPathComponent(r);_adaptBuiltinStateObjectProperties(s,{ownKeys:!0},()=>{const e=getEncapsulatedValue(n,t,r),a=e&&e.value;hasConstructorOf(a,TypesonPromise)?c.push([n,a,Boolean(o),s,A,r,s.type]):e&&(void 0!==a||"substitute"in e)&&setOwnEnumerable(A,r,a)})}),b&&b({endIterateOwn:!0,end:!0});if(s.iterateUnsetNumeric){const r=t.length;for(let n=0;n<r;n++){if(n in t)continue;const r=`${e}${e?".":""}${String(n)}`;_adaptBuiltinStateObjectProperties(s,{ownKeys:!1},()=>{const e=_encapsulate(r,void 0,Boolean(o),s,c,p);hasConstructorOf(e,TypesonPromise)?c.push([r,e,Boolean(o),s,A,n,s.type]):void 0!==e&&setOwnEnumerable(A,n,e)})}b&&b({endIterateUnsetNumeric:!0,end:!0})}return A},replace=(e,t,r,n,a,o,s)=>{const i=a?this.plainObjectReplacers:this.nonplainObjectReplacers;let u=i.length;for(;u--;){const a=i[u];if(a.test(t,r)){const{type:i}=a;if(Object.hasOwn(this.revivers,i)){const t=y[e];y[e]=t?[i].concat(t):i}if(Object.assign(r,{type:i,replaced:!0}),(c||!a.replaceAsync)&&!a.replace)return s&&s({typeDetected:!0}),_encapsulate(e,t,f&&"readonly",r,n,o,i);let u;if(s&&s({replacing:!0}),c||!a.replaceAsync){if(void 0===a.replace)throw new TypeError("Missing replacer");u=a.replace(t,r)}else u=a.replaceAsync(t,r);return _encapsulate(e,u,f&&"readonly",r,n,o,i)}}return t},h=_encapsulate("",e,f,t??{},p);if(p.length)return c&&i.throwOnBadSyncType?(()=>{throw new TypeError("Sync method requested but async result obtained")})():Promise.resolve(checkPromises(h,p)).then(finish);if(!c&&i.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return c&&i.stringification?[finish(h)]:c?finish(h):Promise.resolve(finish(h))}encapsulateSync(e,t,r){return this.encapsulate(e,t,{throwOnBadSyncType:!0,...r,sync:!0})}encapsulateAsync(e,t,r){return this.encapsulate(e,t,{throwOnBadSyncType:!0,...r,sync:!1})}revive(e,t){const o={sync:!0,...this.options,...t},{sync:s}=o;function finishRevival(e){if(s)return e;if(o.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!e||"object"!=typeof e||Array.isArray(e))return finishRevival(e);let i=e.$types;if(!0===i)return finishRevival(e.$);if(!i||"object"!=typeof i||Array.isArray(i))return finishRevival(e);const c=[],y=Object.create(null),u={};let l=!0;i.$&&isPlainObject(i.$)&&(e=e.$,i=i.$,l=!1);const executeReviver=(e,t)=>{const[r]=this.revivers[e]??[];if(!r)throw new Error("Unregistered type: "+e);if(s&&!("revive"in r))return t;if(!s&&r.reviveAsync)return r.reviveAsync(t,u);if(r.revive)return r.revive(t,u);throw new Error("Missing reviver")},p=[];function checkUndefined(e){return hasConstructorOf(e,Undefined)?void 0:e}const f=(()=>{if(!i)throw new Error("Found bad `types`");const t=[];if(Object.entries(i).forEach(([e,r])=>{"#"!==r&&[].concat(r).forEach(r=>{const[,{plain:n}]=this.revivers[r]??[null,{}];n&&(t.push({keypath:e,type:r}),delete i[e])})}),t.length)return t.sort(nestedPathsFirst),t.reduce(function reducer(t,{keypath:r,type:n}){if(isThenable(t))return t.then(e=>reducer(e,{keypath:r,type:n}));let a=getByKeyPath(e,r,!0);if(a=executeReviver(n,a),hasConstructorOf(a,TypesonPromise))return a.then(t=>{const n=setAtKeyPath(e,r,t,!0);n===t&&(e=n)});const o=setAtKeyPath(e,r,a,!0);o===a&&(e=o)},void 0)})();let d;return hasConstructorOf(f,TypesonPromise)?d=f.then(()=>e):(d=function _revive(e,t,o,u,f){if(l&&"$types"===e)return;const d=p.length,m=n(i,e)?i[e]:void 0,h=a(t);if(h||isPlainObject(t)){const a=h?new Array(t.length):{};for(r(t).forEach(r=>{const n=_revive(e+(e?".":"")+escapeKeyPathComponent(r),t[r],o??a,a,r),set=e=>(hasConstructorOf(e,Undefined)?setOwnEnumerable(a,r,void 0):void 0!==e&&setOwnEnumerable(a,r,e),e);hasConstructorOf(n,TypesonPromise)?p.push(n.then(e=>set(e))):set(n)}),t=a;c.length;){const[[e,t,r,a]]=c,o=n(y,t),s=o?y[t]:getByKeyPath(e,t,!0);if(!o&&void 0===s)break;setOwnEnumerable(r,a,s),c.shift()}}if(!m)return y[e]=t,t;if("#"===m){const e=t.slice(1),r=n(y,e),a=r?y[e]:getByKeyPath(o,e,!0);return r||void 0!==a||c.push([o,e,u,f]),a}const applyType=t=>{const r=[].concat(m).reduce(function reducer(e,t){if(hasConstructorOf(e,TypesonPromise))return e.then(e=>reducer(e,t));if("string"!=typeof t)throw new TypeError("Bad type JSON");return executeReviver(t,e)},t);return hasConstructorOf(r,TypesonPromise)?r.then(t=>(y[e]=t,t)):(y[e]=r,r)};return!s&&p.length>d?TypesonPromise.all(p.slice(d)).then(()=>applyType(t)):applyType(t)}("",e,null),p.length&&(d=TypesonPromise.resolve(d).then(e=>TypesonPromise.all([e,...p])).then(([e])=>e))),isThenable(d)?s&&o.throwOnBadSyncType?(()=>{throw new TypeError("Sync method requested but async result obtained")})():hasConstructorOf(d,TypesonPromise)?d.p.then(checkUndefined):d:!s&&o.throwOnBadSyncType?(()=>{throw new TypeError("Async method requested but sync result obtained")})():s?checkUndefined(d):Promise.resolve(checkUndefined(d))}reviveSync(e,t){return this.revive(e,{throwOnBadSyncType:!0,...t,sync:!0})}reviveAsync(e,t){return this.revive(e,{throwOnBadSyncType:!0,...t,sync:!1})}register(e,t){const n=t??{},reg=e=>{a(e)?e.forEach(e=>{reg(e)}):r(e).forEach(t=>{if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(s.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");let r=e[t];if([this.plainObjectReplacers,this.nonplainObjectReplacers].forEach(e=>{const r=e.findIndex(e=>e.type===t);-1!==r&&e.splice(r,1)}),delete this.revivers[t],delete this.types[t],"function"==typeof r){const e=r;r={test:t=>t&&t.constructor===e,replace:e=>({...e}),revive:t=>Object.assign(Object.create(e.prototype),t)}}else if(a(r)){const[e,t,n]=r;r={test:e,replace:t,revive:n}}if(!r?.test)return;const o={type:t,test:r.test.bind(r)};r.replace&&(o.replace=r.replace.bind(r)),r.replaceAsync&&(o.replaceAsync=r.replaceAsync.bind(r));const i="number"==typeof n.fallback?n.fallback:n.fallback?0:1/0;if(r.testPlainObjects?this.plainObjectReplacers.splice(i,0,o):this.nonplainObjectReplacers.splice(i,0,o),r.revive||r.reviveAsync){const e={};r.revive&&(e.revive=r.revive.bind(r)),r.reviveAsync&&(e.reviveAsync=r.reviveAsync.bind(r)),this.revivers[t]=[e,{plain:r.testPlainObjects}]}this.types[t]=r})};return[].concat(e).forEach(e=>{reg(e)}),this}}class Undefined{}Undefined.__typeson__type__="TypesonUndefined";const s=["null","boolean","number","string","array","object"];for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(256),y=0;y<64;y++)c[i.codePointAt(y)]=y;var u=function encode(e,t,r){null==r&&(r=e.byteLength);for(var n=new Uint8Array(e,0,r),a=n.length,o="",s=0;s<a;s+=3)o+=i[n[s]>>2],o+=i[(3&n[s])<<4|n[s+1]>>4],o+=i[(15&n[s+1])<<2|n[s+2]>>6],o+=i[63&n[s+2]];return a%3==2?o=o.slice(0,-1)+"=":a%3==1&&(o=o.slice(0,-2)+"=="),o},l=function decode(e,t){var r=e.length;if(r%4)throw new Error("Bad base64 length: not divisible by four");var n,a,o,s,i=.75*e.length,y=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);for(var u=new ArrayBuffer(i,t),l=new Uint8Array(u),p=0;p<r;p+=4)n=c[e.codePointAt(p)],a=c[e.codePointAt(p+1)],o=c[e.codePointAt(p+2)],s=c[e.codePointAt(p+3)],l[y++]=n<<2|a>>4,l[y++]=(15&a)<<4|o>>2,l[y++]=(3&o)<<6|63&s;return u};const p={arraybuffer:{test:e=>"ArrayBuffer"===toStringTag(e),replace(e,t){t.buffers||(t.buffers=[]);const r=t.buffers.indexOf(e);return-1!==r?{index:r}:(t.buffers.push(e),{s:u(e),maxByteLength:e.maxByteLength,resizable:e.resizable})},revive(e,t){if(t.buffers||(t.buffers=[]),Object.hasOwn(e,"index"))return t.buffers[e.index];const r=l(e.s,e.resizable?{maxByteLength:e.maxByteLength}:void 0);return t.buffers.push(r),r}}},f={audiodata:{test:e=>"AudioData"===toStringTag(e),replace(e){const{format:t,sampleRate:r,numberOfFrames:n,numberOfChannels:a,timestamp:o}=e,s=t.endsWith("-planar")?a:1,i=[];let c=0;for(let t=0;t<s;t++){const r=e.allocationSize({planeIndex:t});i.push(r),c+=r}const y=new ArrayBuffer(c);let u=0;for(let t=0;t<s;t++){const r=new Uint8Array(y,u,i[t]);e.copyTo(r,{planeIndex:t}),u+=i[t]}return{format:t,sampleRate:r,numberOfFrames:n,numberOfChannels:a,timestamp:o,data:y}},revive:({format:e,sampleRate:t,numberOfFrames:r,numberOfChannels:n,timestamp:a,data:o})=>new AudioData({format:e,sampleRate:t,numberOfFrames:r,numberOfChannels:n,timestamp:a,data:new Uint8Array(o)})}},d={bigintObject:{test:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),replace:String,revive:e=>new Object(BigInt(e))}},m={bigint:{test:e=>"bigint"==typeof e,replace:String,revive:e=>BigInt(e)}};function arraybuffer2string(e){return new Uint8Array(e).reduce((e,t)=>e+String.fromCodePoint(t),"")}function string2arraybuffer(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t.buffer}const h={blob:{test:e=>"Blob"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad Blob access: "+t.status);return{type:e.type,stringContents:t.responseText}},revive(e){const{type:t,stringContents:r}=e;return new Blob([string2arraybuffer(r)],{type:t})},replaceAsync:e=>new TypesonPromise((t,r)=>{const n=new FileReader;n.addEventListener("load",()=>{t({type:e.type,stringContents:arraybuffer2string(n.result)})}),n.addEventListener("error",()=>{r(n.error)}),n.readAsArrayBuffer(e)})}};function generateUUID(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/gu,function(t){const r=Math.trunc((e+16*Math.random())%16);return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)})}const g={},b={cloneable:{test:e=>e&&"object"==typeof e&&"function"==typeof e[Symbol.for("cloneEncapsulate")],replace(e){const t=e[Symbol.for("cloneEncapsulate")](),r=generateUUID();return g[r]=e,{uuid:r,encapsulated:t}},revive(e){const{uuid:t,encapsulated:r}=e;return g[t][Symbol.for("cloneRevive")](r)}}},v={cryptokey:{test:e=>"CryptoKey"===toStringTag(e)&&e.extractable,replaceAsync:e=>new TypesonPromise(async(t,r)=>{let n;try{n=await crypto.subtle.exportKey("jwk",e)}catch(e){return void r(e)}t({jwk:n,algorithm:e.algorithm,usages:e.usages})}),revive(e){const{jwk:t,algorithm:r,usages:n}=e;return crypto.subtle.importKey("jwk",t,r,!0,n)}}},w={dataview:{test:e=>"DataView"===toStringTag(e),replace({buffer:e,byteOffset:t,byteLength:r},n){n.buffers||(n.buffers=[]);const a=n.buffers.indexOf(e);return-1!==a?{index:a,byteOffset:t,byteLength:r}:(n.buffers.push(e),{encoded:u(e),maxByteLength:e.maxByteLength,resizable:e.resizable,byteOffset:t,byteLength:r})},revive(e,t){t.buffers||(t.buffers=[]);const{byteOffset:r,byteLength:n,encoded:a,index:o,maxByteLength:s,resizable:i}=e;let c;return"index"in e?c=t.buffers[o]:(c=l(a,i?{maxByteLength:s}:s),t.buffers.push(c)),new DataView(c,r,n)}}},O={date:{test:e=>"Date"===toStringTag(e),replace(e){const t=e.getTime();return Number.isNaN(t)?"NaN":t},revive:e=>"NaN"===e?new Date(NaN):new Date(e)}},A={domexception:{test:e=>"DOMException"===toStringTag(e),replace:e=>({name:e.name,message:e.message}),revive:({message:e,name:t})=>new DOMException(e,t)}},T={};function create$5(e){T[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>e.is2D?{a:e.a,b:e.b,c:e.c,d:e.d,e:e.e,f:e.f}:{m11:e.m11,m12:e.m12,m13:e.m13,m14:e.m14,m21:e.m21,m22:e.m22,m23:e.m23,m24:e.m24,m31:e.m31,m32:e.m32,m33:e.m33,m34:e.m34,m41:e.m41,m42:e.m42,m43:e.m43,m44:e.m44},revive:t=>Object.hasOwn(t,"a")?new e([t.a,t.b,t.c,t.d,t.e,t.f]):new e([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44])}}"undefined"!=typeof DOMMatrix&&create$5(DOMMatrix),"undefined"!=typeof DOMMatrixReadOnly&&create$5(DOMMatrixReadOnly);const S={};function create$4(e){S[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,z:e.z,w:e.w}),revive:({x:t,y:r,z:n,w:a})=>new e(t,r,n,a)}}"undefined"!=typeof DOMPoint&&create$4(DOMPoint),"undefined"!=typeof DOMPointReadOnly&&create$4(DOMPointReadOnly);const P={domquad:{test:e=>"DOMQuad"===toStringTag(e),replace:e=>({p1:e.p1,p2:e.p2,p3:e.p3,p4:e.p4}),revive:({p1:e,p2:t,p3:r,p4:n})=>new DOMQuad(e,t,r,n)}},x={};function create$3(e){x[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),revive:({x:t,y:r,width:n,height:a})=>new e(t,r,n,a)}}"undefined"!=typeof DOMRect&&create$3(DOMRect),"undefined"!=typeof DOMRectReadOnly&&create$3(DOMRectReadOnly);const E={encodedaudiochunk:{test:e=>"EncodedAudioChunk"===toStringTag(e),replace(e){const{type:t,timestamp:r,duration:n,byteLength:a}=e,o=new ArrayBuffer(a);return e.copyTo(o),{type:t,timestamp:r,duration:n,data:o}},revive:({type:e,timestamp:t,duration:r,data:n})=>new EncodedAudioChunk({type:e,timestamp:t,duration:r,data:new Uint8Array(n)})}},j={encodedvideochunk:{test:e=>"EncodedVideoChunk"===toStringTag(e),replace(e){const{type:t,timestamp:r,duration:n,byteLength:a}=e,o=new ArrayBuffer(a);return e.copyTo(o),{type:t,timestamp:r,duration:n,data:o}},revive:({type:e,timestamp:t,duration:r,data:n})=>new EncodedVideoChunk({type:e,timestamp:t,duration:r,data:new Uint8Array(n)})}},N={error:{test:e=>"Error"===toStringTag(e),replace:({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s})=>({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s}),revive(e){const t=new Error(e.message);return t.name=e.name,t.cause=e.cause,t.stack=e.stack,t.fileName=e.fileName,t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}}},C={};function create$2(e){C[e.name.toLowerCase()]={test:t=>hasConstructorOf(t,e),replace:({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s,errors:i})=>({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s,errors:i}),revive(t){const r="undefined"!=typeof AggregateError&&e===AggregateError?new e(t.errors,t.message):new e(t.message);return r.name=t.name,r.cause=t.cause,r.stack=t.stack,r.fileName=t.fileName,r.lineNumber=t.lineNumber,r.columnNumber=t.columnNumber,r}}}[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError].forEach(e=>create$2(e)),"undefined"!=typeof AggregateError&&create$2(AggregateError),"function"==typeof InternalError&&create$2(InternalError);const B={file:{test:e=>"File"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad File access: "+t.status);return{type:e.type,stringContents:t.responseText,name:e.name,lastModified:e.lastModified}},revive:({name:e,type:t,stringContents:r,lastModified:n})=>new File([string2arraybuffer(r)],e,{type:t,lastModified:n}),replaceAsync:e=>new TypesonPromise(function(t,r){const n=new FileReader;n.addEventListener("load",function(){t({type:e.type,stringContents:arraybuffer2string(n.result),name:e.name,lastModified:e.lastModified})}),n.addEventListener("error",function(){r(n.error)}),n.readAsArrayBuffer(e)})}},I={file:B.file,filelist:{test:e=>"FileList"===toStringTag(e),replace(e){const t=[];for(let r=0;r<e.length;r++)t[r]=e.item(r);return t},revive(e){class FileList{constructor(){this._files=arguments[0],this.length=this._files.length}item(e){return this._files[e]}get[Symbol.toStringTag](){return"FileList"}}return new FileList(e)}}},_={imagebitmap:{test:e=>"ImageBitmap"===toStringTag(e)||e&&e.dataset&&"ImageBitmap"===e.dataset.toStringTag,replace(e){const t=document.createElement("canvas");return t.getContext("2d").drawImage(e,0,0),{width:e.width,height:e.height,dataURL:t.toDataURL()}},revive(e){const t="undefined"==typeof OffscreenCanvas?document.createElement("canvas"):new OffscreenCanvas(e.width,e.height),r=t.getContext("2d"),n=document.createElement("img");return n.addEventListener("load",function(){r.drawImage(n,0,0)}),n.src=e.dataURL,"undefined"==typeof OffscreenCanvas?t:t.transferToImageBitmap()},reviveAsync(e){const t=document.createElement("canvas"),r=t.getContext("2d"),n=document.createElement("img");return n.addEventListener("load",function(){r.drawImage(n,0,0)}),n.src=e.dataURL,new TypesonPromise(async(e,r)=>{try{e(await createImageBitmap(t))}catch(e){r(e)}})}}},U={imagedata:{test:e=>"ImageData"===toStringTag(e),replace:e=>({array:[...e.data],width:e.width,height:e.height}),revive:e=>new ImageData(new Uint8ClampedArray(e.array),e.width,e.height)}},M={infinity:{test:e=>e===1/0,replace:()=>"Infinity",revive:()=>1/0}},R={IntlCollator:{test:e=>hasConstructorOf(e,Intl.Collator),replace:e=>e.resolvedOptions(),revive:e=>new Intl.Collator(e.locale,e)},IntlDateTimeFormat:{test:e=>hasConstructorOf(e,Intl.DateTimeFormat),replace:e=>e.resolvedOptions(),revive:e=>new Intl.DateTimeFormat(e.locale,e)},IntlNumberFormat:{test:e=>hasConstructorOf(e,Intl.NumberFormat),replace:e=>e.resolvedOptions(),revive:e=>new Intl.NumberFormat(e.locale,e)}},k={map:{test:e=>"Map"===toStringTag(e),replace:e=>e.entries().toArray(),revive:e=>new Map(e)}},D={nan:{test:e=>Number.isNaN(e),replace:()=>"NaN",revive:()=>NaN}},L={negativeInfinity:{test:e=>e===-1/0,replace:()=>"-Infinity",revive:()=>-1/0}},F={negativeZero:{test:e=>Object.is(e,-0),replace:()=>0,revive:()=>-0}},$={nonbuiltinIgnore:{test:e=>e&&"object"==typeof e&&!Array.isArray(e)&&!["Object","Boolean","Number","String","Error","RegExp","Math","Date","Map","Set","JSON","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","Promise","String Iterator","Array Iterator","Map Iterator","Set Iterator","WeakMap","WeakSet","Atomics","Module"].includes(toStringTag(e)),replace(){}}},K={StringObject:{test:e=>"String"===toStringTag(e)&&"object"==typeof e,replace:String,revive:e=>new String(e)},BooleanObject:{test:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,replace:e=>e.valueOf(),revive:e=>new Boolean(e)},NumberObject:{test:e=>"Number"===toStringTag(e)&&"object"==typeof e,replace(e){const t=e.valueOf();return Number.isNaN(t)?"NaN":t===1/0?"Infinity":t===-1/0?"-Infinity":Object.is(t,-0)?"-0":t},revive:e=>new Number("NaN"===e?NaN:"Infinity"===e?1/0:"-Infinity"===e?-1/0:"-0"===e?-0:e)}},q={promise:{test:e=>"Promise"===toStringTag(e),replaceAsync:e=>new TypesonPromise(async t=>{try{t({value:await e})}catch(e){t({error:e})}}),revive:e=>e.error?Promise.reject(e.error):Promise.resolve(e.value)}},W={quotaexceedederror:{test:e=>"QuotaExceededError"===toStringTag(e),replace:({message:e,quota:t,requested:r})=>({message:e,quota:t,requested:r}),revive({message:e,quota:t,requested:r}){const n={};return null!=t&&(n.quota=t),null!=r&&(n.requested=r),new QuotaExceededError(e,n)}}},z={regexp:{test:e=>"RegExp"===toStringTag(e),replace:e=>({source:e.source,flags:(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":"")+(e.unicodeSets?"v":"")+(e.hasIndices?"d":"")+(e.dotAll?"s":"")}),revive:({source:e,flags:t})=>new RegExp(e,t)}},J={},V={resurrectable:{test:e=>e&&!Array.isArray(e)&&["object","function","symbol"].includes(typeof e),replace(e){const t=generateUUID();return J[t]=e,t},revive:e=>J[e]}},H={set:{test:e=>"Set"===toStringTag(e),replace:e=>e.values().toArray(),revive:e=>new Set(e)}},Q={symbol:{test:e=>"symbol"==typeof e,replace:e=>({global:void 0!==Symbol.keyFor(e),sym:String(e).slice(7,-1)}),revive:e=>e.global?Symbol.for(e.sym):Symbol(e.sym)}},G={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[],..."function"==typeof Float16Array?[Float16Array]:[]].forEach(e=>function create$1(e){const t=e.name;G[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace:e=>(0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(0)).buffer,revive:t=>"ArrayBuffer"===toStringTag(t)?new e(t):t}}(e));const X={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[],..."function"==typeof Float16Array?[Float16Array]:[]].forEach(e=>function create(e){const t=e.name;X[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace({buffer:e,byteOffset:t,length:r},n){n.buffers||(n.buffers=[]);const a=n.buffers.indexOf(e);return-1!==a?{index:a,byteOffset:t,length:r}:(n.buffers.push(e),{maxByteLength:e.maxByteLength,resizable:e.resizable,encoded:u(e),byteOffset:t,length:r})},revive(t,r){r.buffers||(r.buffers=[]);const{byteOffset:n,length:a,encoded:o,index:s,maxByteLength:i,resizable:c}=t;let y;return"index"in t?y=r.buffers[s]:(y=l(o,c?{maxByteLength:i}:void 0),r.buffers.push(y)),new e(y,n,a)}}}(e));const Y={undef:{test:(e,t)=>void 0===e&&(t.ownKeys||!("ownKeys"in t)),replace:()=>0,revive:()=>new Undefined}},Z={userObject:{test:e=>isUserObject(e),replace:e=>({...e}),revive:e=>e}},ee={videoframe:{test:e=>"VideoFrame"===toStringTag(e),replaceAsync:e=>new TypesonPromise(async(t,r)=>{try{const{format:r,codedWidth:n,codedHeight:a,timestamp:o,duration:s,visibleRect:i,displayWidth:c,displayHeight:y,colorSpace:u}=e,l=new ArrayBuffer(e.allocationSize());await e.copyTo(l),t({format:r,codedWidth:n,codedHeight:a,timestamp:o,duration:s,visibleRect:{x:i.x,y:i.y,width:i.width,height:i.height},displayWidth:c,displayHeight:y,colorSpace:{primaries:u.primaries,transfer:u.transfer,matrix:u.matrix,fullRange:u.fullRange},data:l})}catch(e){r(e)}}),revive:({format:e,codedWidth:t,codedHeight:r,timestamp:n,duration:a,visibleRect:o,displayWidth:s,displayHeight:i,colorSpace:c,data:y})=>new VideoFrame(new Uint8Array(y),{format:e,codedWidth:t,codedHeight:r,timestamp:n,duration:a,visibleRect:o,displayWidth:s,displayHeight:i,colorSpace:c})}},te={webtransporterror:{test:e=>"WebTransportError"===toStringTag(e),replace:({message:e,streamErrorCode:t})=>({message:e,streamErrorCode:t}),revive:({message:e,streamErrorCode:t})=>new WebTransportError({message:e,streamErrorCode:t})}},re=[{arrayNonindexKeys:{testPlainObjects:!0,test:(e,t)=>!!Array.isArray(e)&&(Object.keys(e).some(e=>String(Number(e))!==e)&&(t.iterateIn="object",t.addLength=!0),!0),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e),revive(e){if(Array.isArray(e))return e;const t=[];return Object.entries(e).forEach(([e,r])=>{t[e]=r}),t}}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ne=[D,M,L,F],ae=[Y,re,K,ne,O,N,C,z].concat("function"==typeof Map?k:[],"function"==typeof Set?H:[],"function"==typeof ArrayBuffer?p:[],"function"==typeof Uint8Array?X:[],"function"==typeof DataView?w:[],"undefined"!=typeof Intl?R:[],"undefined"!=typeof BigInt?[m,d]:[]),oe=[N,C],se=[ae,{arraybuffer:null},G],ie=[{sparseArrays:{testPlainObjects:!0,test:e=>Array.isArray(e),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e)}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ce=[Z,Y,re,K,ne,O,z,U,_,B,I,h,N,C].concat("function"==typeof Map?k:[],"function"==typeof Set?H:[],"function"==typeof ArrayBuffer?p:[],"function"==typeof Uint8Array?X:[],"function"==typeof DataView?w:[],"undefined"!=typeof crypto?v:[],"undefined"!=typeof BigInt?[m,d]:[],"undefined"!=typeof DOMException?A:[],"undefined"!=typeof QuotaExceededError?W:[],"undefined"!=typeof WebTransportError?te:[],"undefined"!=typeof DOMRect?x:[],"undefined"!=typeof DOMPoint?S:[],"undefined"!=typeof DOMQuad?P:[],"undefined"!=typeof DOMMatrix?T:[],"undefined"!=typeof AudioData?f:[],"undefined"!=typeof EncodedAudioChunk?E:[],"undefined"!=typeof EncodedVideoChunk?j:[],"undefined"!=typeof VideoFrame?ee:[]);const ye=ce.concat({checkDataCloneException:{test(e){const t={}.toString.call(e).slice(8,-1);if(["symbol","function"].includes(typeof e)||["Arguments","Module","Promise","WeakMap","WeakSet","Event","MessageChannel"].includes(t)||["ArrayBuffer","DataView","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(t)&&function isBufferDetached(e){if("boolean"==typeof e.detached)return e.detached;if(0!==e.byteLength)return!1;try{return new Uint8Array(e),!1}catch{return!0}}(e)||e&&"object"==typeof e&&"number"==typeof e.nodeType&&"function"==typeof e.insertBefore)throw new DOMException("The object cannot be cloned.","DataCloneError");return!1}}}),ue=[ie,Y],le=[ae];export{s as JSON_TYPES,Typeson,TypesonPromise,Undefined,re as arrayNonindexKeys,p as arraybuffer,f as audiodata,m as bigint,d as bigintObject,h as blob,ae as builtin,b as cloneable,v as cryptokey,w as dataview,O as date,A as domexception,T as dommatrix,S as dompoint,P as domquad,x as domrect,E as encodedaudiochunk,j as encodedvideochunk,N as error,C as errors,escapeKeyPathComponent,B as file,I as filelist,getByKeyPath,getJSONType,hasConstructorOf,_ as imagebitmap,U as imagedata,M as infinity,R as intlTypes,isObject,isPlainObject,isThenable,isUserObject,k as map,D as nan,L as negativeInfinity,F as negativeZero,$ as nonbuiltinIgnore,oe as postmessage,K as primitiveObjects,q as promise,W as quotaexceedederror,z as regexp,V as resurrectable,H as set,setAtKeyPath,se as socketio,ie as sparseUndefined,ne as specialNumbers,ce as structuredCloning,ye as structuredCloningThrowing,Q as symbol,toStringTag,X as typedArrays,G as typedArraysSocketio,Y as undef,ue as undefPreset,unescapeKeyPathComponent,le as universal,Z as userObject,ee as videoframe,te as webtransporterror};
|
|
6
|
+
*/const{keys:r,hasOwn:n}=Object,{isArray:a}=Array,o=["type","replaced","iterateIn","iterateUnsetNumeric","addLength"];function setOwnEnumerable(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,value:r,writable:!0})}function nestedPathsFirst(e,t){if(""===e.keypath)return-1;let r=e.keypath.match(/\./gu)??0,n=t.keypath.match(/\./gu)??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?1:0}class Typeson{constructor(e){this.options=e,this.plainObjectReplacers=[],this.nonplainObjectReplacers=[],this.revivers={},this.types={}}stringify(e,t,r,n){n={...this.options,...n,stringification:!0};const o=this.encapsulate(e,null,n);return a(o)?JSON.stringify(o[0],t,r):o.then(e=>JSON.stringify(e,t,r))}stringifySync(e,t,r,n){return this.stringify(e,t,r,{throwOnBadSyncType:!0,...n,sync:!0})}stringifyAsync(e,t,r,n){return this.stringify(e,t,r,{throwOnBadSyncType:!0,...n,sync:!1})}parse(e,t,r){return r={...this.options,...r,parse:!0},this.revive(JSON.parse(e,t),r)}parseSync(e,t,r){return this.parse(e,t,{throwOnBadSyncType:!0,...r,sync:!0})}parseAsync(e,t,r){return this.parse(e,t,{throwOnBadSyncType:!0,...r,sync:!1})}specialTypeNames(e,t,r={}){return this.encapsulate(e,t,{...r,returnTypeNames:!0})}rootTypeName(e,t,r={}){return this.encapsulate(e,t,{...r,iterateNone:!0})}encapsulate(e,t,s){const i={sync:!0,...this.options,...s},{sync:c}=i,u={},y=[],l=[],p=[],f=!("cyclic"in i)||i.cyclic,{encapsulateObserver:d,encapsulateError:m}=i,finish=e=>{const t=Object.values(u);if(i.iterateNone)return t.length?t[0]:getJSONType(e);if(t.length){if(i.returnTypeNames)return[...new Set(t)];e&&isPlainObject(e)&&!n(e,"$types")?e.$types=u:e={$:e,$types:{$:u}}}else isObject(e)&&n(e,"$types")&&(e={$:e,$types:!0});return!i.returnTypeNames&&e},checkPromises=async(e,t)=>{const r=await Promise.all(t.map(e=>e[1].p));return await Promise.all(r.map(async function(r){const n=[],[a]=t.splice(0,1),[o,,s,i,c,u,y]=a,l=_encapsulate(o,r,s,i,n,!0,y),p=hasConstructorOf(l,TypesonPromise);return o&&p?(setOwnEnumerable(c,u,await l.p),checkPromises(e,n)):(o?setOwnEnumerable(c,u,l):e=p?l.p:l,checkPromises(e,n))})),e},_adaptBuiltinStateObjectProperties=(e,t,r)=>{Object.assign(e,t);const n=o.map(t=>{const r=e[t];return delete e[t],r});r(),o.forEach((t,r)=>{e[t]=n[r]})},_encapsulate=(e,t,o,s,c,p,f)=>{let h,g={};const b=d?function(r){const n=f??s.type??getJSONType(t);d(Object.assign(r??g,{keypath:e,value:t,cyclic:o,stateObj:s,promisesData:c,resolvingTypesonPromise:p,awaitingTypesonPromise:hasConstructorOf(t,TypesonPromise)},{type:n}))}:null,getEncapsulatedValue=(e,t,r)=>{try{return{value:_encapsulate(e,t[r],Boolean(o),s,c,p)}}catch(n){if(!m)throw n;const a=f??s.type??getJSONType(t),o=m({keypath:e,error:n,parent:t,key:r,stateObj:s,type:a});if(!o)throw n;if("substitute"in o)return{value:o.substitute,substitute:!0};if(o.ignore)return;throw n}};if(["string","boolean","number","undefined"].includes(typeof t))return void 0===t||t===1/0||0===t||t===-1/0||Number.isNaN(t)?(h=s.replaced?t:replace(e,t,s,c,!1,p,b),h!==t&&(g={replaced:h})):h=t,b&&b(),h;if(null===t)return b&&b(),t;if(o&&t&&"object"==typeof t&&!s.iterateIn&&!s.iterateUnsetNumeric){const r=y.indexOf(t);if(-1!==r)return u[e]="#",b&&b({cyclicKeypath:l[r]}),"#"+l[r];!0===o&&(y.push(t),l.push(e))}const v=isPlainObject(t),w=a(t),O=(v||w)&&(!this.plainObjectReplacers.length||s.replaced)||s.iterateIn?t:replace(e,t,s,c,v||w,null,b);let A;if(O!==t?(h=O,g={replaced:O}):""===e&&hasConstructorOf(t,TypesonPromise)?(c.push([e,t,o,s,void 0,void 0,s.type]),h=t):w&&"object"!==s.iterateIn||"array"===s.iterateIn?(A=new Array(t.length),g={clone:A}):!v&&("object"!=typeof t||"toJSON"in t||hasConstructorOf(t,TypesonPromise)||hasConstructorOf(t,Promise)||hasConstructorOf(t,ArrayBuffer))&&"object"!==s.iterateIn?h=t:(A={},s.addLength&&(A.length=t.length),g={clone:A}),b&&b(),i.iterateNone)return A??h;if(!A)return h;if(s.iterateIn){for(const r in t){const a={ownKeys:n(t,r)};_adaptBuiltinStateObjectProperties(s,a,()=>{const n=e+(e?".":"")+escapeKeyPathComponent(r),a=getEncapsulatedValue(n,t,r),i=a&&a.value;hasConstructorOf(i,TypesonPromise)?c.push([n,i,Boolean(o),s,A,r,s.type]):a&&(void 0!==i||"substitute"in a)&&setOwnEnumerable(A,r,i)})}b&&b({endIterateIn:!0,end:!0})}else r(t).forEach(function(r){const n=e+(e?".":"")+escapeKeyPathComponent(r);_adaptBuiltinStateObjectProperties(s,{ownKeys:!0},()=>{const e=getEncapsulatedValue(n,t,r),a=e&&e.value;hasConstructorOf(a,TypesonPromise)?c.push([n,a,Boolean(o),s,A,r,s.type]):e&&(void 0!==a||"substitute"in e)&&setOwnEnumerable(A,r,a)})}),b&&b({endIterateOwn:!0,end:!0});if(s.iterateUnsetNumeric){const r=t.length;for(let n=0;n<r;n++){if(n in t)continue;const r=`${e}${e?".":""}${String(n)}`;_adaptBuiltinStateObjectProperties(s,{ownKeys:!1},()=>{const e=_encapsulate(r,void 0,Boolean(o),s,c,p);hasConstructorOf(e,TypesonPromise)?c.push([r,e,Boolean(o),s,A,n,s.type]):void 0!==e&&setOwnEnumerable(A,n,e)})}b&&b({endIterateUnsetNumeric:!0,end:!0})}return A},replace=(e,t,r,n,a,o,s)=>{const i=a?this.plainObjectReplacers:this.nonplainObjectReplacers;let y=i.length;for(;y--;){const a=i[y];if(a.test(t,r)){const{type:i}=a;if(Object.hasOwn(this.revivers,i)){const t=u[e];u[e]=t?[i].concat(t):i}if(Object.assign(r,{type:i,replaced:!0}),(c||!a.replaceAsync)&&!a.replace)return s&&s({typeDetected:!0}),_encapsulate(e,t,f&&"readonly",r,n,o,i);let y;if(s&&s({replacing:!0}),c||!a.replaceAsync){if(void 0===a.replace)throw new TypeError("Missing replacer");y=a.replace(t,r)}else y=a.replaceAsync(t,r);return _encapsulate(e,y,f&&"readonly",r,n,o,i)}}return t},h=_encapsulate("",e,f,t??{},p);if(p.length)return c&&i.throwOnBadSyncType?(()=>{throw new TypeError("Sync method requested but async result obtained")})():Promise.resolve(checkPromises(h,p)).then(finish);if(!c&&i.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return c&&i.stringification?[finish(h)]:c?finish(h):Promise.resolve(finish(h))}encapsulateSync(e,t,r){return this.encapsulate(e,t,{throwOnBadSyncType:!0,...r,sync:!0})}encapsulateAsync(e,t,r){return this.encapsulate(e,t,{throwOnBadSyncType:!0,...r,sync:!1})}revive(e,t){const o={sync:!0,...this.options,...t},{sync:s}=o;function finishRevival(e){if(s)return e;if(o.throwOnBadSyncType)throw new TypeError("Async method requested but sync result obtained");return Promise.resolve(e)}if(!e||"object"!=typeof e||Array.isArray(e))return finishRevival(e);let i=e.$types;if(!0===i)return finishRevival(e.$);if(!i||"object"!=typeof i||Array.isArray(i))return finishRevival(e);const c=[],u=Object.create(null),y={};let l=!0;i.$&&isPlainObject(i.$)&&(e=e.$,i=i.$,l=!1);const executeReviver=(e,t)=>{const[r]=this.revivers[e]??[];if(!r)throw new Error("Unregistered type: "+e);if(s&&!("revive"in r))return t;if(!s&&r.reviveAsync)return r.reviveAsync(t,y);if(r.revive)return r.revive(t,y);throw new Error("Missing reviver")},p=[];function checkUndefined(e){return hasConstructorOf(e,Undefined)?void 0:e}const f=(()=>{if(!i)throw new Error("Found bad `types`");const t=[];if(Object.entries(i).forEach(([e,r])=>{"#"!==r&&[].concat(r).forEach(r=>{const[,{plain:n}]=this.revivers[r]??[null,{}];n&&(t.push({keypath:e,type:r}),delete i[e])})}),t.length)return t.sort(nestedPathsFirst),t.reduce(function reducer(t,{keypath:r,type:n}){if(isThenable(t))return t.then(e=>reducer(e,{keypath:r,type:n}));let a=getByKeyPath(e,r,!0);if(a=executeReviver(n,a),hasConstructorOf(a,TypesonPromise))return a.then(t=>{const n=setAtKeyPath(e,r,t,!0);n===t&&(e=n)});const o=setAtKeyPath(e,r,a,!0);o===a&&(e=o)},void 0)})();let d;return hasConstructorOf(f,TypesonPromise)?d=f.then(()=>e):(d=function _revive(e,t,o,y,f){if(l&&"$types"===e)return;const d=p.length,m=n(i,e)?i[e]:void 0,h=a(t);if(h||isPlainObject(t)){const a=h?new Array(t.length):{};for(r(t).forEach(r=>{const n=_revive(e+(e?".":"")+escapeKeyPathComponent(r),t[r],o??a,a,r),set=e=>(hasConstructorOf(e,Undefined)?setOwnEnumerable(a,r,void 0):void 0!==e&&setOwnEnumerable(a,r,e),e);hasConstructorOf(n,TypesonPromise)?p.push(n.then(e=>set(e))):set(n)}),t=a;c.length;){const[[e,t,r,a]]=c,o=n(u,t),s=o?u[t]:getByKeyPath(e,t,!0);if(!o&&void 0===s)break;setOwnEnumerable(r,a,s),c.shift()}}if(!m)return u[e]=t,t;if("#"===m){const e=t.slice(1),r=n(u,e),a=r?u[e]:getByKeyPath(o,e,!0);return r||void 0!==a||c.push([o,e,y,f]),a}const applyType=t=>{const r=[].concat(m).reduce(function reducer(e,t){if(hasConstructorOf(e,TypesonPromise))return e.then(e=>reducer(e,t));if("string"!=typeof t)throw new TypeError("Bad type JSON");return executeReviver(t,e)},t);return hasConstructorOf(r,TypesonPromise)?r.then(t=>(u[e]=t,t)):(u[e]=r,r)};return!s&&p.length>d?TypesonPromise.all(p.slice(d)).then(()=>applyType(t)):applyType(t)}("",e,null),p.length&&(d=TypesonPromise.resolve(d).then(e=>TypesonPromise.all([e,...p])).then(([e])=>e))),isThenable(d)?s&&o.throwOnBadSyncType?(()=>{throw new TypeError("Sync method requested but async result obtained")})():hasConstructorOf(d,TypesonPromise)?d.p.then(checkUndefined):d:!s&&o.throwOnBadSyncType?(()=>{throw new TypeError("Async method requested but sync result obtained")})():s?checkUndefined(d):Promise.resolve(checkUndefined(d))}reviveSync(e,t){return this.revive(e,{throwOnBadSyncType:!0,...t,sync:!0})}reviveAsync(e,t){return this.revive(e,{throwOnBadSyncType:!0,...t,sync:!1})}register(e,t){const n=t??{},reg=e=>{a(e)?e.forEach(e=>{reg(e)}):r(e).forEach(t=>{if("#"===t)throw new TypeError("# cannot be used as a type name as it is reserved for cyclic objects");if(s.includes(t))throw new TypeError("Plain JSON object types are reserved as type names");let r=e[t];if([this.plainObjectReplacers,this.nonplainObjectReplacers].forEach(e=>{const r=e.findIndex(e=>e.type===t);-1!==r&&e.splice(r,1)}),delete this.revivers[t],delete this.types[t],"function"==typeof r){const e=r;r={test:t=>t&&t.constructor===e,replace:e=>({...e}),revive:t=>Object.assign(Object.create(e.prototype),t)}}else if(a(r)){const[e,t,n]=r;r={test:e,replace:t,revive:n}}if(!r?.test)return;const o={type:t,test:r.test.bind(r)};r.replace&&(o.replace=r.replace.bind(r)),r.replaceAsync&&(o.replaceAsync=r.replaceAsync.bind(r));const i="number"==typeof n.fallback?n.fallback:n.fallback?0:1/0;if(r.testPlainObjects?this.plainObjectReplacers.splice(i,0,o):this.nonplainObjectReplacers.splice(i,0,o),r.revive||r.reviveAsync){const e={};r.revive&&(e.revive=r.revive.bind(r)),r.reviveAsync&&(e.reviveAsync=r.reviveAsync.bind(r)),this.revivers[t]=[e,{plain:r.testPlainObjects}]}this.types[t]=r})};return[].concat(e).forEach(e=>{reg(e)}),this}}class Undefined{}Undefined.__typeson__type__="TypesonUndefined";const s=["null","boolean","number","string","array","object"];for(var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c=new Uint8Array(256),u=0;u<64;u++)c[i.codePointAt(u)]=u;var y=function encode(e,t,r){null==r&&(r=e.byteLength);for(var n=new Uint8Array(e,0,r),a=n.length,o="",s=0;s<a;s+=3)o+=i[n[s]>>2],o+=i[(3&n[s])<<4|n[s+1]>>4],o+=i[(15&n[s+1])<<2|n[s+2]>>6],o+=i[63&n[s+2]];return a%3==2?o=o.slice(0,-1)+"=":a%3==1&&(o=o.slice(0,-2)+"=="),o},l=function decode(e,t){var r=e.length;if(r%4)throw new Error("Bad base64 length: not divisible by four");var n,a,o,s,i=.75*e.length,u=0;"="===e[e.length-1]&&(i--,"="===e[e.length-2]&&i--);for(var y=new ArrayBuffer(i,t),l=new Uint8Array(y),p=0;p<r;p+=4)n=c[e.codePointAt(p)],a=c[e.codePointAt(p+1)],o=c[e.codePointAt(p+2)],s=c[e.codePointAt(p+3)],l[u++]=n<<2|a>>4,l[u++]=(15&a)<<4|o>>2,l[u++]=(3&o)<<6|63&s;return y};const p={arraybuffer:{test:e=>"ArrayBuffer"===toStringTag(e),replace(e,t){t.buffers||(t.buffers=[]);const r=t.buffers.indexOf(e);return-1!==r?{index:r}:(t.buffers.push(e),{s:y(e),maxByteLength:e.maxByteLength,resizable:e.resizable})},revive(e,t){if(t.buffers||(t.buffers=[]),Object.hasOwn(e,"index"))return t.buffers[e.index];const r=l(e.s,e.resizable?{maxByteLength:e.maxByteLength}:void 0);return t.buffers.push(r),r}}},f={audiodata:{test:e=>"AudioData"===toStringTag(e),replace(e){const{format:t,sampleRate:r,numberOfFrames:n,numberOfChannels:a,timestamp:o}=e,s=t.endsWith("-planar")?a:1,i=[];let c=0;for(let t=0;t<s;t++){const r=e.allocationSize({planeIndex:t});i.push(r),c+=r}const u=new ArrayBuffer(c);let y=0;for(let t=0;t<s;t++){const r=new Uint8Array(u,y,i[t]);e.copyTo(r,{planeIndex:t}),y+=i[t]}return{format:t,sampleRate:r,numberOfFrames:n,numberOfChannels:a,timestamp:o,data:u}},revive:({format:e,sampleRate:t,numberOfFrames:r,numberOfChannels:n,timestamp:a,data:o})=>new AudioData({format:e,sampleRate:t,numberOfFrames:r,numberOfChannels:n,timestamp:a,data:new Uint8Array(o)})}},d={bigintObject:{test:e=>"object"==typeof e&&hasConstructorOf(e,BigInt),replace:String,revive:e=>new Object(BigInt(e))}},m={bigint:{test:e=>"bigint"==typeof e,replace:String,revive:e=>BigInt(e)}};function arraybuffer2string(e){return new Uint8Array(e).reduce((e,t)=>e+String.fromCodePoint(t),"")}function string2arraybuffer(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t.buffer}const h={blob:{test:e=>"Blob"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad Blob access: "+t.status);return{type:e.type,stringContents:t.responseText}},revive(e){const{type:t,stringContents:r}=e;return new Blob([string2arraybuffer(r)],{type:t})},replaceAsync:e=>new TypesonPromise((t,r)=>{const n=new FileReader;n.addEventListener("load",()=>{t({type:e.type,stringContents:arraybuffer2string(n.result)})}),n.addEventListener("error",()=>{r(n.error)}),n.readAsArrayBuffer(e)})}};function generateUUID(){let e=Date.now();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replaceAll(/[xy]/gu,function(t){const r=Math.trunc((e+16*Math.random())%16);return e=Math.floor(e/16),("x"===t?r:3&r|8).toString(16)})}const g={},b={cloneable:{test:e=>e&&"object"==typeof e&&"function"==typeof e[Symbol.for("cloneEncapsulate")],replace(e){const t=e[Symbol.for("cloneEncapsulate")](),r=generateUUID();return g[r]=e,{uuid:r,encapsulated:t}},revive(e){const{uuid:t,encapsulated:r}=e;return g[t][Symbol.for("cloneRevive")](r)}}},v={cryptokey:{test:e=>"CryptoKey"===toStringTag(e)&&e.extractable,replaceAsync:e=>new TypesonPromise(async(t,r)=>{let n;try{n=await crypto.subtle.exportKey("jwk",e)}catch(e){return void r(e)}t({jwk:n,algorithm:e.algorithm,usages:e.usages})}),revive(e){const{jwk:t,algorithm:r,usages:n}=e;return crypto.subtle.importKey("jwk",t,r,!0,n)}}},w={dataview:{test:e=>"DataView"===toStringTag(e),replace({buffer:e,byteOffset:t,byteLength:r},n){n.buffers||(n.buffers=[]);const a=n.buffers.indexOf(e);return-1!==a?{index:a,byteOffset:t,byteLength:r}:(n.buffers.push(e),{encoded:y(e),maxByteLength:e.maxByteLength,resizable:e.resizable,byteOffset:t,byteLength:r})},revive(e,t){t.buffers||(t.buffers=[]);const{byteOffset:r,byteLength:n,encoded:a,index:o,maxByteLength:s,resizable:i}=e;let c;return"index"in e?c=t.buffers[o]:(c=l(a,i?{maxByteLength:s}:s),t.buffers.push(c)),new DataView(c,r,n)}}},O={date:{test:e=>"Date"===toStringTag(e),replace(e){const t=e.getTime();return Number.isNaN(t)?"NaN":t},revive:e=>"NaN"===e?new Date(NaN):new Date(e)}},A={domexception:{test:e=>"DOMException"===toStringTag(e),replace:e=>({name:e.name,message:e.message}),revive:({message:e,name:t})=>new DOMException(e,t)}},T={};function create$5(e){T[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>e.is2D?{a:e.a,b:e.b,c:e.c,d:e.d,e:e.e,f:e.f}:{m11:e.m11,m12:e.m12,m13:e.m13,m14:e.m14,m21:e.m21,m22:e.m22,m23:e.m23,m24:e.m24,m31:e.m31,m32:e.m32,m33:e.m33,m34:e.m34,m41:e.m41,m42:e.m42,m43:e.m43,m44:e.m44},revive:t=>Object.hasOwn(t,"a")?new e([t.a,t.b,t.c,t.d,t.e,t.f]):new e([t.m11,t.m12,t.m13,t.m14,t.m21,t.m22,t.m23,t.m24,t.m31,t.m32,t.m33,t.m34,t.m41,t.m42,t.m43,t.m44])}}"undefined"!=typeof DOMMatrix&&create$5(DOMMatrix),"undefined"!=typeof DOMMatrixReadOnly&&create$5(DOMMatrixReadOnly);const S={};function create$4(e){S[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,z:e.z,w:e.w}),revive:({x:t,y:r,z:n,w:a})=>new e(t,r,n,a)}}"undefined"!=typeof DOMPoint&&create$4(DOMPoint),"undefined"!=typeof DOMPointReadOnly&&create$4(DOMPointReadOnly);const P={domquad:{test:e=>"DOMQuad"===toStringTag(e),replace:e=>({p1:e.p1,p2:e.p2,p3:e.p3,p4:e.p4}),revive:({p1:e,p2:t,p3:r,p4:n})=>new DOMQuad(e,t,r,n)}},x={};function create$3(e){x[e.name.toLowerCase()]={test:t=>toStringTag(t)===e.name,replace:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),revive:({x:t,y:r,width:n,height:a})=>new e(t,r,n,a)}}"undefined"!=typeof DOMRect&&create$3(DOMRect),"undefined"!=typeof DOMRectReadOnly&&create$3(DOMRectReadOnly);const E={encodedaudiochunk:{test:e=>"EncodedAudioChunk"===toStringTag(e),replace(e){const{type:t,timestamp:r,duration:n,byteLength:a}=e,o=new ArrayBuffer(a);return e.copyTo(o),{type:t,timestamp:r,duration:n,data:o}},revive:({type:e,timestamp:t,duration:r,data:n})=>new EncodedAudioChunk({type:e,timestamp:t,duration:r,data:new Uint8Array(n)})}},j={encodedvideochunk:{test:e=>"EncodedVideoChunk"===toStringTag(e),replace(e){const{type:t,timestamp:r,duration:n,byteLength:a}=e,o=new ArrayBuffer(a);return e.copyTo(o),{type:t,timestamp:r,duration:n,data:o}},revive:({type:e,timestamp:t,duration:r,data:n})=>new EncodedVideoChunk({type:e,timestamp:t,duration:r,data:new Uint8Array(n)})}},N={error:{test:e=>"Error"===toStringTag(e),replace:({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s})=>({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s}),revive(e){const t=new Error(e.message);return t.name=e.name,t.cause=e.cause,t.stack=e.stack,t.fileName=e.fileName,t.lineNumber=e.lineNumber,t.columnNumber=e.columnNumber,t}}},C={};function create$2(e){C[e.name.toLowerCase()]={test:t=>hasConstructorOf(t,e),replace:({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s,errors:i})=>({name:e,message:t,cause:r,stack:n,fileName:a,lineNumber:o,columnNumber:s,errors:i}),revive(t){const r="undefined"!=typeof AggregateError&&e===AggregateError?new e(t.errors,t.message):new e(t.message);return r.name=t.name,r.cause=t.cause,r.stack=t.stack,r.fileName=t.fileName,r.lineNumber=t.lineNumber,r.columnNumber=t.columnNumber,r}}}[TypeError,RangeError,SyntaxError,ReferenceError,EvalError,URIError].forEach(e=>create$2(e)),"undefined"!=typeof AggregateError&&create$2(AggregateError),"function"==typeof InternalError&&create$2(InternalError);const B={file:{test:e=>"File"===toStringTag(e),replace(e){const t=new XMLHttpRequest;if(t.overrideMimeType("text/plain; charset=x-user-defined"),t.open("GET",URL.createObjectURL(e),!1),t.send(),200!==t.status&&0!==t.status)throw new Error("Bad File access: "+t.status);return{type:e.type,stringContents:t.responseText,name:e.name,lastModified:e.lastModified}},revive:({name:e,type:t,stringContents:r,lastModified:n})=>new File([string2arraybuffer(r)],e,{type:t,lastModified:n}),replaceAsync:e=>new TypesonPromise(function(t,r){const n=new FileReader;n.addEventListener("load",function(){t({type:e.type,stringContents:arraybuffer2string(n.result),name:e.name,lastModified:e.lastModified})}),n.addEventListener("error",function(){r(n.error)}),n.readAsArrayBuffer(e)})}},I={file:B.file,filelist:{test:e=>"FileList"===toStringTag(e),replace(e){const t=[];for(let r=0;r<e.length;r++)t[r]=e.item(r);return t},revive(e){class FileList{constructor(){this._files=arguments[0],this.length=this._files.length}item(e){return this._files[e]}get[Symbol.toStringTag](){return"FileList"}}return new FileList(e)}}},_={imagebitmap:{test:e=>"ImageBitmap"===toStringTag(e)||e&&e.dataset&&"ImageBitmap"===e.dataset.toStringTag,replace(e){const t=document.createElement("canvas");return t.getContext("2d").drawImage(e,0,0),{width:e.width,height:e.height,dataURL:t.toDataURL()}},revive(e){const t="undefined"==typeof OffscreenCanvas?document.createElement("canvas"):new OffscreenCanvas(e.width,e.height),r=t.getContext("2d"),n=document.createElement("img");return n.addEventListener("load",function(){r.drawImage(n,0,0)}),n.src=e.dataURL,"undefined"==typeof OffscreenCanvas?t:t.transferToImageBitmap()},reviveAsync(e){const t=document.createElement("canvas"),r=t.getContext("2d"),n=document.createElement("img");return n.addEventListener("load",function(){r.drawImage(n,0,0)}),n.src=e.dataURL,new TypesonPromise(async(e,r)=>{try{e(await createImageBitmap(t))}catch(e){r(e)}})}}},U={imagedata:{test:e=>"ImageData"===toStringTag(e),replace:e=>({array:[...e.data],width:e.width,height:e.height}),revive:e=>new ImageData(new Uint8ClampedArray(e.array),e.width,e.height)}},M={infinity:{test:e=>e===1/0,replace:()=>"Infinity",revive:()=>1/0}},R={IntlCollator:{test:e=>hasConstructorOf(e,Intl.Collator),replace:e=>e.resolvedOptions(),revive:e=>new Intl.Collator(e.locale,e)},IntlDateTimeFormat:{test:e=>hasConstructorOf(e,Intl.DateTimeFormat),replace:e=>e.resolvedOptions(),revive:e=>new Intl.DateTimeFormat(e.locale,e)},IntlNumberFormat:{test:e=>hasConstructorOf(e,Intl.NumberFormat),replace:e=>e.resolvedOptions(),revive:e=>new Intl.NumberFormat(e.locale,e)}},k={map:{test:e=>"Map"===toStringTag(e),replace:e=>e.entries().toArray(),revive:e=>new Map(e)}},D={nan:{test:e=>Number.isNaN(e),replace:()=>"NaN",revive:()=>NaN}},L={negativeInfinity:{test:e=>e===-1/0,replace:()=>"-Infinity",revive:()=>-1/0}},F={negativeZero:{test:e=>Object.is(e,-0),replace:()=>0,revive:()=>-0}},$={nonbuiltinIgnore:{test:e=>e&&"object"==typeof e&&!Array.isArray(e)&&!["Object","Boolean","Number","String","Error","RegExp","Math","Date","Map","Set","JSON","ArrayBuffer","SharedArrayBuffer","DataView","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","Promise","String Iterator","Array Iterator","Map Iterator","Set Iterator","WeakMap","WeakSet","Atomics","Module"].includes(toStringTag(e)),replace(){}}},K={StringObject:{test:e=>"String"===toStringTag(e)&&"object"==typeof e,replace:String,revive:e=>new String(e)},BooleanObject:{test:e=>"Boolean"===toStringTag(e)&&"object"==typeof e,replace:e=>e.valueOf(),revive:e=>new Boolean(e)},NumberObject:{test:e=>"Number"===toStringTag(e)&&"object"==typeof e,replace(e){const t=e.valueOf();return Number.isNaN(t)?"NaN":t===1/0?"Infinity":t===-1/0?"-Infinity":Object.is(t,-0)?"-0":t},revive:e=>new Number("NaN"===e?NaN:"Infinity"===e?1/0:"-Infinity"===e?-1/0:"-0"===e?-0:e)}},q={promise:{test:e=>"Promise"===toStringTag(e),replaceAsync:e=>new TypesonPromise(async t=>{try{t({value:await e})}catch(e){t({error:e})}}),revive:e=>e.error?Promise.reject(e.error):Promise.resolve(e.value)}},W={quotaexceedederror:{test:e=>"QuotaExceededError"===toStringTag(e),replace:({message:e,quota:t,requested:r})=>({message:e,quota:t,requested:r}),revive({message:e,quota:t,requested:r}){const n={};return null!=t&&(n.quota=t),null!=r&&(n.requested=r),new QuotaExceededError(e,n)}}},z={regexp:{test:e=>"RegExp"===toStringTag(e),replace:e=>({source:e.source,flags:(e.global?"g":"")+(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.sticky?"y":"")+(e.unicode?"u":"")+(e.unicodeSets?"v":"")+(e.hasIndices?"d":"")+(e.dotAll?"s":"")}),revive:({source:e,flags:t})=>new RegExp(e,t)}},J={},V={resurrectable:{test:e=>e&&!Array.isArray(e)&&["object","function","symbol"].includes(typeof e),replace(e){const t=generateUUID();return J[t]=e,t},revive:e=>J[e]}},H={set:{test:e=>"Set"===toStringTag(e),replace:e=>e.values().toArray(),revive:e=>new Set(e)}},Q={symbol:{test:e=>"symbol"==typeof e,replace:e=>({global:void 0!==Symbol.keyFor(e),sym:String(e).slice(7,-1)}),revive:e=>e.global?Symbol.for(e.sym):Symbol(e.sym)}},G={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[],..."function"==typeof Float16Array?[Float16Array]:[]].forEach(e=>function create$1(e){const t=e.name;G[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace:e=>(0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e:e.slice(0)).buffer,revive:t=>"ArrayBuffer"===toStringTag(t)?new e(t):t}}(e));const X={};"function"==typeof Int8Array&&[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,..."function"==typeof BigInt64Array?[BigInt64Array,BigUint64Array]:[],..."function"==typeof Float16Array?[Float16Array]:[]].forEach(e=>function create(e){const t=e.name;X[t.toLowerCase()]={test:e=>toStringTag(e)===t,replace({buffer:e,byteOffset:t,length:r},n){n.buffers||(n.buffers=[]);const a=n.buffers.indexOf(e);return-1!==a?{index:a,byteOffset:t,length:r}:(n.buffers.push(e),{maxByteLength:e.maxByteLength,resizable:e.resizable,encoded:y(e),byteOffset:t,length:r})},revive(t,r){r.buffers||(r.buffers=[]);const{byteOffset:n,length:a,encoded:o,index:s,maxByteLength:i,resizable:c}=t;let u;return"index"in t?u=r.buffers[s]:(u=l(o,c?{maxByteLength:i}:void 0),r.buffers.push(u)),new e(u,n,a)}}}(e));const Y={undef:{test:(e,t)=>void 0===e&&(t.ownKeys||!("ownKeys"in t)),replace:()=>0,revive:()=>new Undefined}},Z={userObject:{test:e=>isUserObject(e),replace:e=>({...e}),revive:e=>e}},ee={videoframe:{test:e=>"VideoFrame"===toStringTag(e),replaceAsync:e=>new TypesonPromise(async(t,r)=>{try{const{format:r,codedWidth:n,codedHeight:a,timestamp:o,duration:s,visibleRect:i,displayWidth:c,displayHeight:u,colorSpace:y}=e,l=new ArrayBuffer(e.allocationSize());await e.copyTo(l),t({format:r,codedWidth:n,codedHeight:a,timestamp:o,duration:s,visibleRect:{x:i.x,y:i.y,width:i.width,height:i.height},displayWidth:c,displayHeight:u,colorSpace:{primaries:y.primaries,transfer:y.transfer,matrix:y.matrix,fullRange:y.fullRange},data:l})}catch(e){r(e)}}),revive:({format:e,codedWidth:t,codedHeight:r,timestamp:n,duration:a,visibleRect:o,displayWidth:s,displayHeight:i,colorSpace:c,data:u})=>new VideoFrame(new Uint8Array(u),{format:e,codedWidth:t,codedHeight:r,timestamp:n,duration:a,visibleRect:o,displayWidth:s,displayHeight:i,colorSpace:c})}},te={webtransporterror:{test:e=>"WebTransportError"===toStringTag(e),replace:({message:e,streamErrorCode:t})=>({message:e,streamErrorCode:t}),revive:({message:e,streamErrorCode:t})=>new WebTransportError({message:e,streamErrorCode:t})}},re=[{arrayNonindexKeys:{testPlainObjects:!0,test:(e,t)=>!!Array.isArray(e)&&(Object.keys(e).some(e=>String(Number(e))!==e)&&(t.iterateIn="object",t.addLength=!0),!0),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e),revive(e){if(Array.isArray(e))return e;const t=[];return Object.entries(e).forEach(([e,r])=>{t[e]=r}),t}}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ne=[D,M,L,F],ae=[Y,re,K,ne,O,N,C,z].concat("function"==typeof Map?k:[],"function"==typeof Set?H:[],"function"==typeof ArrayBuffer?p:[],"function"==typeof Uint8Array?X:[],"function"==typeof DataView?w:[],"undefined"!=typeof Intl?R:[],"undefined"!=typeof BigInt?[m,d]:[]),oe=[N,C],se=[ae,{arraybuffer:null},G],ie=[{sparseArrays:{testPlainObjects:!0,test:e=>Array.isArray(e),replace:(e,t)=>(t.iterateUnsetNumeric=!0,e)}},{sparseUndefined:{test:(e,t)=>void 0===e&&!1===t.ownKeys,replace:()=>0,revive(){}}}],ce=[Z,Y,re,K,ne,O,z,U,_,B,I,h,N,C].concat("function"==typeof Map?k:[],"function"==typeof Set?H:[],"function"==typeof ArrayBuffer?p:[],"function"==typeof Uint8Array?X:[],"function"==typeof DataView?w:[],"undefined"!=typeof crypto?v:[],"undefined"!=typeof BigInt?[m,d]:[],"undefined"!=typeof DOMException?A:[],"undefined"!=typeof QuotaExceededError?W:[],"undefined"!=typeof WebTransportError?te:[],"undefined"!=typeof DOMRect?x:[],"undefined"!=typeof DOMPoint?S:[],"undefined"!=typeof DOMQuad?P:[],"undefined"!=typeof DOMMatrix?T:[],"undefined"!=typeof AudioData?f:[],"undefined"!=typeof EncodedAudioChunk?E:[],"undefined"!=typeof EncodedVideoChunk?j:[],"undefined"!=typeof VideoFrame?ee:[]);const ue=ce.concat({checkDataCloneException:{test(e){const t={}.toString.call(e).slice(8,-1);if(["symbol","function"].includes(typeof e)||["Arguments","Module","Promise","WeakMap","WeakSet","Event","MessageChannel","MessagePort"].includes(t)||e&&e.constructor&&["MessageChannel","MessagePort"].includes(e.constructor.name)||["ArrayBuffer","DataView","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"].includes(t)&&function isBufferDetached(e){if("boolean"==typeof e.detached)return e.detached;if(0!==e.byteLength)return!1;try{return new Uint8Array(e),!1}catch{return!0}}(e)||e&&"object"==typeof e&&"number"==typeof e.nodeType&&"function"==typeof e.insertBefore)throw new DOMException("The object cannot be cloned.","DataCloneError");return!1}}}),ye=[ie,Y],le=[ae];export{s as JSON_TYPES,Typeson,TypesonPromise,Undefined,re as arrayNonindexKeys,p as arraybuffer,f as audiodata,m as bigint,d as bigintObject,h as blob,ae as builtin,b as cloneable,v as cryptokey,w as dataview,O as date,A as domexception,T as dommatrix,S as dompoint,P as domquad,x as domrect,E as encodedaudiochunk,j as encodedvideochunk,N as error,C as errors,escapeKeyPathComponent,B as file,I as filelist,getByKeyPath,getJSONType,hasConstructorOf,_ as imagebitmap,U as imagedata,M as infinity,R as intlTypes,isObject,isPlainObject,isThenable,isUserObject,k as map,D as nan,L as negativeInfinity,F as negativeZero,$ as nonbuiltinIgnore,oe as postmessage,K as primitiveObjects,q as promise,W as quotaexceedederror,z as regexp,V as resurrectable,H as set,setAtKeyPath,se as socketio,ie as sparseUndefined,ne as specialNumbers,ce as structuredCloning,ue as structuredCloningThrowing,Q as symbol,toStringTag,X as typedArrays,G as typedArraysSocketio,Y as undef,ye as undefPreset,unescapeKeyPathComponent,le as universal,Z as userObject,ee as videoframe,te as webtransporterror};
|
|
7
7
|
//# sourceMappingURL=index.min.js.map
|