@gjsify/utils 0.4.9 → 0.4.10

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/gio.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";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};
1
+ import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";import t from"@girs/gio-2.0";const n=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(r,i=4096,a=e.PRIORITY_DEFAULT,o=null){return new Promise((e,s)=>{r.read_bytes_async(i,a,o,(i,a)=>{try{let t=r.read_bytes_finish(a);return t.get_size()===0?e(null):e(n.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);s(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};
@@ -9,6 +9,12 @@ export declare function gioAsync<T>(obj: any, asyncMethod: string, finishMethod:
9
9
  /**
10
10
  * Promise wrapper around `Gio.InputStream.read_bytes_async` / `read_bytes_finish`.
11
11
  * Returns a `Uint8Array` or `null` if the end of the stream is reached.
12
+ *
13
+ * Treats `G_IO_ERROR_PARTIAL_INPUT` as EOF: Soup3's chunked-decoding input
14
+ * stream surfaces this when the upstream closes the connection cleanly at a
15
+ * non-chunk boundary (common on the npm registry CDN). Without this, the
16
+ * fetch `Body.text()` path raises "Invalid response body" mid-read even
17
+ * though the full payload has already arrived. Bubble all other errors.
12
18
  */
13
19
  export declare function readBytesAsync(inputStream: Gio.InputStream, count?: number, ioPriority?: number, cancellable?: Gio.Cancellable | null): Promise<Uint8Array | null>;
14
20
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/utils",
3
- "version": "0.4.9",
3
+ "version": "0.4.10",
4
4
  "description": "Utils module for gjsify",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "fs"
36
36
  ],
37
37
  "devDependencies": {
38
- "@gjsify/cli": "^0.4.9",
38
+ "@gjsify/cli": "^0.4.10",
39
39
  "typescript": "^6.0.3"
40
40
  },
41
41
  "dependencies": {