@gjsify/utils 0.24.2 → 0.26.0

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";function gbytesToUint8Array(e){return imports.byteArray.fromGBytes(e)}export{gbytesToUint8Array};
1
+ import"./_virtual/_rolldown/runtime.js";function gbytesToUint8Array(e){return e.toArray()}export{gbytesToUint8Array};
package/lib/esm/cli.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";const cli=t=>{let[n,r,i,a]=e.spawn_command_line_sync(t);if(i.byteLength)throw Error(imports.byteArray.toString(i));return imports.byteArray.toString(r)};export{cli};
1
+ import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";const t=new TextDecoder,cli=n=>{let[r,i,a,o]=e.spawn_command_line_sync(n);if(a.byteLength)throw Error(t.decode(a));return t.decode(i)};export{cli};
package/lib/esm/file.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";const readJSON=t=>{let[n,r]=e.file_get_contents(t);if(n)return JSON.parse(imports.byteArray.toString(r));throw Error(`Error on require "${t}"`)};export{readJSON};
1
+ import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";const t=new TextDecoder,readJSON=n=>{let[r,i]=e.file_get_contents(n);if(r)return JSON.parse(t.decode(i));throw Error(`Error on require "${n}"`)};export{readJSON};
package/lib/esm/gio.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";import t from"@girs/gio-2.0";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 t=n.read_bytes_finish(i);return t.get_size()===0?e(null):e(imports.byteArray.fromGBytes(t))}catch(n){let r=n;if(typeof r.matches==`function`&&(r.matches(t.IOErrorEnum,t.IOErrorEnum.PARTIAL_INPUT)||r.matches(t.IOErrorEnum,t.IOErrorEnum.CONNECTION_CLOSED)||r.matches(t.IOErrorEnum,t.IOErrorEnum.BROKEN_PIPE)||r.matches(t.IOErrorEnum,t.IOErrorEnum.CLOSED)))return e(null);o(n)}})})}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
+ import"./_virtual/_rolldown/runtime.js";import{gbytesToUint8Array as e}from"./byte-array.js";import t from"@girs/glib-2.0";import n from"@girs/gio-2.0";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(r,i=4096,a=t.PRIORITY_DEFAULT,o=null){return new Promise((t,s)=>{r.read_bytes_async(i,a,o,(i,a)=>{try{let n=r.read_bytes_finish(a);return n.get_size()===0?t(null):t(e(n))}catch(e){let r=e;if(typeof r.matches==`function`&&(r.matches(n.IOErrorEnum,n.IOErrorEnum.PARTIAL_INPUT)||r.matches(n.IOErrorEnum,n.IOErrorEnum.CONNECTION_CLOSED)||r.matches(n.IOErrorEnum,n.IOErrorEnum.BROKEN_PIPE)||r.matches(n.IOErrorEnum,n.IOErrorEnum.CLOSED)))return t(null);s(e)}})})}async function*inputStreamAsyncIterator(e,n=4096,r=t.PRIORITY_DEFAULT,i=null){let a;for(;(a=await readBytesAsync(e,n,r,i))!==null;)yield a}export{gioAsync,inputStreamAsyncIterator,readBytesAsync};
@@ -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?.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
+ 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)return t=new r.MainLoop(null,!1),e=!0,r.main_depth()===0&&t.runAsync().catch(()=>{}),t}function quitMainLoop(){t&&=(t.quit(),e=!1,null)}export{ensureMainLoop,quitMainLoop};
package/lib/esm/path.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";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=()=>e.get_current_dir().startsWith(`/`)?`/`:`\\`,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
+ import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";import t from"@girs/gio-2.0";import n from"system";const{File:r}=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 n=r.new_for_path(e);for(let e of t)n=n.resolve_relative_path(e);return n},getProgramExe=()=>{let t=e.get_current_dir();return r.new_for_path(t).resolve_relative_path(n.programInvocationName)},getProgramDir=()=>_getProgramDir(getProgramExe()).get_path(),getPathSeparator=()=>e.get_current_dir().startsWith(`/`)?`/`:`\\`,getNodeModulesPath=()=>{let e=r.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,7 +1,11 @@
1
1
  import type GLib from '@girs/glib-2.0';
2
2
  /**
3
- * Convert GLib.Bytes to Uint8Array using GJS's byteArray module.
4
- * This wraps the GJS-specific `imports.byteArray.fromGBytes()` API
5
- * with proper typing to eliminate `as any` casts throughout the codebase.
3
+ * Convert GLib.Bytes to Uint8Array.
4
+ *
5
+ * Uses `GLib.Bytes.prototype.toArray()` — the GJS core override
6
+ * (`refs/gjs/modules/core/overrides/GLib.js`), which `@gjsify/node-gi` mirrors
7
+ * on its boxed-GBytes proxy — instead of the legacy
8
+ * `imports.byteArray.fromGBytes()` (AGENTS.md § The legacy imports.* object is
9
+ * NOT an API).
6
10
  */
7
11
  export declare function gbytesToUint8Array(bytes: GLib.Bytes): Uint8Array;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/utils",
3
- "version": "0.24.2",
3
+ "version": "0.26.0",
4
4
  "description": "Utils module for gjsify",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "fs"
41
41
  ],
42
42
  "devDependencies": {
43
- "@gjsify/cli": "^0.24.2",
43
+ "@gjsify/cli": "^0.26.0",
44
44
  "typescript": "^6.0.3"
45
45
  },
46
46
  "dependencies": {