@gjsify/utils 0.3.19 → 0.3.21

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/lib/esm/base64.js CHANGED
@@ -1 +1 @@
1
- const e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,t=new Uint8Array(256);for(let n=0;n<64;n++)t[e.charCodeAt(n)]=n;function n(e){if(typeof globalThis.atob==`function`)return globalThis.atob(e);let n=e.replace(/[=\s]/g,``),r=``,i=0,a=0;for(let e=0;e<n.length;e++)i=i<<6|t[n.charCodeAt(e)],a+=6,a>=8&&(a-=8,r+=String.fromCharCode(i>>a&255));return r}function r(t){if(typeof globalThis.btoa==`function`)return globalThis.btoa(t);let n=``,r=0;for(;r+2<t.length;r+=3){let i=t.charCodeAt(r)<<16|t.charCodeAt(r+1)<<8|t.charCodeAt(r+2);n+=e[i>>18&63]+e[i>>12&63]+e[i>>6&63]+e[i&63]}if(r+1===t.length){let i=t.charCodeAt(r)<<16;n+=e[i>>18&63]+e[i>>12&63]+`==`}else if(r+2===t.length){let i=t.charCodeAt(r)<<16|t.charCodeAt(r+1)<<8;n+=e[i>>18&63]+e[i>>12&63]+e[i>>6&63]+`=`}return n}function i(e){let n=e.replace(/[=\s]/g,``),r=new Uint8Array(n.length*3>>2),i=0,a=0,o=0;for(let e=0;e<n.length;e++)i=i<<6|t[n.charCodeAt(e)],a+=6,a>=8&&(a-=8,r[o++]=i>>a&255);return r.subarray(0,o)}function a(t){let n=``,r=t.length;for(let i=0;i<r;i+=3){let a=t[i],o=i+1<r?t[i+1]:0,s=i+2<r?t[i+2]:0;n+=e[a>>2],n+=e[(a&3)<<4|o>>4],n+=i+1<r?e[(o&15)<<2|s>>6]:`=`,n+=i+2<r?e[s&63]:`=`}return n}export{n as atobPolyfill,i as base64Decode,a as base64Encode,r as btoaPolyfill};
1
+ const e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,t=new Uint8Array(256);for(let n=0;n<64;n++)t[e.charCodeAt(n)]=n;function atobPolyfill(e){if(typeof globalThis.atob==`function`)return globalThis.atob(e);let n=e.replace(/[=\s]/g,``),r=``,i=0,a=0;for(let e=0;e<n.length;e++)i=i<<6|t[n.charCodeAt(e)],a+=6,a>=8&&(a-=8,r+=String.fromCharCode(i>>a&255));return r}function btoaPolyfill(t){if(typeof globalThis.btoa==`function`)return globalThis.btoa(t);let n=``,r=0;for(;r+2<t.length;r+=3){let i=t.charCodeAt(r)<<16|t.charCodeAt(r+1)<<8|t.charCodeAt(r+2);n+=e[i>>18&63]+e[i>>12&63]+e[i>>6&63]+e[i&63]}if(r+1===t.length){let i=t.charCodeAt(r)<<16;n+=e[i>>18&63]+e[i>>12&63]+`==`}else if(r+2===t.length){let i=t.charCodeAt(r)<<16|t.charCodeAt(r+1)<<8;n+=e[i>>18&63]+e[i>>12&63]+e[i>>6&63]+`=`}return n}function base64Decode(e){let n=e.replace(/[=\s]/g,``),r=new Uint8Array(n.length*3>>2),i=0,a=0,o=0;for(let e=0;e<n.length;e++)i=i<<6|t[n.charCodeAt(e)],a+=6,a>=8&&(a-=8,r[o++]=i>>a&255);return r.subarray(0,o)}function base64Encode(t){let n=``,r=t.length;for(let i=0;i<r;i+=3){let a=t[i],o=i+1<r?t[i+1]:0,s=i+2<r?t[i+2]:0;n+=e[a>>2],n+=e[(a&3)<<4|o>>4],n+=i+1<r?e[(o&15)<<2|s>>6]:`=`,n+=i+2<r?e[s&63]:`=`}return n}export{atobPolyfill,base64Decode,base64Encode,btoaPolyfill};
@@ -1 +1 @@
1
- function e(e){return imports.byteArray.fromGBytes(e)}export{e as gbytesToUint8Array};
1
+ function gbytesToUint8Array(e){return imports.byteArray.fromGBytes(e)}export{gbytesToUint8Array};
@@ -1 +1 @@
1
- function e(e){return new Proxy(e,{apply(e,t,n){let r=Reflect.construct(e,n,e);for(let e of Reflect.ownKeys(r)){let n=Object.getOwnPropertyDescriptor(r,e);n&&Object.defineProperty(t,e,n)}return t}})}export{e as makeCallable};
1
+ function makeCallable(e){return new Proxy(e,{apply(e,t,n){let r=Reflect.construct(e,n,e);for(let e of Reflect.ownKeys(r)){let n=Object.getOwnPropertyDescriptor(r,e);n&&Object.defineProperty(t,e,n)}return t}})}export{makeCallable};
package/lib/esm/cli.js CHANGED
@@ -1 +1 @@
1
- import e from"@girs/glib-2.0";const t=imports.byteArray,n=n=>{let[r,i,a,o]=e.spawn_command_line_sync(n);if(a.byteLength)throw Error(t.toString(a));return t.toString(i)};export{n as cli};
1
+ import e from"@girs/glib-2.0";const t=imports.byteArray,cli=n=>{let[r,i,a,o]=e.spawn_command_line_sync(n);if(a.byteLength)throw Error(t.toString(a));return t.toString(i)};export{cli};
package/lib/esm/defer.js CHANGED
@@ -1 +1 @@
1
- function e(e,t,...n){setTimeout(()=>e.emit(t,...n),0)}export{e as deferEmit};
1
+ function deferEmit(e,t,...n){setTimeout(()=>e.emit(t,...n),0)}export{deferEmit};
@@ -1 +1 @@
1
- const e=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`];function t(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function n(t){let n=(``+t).toLowerCase().replace(/-/g,``);if(!e.includes(n))throw TypeError(`Unknown encoding: ${t}`)}export{n as checkEncoding,t as normalizeEncoding};
1
+ const e=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`];function normalizeEncoding(e){if(!e||e===`utf8`||e===`utf-8`)return`utf8`;switch((``+e).toLowerCase().replace(/-/g,``)){case`utf8`:return`utf8`;case`ascii`:return`ascii`;case`latin1`:case`binary`:return`latin1`;case`base64`:return`base64`;case`base64url`:return`base64url`;case`hex`:return`hex`;case`ucs2`:case`utf16le`:return`utf16le`;default:return`utf8`}}function checkEncoding(t){let n=(``+t).toLowerCase().replace(/-/g,``);if(!e.includes(n))throw TypeError(`Unknown encoding: ${t}`)}export{checkEncoding,normalizeEncoding};
package/lib/esm/error.js CHANGED
@@ -1 +1 @@
1
- const e=e=>{Error.captureStackTrace||(Error.captureStackTrace=function(e,t){let n=Error();Object.defineProperty(t||e,`stack`,{configurable:!0,get:function(){var e=n.stack;return Object.defineProperty(this,`stack`,{value:e}),e}})})};export{e as initErrorV8Methods};
1
+ const initErrorV8Methods=e=>{Error.captureStackTrace||(Error.captureStackTrace=function(e,t){let n=Error();Object.defineProperty(t||e,`stack`,{configurable:!0,get:function(){var e=n.stack;return Object.defineProperty(this,`stack`,{value:e}),e}})})};export{initErrorV8Methods};
package/lib/esm/file.js CHANGED
@@ -1 +1 @@
1
- import e from"@girs/glib-2.0";const t=imports.byteArray,n=n=>{let[r,i]=e.file_get_contents(n);if(r)return JSON.parse(t.toString(i));throw Error(`Error on require "${n}"`)};export{n as readJSON};
1
+ import e from"@girs/glib-2.0";const t=imports.byteArray,readJSON=n=>{let[r,i]=e.file_get_contents(n);if(r)return JSON.parse(t.toString(i));throw Error(`Error on require "${n}"`)};export{readJSON};
package/lib/esm/fs.js CHANGED
@@ -1 +1 @@
1
- import e from"@girs/gio-2.0";import t from"@girs/giounix-2.0";const n=e=>{try{return t.InputStream.new(e,!1).close(null),!0}catch{return!1}};function r(t){return typeof t!=`string`||t===``?!1:e.File.new_for_path(t).query_exists(null)}export{n as existsFD,r as existsSync};
1
+ import e from"@girs/gio-2.0";import t from"@girs/giounix-2.0";const existsFD=e=>{try{return t.InputStream.new(e,!1).close(null),!0}catch{return!1}};function existsSync(t){return typeof t!=`string`||t===``?!1:e.File.new_for_path(t).query_exists(null)}export{existsFD,existsSync};
@@ -1 +1 @@
1
- const e={0:`EIO`,1:`ENOENT`,2:`EEXIST`,3:`EISDIR`,4:`ENOTDIR`,5:`ENOTEMPTY`,6:`ENOENT`,7:`ENFILE`,9:`EACCES`,10:`ENFILE`,11:`EINVAL`,12:`ELOOP`,13:`ENOSPC`,14:`EACCES`,17:`ELOOP`,19:`ENOSPC`,20:`ENOTSUP`,22:`EMFILE`,24:`EROFS`,25:`ECANCELED`,26:`EBUSY`,27:`ETIMEDOUT`,28:`EHOSTUNREACH`,30:`EHOSTUNREACH`,31:`ENETUNREACH`,32:`ECONNREFUSED`,33:`EADDRINUSE`,34:`ECONNRESET`,36:`EPIPE`,38:`ENETUNREACH`,39:`ECONNREFUSED`,40:`ECONNREFUSED`,41:`EACCES`,44:`ECONNRESET`,46:`EMSGSIZE`};function t(t,n,r){let i=t,a=e[i?.code??-1]||`EIO`,o=`${a}: ${i?.message||`unknown error`}, ${n}`;r?.path&&(o+=` '${r.path}'`),r?.dest&&(o+=` -> '${r.dest}'`),r?.address&&(o+=` ${r.address}`),r?.port!=null&&(o+=`:${r.port}`);let s=Error(o);return s.code=a,s.syscall=n,s.errno=-(i?.code||0),r?.path&&(s.path=r.path),r?.address&&(s.address=r.address),r?.port!=null&&(s.port=r.port),s}function n(e){let t=e;return t?.code===1||t?.code===`ENOENT`}const r={0:`EEXIST`,1:`EISDIR`,2:`EACCES`,3:`ENAMETOOLONG`,4:`ENOENT`,5:`ENOTDIR`,6:`ENXIO`,7:`ENODEV`,8:`EROFS`,11:`ELOOP`,12:`ENOSPC`,13:`ENOMEM`,14:`EMFILE`,15:`ENFILE`,16:`EBADF`,17:`EINVAL`,18:`EPIPE`,21:`EIO`,22:`EPERM`,24:`EIO`};function i(e,t,n){let i=e,a=r[i?.code??-1]??`EIO`,o=`${a}: ${i?.message||`unknown error`}, ${t}`;n?.path&&(o+=` '${n.path}'`),n?.dest&&(o+=` -> '${n.dest}'`);let s=Error(o);return s.code=a,s.syscall=t,s.errno=-(i?.code||0),n?.path&&(s.path=n.path),s}export{e as GIO_ERROR_TO_NODE,r as GLIB_FILE_ERROR_TO_NODE,i as createGLibFileError,t as createNodeError,n as isNotFoundError};
1
+ const e={0:`EIO`,1:`ENOENT`,2:`EEXIST`,3:`EISDIR`,4:`ENOTDIR`,5:`ENOTEMPTY`,6:`ENOENT`,7:`ENFILE`,9:`EACCES`,10:`ENFILE`,11:`EINVAL`,12:`ELOOP`,13:`ENOSPC`,14:`EACCES`,17:`ELOOP`,19:`ENOSPC`,20:`ENOTSUP`,22:`EMFILE`,24:`EROFS`,25:`ECANCELED`,26:`EBUSY`,27:`ETIMEDOUT`,28:`EHOSTUNREACH`,30:`EHOSTUNREACH`,31:`ENETUNREACH`,32:`ECONNREFUSED`,33:`EADDRINUSE`,34:`ECONNRESET`,36:`EPIPE`,38:`ENETUNREACH`,39:`ECONNREFUSED`,40:`ECONNREFUSED`,41:`EACCES`,44:`ECONNRESET`,46:`EMSGSIZE`};function createNodeError(t,n,r){let i=t,a=e[i?.code??-1]||`EIO`,o=`${a}: ${i?.message||`unknown error`}, ${n}`;r?.path&&(o+=` '${r.path}'`),r?.dest&&(o+=` -> '${r.dest}'`),r?.address&&(o+=` ${r.address}`),r?.port!=null&&(o+=`:${r.port}`);let s=Error(o);return s.code=a,s.syscall=n,s.errno=-(i?.code||0),r?.path&&(s.path=r.path),r?.address&&(s.address=r.address),r?.port!=null&&(s.port=r.port),s}function isNotFoundError(e){let t=e;return t?.code===1||t?.code===`ENOENT`}const t={0:`EEXIST`,1:`EISDIR`,2:`EACCES`,3:`ENAMETOOLONG`,4:`ENOENT`,5:`ENOTDIR`,6:`ENXIO`,7:`ENODEV`,8:`EROFS`,11:`ELOOP`,12:`ENOSPC`,13:`ENOMEM`,14:`EMFILE`,15:`ENFILE`,16:`EBADF`,17:`EINVAL`,18:`EPIPE`,21:`EIO`,22:`EPERM`,24:`EIO`};function createGLibFileError(e,n,r){let i=e,a=t[i?.code??-1]??`EIO`,o=`${a}: ${i?.message||`unknown error`}, ${n}`;r?.path&&(o+=` '${r.path}'`),r?.dest&&(o+=` -> '${r.dest}'`);let s=Error(o);return s.code=a,s.syscall=n,s.errno=-(i?.code||0),r?.path&&(s.path=r.path),s}export{e as GIO_ERROR_TO_NODE,t as GLIB_FILE_ERROR_TO_NODE,createGLibFileError,createNodeError,isNotFoundError};
package/lib/esm/gio.js CHANGED
@@ -1 +1 @@
1
- import e from"@girs/glib-2.0";const t=imports.byteArray;function n(e,t,n,...r){return new Promise((i,a)=>{e[t](...r,(t,r)=>{try{i(e[n](r))}catch(e){a(e)}})})}async function r(n,r=4096,i=e.PRIORITY_DEFAULT,a=null){return new Promise((e,o)=>{n.read_bytes_async(r,i,a,(r,i)=>{try{let r=n.read_bytes_finish(i);return r.get_size()===0?e(null):e(t.fromGBytes(r))}catch(e){o(e)}})})}async function*i(t,n=4096,i=e.PRIORITY_DEFAULT,a=null){let o;for(;(o=await r(t,n,i,a))!==null;)yield o}export{n as gioAsync,i as inputStreamAsyncIterator,r as readBytesAsync};
1
+ import e from"@girs/glib-2.0";const t=imports.byteArray;function gioAsync(e,t,n,...r){return new Promise((i,a)=>{e[t](...r,(t,r)=>{try{i(e[n](r))}catch(e){a(e)}})})}async function readBytesAsync(n,r=4096,i=e.PRIORITY_DEFAULT,a=null){return new Promise((e,o)=>{n.read_bytes_async(r,i,a,(r,i)=>{try{let r=n.read_bytes_finish(i);return r.get_size()===0?e(null):e(t.fromGBytes(r))}catch(e){o(e)}})})}async function*inputStreamAsyncIterator(t,n=4096,r=e.PRIORITY_DEFAULT,i=null){let a;for(;(a=await readBytesAsync(t,n,r,i))!==null;)yield a}export{gioAsync,inputStreamAsyncIterator,readBytesAsync};
@@ -1 +1 @@
1
- function e(e,t){globalThis[e]===void 0&&(globalThis[e]=t)}export{e as registerGlobal};
1
+ function registerGlobal(e,t){globalThis[e]===void 0&&(globalThis[e]=t)}export{registerGlobal};
@@ -1 +1 @@
1
- let e=!1,t=null;function n(){let n=globalThis.imports;if(!n)return;if(e)return t;let r=n.gi.GLib;if(t=new r.MainLoop(null,!1),e=!0,r.main_depth()===0)try{t.runAsync()}catch{}return t}function r(){t&&=(t.quit(),e=!1,null)}export{n as ensureMainLoop,r as quitMainLoop};
1
+ let e=!1,t=null;function ensureMainLoop(){let n=globalThis.imports;if(!n)return;if(e)return t;let r=n.gi.GLib;if(t=new r.MainLoop(null,!1),e=!0,r.main_depth()===0)try{t.runAsync()}catch{}return t}function quitMainLoop(){t&&=(t.quit(),e=!1,null)}export{ensureMainLoop,quitMainLoop};
@@ -1 +1 @@
1
- const e=e=>{let t=e?`Not implemented: ${e}`:`Not implemented`;throw Error(t)},t=e=>{let t=e?`Not implemented: ${e}`:`Not implemented`;return console.warn(t),t};export{e as notImplemented,t as warnNotImplemented};
1
+ const notImplemented=e=>{let t=e?`Not implemented: ${e}`:`Not implemented`;throw Error(t)},warnNotImplemented=e=>{let t=e?`Not implemented: ${e}`:`Not implemented`;return console.warn(t),t};export{notImplemented,warnNotImplemented};
@@ -1 +1 @@
1
- const e=e=>{Promise.resolve().then(e)};export{e as queueMicrotask};
1
+ const queueMicrotask=e=>{Promise.resolve().then(e)};export{queueMicrotask};
@@ -1 +1 @@
1
- const e=[];let t=!1;function n(r){let i=Math.min(64,e.length);for(let t=0;t<i;t++){let t=e.shift();try{t()}catch(e){try{r.log_default_handler(`gjsify-nextTick`,r.LogLevelFlags.LEVEL_WARNING,String(e?.stack||e),null)}catch{}}}e.length>0?r.timeout_add(r.PRIORITY_DEFAULT,1,()=>(n(r),!1)):t=!1}function r(r){let i=globalThis.imports?.gi?.GLib;return i?.timeout_add?(e.push(r),t||(t=!0,i.timeout_add(i.PRIORITY_DEFAULT,0,()=>(n(i),!1))),!0):!1}function i(){e.length=0,t=!1}const a=(e,...t)=>{let n=t.length>0?()=>e(...t):e;if(!r(n)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...t);return}if(typeof queueMicrotask==`function`){queueMicrotask(n);return}Promise.resolve().then(n)}};export{i as __resetBurstStateForTests,a as nextTick};
1
+ const e=[];let t=!1;function drainOnce(n){let r=Math.min(64,e.length);for(let t=0;t<r;t++){let t=e.shift();try{t()}catch(e){try{n.log_default_handler(`gjsify-nextTick`,n.LogLevelFlags.LEVEL_WARNING,String(e?.stack||e),null)}catch{}}}e.length>0?n.timeout_add(n.PRIORITY_DEFAULT,1,()=>(drainOnce(n),!1)):t=!1}function tryGLibTimeout(n){let r=globalThis.imports?.gi?.GLib;return r?.timeout_add?(e.push(n),t||(t=!0,r.timeout_add(r.PRIORITY_DEFAULT,0,()=>(drainOnce(r),!1))),!0):!1}function __resetBurstStateForTests(){e.length=0,t=!1}const nextTick=(e,...t)=>{let n=t.length>0?()=>e(...t):e;if(!tryGLibTimeout(n)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...t);return}if(typeof queueMicrotask==`function`){queueMicrotask(n);return}Promise.resolve().then(n)}};export{__resetBurstStateForTests,nextTick};
package/lib/esm/path.js CHANGED
@@ -1 +1 @@
1
- import e from"@girs/glib-2.0";import t from"@girs/gio-2.0";const{File:n}=t,r=e=>{let n=e.query_info(`standard::`,t.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);return n.get_is_symlink()?e.get_parent().resolve_relative_path(n.get_symlink_target()).get_parent():e.get_parent()},i=(e,...t)=>{let r=n.new_for_path(e);for(let e of t)r=r.resolve_relative_path(e);return r},a=()=>{let t=e.get_current_dir();return n.new_for_path(t).resolve_relative_path(imports.system.programInvocationName)},o=()=>r(a()).get_path(),s=()=>{let t=e.get_current_dir();return/^\//.test(t)?`/`:`\\`},c=()=>{let e=n.new_for_path(o()),t=!1;do{e=e.resolve_relative_path(`..`);let n=e.resolve_relative_path(`node_modules`);t=n.query_exists(null),t&&(e=n)}while(e.has_parent(null)&&!t);return e};export{c as getNodeModulesPath,s as getPathSeparator,o as getProgramDir,a as getProgramExe,i as resolve};
1
+ import e from"@girs/glib-2.0";import t from"@girs/gio-2.0";const{File:n}=t,_getProgramDir=e=>{let n=e.query_info(`standard::`,t.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);return n.get_is_symlink()?e.get_parent().resolve_relative_path(n.get_symlink_target()).get_parent():e.get_parent()},resolve=(e,...t)=>{let r=n.new_for_path(e);for(let e of t)r=r.resolve_relative_path(e);return r},getProgramExe=()=>{let t=e.get_current_dir();return n.new_for_path(t).resolve_relative_path(imports.system.programInvocationName)},getProgramDir=()=>_getProgramDir(getProgramExe()).get_path(),getPathSeparator=()=>{let t=e.get_current_dir();return/^\//.test(t)?`/`:`\\`},getNodeModulesPath=()=>{let e=n.new_for_path(getProgramDir()),t=!1;do{e=e.resolve_relative_path(`..`);let n=e.resolve_relative_path(`node_modules`);t=n.query_exists(null),t&&(e=n)}while(e.has_parent(null)&&!t);return e};export{getNodeModulesPath,getPathSeparator,getProgramDir,getProgramExe,resolve};
@@ -1 +1 @@
1
- const{toString:e}=Object.prototype;function t(t){return e.call(t).slice(8,-1)}function n(e){let t=globalThis.DOMException;if(typeof t==`function`)throw new t(e,`DataCloneError`);let n=Error(e);throw n.name=`DataCloneError`,n}const r={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},i=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]);function a(e,o){if(e==null)return e;let s=typeof e;if(s===`boolean`||s===`number`||s===`string`||s===`bigint`)return e;s===`symbol`&&n(`Symbol cannot be cloned`),s===`function`&&n(`Function cannot be cloned`);let c=e;if(o.has(c))return o.get(c);let l=t(c);if(l===`Date`)return new Date(c.getTime());if(l===`RegExp`)return new RegExp(c.source,c.flags);if(l===`Boolean`||l===`Number`||l===`String`)return Object(c.valueOf());if(l===`BigInt`)return Object(BigInt.prototype.valueOf.call(c));if(c instanceof Error){let e=c,t=e.constructor?.name,n=new(t&&r[t]||r[e.name]||Error)(e.message);return n.name=e.name,`cause`in e&&Object.defineProperty(n,`cause`,{value:a(e.cause,o),writable:!0,enumerable:!1,configurable:!0}),n}if(l===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=c;return new e(t.message,t.name)}}if(l===`ArrayBuffer`){let e=c.slice(0);return o.set(c,e),e}if(l===`SharedArrayBuffer`)return c;if(l===`DataView`){let e=c,t=a(e.buffer,o),n=new DataView(t,e.byteOffset,e.byteLength);return o.set(c,n),n}if(i.has(l)){let e=c,t=a(e.buffer,o),n=e.constructor,r=new n(t,e.byteOffset,e.length);return o.set(c,r),r}if(l===`Map`){let e=new Map;o.set(c,e);for(let[t,n]of c)e.set(a(t,o),a(n,o));return e}if(l===`Set`){let e=new Set;o.set(c,e);for(let t of c)e.add(a(t,o));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&c instanceof n){let e=c;return new n([c],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&c instanceof t)return new t([c],{type:c.type})}if(c instanceof WeakMap&&n(`WeakMap cannot be cloned`),c instanceof WeakSet&&n(`WeakSet cannot be cloned`),c instanceof WeakRef&&n(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&c instanceof Promise&&n(`Promise cannot be cloned`),l===`Array`){let e=c,t=[];o.set(c,t);for(let n=0;n<e.length;n++)n in e&&(t[n]=a(e[n],o));return t}if(l===`Object`||typeof c==`object`){let e={};o.set(c,e);for(let t of Object.keys(c))e[t]=a(c[t],o);return e}n(`${l} cannot be cloned`)}function o(e,t){return a(e,new Map)}export{o as structuredClone};
1
+ 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){if(e==null)return e;let i=typeof e;if(i===`boolean`||i===`number`||i===`string`||i===`bigint`)return e;i===`symbol`&&throwDataCloneError(`Symbol cannot be cloned`),i===`function`&&throwDataCloneError(`Function cannot be cloned`);let a=e;if(r.has(a))return r.get(a);let o=classOf(a);if(o===`Date`)return new Date(a.getTime());if(o===`RegExp`)return new RegExp(a.source,a.flags);if(o===`Boolean`||o===`Number`||o===`String`)return Object(a.valueOf());if(o===`BigInt`)return Object(BigInt.prototype.valueOf.call(a));if(a instanceof Error){let e=a,n=e.constructor?.name,i=new(n&&t[n]||t[e.name]||Error)(e.message);return i.name=e.name,`cause`in e&&Object.defineProperty(i,`cause`,{value:internalClone(e.cause,r),writable:!0,enumerable:!1,configurable:!0}),i}if(o===`DOMException`){let e=globalThis.DOMException;if(typeof e==`function`){let t=a;return new e(t.message,t.name)}}if(o===`ArrayBuffer`){let e=a.slice(0);return r.set(a,e),e}if(o===`SharedArrayBuffer`)return a;if(o===`DataView`){let e=a,t=internalClone(e.buffer,r),n=new DataView(t,e.byteOffset,e.byteLength);return r.set(a,n),n}if(n.has(o)){let e=a,t=internalClone(e.buffer,r),n=e.constructor,i=new n(t,e.byteOffset,e.length);return r.set(a,i),i}if(o===`Map`){let e=new Map;r.set(a,e);for(let[t,n]of a)e.set(internalClone(t,r),internalClone(n,r));return e}if(o===`Set`){let e=new Set;r.set(a,e);for(let t of a)e.add(internalClone(t,r));return e}{let e=globalThis,t=e.Blob,n=e.File;if(typeof n==`function`&&a instanceof n){let e=a;return new n([a],e.name,{type:e.type,lastModified:e.lastModified})}if(typeof t==`function`&&a instanceof t)return new t([a],{type:a.type})}if(a instanceof WeakMap&&throwDataCloneError(`WeakMap cannot be cloned`),a instanceof WeakSet&&throwDataCloneError(`WeakSet cannot be cloned`),a instanceof WeakRef&&throwDataCloneError(`WeakRef cannot be cloned`),typeof globalThis.Promise==`function`&&a instanceof Promise&&throwDataCloneError(`Promise cannot be cloned`),o===`Array`){let e=a,t=[];r.set(a,t);for(let n=0;n<e.length;n++)n in e&&(t[n]=internalClone(e[n],r));return t}if(o===`Object`||typeof a==`object`){let e={};r.set(a,e);for(let t of Object.keys(a))e[t]=internalClone(a[t],r);return e}throwDataCloneError(`${o} cannot be cloned`)}function structuredClone(e,t){return internalClone(e,new Map)}export{structuredClone};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/utils",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
4
4
  "description": "Utils module for gjsify",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -32,7 +32,7 @@
32
32
  "fs"
33
33
  ],
34
34
  "devDependencies": {
35
- "@gjsify/cli": "^0.3.19",
35
+ "@gjsify/cli": "^0.3.21",
36
36
  "typescript": "^6.0.3"
37
37
  },
38
38
  "dependencies": {