@gjsify/utils 0.4.20 → 0.4.22
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/error.js +1 -1
- package/lib/esm/globals.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/main-loop.js +1 -1
- package/lib/esm/structured-clone.js +1 -1
- package/lib/types/index.d.ts +0 -2
- package/lib/types/main-loop.d.ts +0 -10
- package/package.json +6 -6
- package/lib/esm/base64.js +0 -1
- package/lib/esm/encoding.js +0 -1
- package/lib/types/base64.d.ts +0 -8
- package/lib/types/encoding.d.ts +0 -11
package/lib/esm/error.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";const initErrorV8Methods=e=>{Error.captureStackTrace
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const initErrorV8Methods=e=>{let t=Error;t.captureStackTrace||=function(e,t){let n=Error();Object.defineProperty(t||e,"stack",{configurable:!0,get:function getStack(){var e=n.stack;return Object.defineProperty(this,"stack",{value:e}),e}})}};export{initErrorV8Methods};
|
package/lib/esm/globals.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";function registerGlobal(e,t){globalThis[e]===void 0&&(
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";function registerGlobal(e,t){let n=globalThis;n[e]===void 0&&(n[e]=t)}export{registerGlobal};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{gbytesToUint8Array as e}from"./byte-array.js";import{makeCallable as t}from"./callable.js";import{cli as n}from"./cli.js";import{deferEmit as r}from"./defer.js";import{initErrorV8Methods as i}from"./error.js";import{readJSON as a}from"./file.js";import{existsFD as o,existsSync as s}from"./fs.js";import{GIO_ERROR_TO_NODE as c,GLIB_FILE_ERROR_TO_NODE as l,createGLibFileError as u,createNodeError as d,isNotFoundError as f}from"./gio-errors.js";import{gioAsync as p,inputStreamAsyncIterator as m,readBytesAsync as h}from"./gio.js";import{registerGlobal as g}from"./globals.js";import{notImplemented as _,warnNotImplemented as v}from"./message.js";import{queueMicrotask as y}from"./microtask.js";import{__resetBurstStateForTests as b,nextTick as x}from"./next-tick.js";import{getNodeModulesPath as S,getPathSeparator as C,getProgramDir as w,getProgramExe as T,resolve as E}from"./path.js";import{structuredClone as D}from"./structured-clone.js";import{ensureMainLoop as O,quitMainLoop as k}from"./main-loop.js";export{c as GIO_ERROR_TO_NODE,l as GLIB_FILE_ERROR_TO_NODE,b as __resetBurstStateForTests,n as cli,u as createGLibFileError,d as createNodeError,r as deferEmit,O as ensureMainLoop,o as existsFD,s as existsSync,e as gbytesToUint8Array,S as getNodeModulesPath,C as getPathSeparator,w as getProgramDir,T as getProgramExe,p as gioAsync,i as initErrorV8Methods,m as inputStreamAsyncIterator,f as isNotFoundError,t as makeCallable,x as nextTick,_ as notImplemented,y as queueMicrotask,k as quitMainLoop,h as readBytesAsync,a as readJSON,g as registerGlobal,E as resolve,D as structuredClone,v as warnNotImplemented};
|
package/lib/esm/main-loop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";let e=!1,t=null;function ensureMainLoop(){let n=globalThis.imports;if(!n)return;if(e)return t;let r=n.gi
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";let e=!1,t=null;function ensureMainLoop(){let n=globalThis.imports;if(!n)return;if(e)return t;let r=n.gi?.GLib;if(r){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
|
-
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
|
|
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/lib/types/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export * from './callable.js';
|
|
2
|
-
export * from './base64.js';
|
|
3
2
|
export * from './byte-array.js';
|
|
4
3
|
export * from './cli.js';
|
|
5
4
|
export * from './defer.js';
|
|
6
|
-
export * from './encoding.js';
|
|
7
5
|
export * from './globals.js';
|
|
8
6
|
export * from './error.js';
|
|
9
7
|
export * from './file.js';
|
package/lib/types/main-loop.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import type GLib from '@girs/glib-2.0';
|
|
2
|
-
/**
|
|
3
|
-
* Ensure a GLib MainLoop is running for async I/O dispatch (Soup.Server,
|
|
4
|
-
* Gio.SocketService, etc.). No-op on Node.js. Idempotent.
|
|
5
|
-
*
|
|
6
|
-
* - Called automatically by `http.Server.listen()`, `net.Server.listen()`,
|
|
7
|
-
* `dgram.Socket.bind()` etc.
|
|
8
|
-
* - GTK apps should NOT call this — they use `Gtk.Application.runAsync()` instead.
|
|
9
|
-
*
|
|
10
|
-
* @returns The MainLoop instance on GJS, or `undefined` on Node.js.
|
|
11
|
-
*/
|
|
12
2
|
export declare function ensureMainLoop(): GLib.MainLoop | undefined;
|
|
13
3
|
/**
|
|
14
4
|
* Quit the MainLoop created by `ensureMainLoop()`. Idempotent, no-op on Node.js.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/utils",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.22",
|
|
4
4
|
"description": "Utils module for gjsify",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"fs"
|
|
36
36
|
],
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@gjsify/cli": "^0.4.
|
|
38
|
+
"@gjsify/cli": "^0.4.22",
|
|
39
39
|
"typescript": "^6.0.3"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@girs/gio-2.0": "2.88.0-4.0.
|
|
43
|
-
"@girs/giounix-2.0": "2.0.0-4.0.
|
|
44
|
-
"@girs/gjs": "4.0.
|
|
45
|
-
"@girs/glib-2.0": "2.88.0-4.0.
|
|
42
|
+
"@girs/gio-2.0": "2.88.0-4.0.1",
|
|
43
|
+
"@girs/giounix-2.0": "2.0.0-4.0.1",
|
|
44
|
+
"@girs/gjs": "4.0.1",
|
|
45
|
+
"@girs/glib-2.0": "2.88.0-4.0.1"
|
|
46
46
|
}
|
|
47
47
|
}
|
package/lib/esm/base64.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";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/encoding.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";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/types/base64.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Decode a base64 string to a binary string. Uses native atob when available. */
|
|
2
|
-
export declare function atobPolyfill(str: string): string;
|
|
3
|
-
/** Encode a binary string to base64. Uses native btoa when available. */
|
|
4
|
-
export declare function btoaPolyfill(str: string): string;
|
|
5
|
-
/** Decode a base64 string directly to Uint8Array (avoids lossy atob string round-trip). */
|
|
6
|
-
export declare function base64Decode(str: string): Uint8Array;
|
|
7
|
-
/** Encode a Uint8Array to base64 string. */
|
|
8
|
-
export declare function base64Encode(bytes: Uint8Array): string;
|
package/lib/types/encoding.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/** Canonical encoding names (matches BufferEncoding from @types/node). */
|
|
2
|
-
export type Encoding = 'utf8' | 'ascii' | 'latin1' | 'base64' | 'base64url' | 'hex' | 'utf16le' | 'binary' | 'ucs2' | 'ucs-2' | 'utf-8';
|
|
3
|
-
/**
|
|
4
|
-
* Normalize an encoding string to a canonical encoding value.
|
|
5
|
-
* Returns 'utf8' as default for undefined/null/empty input.
|
|
6
|
-
*/
|
|
7
|
-
export declare function normalizeEncoding(enc?: string): Encoding;
|
|
8
|
-
/**
|
|
9
|
-
* Check that an encoding string is valid. Throws TypeError if not.
|
|
10
|
-
*/
|
|
11
|
-
export declare function checkEncoding(encoding: string): void;
|