@gjsify/zlib 0.0.4 → 0.1.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/README.md +28 -2
- package/lib/esm/index.js +276 -4
- package/lib/types/index.d.ts +91 -3
- package/package.json +16 -22
- package/src/index.spec.ts +1145 -39
- package/src/index.ts +329 -3
- package/tsconfig.json +21 -9
- package/tsconfig.tsbuildinfo +1 -0
- package/lib/cjs/index.js +0 -6
- package/test.gjs.js +0 -35635
- package/test.gjs.js.map +0 -7
- package/test.gjs.mjs +0 -40864
- package/test.node.js +0 -1252
- package/test.node.js.map +0 -7
- package/test.node.mjs +0 -333
- package/tsconfig.types.json +0 -8
- package/tsconfig.types.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
# @gjsify/zlib
|
|
2
2
|
|
|
3
|
-
Node.js zlib module
|
|
3
|
+
GJS implementation of the Node.js `zlib` module. Provides gzip/deflate via Web Compression API with Gio.ZlibCompressor fallback.
|
|
4
|
+
|
|
5
|
+
Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and Web APIs for GJS (GNOME JavaScript).
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @gjsify/zlib
|
|
11
|
+
# or
|
|
12
|
+
yarn add @gjsify/zlib
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { gzipSync, gunzipSync, deflateSync, inflateSync } from '@gjsify/zlib';
|
|
19
|
+
|
|
20
|
+
const compressed = gzipSync(Buffer.from('hello world'));
|
|
21
|
+
const decompressed = gunzipSync(compressed);
|
|
22
|
+
console.log(decompressed.toString()); // 'hello world'
|
|
23
|
+
```
|
|
24
|
+
|
|
4
25
|
## Inspirations and credits
|
|
26
|
+
|
|
5
27
|
- https://nodejs.org/api/zlib.html
|
|
6
28
|
- https://github.com/geut/brode/blob/main/packages/browser-node-core/src/zlib.js
|
|
7
29
|
- https://github.com/browserify/browserify-zlib
|
|
8
|
-
- https://github.com/denoland/deno_std/blob/main/node/zlib.ts
|
|
30
|
+
- https://github.com/denoland/deno_std/blob/main/node/zlib.ts
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
MIT
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,278 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
import Gio from "@girs/gio-2.0";
|
|
2
|
+
import GLib from "@girs/glib-2.0";
|
|
3
|
+
const hasWebCompression = typeof globalThis.CompressionStream !== "undefined";
|
|
4
|
+
function getGioFormat(format) {
|
|
5
|
+
switch (format) {
|
|
6
|
+
case "gzip":
|
|
7
|
+
return Gio.ZlibCompressorFormat.GZIP;
|
|
8
|
+
case "deflate":
|
|
9
|
+
return Gio.ZlibCompressorFormat.ZLIB;
|
|
10
|
+
case "deflate-raw":
|
|
11
|
+
return Gio.ZlibCompressorFormat.RAW;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function compressWithGio(data, format) {
|
|
15
|
+
const compressor = new Gio.ZlibCompressor({ format: getGioFormat(format) });
|
|
16
|
+
const converter = new Gio.ConverterOutputStream({
|
|
17
|
+
base_stream: Gio.MemoryOutputStream.new_resizable(),
|
|
18
|
+
converter: compressor
|
|
19
|
+
});
|
|
20
|
+
converter.write_bytes(new GLib.Bytes(data), null);
|
|
21
|
+
converter.close(null);
|
|
22
|
+
const memStream = converter.get_base_stream();
|
|
23
|
+
const bytes = memStream.steal_as_bytes();
|
|
24
|
+
return new Uint8Array(bytes.get_data() ?? []);
|
|
25
|
+
}
|
|
26
|
+
function decompressStreamWithGio(data, format) {
|
|
27
|
+
const decompressor = new Gio.ZlibDecompressor({ format: getGioFormat(format) });
|
|
28
|
+
const memInput = Gio.MemoryInputStream.new_from_bytes(new GLib.Bytes(data));
|
|
29
|
+
const converter = new Gio.ConverterInputStream({
|
|
30
|
+
base_stream: memInput,
|
|
31
|
+
converter: decompressor
|
|
32
|
+
});
|
|
33
|
+
const chunks = [];
|
|
34
|
+
const bufSize = 4096;
|
|
35
|
+
while (true) {
|
|
36
|
+
const bytes = converter.read_bytes(bufSize, null);
|
|
37
|
+
const size = bytes.get_size();
|
|
38
|
+
if (size === 0) break;
|
|
39
|
+
chunks.push(new Uint8Array(bytes.get_data()));
|
|
40
|
+
}
|
|
41
|
+
converter.close(null);
|
|
42
|
+
const totalLength = chunks.reduce((acc, c) => acc + c.length, 0);
|
|
43
|
+
const result = new Uint8Array(totalLength);
|
|
44
|
+
let offset = 0;
|
|
45
|
+
for (const chunk of chunks) {
|
|
46
|
+
result.set(chunk, offset);
|
|
47
|
+
offset += chunk.length;
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
function findGzipMemberEnd(data) {
|
|
52
|
+
const decompressor = new Gio.ZlibDecompressor({ format: Gio.ZlibCompressorFormat.GZIP });
|
|
53
|
+
const outBuf = new Uint8Array(65536);
|
|
54
|
+
let totalRead = 0;
|
|
55
|
+
let finished = false;
|
|
56
|
+
while (!finished) {
|
|
57
|
+
const input = data.subarray(totalRead);
|
|
58
|
+
try {
|
|
59
|
+
const [result, bytesRead] = decompressor.convert(input, outBuf, Gio.ConverterFlags.NONE);
|
|
60
|
+
totalRead += bytesRead;
|
|
61
|
+
if (result === Gio.ConverterResult.FINISHED) finished = true;
|
|
62
|
+
} catch {
|
|
63
|
+
finished = true;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return totalRead;
|
|
67
|
+
}
|
|
68
|
+
function decompressWithGio(data, format) {
|
|
69
|
+
if (format !== "gzip") {
|
|
70
|
+
return decompressStreamWithGio(data, format);
|
|
71
|
+
}
|
|
72
|
+
const allChunks = [];
|
|
73
|
+
let inputOffset = 0;
|
|
74
|
+
while (inputOffset < data.length) {
|
|
75
|
+
if (data.length - inputOffset < 2 || data[inputOffset] !== 31 || data[inputOffset + 1] !== 139) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
const memberData = data.subarray(inputOffset);
|
|
79
|
+
const consumed = findGzipMemberEnd(memberData);
|
|
80
|
+
if (consumed <= 0) break;
|
|
81
|
+
const decompressed = decompressStreamWithGio(memberData.subarray(0, consumed), "gzip");
|
|
82
|
+
allChunks.push(decompressed);
|
|
83
|
+
inputOffset += consumed;
|
|
84
|
+
}
|
|
85
|
+
if (allChunks.length === 0) {
|
|
86
|
+
return decompressStreamWithGio(data, "gzip");
|
|
87
|
+
}
|
|
88
|
+
const totalLength = allChunks.reduce((acc, c) => acc + c.length, 0);
|
|
89
|
+
const result = new Uint8Array(totalLength);
|
|
90
|
+
let offset = 0;
|
|
91
|
+
for (const chunk of allChunks) {
|
|
92
|
+
result.set(chunk, offset);
|
|
93
|
+
offset += chunk.length;
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|
|
97
|
+
async function compressWithWeb(data, format) {
|
|
98
|
+
const cs = new CompressionStream(format);
|
|
99
|
+
const writer = cs.writable.getWriter();
|
|
100
|
+
writer.write(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
101
|
+
writer.close();
|
|
102
|
+
const chunks = [];
|
|
103
|
+
const reader = cs.readable.getReader();
|
|
104
|
+
while (true) {
|
|
105
|
+
const { done, value } = await reader.read();
|
|
106
|
+
if (done) break;
|
|
107
|
+
chunks.push(value);
|
|
108
|
+
}
|
|
109
|
+
const totalLength = chunks.reduce((acc, c) => acc + c.length, 0);
|
|
110
|
+
const result = new Uint8Array(totalLength);
|
|
111
|
+
let offset = 0;
|
|
112
|
+
for (const chunk of chunks) {
|
|
113
|
+
result.set(chunk, offset);
|
|
114
|
+
offset += chunk.length;
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
async function decompressWithWeb(data, format) {
|
|
119
|
+
const ds = new DecompressionStream(format);
|
|
120
|
+
const writer = ds.writable.getWriter();
|
|
121
|
+
writer.write(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
122
|
+
writer.close();
|
|
123
|
+
const chunks = [];
|
|
124
|
+
const reader = ds.readable.getReader();
|
|
125
|
+
while (true) {
|
|
126
|
+
const { done, value } = await reader.read();
|
|
127
|
+
if (done) break;
|
|
128
|
+
chunks.push(value);
|
|
129
|
+
}
|
|
130
|
+
const totalLength = chunks.reduce((acc, c) => acc + c.length, 0);
|
|
131
|
+
const result = new Uint8Array(totalLength);
|
|
132
|
+
let offset = 0;
|
|
133
|
+
for (const chunk of chunks) {
|
|
134
|
+
result.set(chunk, offset);
|
|
135
|
+
offset += chunk.length;
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
async function compress(data, format) {
|
|
140
|
+
if (hasWebCompression) {
|
|
141
|
+
return compressWithWeb(data, format);
|
|
142
|
+
}
|
|
143
|
+
return compressWithGio(data, format);
|
|
144
|
+
}
|
|
145
|
+
async function decompress(data, format) {
|
|
146
|
+
if (hasWebCompression) {
|
|
147
|
+
return decompressWithWeb(data, format);
|
|
148
|
+
}
|
|
149
|
+
return decompressWithGio(data, format);
|
|
150
|
+
}
|
|
151
|
+
function toUint8Array(data) {
|
|
152
|
+
if (typeof data === "string") {
|
|
153
|
+
return new TextEncoder().encode(data);
|
|
154
|
+
}
|
|
155
|
+
if (data instanceof ArrayBuffer) {
|
|
156
|
+
return new Uint8Array(data);
|
|
157
|
+
}
|
|
158
|
+
return data;
|
|
159
|
+
}
|
|
160
|
+
function gzip(data, optionsOrCallback, callback) {
|
|
161
|
+
const cb = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
162
|
+
compress(toUint8Array(data), "gzip").then(
|
|
163
|
+
(result) => cb(null, result),
|
|
164
|
+
(err) => cb(err instanceof Error ? err : new Error(String(err)), new Uint8Array(0))
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function gunzip(data, optionsOrCallback, callback) {
|
|
168
|
+
const cb = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
169
|
+
decompress(toUint8Array(data), "gzip").then(
|
|
170
|
+
(result) => cb(null, result),
|
|
171
|
+
(err) => cb(err instanceof Error ? err : new Error(String(err)), new Uint8Array(0))
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
function deflate(data, optionsOrCallback, callback) {
|
|
175
|
+
const cb = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
176
|
+
compress(toUint8Array(data), "deflate").then(
|
|
177
|
+
(result) => cb(null, result),
|
|
178
|
+
(err) => cb(err instanceof Error ? err : new Error(String(err)), new Uint8Array(0))
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function inflate(data, optionsOrCallback, callback) {
|
|
182
|
+
const cb = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
183
|
+
decompress(toUint8Array(data), "deflate").then(
|
|
184
|
+
(result) => cb(null, result),
|
|
185
|
+
(err) => cb(err instanceof Error ? err : new Error(String(err)), new Uint8Array(0))
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
function deflateRaw(data, optionsOrCallback, callback) {
|
|
189
|
+
const cb = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
190
|
+
compress(toUint8Array(data), "deflate-raw").then(
|
|
191
|
+
(result) => cb(null, result),
|
|
192
|
+
(err) => cb(err instanceof Error ? err : new Error(String(err)), new Uint8Array(0))
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
function inflateRaw(data, optionsOrCallback, callback) {
|
|
196
|
+
const cb = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
197
|
+
decompress(toUint8Array(data), "deflate-raw").then(
|
|
198
|
+
(result) => cb(null, result),
|
|
199
|
+
(err) => cb(err instanceof Error ? err : new Error(String(err)), new Uint8Array(0))
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
function gzipSync(data, _options) {
|
|
203
|
+
return compressWithGio(toUint8Array(data), "gzip");
|
|
204
|
+
}
|
|
205
|
+
function gunzipSync(data, _options) {
|
|
206
|
+
return decompressWithGio(toUint8Array(data), "gzip");
|
|
207
|
+
}
|
|
208
|
+
function deflateSync(data, _options) {
|
|
209
|
+
return compressWithGio(toUint8Array(data), "deflate");
|
|
210
|
+
}
|
|
211
|
+
function inflateSync(data, _options) {
|
|
212
|
+
return decompressWithGio(toUint8Array(data), "deflate");
|
|
213
|
+
}
|
|
214
|
+
function deflateRawSync(data, _options) {
|
|
215
|
+
return compressWithGio(toUint8Array(data), "deflate-raw");
|
|
216
|
+
}
|
|
217
|
+
function inflateRawSync(data, _options) {
|
|
218
|
+
return decompressWithGio(toUint8Array(data), "deflate-raw");
|
|
219
|
+
}
|
|
220
|
+
const constants = {
|
|
221
|
+
Z_NO_FLUSH: 0,
|
|
222
|
+
Z_PARTIAL_FLUSH: 1,
|
|
223
|
+
Z_SYNC_FLUSH: 2,
|
|
224
|
+
Z_FULL_FLUSH: 3,
|
|
225
|
+
Z_FINISH: 4,
|
|
226
|
+
Z_BLOCK: 5,
|
|
227
|
+
Z_TREES: 6,
|
|
228
|
+
Z_OK: 0,
|
|
229
|
+
Z_STREAM_END: 1,
|
|
230
|
+
Z_NEED_DICT: 2,
|
|
231
|
+
Z_ERRNO: -1,
|
|
232
|
+
Z_STREAM_ERROR: -2,
|
|
233
|
+
Z_DATA_ERROR: -3,
|
|
234
|
+
Z_MEM_ERROR: -4,
|
|
235
|
+
Z_BUF_ERROR: -5,
|
|
236
|
+
Z_VERSION_ERROR: -6,
|
|
237
|
+
Z_NO_COMPRESSION: 0,
|
|
238
|
+
Z_BEST_SPEED: 1,
|
|
239
|
+
Z_BEST_COMPRESSION: 9,
|
|
240
|
+
Z_DEFAULT_COMPRESSION: -1,
|
|
241
|
+
Z_FILTERED: 1,
|
|
242
|
+
Z_HUFFMAN_ONLY: 2,
|
|
243
|
+
Z_RLE: 3,
|
|
244
|
+
Z_FIXED: 4,
|
|
245
|
+
Z_DEFAULT_STRATEGY: 0,
|
|
246
|
+
Z_DEFLATED: 8
|
|
247
|
+
};
|
|
248
|
+
var index_default = {
|
|
249
|
+
gzip,
|
|
250
|
+
gunzip,
|
|
251
|
+
deflate,
|
|
252
|
+
inflate,
|
|
253
|
+
deflateRaw,
|
|
254
|
+
inflateRaw,
|
|
255
|
+
gzipSync,
|
|
256
|
+
gunzipSync,
|
|
257
|
+
deflateSync,
|
|
258
|
+
inflateSync,
|
|
259
|
+
deflateRawSync,
|
|
260
|
+
inflateRawSync,
|
|
261
|
+
constants
|
|
262
|
+
};
|
|
4
263
|
export {
|
|
5
|
-
|
|
264
|
+
constants,
|
|
265
|
+
index_default as default,
|
|
266
|
+
deflate,
|
|
267
|
+
deflateRaw,
|
|
268
|
+
deflateRawSync,
|
|
269
|
+
deflateSync,
|
|
270
|
+
gunzip,
|
|
271
|
+
gunzipSync,
|
|
272
|
+
gzip,
|
|
273
|
+
gzipSync,
|
|
274
|
+
inflate,
|
|
275
|
+
inflateRaw,
|
|
276
|
+
inflateRawSync,
|
|
277
|
+
inflateSync
|
|
6
278
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
1
|
+
import type { ZlibOptions } from 'node:zlib';
|
|
2
|
+
type ZlibCallback = (error: Error | null, result: Uint8Array) => void;
|
|
3
|
+
export declare function gzip(data: string | Uint8Array | ArrayBuffer, callback: ZlibCallback): void;
|
|
4
|
+
export declare function gzip(data: string | Uint8Array | ArrayBuffer, options: ZlibOptions, callback: ZlibCallback): void;
|
|
5
|
+
export declare function gunzip(data: string | Uint8Array | ArrayBuffer, callback: ZlibCallback): void;
|
|
6
|
+
export declare function gunzip(data: string | Uint8Array | ArrayBuffer, options: ZlibOptions, callback: ZlibCallback): void;
|
|
7
|
+
export declare function deflate(data: string | Uint8Array | ArrayBuffer, callback: ZlibCallback): void;
|
|
8
|
+
export declare function deflate(data: string | Uint8Array | ArrayBuffer, options: ZlibOptions, callback: ZlibCallback): void;
|
|
9
|
+
export declare function inflate(data: string | Uint8Array | ArrayBuffer, callback: ZlibCallback): void;
|
|
10
|
+
export declare function inflate(data: string | Uint8Array | ArrayBuffer, options: ZlibOptions, callback: ZlibCallback): void;
|
|
11
|
+
export declare function deflateRaw(data: string | Uint8Array | ArrayBuffer, callback: ZlibCallback): void;
|
|
12
|
+
export declare function deflateRaw(data: string | Uint8Array | ArrayBuffer, options: ZlibOptions, callback: ZlibCallback): void;
|
|
13
|
+
export declare function inflateRaw(data: string | Uint8Array | ArrayBuffer, callback: ZlibCallback): void;
|
|
14
|
+
export declare function inflateRaw(data: string | Uint8Array | ArrayBuffer, options: ZlibOptions, callback: ZlibCallback): void;
|
|
15
|
+
export declare function gzipSync(data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
|
|
16
|
+
export declare function gunzipSync(data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
|
|
17
|
+
export declare function deflateSync(data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
|
|
18
|
+
export declare function inflateSync(data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
|
|
19
|
+
export declare function deflateRawSync(data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
|
|
20
|
+
export declare function inflateRawSync(data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
|
|
21
|
+
export declare const constants: {
|
|
22
|
+
Z_NO_FLUSH: number;
|
|
23
|
+
Z_PARTIAL_FLUSH: number;
|
|
24
|
+
Z_SYNC_FLUSH: number;
|
|
25
|
+
Z_FULL_FLUSH: number;
|
|
26
|
+
Z_FINISH: number;
|
|
27
|
+
Z_BLOCK: number;
|
|
28
|
+
Z_TREES: number;
|
|
29
|
+
Z_OK: number;
|
|
30
|
+
Z_STREAM_END: number;
|
|
31
|
+
Z_NEED_DICT: number;
|
|
32
|
+
Z_ERRNO: number;
|
|
33
|
+
Z_STREAM_ERROR: number;
|
|
34
|
+
Z_DATA_ERROR: number;
|
|
35
|
+
Z_MEM_ERROR: number;
|
|
36
|
+
Z_BUF_ERROR: number;
|
|
37
|
+
Z_VERSION_ERROR: number;
|
|
38
|
+
Z_NO_COMPRESSION: number;
|
|
39
|
+
Z_BEST_SPEED: number;
|
|
40
|
+
Z_BEST_COMPRESSION: number;
|
|
41
|
+
Z_DEFAULT_COMPRESSION: number;
|
|
42
|
+
Z_FILTERED: number;
|
|
43
|
+
Z_HUFFMAN_ONLY: number;
|
|
44
|
+
Z_RLE: number;
|
|
45
|
+
Z_FIXED: number;
|
|
46
|
+
Z_DEFAULT_STRATEGY: number;
|
|
47
|
+
Z_DEFLATED: number;
|
|
48
|
+
};
|
|
49
|
+
declare const _default: {
|
|
50
|
+
gzip: typeof gzip;
|
|
51
|
+
gunzip: typeof gunzip;
|
|
52
|
+
deflate: typeof deflate;
|
|
53
|
+
inflate: typeof inflate;
|
|
54
|
+
deflateRaw: typeof deflateRaw;
|
|
55
|
+
inflateRaw: typeof inflateRaw;
|
|
56
|
+
gzipSync: typeof gzipSync;
|
|
57
|
+
gunzipSync: typeof gunzipSync;
|
|
58
|
+
deflateSync: typeof deflateSync;
|
|
59
|
+
inflateSync: typeof inflateSync;
|
|
60
|
+
deflateRawSync: typeof deflateRawSync;
|
|
61
|
+
inflateRawSync: typeof inflateRawSync;
|
|
62
|
+
constants: {
|
|
63
|
+
Z_NO_FLUSH: number;
|
|
64
|
+
Z_PARTIAL_FLUSH: number;
|
|
65
|
+
Z_SYNC_FLUSH: number;
|
|
66
|
+
Z_FULL_FLUSH: number;
|
|
67
|
+
Z_FINISH: number;
|
|
68
|
+
Z_BLOCK: number;
|
|
69
|
+
Z_TREES: number;
|
|
70
|
+
Z_OK: number;
|
|
71
|
+
Z_STREAM_END: number;
|
|
72
|
+
Z_NEED_DICT: number;
|
|
73
|
+
Z_ERRNO: number;
|
|
74
|
+
Z_STREAM_ERROR: number;
|
|
75
|
+
Z_DATA_ERROR: number;
|
|
76
|
+
Z_MEM_ERROR: number;
|
|
77
|
+
Z_BUF_ERROR: number;
|
|
78
|
+
Z_VERSION_ERROR: number;
|
|
79
|
+
Z_NO_COMPRESSION: number;
|
|
80
|
+
Z_BEST_SPEED: number;
|
|
81
|
+
Z_BEST_COMPRESSION: number;
|
|
82
|
+
Z_DEFAULT_COMPRESSION: number;
|
|
83
|
+
Z_FILTERED: number;
|
|
84
|
+
Z_HUFFMAN_ONLY: number;
|
|
85
|
+
Z_RLE: number;
|
|
86
|
+
Z_FIXED: number;
|
|
87
|
+
Z_DEFAULT_STRATEGY: number;
|
|
88
|
+
Z_DEFLATED: number;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/zlib",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Node.js zlib module for Gjs",
|
|
5
|
-
"main": "lib/cjs/index.js",
|
|
6
5
|
"module": "lib/esm/index.js",
|
|
7
6
|
"types": "lib/types/index.d.ts",
|
|
8
7
|
"type": "module",
|
|
9
8
|
"exports": {
|
|
10
9
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
"default": "./lib/esm/index.js"
|
|
14
|
-
},
|
|
15
|
-
"require": {
|
|
16
|
-
"types": "./lib/types/index.d.ts",
|
|
17
|
-
"default": "./lib/cjs/index.js"
|
|
18
|
-
}
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"default": "./lib/esm/index.js"
|
|
19
12
|
}
|
|
20
13
|
},
|
|
21
14
|
"scripts": {
|
|
22
|
-
"clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo || exit 0",
|
|
23
|
-
"
|
|
24
|
-
"build": "yarn
|
|
15
|
+
"clear": "rm -rf lib tsconfig.tsbuildinfo tsconfig.types.tsbuildinfo test.gjs.mjs test.node.mjs || exit 0",
|
|
16
|
+
"check": "tsc --noEmit",
|
|
17
|
+
"build": "yarn build:gjsify && yarn build:types",
|
|
25
18
|
"build:gjsify": "gjsify build --library 'src/**/*.{ts,js}' --exclude 'src/**/*.spec.{mts,ts}' 'src/test.{mts,ts}'",
|
|
26
|
-
"build:types": "tsc
|
|
19
|
+
"build:types": "tsc",
|
|
27
20
|
"build:test": "yarn build:test:gjs && yarn build:test:node",
|
|
28
21
|
"build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
|
|
29
22
|
"build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
|
|
30
|
-
"test": "yarn
|
|
23
|
+
"test": "yarn build:gjsify && yarn build:test && yarn test:node && yarn test:gjs",
|
|
31
24
|
"test:gjs": "gjs -m test.gjs.mjs",
|
|
32
25
|
"test:node": "node test.node.mjs"
|
|
33
26
|
},
|
|
@@ -36,13 +29,14 @@
|
|
|
36
29
|
"node",
|
|
37
30
|
"zlib"
|
|
38
31
|
],
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@gjsify/cli": "^0.0.4",
|
|
41
|
-
"@gjsify/unit": "^0.0.4",
|
|
42
|
-
"@types/node": "^20.10.5",
|
|
43
|
-
"typescript": "^5.3.3"
|
|
44
|
-
},
|
|
45
32
|
"dependencies": {
|
|
46
|
-
"@
|
|
33
|
+
"@girs/gio-2.0": "^2.88.0-4.0.0-beta.42",
|
|
34
|
+
"@girs/glib-2.0": "^2.88.0-4.0.0-beta.42"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@gjsify/cli": "^0.1.0",
|
|
38
|
+
"@gjsify/unit": "^0.1.0",
|
|
39
|
+
"@types/node": "^25.5.0",
|
|
40
|
+
"typescript": "^6.0.2"
|
|
47
41
|
}
|
|
48
42
|
}
|