@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.
- package/lib/esm/byte-array.js +1 -1
- package/lib/esm/cli.js +1 -1
- package/lib/esm/file.js +1 -1
- package/lib/esm/gio.js +1 -1
- package/lib/esm/main-loop.js +1 -1
- package/lib/esm/path.js +1 -1
- package/lib/types/byte-array.d.ts +7 -3
- package/package.json +2 -2
package/lib/esm/byte-array.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";function gbytesToUint8Array(e){return
|
|
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=
|
|
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=
|
|
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
|
|
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/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?.GLib;if(r)
|
|
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:
|
|
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
|
|
4
|
-
*
|
|
5
|
-
*
|
|
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.
|
|
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.
|
|
43
|
+
"@gjsify/cli": "^0.26.0",
|
|
44
44
|
"typescript": "^6.0.3"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|