@gjsify/zlib 0.4.36 → 0.4.37
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/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";import{Transform as e}from"@gjsify/stream/browser";const t={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,ZLIB_VERNUM:4784,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,ZSTD_COMPRESS:10,ZSTD_DECOMPRESS:11,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_PARAM_MODE:0,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_PARAM_LGWIN:2,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_PARAM_LGBLOCK:3,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8};function toUint8(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof Uint8Array?e:new Uint8Array(e)}async function runStream(e,t,n){let r=t===`compress`?globalThis.CompressionStream:globalThis.DecompressionStream;if(!r)throw Error(`zlib browser polyfill requires ${t===`compress`?`CompressionStream`:`DecompressionStream`} (not available in this browser)`);let i=new r(e),a=i.writable.getWriter(),o=i.readable.getReader();a.write(n),a.close();let s=[],c=0;for(;;){let{done:e,value:t}=await o.read();if(e)break;let n=t;s.push(n),c+=n.length}let l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;return l}function asyncOp(e,t){return(n,r,i)=>{let a=typeof r==`function`?r:i;if(typeof a!=`function`)throw TypeError(`callback is required`);runStream(e,t,toUint8(n)).then(e=>a(null,e),e=>a(e))}}function syncOp(e,t,n){return(e,t)=>{throw
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{Transform as e}from"@gjsify/stream/browser";const t={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,ZLIB_VERNUM:4784,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,ZSTD_COMPRESS:10,ZSTD_DECOMPRESS:11,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_PARAM_MODE:0,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_PARAM_LGWIN:2,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_PARAM_LGBLOCK:3,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8};function toUint8(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof Uint8Array?e:new Uint8Array(e)}function notSupportedError(e,t){return Object.assign(Error(`zlib.${e} is not supported in the browser (${t})`),{code:`ENOTSUP`,syscall:e})}async function runStream(e,t,n){let r=t===`compress`?globalThis.CompressionStream:globalThis.DecompressionStream;if(!r)throw Error(`zlib browser polyfill requires ${t===`compress`?`CompressionStream`:`DecompressionStream`} (not available in this browser)`);let i=new r(e),a=i.writable.getWriter(),o=i.readable.getReader();a.write(n),a.close();let s=[],c=0;for(;;){let{done:e,value:t}=await o.read();if(e)break;let n=t;s.push(n),c+=n.length}let l=new Uint8Array(c),u=0;for(let e of s)l.set(e,u),u+=e.length;return l}function asyncOp(e,t){return(n,r,i)=>{let a=typeof r==`function`?r:i;if(typeof a!=`function`)throw TypeError(`callback is required`);runStream(e,t,toUint8(n)).then(e=>a(null,e),e=>a(e))}}function syncOp(e,t,n){return(e,t)=>{throw notSupportedError(n,`CompressionStream is async-only — use the callback form`)}}function unsupportedAsyncOp(e,t){return(n,r,i)=>{let a=typeof r==`function`?r:i;if(typeof a!=`function`)throw TypeError(`callback is required`);let o=notSupportedError(e,`${t} is not in the WHATWG Compression Streams spec`);queueMicrotask(()=>a(o))}}function unsupportedSyncOp(e,t){return(n,r)=>{throw notSupportedError(e,`${t} is not in the WHATWG Compression Streams spec`)}}const n=asyncOp(`gzip`,`compress`),r=asyncOp(`gzip`,`decompress`),i=asyncOp(`deflate`,`compress`),a=asyncOp(`deflate`,`decompress`),o=asyncOp(`deflate-raw`,`compress`),s=asyncOp(`deflate-raw`,`decompress`),c=unsupportedAsyncOp(`brotliCompress`,`brotli`),l=unsupportedAsyncOp(`brotliDecompress`,`brotli`),u=unsupportedAsyncOp(`zstdCompress`,`zstd`),d=unsupportedAsyncOp(`zstdDecompress`,`zstd`),f=syncOp(`gzip`,`compress`,`gzipSync`),p=syncOp(`gzip`,`decompress`,`gunzipSync`),m=syncOp(`deflate`,`compress`,`deflateSync`),h=syncOp(`deflate`,`decompress`,`inflateSync`),g=syncOp(`deflate-raw`,`compress`,`deflateRawSync`),_=syncOp(`deflate-raw`,`decompress`,`inflateRawSync`),v=unsupportedSyncOp(`brotliCompressSync`,`brotli`),y=unsupportedSyncOp(`brotliDecompressSync`,`brotli`),b=unsupportedSyncOp(`zstdCompressSync`,`zstd`),x=unsupportedSyncOp(`zstdDecompressSync`,`zstd`);var ZlibTransform=class extends e{_format;_direction;_chunks=[];constructor(e,t){super(),this._format=e,this._direction=t}_transform(e,t,n){this._chunks.push(toUint8(e)),n(null)}_flush(e){let t=this._chunks.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let e of this._chunks)n.set(e,r),r+=e.length;runStream(this._format,this._direction,n).then(t=>{this.push(t),e()},t=>e(t))}},Gzip=class extends ZlibTransform{constructor(){super(`gzip`,`compress`)}},Gunzip=class extends ZlibTransform{constructor(){super(`gzip`,`decompress`)}},Deflate=class extends ZlibTransform{constructor(){super(`deflate`,`compress`)}},Inflate=class extends ZlibTransform{constructor(){super(`deflate`,`decompress`)}},DeflateRaw=class extends ZlibTransform{constructor(){super(`deflate-raw`,`compress`)}},InflateRaw=class extends ZlibTransform{constructor(){super(`deflate-raw`,`decompress`)}},BrotliCompress=class extends e{constructor(){throw super(),notSupportedError(`BrotliCompress`,`brotli is not in the WHATWG Compression Streams spec`)}},BrotliDecompress=class extends e{constructor(){throw super(),notSupportedError(`BrotliDecompress`,`brotli is not in the WHATWG Compression Streams spec`)}};const createGzip=e=>new Gzip,createGunzip=e=>new Gunzip,createDeflate=e=>new Deflate,createInflate=e=>new Inflate,createDeflateRaw=e=>new DeflateRaw,createInflateRaw=e=>new InflateRaw,createBrotliCompress=e=>new BrotliCompress,createBrotliDecompress=e=>new BrotliDecompress,createUnzip=e=>new Gunzip,S={constants:t,gzip:n,gunzip:r,deflate:i,inflate:a,deflateRaw:o,inflateRaw:s,brotliCompress:c,brotliDecompress:l,zstdCompress:u,zstdDecompress:d,gzipSync:f,gunzipSync:p,deflateSync:m,inflateSync:h,deflateRawSync:g,inflateRawSync:_,brotliCompressSync:v,brotliDecompressSync:y,zstdCompressSync:b,zstdDecompressSync:x,Gzip,Gunzip,Deflate,Inflate,DeflateRaw,InflateRaw,BrotliCompress,BrotliDecompress,createGzip,createGunzip,createDeflate,createInflate,createDeflateRaw,createInflateRaw,createBrotliCompress,createBrotliDecompress,createUnzip};export{BrotliCompress,BrotliDecompress,Deflate,DeflateRaw,Gunzip,Gzip,Inflate,InflateRaw,c as brotliCompress,v as brotliCompressSync,l as brotliDecompress,y as brotliDecompressSync,t as constants,createBrotliCompress,createBrotliDecompress,createDeflate,createDeflateRaw,createGunzip,createGzip,createInflate,createInflateRaw,createUnzip,S as default,i as deflate,o as deflateRaw,g as deflateRawSync,m as deflateSync,r as gunzip,p as gunzipSync,n as gzip,f as gzipSync,a as inflate,s as inflateRaw,_ as inflateRawSync,h as inflateSync,u as zstdCompress,b as zstdCompressSync,d as zstdDecompress,x as zstdDecompressSync};
|
package/lib/types/browser.d.ts
CHANGED
|
@@ -78,15 +78,17 @@ export declare const constants: {
|
|
|
78
78
|
};
|
|
79
79
|
export type ZlibOptions = Record<string, unknown>;
|
|
80
80
|
type Callback = (err: Error | null, result?: Uint8Array) => void;
|
|
81
|
-
type WebCompressionFormat = 'gzip' | 'deflate' | 'deflate-raw'
|
|
81
|
+
type WebCompressionFormat = 'gzip' | 'deflate' | 'deflate-raw';
|
|
82
82
|
export declare const gzip: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
83
83
|
export declare const gunzip: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
84
84
|
export declare const deflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
85
85
|
export declare const inflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
86
86
|
export declare const deflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
87
87
|
export declare const inflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
88
|
-
export declare const brotliCompress: (
|
|
89
|
-
export declare const brotliDecompress: (
|
|
88
|
+
export declare const brotliCompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
89
|
+
export declare const brotliDecompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
90
|
+
export declare const zstdCompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
91
|
+
export declare const zstdDecompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
90
92
|
export declare const gzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
91
93
|
export declare const gunzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
92
94
|
export declare const deflateSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
@@ -95,6 +97,8 @@ export declare const deflateRawSync: (_data: string | Uint8Array | ArrayBuffer,
|
|
|
95
97
|
export declare const inflateRawSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
96
98
|
export declare const brotliCompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
97
99
|
export declare const brotliDecompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
100
|
+
export declare const zstdCompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
101
|
+
export declare const zstdDecompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
98
102
|
declare class ZlibTransform extends Transform {
|
|
99
103
|
private _format;
|
|
100
104
|
private _direction;
|
|
@@ -121,10 +125,10 @@ export declare class DeflateRaw extends ZlibTransform {
|
|
|
121
125
|
export declare class InflateRaw extends ZlibTransform {
|
|
122
126
|
constructor();
|
|
123
127
|
}
|
|
124
|
-
export declare class BrotliCompress extends
|
|
128
|
+
export declare class BrotliCompress extends Transform {
|
|
125
129
|
constructor();
|
|
126
130
|
}
|
|
127
|
-
export declare class BrotliDecompress extends
|
|
131
|
+
export declare class BrotliDecompress extends Transform {
|
|
128
132
|
constructor();
|
|
129
133
|
}
|
|
130
134
|
export declare const createGzip: (_opts?: ZlibOptions) => Gzip;
|
|
@@ -220,8 +224,10 @@ declare const zlibDefault: {
|
|
|
220
224
|
inflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
221
225
|
deflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
222
226
|
inflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
223
|
-
brotliCompress: (
|
|
224
|
-
brotliDecompress: (
|
|
227
|
+
brotliCompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
228
|
+
brotliDecompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
229
|
+
zstdCompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
230
|
+
zstdDecompress: (_data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
|
|
225
231
|
gzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
226
232
|
gunzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
227
233
|
deflateSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
@@ -230,6 +236,8 @@ declare const zlibDefault: {
|
|
|
230
236
|
inflateRawSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
231
237
|
brotliCompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
232
238
|
brotliDecompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
239
|
+
zstdCompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
240
|
+
zstdDecompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
|
|
233
241
|
Gzip: typeof Gzip;
|
|
234
242
|
Gunzip: typeof Gunzip;
|
|
235
243
|
Deflate: typeof Deflate;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/zlib",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.37",
|
|
4
4
|
"description": "Node.js zlib module for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"build:test": "gjsify run build:test:gjs && gjsify run build:test:node",
|
|
28
28
|
"build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
|
|
29
29
|
"build:test:node": "gjsify build src/test.mts --app node --outfile test.node.mjs",
|
|
30
|
+
"build:test:browser": "gjsify build src/test.browser.mts --app browser --outfile dist/test.browser.mjs",
|
|
30
31
|
"test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:node && gjsify run test:gjs",
|
|
31
32
|
"test:gjs": "gjsify run test.gjs.mjs",
|
|
32
33
|
"test:node": "node test.node.mjs"
|
|
@@ -41,9 +42,9 @@
|
|
|
41
42
|
"@girs/glib-2.0": "2.88.0-4.0.4"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@gjsify/cli": "^0.4.
|
|
45
|
-
"@gjsify/stream": "^0.4.
|
|
46
|
-
"@gjsify/unit": "^0.4.
|
|
45
|
+
"@gjsify/cli": "^0.4.37",
|
|
46
|
+
"@gjsify/stream": "^0.4.37",
|
|
47
|
+
"@gjsify/unit": "^0.4.37",
|
|
47
48
|
"@types/node": "^25.9.1",
|
|
48
49
|
"typescript": "^5.9.3"
|
|
49
50
|
},
|
|
@@ -51,7 +52,8 @@
|
|
|
51
52
|
"runtimes": {
|
|
52
53
|
"gjs": "polyfill",
|
|
53
54
|
"node": "none",
|
|
54
|
-
"browser": "partial"
|
|
55
|
+
"browser": "partial",
|
|
56
|
+
"nativescript": "none"
|
|
55
57
|
}
|
|
56
58
|
},
|
|
57
59
|
"license": "MIT",
|