@gjsify/utils 0.4.9 → 0.4.11
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 +1 -1
- package/lib/types/gio.d.ts +6 -0
- package/package.json +2 -2
package/lib/esm/gio.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import e from"@girs/glib-2.0";const
|
|
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};
|
package/lib/types/gio.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "0.4.11",
|
|
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.
|
|
38
|
+
"@gjsify/cli": "^0.4.11",
|
|
39
39
|
"typescript": "^6.0.3"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|