@gjsify/utils 0.3.20 → 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 +1 -1
- package/lib/esm/byte-array.js +1 -1
- package/lib/esm/callable.js +1 -1
- package/lib/esm/cli.js +1 -1
- package/lib/esm/defer.js +1 -1
- package/lib/esm/encoding.js +1 -1
- package/lib/esm/error.js +1 -1
- package/lib/esm/file.js +1 -1
- package/lib/esm/fs.js +1 -1
- package/lib/esm/gio-errors.js +1 -1
- package/lib/esm/gio.js +1 -1
- package/lib/esm/globals.js +1 -1
- package/lib/esm/main-loop.js +1 -1
- package/lib/esm/message.js +1 -1
- package/lib/esm/microtask.js +1 -1
- package/lib/esm/next-tick.js +1 -1
- package/lib/esm/path.js +1 -1
- package/lib/esm/structured-clone.js +1 -1
- package/package.json +2 -2
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
|
|
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};
|
package/lib/esm/byte-array.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function gbytesToUint8Array(e){return imports.byteArray.fromGBytes(e)}export{gbytesToUint8Array};
|
package/lib/esm/callable.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
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,
|
|
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
|
|
1
|
+
function deferEmit(e,t,...n){setTimeout(()=>e.emit(t,...n),0)}export{deferEmit};
|
package/lib/esm/encoding.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=[`utf8`,`ascii`,`latin1`,`binary`,`base64`,`base64url`,`hex`,`ucs2`,`utf16le`];function
|
|
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
|
|
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,
|
|
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
|
|
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};
|
package/lib/esm/gio-errors.js
CHANGED
|
@@ -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
|
|
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
|
|
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};
|
package/lib/esm/globals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function registerGlobal(e,t){globalThis[e]===void 0&&(globalThis[e]=t)}export{registerGlobal};
|
package/lib/esm/main-loop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e=!1,t=null;function
|
|
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};
|
package/lib/esm/message.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
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};
|
package/lib/esm/microtask.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const queueMicrotask=e=>{Promise.resolve().then(e)};export{queueMicrotask};
|
package/lib/esm/next-tick.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=[];let t=!1;function n
|
|
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,
|
|
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
|
|
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.
|
|
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.
|
|
35
|
+
"@gjsify/cli": "^0.3.21",
|
|
36
36
|
"typescript": "^6.0.3"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|