@gjsify/utils 0.4.10 → 0.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";const{toString:e}=Object.prototype;function classOf(t){return e.call(t).slice(8,-1)}function throwDataCloneError(e){let t=globalThis.DOMException;if(typeof t==`function`)throw new t(e,`DataCloneError`);let n=Error(e);throw n.name=`DataCloneError`,n}const t={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},n=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]);function internalClone(e,r,i){if(e==null)return e;let a=typeof e;if(a===`boolean`||a===`number`||a===`string`||a===`bigint`)return e;a===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),a===`function`&&throwDataCloneError(`Function cannot be cloned`);let o=e;if(r.has(o))return r.get(o);let s=classOf(o);if(s===`Date`)return new Date(o.getTime());if(s===`RegExp`)return new RegExp(o.source,o.flags);if(s===`Boolean`||s===`Number`||s===`String`)return Object(o.valueOf());if(s===`BigInt`)return Object(BigInt.prototype.valueOf.call(o));if(o instanceof Error){let e=o,n=e.constructor?.name,a=new(n&&t[n]||t[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,`cause`,{value:internalClone(e.cause,r,i),writable:!0,enumerable:!1,configurable:!0}),a}if(s===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=o;return new e(t.message,t.name)}}if(s===`ArrayBuffer`){let e=o;if(i&&i.transferred.has(e)){let t=i.transferred.get(e);return r.set(o,t),t}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let t=e.slice(0);return r.set(o,t),t}if(s===`SharedArrayBuffer`)return o;if(s===`DataView`){let e=o,t=i?.viewSnapshots.get(o),n=internalClone(e.buffer,r,i),a=t?t.byteOffset:e.byteOffset,s=t?t.byteLength:e.byteLength,c=new DataView(n,a,s);return r.set(o,c),c}if(n.has(s)){let e=o,t=i?.viewSnapshots.get(o),n=internalClone(e.buffer,r,i),a=e.constructor,s=new a(n,t?t.byteOffset:e.byteOffset,t?t.length:e.length);return r.set(o,s),s}if(s===`Map`){let e=new Map;r.set(o,e);for(let[t,n]of o)e.set(internalClone(t,r,i),internalClone(n,r,i));return e}if(s===`Set`){let e=new Set;r.set(o,e);for(let t of o)e.add(internalClone(t,r,i));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&o instanceof n){let e=o;return new n([o],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&o instanceof t)return new t([o],{type:o.type})}if(o instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),o instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),o instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&o instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),s===`Array`){let e=o,t=[];r.set(o,t);for(let n=0;n<e.length;n++)n in e&&(t[n]=internalClone(e[n],r,i));return t}if(s===`Object`||typeof o==`object`){let e={};r.set(o,e);for(let t of Object.keys(o))e[t]=internalClone(o[t],r,i);return e}throwDataCloneError(`${s} cannot be cloned`)}function structuredClone(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}function snapshotViewsBackedByTransferredBuffers(e,t,r,i){if(typeof e!=`object`||!e)return;let a=e;if(i.has(a))return;i.add(a);let o=classOf(a);if(o===`DataView`){let e=a;t.has(e.buffer)&&r.set(a,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(n.has(o)){let e=a;t.has(e.buffer)&&r.set(a,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(a)){for(let e=0;e<a.length;e++)e in a&&snapshotViewsBackedByTransferredBuffers(a[e],t,r,i);return}if(o===`Map`){for(let[e,n]of a)snapshotViewsBackedByTransferredBuffers(e,t,r,i),snapshotViewsBackedByTransferredBuffers(n,t,r,i);return}if(o===`Set`){for(let e of a)snapshotViewsBackedByTransferredBuffers(e,t,r,i);return}if(o===`Object`)for(let e of Object.keys(a))snapshotViewsBackedByTransferredBuffers(a[e],t,r,i)}export{structuredClone};
1
+ import"./_virtual/_rolldown/runtime.js";const{toString:e}=Object.prototype;function classOf(t){return e.call(t).slice(8,-1)}function throwDataCloneError(e){let t=globalThis.DOMException;if(typeof t==`function`)throw new t(e,`DataCloneError`);let n=Error(e);throw n.name=`DataCloneError`,n}const t={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},n=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]);function internalClone(e,r,i){if(e==null)return e;let a=typeof e;if(a===`boolean`||a===`number`||a===`string`||a===`bigint`)return e;a===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),a===`function`&&throwDataCloneError(`Function cannot be cloned`);let o=e;if(r.has(o))return r.get(o);let s=classOf(o);if(s===`Date`)return new Date(o.getTime());if(s===`RegExp`)return new RegExp(o.source,o.flags);if(s===`Boolean`||s===`Number`||s===`String`)return Object(o.valueOf());if(s===`BigInt`)return Object(BigInt.prototype.valueOf.call(o));if(o instanceof Error){let e=o,n=e.constructor?.name,a=new(n&&t[n]||t[e.name]||Error)(e.message);return a.name=e.name,`cause`in e&&Object.defineProperty(a,`cause`,{value:internalClone(e.cause,r,i),writable:!0,enumerable:!1,configurable:!0}),a}if(s===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=o;return new e(t.message,t.name)}}if(s===`ArrayBuffer`){let e=o;if(i&&i.transferred.has(e)){let t=i.transferred.get(e);return r.set(o,t),t}(e.detached===!0||e.byteLength===0&&e.detached)&&throwDataCloneError(`ArrayBuffer is detached and cannot be cloned`);let t=e.slice(0);return r.set(o,t),t}if(s===`SharedArrayBuffer`||o&&typeof o==`object`&&o.constructor?.name===`SharedBuffer`)return o;if(s===`DataView`){let e=o,t=i?.viewSnapshots.get(o),n=internalClone(e.buffer,r,i),a=t?t.byteOffset:e.byteOffset,s=t?t.byteLength:e.byteLength,c=new DataView(n,a,s);return r.set(o,c),c}if(n.has(s)){let e=o,t=i?.viewSnapshots.get(o),n=internalClone(e.buffer,r,i),a=e.constructor,s=new a(n,t?t.byteOffset:e.byteOffset,t?t.length:e.length);return r.set(o,s),s}if(s===`Map`){let e=new Map;r.set(o,e);for(let[t,n]of o)e.set(internalClone(t,r,i),internalClone(n,r,i));return e}if(s===`Set`){let e=new Set;r.set(o,e);for(let t of o)e.add(internalClone(t,r,i));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&o instanceof n){let e=o;return new n([o],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&o instanceof t)return new t([o],{type:o.type})}if(o instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),o instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),o instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&o instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),s===`Array`){let e=o,t=[];r.set(o,t);for(let n=0;n<e.length;n++)n in e&&(t[n]=internalClone(e[n],r,i));return t}if(s===`Object`||typeof o==`object`){let e={};r.set(o,e);for(let t of Object.keys(o))e[t]=internalClone(o[t],r,i);return e}throwDataCloneError(`${s} cannot be cloned`)}function structuredClone(e,t){let n=t?.transfer;if(!n||n.length===0)return internalClone(e,new Map);let r=new Set;for(let e of n)if(classOf(e)===`ArrayBuffer`){let t=e;t.detached===!0&&throwDataCloneError(`ArrayBuffer in transfer list is detached`),r.add(t)}let i=new Map;r.size>0&&snapshotViewsBackedByTransferredBuffers(e,r,i,new Set);let a=new Map;for(let e of r){let t=e;typeof t.transfer!=`function`&&throwDataCloneError(`ArrayBuffer.prototype.transfer() not available — runtime is not SM140+`),a.set(e,t.transfer())}return internalClone(e,new Map,{transferred:a,viewSnapshots:i})}function snapshotViewsBackedByTransferredBuffers(e,t,r,i){if(typeof e!=`object`||!e)return;let a=e;if(i.has(a))return;i.add(a);let o=classOf(a);if(o===`DataView`){let e=a;t.has(e.buffer)&&r.set(a,{byteOffset:e.byteOffset,length:0,byteLength:e.byteLength});return}if(n.has(o)){let e=a;t.has(e.buffer)&&r.set(a,{byteOffset:e.byteOffset,length:e.length,byteLength:e.byteLength});return}if(Array.isArray(a)){for(let e=0;e<a.length;e++)e in a&&snapshotViewsBackedByTransferredBuffers(a[e],t,r,i);return}if(o===`Map`){for(let[e,n]of a)snapshotViewsBackedByTransferredBuffers(e,t,r,i),snapshotViewsBackedByTransferredBuffers(n,t,r,i);return}if(o===`Set`){for(let e of a)snapshotViewsBackedByTransferredBuffers(e,t,r,i);return}if(o===`Object`)for(let e of Object.keys(a))snapshotViewsBackedByTransferredBuffers(a[e],t,r,i)}export{structuredClone};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/utils",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Utils module for gjsify",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "fs"
36
36
  ],
37
37
  "devDependencies": {
38
- "@gjsify/cli": "^0.4.10",
38
+ "@gjsify/cli": "^0.4.12",
39
39
  "typescript": "^6.0.3"
40
40
  },
41
41
  "dependencies": {