@gjsify/utils 0.24.1 → 0.25.1

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};
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,12 @@
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. The legacy `imports.byteArray.fromGBytes()` does
8
+ * the same thing but only exists when the GJS ambient globals are present, so
9
+ * it throws a `ReferenceError` on a `--app node` bundle that was not given the
10
+ * `@gjsify/node-gi/globals` shim.
6
11
  */
7
12
  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.1",
3
+ "version": "0.25.1",
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.1",
43
+ "@gjsify/cli": "^0.25.1",
44
44
  "typescript": "^6.0.3"
45
45
  },
46
46
  "dependencies": {