jiren 1.3.0 → 1.4.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.
|
@@ -535,29 +535,29 @@ export class JirenClient<
|
|
|
535
535
|
// Copy body content
|
|
536
536
|
buffer = Buffer.from(koffi.decode(bodyPtr, "uint8_t", len));
|
|
537
537
|
|
|
538
|
-
// Handle GZIP compression
|
|
538
|
+
// Handle GZIP compression - search for magic bytes in first 16 bytes
|
|
539
|
+
// (handles chunked encoding or other framing that may add prefix bytes)
|
|
539
540
|
const contentEncoding = headersProxy["content-encoding"]?.toLowerCase();
|
|
541
|
+
let gzipOffset = -1;
|
|
540
542
|
|
|
541
|
-
//
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
`[Jiren] Bytes: 0x${buffer[0]?.toString(
|
|
547
|
-
16
|
|
548
|
-
)} 0x${buffer[1]?.toString(16)} 0x${buffer[2]?.toString(16)}`
|
|
549
|
-
);
|
|
543
|
+
// Search for gzip magic bytes (0x1f 0x8b) in first 16 bytes
|
|
544
|
+
for (let i = 0; i < Math.min(16, buffer.length - 1); i++) {
|
|
545
|
+
if (buffer[i] === 0x1f && buffer[i + 1] === 0x8b) {
|
|
546
|
+
gzipOffset = i;
|
|
547
|
+
break;
|
|
550
548
|
}
|
|
551
549
|
}
|
|
552
550
|
|
|
553
|
-
if (
|
|
554
|
-
contentEncoding === "gzip" ||
|
|
555
|
-
(buffer.length > 2 && buffer[0] === 0x1f && buffer[1] === 0x8b)
|
|
556
|
-
) {
|
|
551
|
+
if (contentEncoding === "gzip" || gzipOffset >= 0) {
|
|
557
552
|
try {
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
console.log(
|
|
553
|
+
// If we found gzip at an offset, slice from there
|
|
554
|
+
const gzipData = gzipOffset > 0 ? buffer.slice(gzipOffset) : buffer;
|
|
555
|
+
console.log(
|
|
556
|
+
`[Jiren] Decompressing gzip (offset: ${
|
|
557
|
+
gzipOffset >= 0 ? gzipOffset : 0
|
|
558
|
+
}, size: ${gzipData.length})`
|
|
559
|
+
);
|
|
560
|
+
buffer = zlib.gunzipSync(gzipData);
|
|
561
561
|
} catch (e) {
|
|
562
562
|
console.warn("Failed to gunzip response body:", e);
|
|
563
563
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jiren",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"author": "",
|
|
5
|
-
"main": "
|
|
6
|
-
"module": "
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"module": "index.ts",
|
|
7
7
|
"types": "index.ts",
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"@types/bun": "^1.3.4"
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
"index-node.ts",
|
|
18
18
|
"types",
|
|
19
19
|
"lib",
|
|
20
|
-
"components"
|
|
21
|
-
"dist"
|
|
20
|
+
"components"
|
|
22
21
|
],
|
|
23
22
|
"keywords": [
|
|
24
23
|
"http",
|
|
@@ -35,7 +34,6 @@
|
|
|
35
34
|
"license": "MIT",
|
|
36
35
|
"scripts": {
|
|
37
36
|
"build:zig": "cd .. && zig build --release=fast",
|
|
38
|
-
"build": "bun build ./index.ts --outfile ./dist/index.js --target bun && bun build ./index-node.ts --outfile ./dist/index-node.js --target node --external koffi",
|
|
39
37
|
"test": "bun run examples/basic.ts"
|
|
40
38
|
},
|
|
41
39
|
"engines": {
|
|
@@ -45,14 +43,8 @@
|
|
|
45
43
|
"type": "module",
|
|
46
44
|
"exports": {
|
|
47
45
|
".": {
|
|
48
|
-
"bun":
|
|
49
|
-
|
|
50
|
-
"default": "./dist/index.js"
|
|
51
|
-
},
|
|
52
|
-
"default": {
|
|
53
|
-
"types": "./index-node.ts",
|
|
54
|
-
"default": "./dist/index-node.js"
|
|
55
|
-
}
|
|
46
|
+
"bun": "./index.ts",
|
|
47
|
+
"default": "./index-node.ts"
|
|
56
48
|
},
|
|
57
49
|
"./package.json": "./package.json"
|
|
58
50
|
},
|
|
Binary file
|