@gjsify/zlib 0.4.35 → 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.
@@ -0,0 +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)}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/esm/index.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{ZlibTransform as e,createBrotliCompress as t,createBrotliDecompress as n,createDeflate as r,createDeflateRaw as i,createGunzip as a,createGzip as o,createInflate as s,createInflateRaw as c,createUnzip as l}from"./transform-streams.js";import u from"@girs/gio-2.0";import d from"@girs/glib-2.0";const f=globalThis.CompressionStream!==void 0;function getGioFormat(e){switch(e){case`gzip`:return u.ZlibCompressorFormat.GZIP;case`deflate`:return u.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return u.ZlibCompressorFormat.RAW}}function compressWithGio(e,t){let n=new u.ZlibCompressor({format:getGioFormat(t)}),r=new u.ConverterOutputStream({base_stream:u.MemoryOutputStream.new_resizable(),converter:n});r.write_bytes(new d.Bytes(e),null),r.close(null);let i=r.get_base_stream().steal_as_bytes();return new Uint8Array(i.get_data()??[])}function decompressStreamWithGio(e,t){let n=new u.ZlibDecompressor({format:getGioFormat(t)}),r=u.MemoryInputStream.new_from_bytes(new d.Bytes(e)),i=new u.ConverterInputStream({base_stream:r,converter:n}),a=[];for(;;){let e=i.read_bytes(4096,null);if(e.get_size()===0)break;a.push(new Uint8Array(e.get_data()))}i.close(null);let o=a.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s}function findGzipMemberEnd(e){let t=new u.ZlibDecompressor({format:u.ZlibCompressorFormat.GZIP}),n=new Uint8Array(65536),r=0,i=!1;for(;!i;){let a=e.subarray(r);try{let[e,o]=t.convert(a,n,u.ConverterFlags.NONE);r+=o,e===u.ConverterResult.FINISHED&&(i=!0)}catch{i=!0}}return r}function decompressWithGio(e,t){if(t!==`gzip`)return decompressStreamWithGio(e,t);let n=[],r=0;for(;r<e.length&&!(e.length-r<2||e[r]!==31||e[r+1]!==139);){let t=e.subarray(r),i=findGzipMemberEnd(t);if(i<=0)break;let a=decompressStreamWithGio(t.subarray(0,i),`gzip`);n.push(a),r+=i}if(n.length===0)return decompressStreamWithGio(e,`gzip`);let i=n.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of n)a.set(e,o),o+=e.length;return a}async function compressWithWeb(e,t){let n=new CompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function decompressWithWeb(e,t){let n=new DecompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function compress(e,t){return f?compressWithWeb(e,t):compressWithGio(e,t)}async function decompress(e,t){return f?decompressWithWeb(e,t):decompressWithGio(e,t)}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array(e),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array(e),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array(e),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array(e),`deflate-raw`)}const p=new Uint8Array;function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),p)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),p)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}const m={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,Z_DEFLATED:8};var h={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,createGzip:o,createGunzip:a,createDeflate:r,createInflate:s,createDeflateRaw:i,createInflateRaw:c,createUnzip:l,createBrotliCompress:t,createBrotliDecompress:n,constants:m};export{e as ZlibTransform,brotliCompress,brotliCompressSync,brotliDecompress,brotliDecompressSync,m as constants,t as createBrotliCompress,n as createBrotliDecompress,r as createDeflate,i as createDeflateRaw,a as createGunzip,o as createGzip,s as createInflate,c as createInflateRaw,l as createUnzip,h as default,deflate,deflateRaw,deflateRawSync,deflateSync,gunzip,gunzipSync,gzip,gzipSync,inflate,inflateRaw,inflateRawSync,inflateSync};
1
+ import"./_virtual/_rolldown/runtime.js";import{ZlibTransform as e,createBrotliCompress as t,createBrotliDecompress as n,createDeflate as r,createDeflateRaw as i,createGunzip as a,createGzip as o,createInflate as s,createInflateRaw as c,createUnzip as l,createZstdCompress as u,createZstdDecompress as d}from"./transform-streams.js";import f from"@girs/gio-2.0";import p from"@girs/glib-2.0";const m=globalThis.CompressionStream!==void 0;function getGioFormat(e){switch(e){case`gzip`:return f.ZlibCompressorFormat.GZIP;case`deflate`:return f.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return f.ZlibCompressorFormat.RAW}}function compressWithGio(e,t){let n=new f.ZlibCompressor({format:getGioFormat(t)}),r=new f.ConverterOutputStream({base_stream:f.MemoryOutputStream.new_resizable(),converter:n});r.write_bytes(new p.Bytes(e),null),r.close(null);let i=r.get_base_stream().steal_as_bytes();return new Uint8Array(i.get_data()??[])}function decompressStreamWithGio(e,t){let n=new f.ZlibDecompressor({format:getGioFormat(t)}),r=f.MemoryInputStream.new_from_bytes(new p.Bytes(e)),i=new f.ConverterInputStream({base_stream:r,converter:n}),a=[];for(;;){let e=i.read_bytes(4096,null);if(e.get_size()===0)break;a.push(new Uint8Array(e.get_data()))}i.close(null);let o=a.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.length;return s}function findGzipMemberEnd(e){let t=new f.ZlibDecompressor({format:f.ZlibCompressorFormat.GZIP}),n=new Uint8Array(65536),r=0,i=!1;for(;!i;){let a=e.subarray(r);try{let[e,o]=t.convert(a,n,f.ConverterFlags.NONE);r+=o,e===f.ConverterResult.FINISHED&&(i=!0)}catch{i=!0}}return r}function decompressWithGio(e,t){if(t!==`gzip`)return decompressStreamWithGio(e,t);let n=[],r=0;for(;r<e.length&&!(e.length-r<2||e[r]!==31||e[r+1]!==139);){let t=e.subarray(r),i=findGzipMemberEnd(t);if(i<=0)break;let a=decompressStreamWithGio(t.subarray(0,i),`gzip`);n.push(a),r+=i}if(n.length===0)return decompressStreamWithGio(e,`gzip`);let i=n.reduce((e,t)=>e+t.length,0),a=new Uint8Array(i),o=0;for(let e of n)a.set(e,o),o+=e.length;return a}async function compressWithWeb(e,t){let n=new CompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function decompressWithWeb(e,t){let n=new DecompressionStream(t),r=n.writable.getWriter();r.write(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),r.close();let i=[],a=n.readable.getReader();for(;;){let{done:e,value:t}=await a.read();if(e)break;i.push(t)}let o=i.reduce((e,t)=>e+t.length,0),s=new Uint8Array(o),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function compress(e,t){return m?compressWithWeb(e,t):compressWithGio(e,t)}async function decompress(e,t){return m?decompressWithWeb(e,t):decompressWithGio(e,t)}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):e instanceof ArrayBuffer?new Uint8Array(e):e}function gzip(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gunzip(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`gzip`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflate(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflate(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function deflateRaw(e,t,n){let r=typeof t==`function`?t:n;compress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function inflateRaw(e,t,n){let r=typeof t==`function`?t:n;decompress(toUint8Array(e),`deflate-raw`).then(e=>r(null,e),e=>r(e instanceof Error?e:Error(String(e)),new Uint8Array))}function gzipSync(e,t){return compressWithGio(toUint8Array(e),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(e,t){return compressWithGio(toUint8Array(e),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(e,t){return compressWithGio(toUint8Array(e),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array(e),`deflate-raw`)}const h=new Uint8Array;function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),h)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),h)}function brotliCompressSync(e,t){throw Error(`brotliCompressSync: Brotli is not supported in this environment`)}function brotliDecompressSync(e,t){throw Error(`brotliDecompressSync: Brotli is not supported in this environment`)}function zstdCompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdCompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,h)}function zstdDecompress(e,t,n){let r=typeof t==`function`?t:n,i=Error(`zstdDecompress: Zstd is not supported in this environment`);i.code=`ERR_UNSUPPORTED_OPERATION`,r(i,h)}function zstdCompressSync(e,t){let n=Error(`zstdCompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}function zstdDecompressSync(e,t){let n=Error(`zstdDecompressSync: Zstd is not supported in this environment`);throw n.code=`ERR_UNSUPPORTED_OPERATION`,n}const g={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,Z_DEFLATED:8};var _={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,createGzip:o,createGunzip:a,createDeflate:r,createInflate:s,createDeflateRaw:i,createInflateRaw:c,createUnzip:l,createBrotliCompress:t,createBrotliDecompress:n,createZstdCompress:u,createZstdDecompress:d,constants:g};export{e as ZlibTransform,brotliCompress,brotliCompressSync,brotliDecompress,brotliDecompressSync,g as constants,t as createBrotliCompress,n as createBrotliDecompress,r as createDeflate,i as createDeflateRaw,a as createGunzip,o as createGzip,s as createInflate,c as createInflateRaw,l as createUnzip,u as createZstdCompress,d as createZstdDecompress,_ as default,deflate,deflateRaw,deflateRawSync,deflateSync,gunzip,gunzipSync,gzip,gzipSync,inflate,inflateRaw,inflateRawSync,inflateSync,zstdCompress,zstdCompressSync,zstdDecompress,zstdDecompressSync};
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import e from"@girs/gio-2.0";import t from"@girs/glib-2.0";import{Transform as n}from"node:stream";function getGioCompressorFormat(t){switch(t){case`gzip`:return e.ZlibCompressorFormat.GZIP;case`deflate`:return e.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return e.ZlibCompressorFormat.RAW}}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var ZlibTransform=class extends n{_format;_mode;_chunks=[];constructor(e,t,n){super(n),this._format=e,this._mode=t}_transform(e,t,n){this._chunks.push(toUint8Array(e)),n()}_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;this._chunks=[];try{let t=this._mode===`compress`?this._compress(n):this._decompress(n);this.push(Buffer.from(t)),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_compress(n){let r=new e.ZlibCompressor({format:getGioCompressorFormat(this._format)}),i=new e.ConverterOutputStream({base_stream:e.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new t.Bytes(n),null),i.close(null);let a=i.get_base_stream().steal_as_bytes();return new Uint8Array(a.get_data()??[])}_decompress(n){let r=new e.ZlibDecompressor({format:getGioCompressorFormat(this._format)}),i=e.MemoryInputStream.new_from_bytes(new t.Bytes(n)),a=new e.ConverterInputStream({base_stream:i,converter:r}),o=[];for(;;){let e=a.read_bytes(4096,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}a.close(null);let s=o.reduce((e,t)=>e+t.length,0),c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}};function createGzip(e){return new ZlibTransform(`gzip`,`compress`,e)}function createGunzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createDeflate(e){return new ZlibTransform(`deflate`,`compress`,e)}function createInflate(e){return new ZlibTransform(`deflate`,`decompress`,e)}function createDeflateRaw(e){return new ZlibTransform(`deflate-raw`,`compress`,e)}function createInflateRaw(e){return new ZlibTransform(`deflate-raw`,`decompress`,e)}function createUnzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}export{ZlibTransform,createBrotliCompress,createBrotliDecompress,createDeflate,createDeflateRaw,createGunzip,createGzip,createInflate,createInflateRaw,createUnzip};
1
+ import"./_virtual/_rolldown/runtime.js";import e from"@girs/gio-2.0";import t from"@girs/glib-2.0";import{Transform as n}from"node:stream";function getGioCompressorFormat(t){switch(t){case`gzip`:return e.ZlibCompressorFormat.GZIP;case`deflate`:return e.ZlibCompressorFormat.ZLIB;case`deflate-raw`:return e.ZlibCompressorFormat.RAW}}function toUint8Array(e){return typeof e==`string`?new TextEncoder().encode(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var ZlibTransform=class extends n{_format;_mode;_chunks=[];constructor(e,t,n){super(n),this._format=e,this._mode=t}_transform(e,t,n){this._chunks.push(toUint8Array(e)),n()}_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;this._chunks=[];try{let t=this._mode===`compress`?this._compress(n):this._decompress(n);this.push(Buffer.from(t)),e()}catch(t){e(t instanceof Error?t:Error(String(t)))}}_compress(n){let r=new e.ZlibCompressor({format:getGioCompressorFormat(this._format)}),i=new e.ConverterOutputStream({base_stream:e.MemoryOutputStream.new_resizable(),converter:r});i.write_bytes(new t.Bytes(n),null),i.close(null);let a=i.get_base_stream().steal_as_bytes();return new Uint8Array(a.get_data()??[])}_decompress(n){let r=new e.ZlibDecompressor({format:getGioCompressorFormat(this._format)}),i=e.MemoryInputStream.new_from_bytes(new t.Bytes(n)),a=new e.ConverterInputStream({base_stream:i,converter:r}),o=[];for(;;){let e=a.read_bytes(4096,null);if(e.get_size()===0)break;o.push(new Uint8Array(e.get_data()))}a.close(null);let s=o.reduce((e,t)=>e+t.length,0),c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}};function createGzip(e){return new ZlibTransform(`gzip`,`compress`,e)}function createGunzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createDeflate(e){return new ZlibTransform(`deflate`,`compress`,e)}function createInflate(e){return new ZlibTransform(`deflate`,`decompress`,e)}function createDeflateRaw(e){return new ZlibTransform(`deflate-raw`,`compress`,e)}function createInflateRaw(e){return new ZlibTransform(`deflate-raw`,`decompress`,e)}function createUnzip(e){return new ZlibTransform(`gzip`,`decompress`,e)}function createBrotliCompress(e){throw Error(`createBrotliCompress is not supported on GJS (no Brotli in GLib)`)}function createBrotliDecompress(e){throw Error(`createBrotliDecompress is not supported on GJS (no Brotli in GLib)`)}function createZstdCompress(e){let t=Error(`createZstdCompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}function createZstdDecompress(e){let t=Error(`createZstdDecompress is not supported on GJS (no Zstd in GLib)`);throw t.code=`ERR_UNSUPPORTED_OPERATION`,t}export{ZlibTransform,createBrotliCompress,createBrotliDecompress,createDeflate,createDeflateRaw,createGunzip,createGzip,createInflate,createInflateRaw,createUnzip,createZstdCompress,createZstdDecompress};
@@ -0,0 +1,259 @@
1
+ import { Transform } from '@gjsify/stream/browser';
2
+ export declare const constants: {
3
+ readonly Z_NO_FLUSH: 0;
4
+ readonly Z_PARTIAL_FLUSH: 1;
5
+ readonly Z_SYNC_FLUSH: 2;
6
+ readonly Z_FULL_FLUSH: 3;
7
+ readonly Z_FINISH: 4;
8
+ readonly Z_BLOCK: 5;
9
+ readonly Z_TREES: 6;
10
+ readonly Z_OK: 0;
11
+ readonly Z_STREAM_END: 1;
12
+ readonly Z_NEED_DICT: 2;
13
+ readonly Z_ERRNO: -1;
14
+ readonly Z_STREAM_ERROR: -2;
15
+ readonly Z_DATA_ERROR: -3;
16
+ readonly Z_MEM_ERROR: -4;
17
+ readonly Z_BUF_ERROR: -5;
18
+ readonly Z_VERSION_ERROR: -6;
19
+ readonly Z_NO_COMPRESSION: 0;
20
+ readonly Z_BEST_SPEED: 1;
21
+ readonly Z_BEST_COMPRESSION: 9;
22
+ readonly Z_DEFAULT_COMPRESSION: -1;
23
+ readonly Z_FILTERED: 1;
24
+ readonly Z_HUFFMAN_ONLY: 2;
25
+ readonly Z_RLE: 3;
26
+ readonly Z_FIXED: 4;
27
+ readonly Z_DEFAULT_STRATEGY: 0;
28
+ readonly ZLIB_VERNUM: 4784;
29
+ readonly DEFLATE: 1;
30
+ readonly INFLATE: 2;
31
+ readonly GZIP: 3;
32
+ readonly GUNZIP: 4;
33
+ readonly DEFLATERAW: 5;
34
+ readonly INFLATERAW: 6;
35
+ readonly UNZIP: 7;
36
+ readonly BROTLI_DECODE: 8;
37
+ readonly BROTLI_ENCODE: 9;
38
+ readonly ZSTD_COMPRESS: 10;
39
+ readonly ZSTD_DECOMPRESS: 11;
40
+ readonly Z_MIN_WINDOWBITS: 8;
41
+ readonly Z_MAX_WINDOWBITS: 15;
42
+ readonly Z_DEFAULT_WINDOWBITS: 15;
43
+ readonly Z_MIN_CHUNK: 64;
44
+ readonly Z_MAX_CHUNK: number;
45
+ readonly Z_DEFAULT_CHUNK: 16384;
46
+ readonly Z_MIN_MEMLEVEL: 1;
47
+ readonly Z_MAX_MEMLEVEL: 9;
48
+ readonly Z_DEFAULT_MEMLEVEL: 8;
49
+ readonly Z_MIN_LEVEL: -1;
50
+ readonly Z_MAX_LEVEL: 9;
51
+ readonly Z_DEFAULT_LEVEL: -1;
52
+ readonly BROTLI_OPERATION_PROCESS: 0;
53
+ readonly BROTLI_OPERATION_FLUSH: 1;
54
+ readonly BROTLI_OPERATION_FINISH: 2;
55
+ readonly BROTLI_OPERATION_EMIT_METADATA: 3;
56
+ readonly BROTLI_PARAM_MODE: 0;
57
+ readonly BROTLI_MODE_GENERIC: 0;
58
+ readonly BROTLI_MODE_TEXT: 1;
59
+ readonly BROTLI_MODE_FONT: 2;
60
+ readonly BROTLI_DEFAULT_MODE: 0;
61
+ readonly BROTLI_PARAM_QUALITY: 1;
62
+ readonly BROTLI_MIN_QUALITY: 0;
63
+ readonly BROTLI_MAX_QUALITY: 11;
64
+ readonly BROTLI_DEFAULT_QUALITY: 11;
65
+ readonly BROTLI_PARAM_LGWIN: 2;
66
+ readonly BROTLI_MIN_WINDOW_BITS: 10;
67
+ readonly BROTLI_MAX_WINDOW_BITS: 24;
68
+ readonly BROTLI_LARGE_MAX_WINDOW_BITS: 30;
69
+ readonly BROTLI_DEFAULT_WINDOW: 22;
70
+ readonly BROTLI_PARAM_LGBLOCK: 3;
71
+ readonly BROTLI_MIN_INPUT_BLOCK_BITS: 16;
72
+ readonly BROTLI_MAX_INPUT_BLOCK_BITS: 24;
73
+ readonly BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4;
74
+ readonly BROTLI_PARAM_SIZE_HINT: 5;
75
+ readonly BROTLI_PARAM_LARGE_WINDOW: 6;
76
+ readonly BROTLI_PARAM_NPOSTFIX: 7;
77
+ readonly BROTLI_PARAM_NDIRECT: 8;
78
+ };
79
+ export type ZlibOptions = Record<string, unknown>;
80
+ type Callback = (err: Error | null, result?: Uint8Array) => void;
81
+ type WebCompressionFormat = 'gzip' | 'deflate' | 'deflate-raw';
82
+ export declare const gzip: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
83
+ export declare const gunzip: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
84
+ export declare const deflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
85
+ export declare const inflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
86
+ export declare const deflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
87
+ export declare const inflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
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;
92
+ export declare const gzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
93
+ export declare const gunzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
94
+ export declare const deflateSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
95
+ export declare const inflateSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
96
+ export declare const deflateRawSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
97
+ export declare const inflateRawSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
98
+ export declare const brotliCompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
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;
102
+ declare class ZlibTransform extends Transform {
103
+ private _format;
104
+ private _direction;
105
+ private _chunks;
106
+ constructor(format: WebCompressionFormat, direction: 'compress' | 'decompress');
107
+ _transform(chunk: unknown, _enc: string, cb: (err: Error | null, data?: unknown) => void): void;
108
+ _flush(cb: (err?: Error | null) => void): void;
109
+ }
110
+ export declare class Gzip extends ZlibTransform {
111
+ constructor();
112
+ }
113
+ export declare class Gunzip extends ZlibTransform {
114
+ constructor();
115
+ }
116
+ export declare class Deflate extends ZlibTransform {
117
+ constructor();
118
+ }
119
+ export declare class Inflate extends ZlibTransform {
120
+ constructor();
121
+ }
122
+ export declare class DeflateRaw extends ZlibTransform {
123
+ constructor();
124
+ }
125
+ export declare class InflateRaw extends ZlibTransform {
126
+ constructor();
127
+ }
128
+ export declare class BrotliCompress extends Transform {
129
+ constructor();
130
+ }
131
+ export declare class BrotliDecompress extends Transform {
132
+ constructor();
133
+ }
134
+ export declare const createGzip: (_opts?: ZlibOptions) => Gzip;
135
+ export declare const createGunzip: (_opts?: ZlibOptions) => Gunzip;
136
+ export declare const createDeflate: (_opts?: ZlibOptions) => Deflate;
137
+ export declare const createInflate: (_opts?: ZlibOptions) => Inflate;
138
+ export declare const createDeflateRaw: (_opts?: ZlibOptions) => DeflateRaw;
139
+ export declare const createInflateRaw: (_opts?: ZlibOptions) => InflateRaw;
140
+ export declare const createBrotliCompress: (_opts?: ZlibOptions) => BrotliCompress;
141
+ export declare const createBrotliDecompress: (_opts?: ZlibOptions) => BrotliDecompress;
142
+ export declare const createUnzip: (_opts?: ZlibOptions) => Gunzip;
143
+ declare const zlibDefault: {
144
+ constants: {
145
+ readonly Z_NO_FLUSH: 0;
146
+ readonly Z_PARTIAL_FLUSH: 1;
147
+ readonly Z_SYNC_FLUSH: 2;
148
+ readonly Z_FULL_FLUSH: 3;
149
+ readonly Z_FINISH: 4;
150
+ readonly Z_BLOCK: 5;
151
+ readonly Z_TREES: 6;
152
+ readonly Z_OK: 0;
153
+ readonly Z_STREAM_END: 1;
154
+ readonly Z_NEED_DICT: 2;
155
+ readonly Z_ERRNO: -1;
156
+ readonly Z_STREAM_ERROR: -2;
157
+ readonly Z_DATA_ERROR: -3;
158
+ readonly Z_MEM_ERROR: -4;
159
+ readonly Z_BUF_ERROR: -5;
160
+ readonly Z_VERSION_ERROR: -6;
161
+ readonly Z_NO_COMPRESSION: 0;
162
+ readonly Z_BEST_SPEED: 1;
163
+ readonly Z_BEST_COMPRESSION: 9;
164
+ readonly Z_DEFAULT_COMPRESSION: -1;
165
+ readonly Z_FILTERED: 1;
166
+ readonly Z_HUFFMAN_ONLY: 2;
167
+ readonly Z_RLE: 3;
168
+ readonly Z_FIXED: 4;
169
+ readonly Z_DEFAULT_STRATEGY: 0;
170
+ readonly ZLIB_VERNUM: 4784;
171
+ readonly DEFLATE: 1;
172
+ readonly INFLATE: 2;
173
+ readonly GZIP: 3;
174
+ readonly GUNZIP: 4;
175
+ readonly DEFLATERAW: 5;
176
+ readonly INFLATERAW: 6;
177
+ readonly UNZIP: 7;
178
+ readonly BROTLI_DECODE: 8;
179
+ readonly BROTLI_ENCODE: 9;
180
+ readonly ZSTD_COMPRESS: 10;
181
+ readonly ZSTD_DECOMPRESS: 11;
182
+ readonly Z_MIN_WINDOWBITS: 8;
183
+ readonly Z_MAX_WINDOWBITS: 15;
184
+ readonly Z_DEFAULT_WINDOWBITS: 15;
185
+ readonly Z_MIN_CHUNK: 64;
186
+ readonly Z_MAX_CHUNK: number;
187
+ readonly Z_DEFAULT_CHUNK: 16384;
188
+ readonly Z_MIN_MEMLEVEL: 1;
189
+ readonly Z_MAX_MEMLEVEL: 9;
190
+ readonly Z_DEFAULT_MEMLEVEL: 8;
191
+ readonly Z_MIN_LEVEL: -1;
192
+ readonly Z_MAX_LEVEL: 9;
193
+ readonly Z_DEFAULT_LEVEL: -1;
194
+ readonly BROTLI_OPERATION_PROCESS: 0;
195
+ readonly BROTLI_OPERATION_FLUSH: 1;
196
+ readonly BROTLI_OPERATION_FINISH: 2;
197
+ readonly BROTLI_OPERATION_EMIT_METADATA: 3;
198
+ readonly BROTLI_PARAM_MODE: 0;
199
+ readonly BROTLI_MODE_GENERIC: 0;
200
+ readonly BROTLI_MODE_TEXT: 1;
201
+ readonly BROTLI_MODE_FONT: 2;
202
+ readonly BROTLI_DEFAULT_MODE: 0;
203
+ readonly BROTLI_PARAM_QUALITY: 1;
204
+ readonly BROTLI_MIN_QUALITY: 0;
205
+ readonly BROTLI_MAX_QUALITY: 11;
206
+ readonly BROTLI_DEFAULT_QUALITY: 11;
207
+ readonly BROTLI_PARAM_LGWIN: 2;
208
+ readonly BROTLI_MIN_WINDOW_BITS: 10;
209
+ readonly BROTLI_MAX_WINDOW_BITS: 24;
210
+ readonly BROTLI_LARGE_MAX_WINDOW_BITS: 30;
211
+ readonly BROTLI_DEFAULT_WINDOW: 22;
212
+ readonly BROTLI_PARAM_LGBLOCK: 3;
213
+ readonly BROTLI_MIN_INPUT_BLOCK_BITS: 16;
214
+ readonly BROTLI_MAX_INPUT_BLOCK_BITS: 24;
215
+ readonly BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING: 4;
216
+ readonly BROTLI_PARAM_SIZE_HINT: 5;
217
+ readonly BROTLI_PARAM_LARGE_WINDOW: 6;
218
+ readonly BROTLI_PARAM_NPOSTFIX: 7;
219
+ readonly BROTLI_PARAM_NDIRECT: 8;
220
+ };
221
+ gzip: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
222
+ gunzip: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
223
+ deflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
224
+ inflate: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
225
+ deflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
226
+ inflateRaw: (data: string | Uint8Array | ArrayBuffer, optsOrCb: ZlibOptions | Callback, maybeCb?: Callback) => void;
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;
231
+ gzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
232
+ gunzipSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
233
+ deflateSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
234
+ inflateSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
235
+ deflateRawSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
236
+ inflateRawSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
237
+ brotliCompressSync: (_data: string | Uint8Array | ArrayBuffer, _opts?: ZlibOptions) => Uint8Array;
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;
241
+ Gzip: typeof Gzip;
242
+ Gunzip: typeof Gunzip;
243
+ Deflate: typeof Deflate;
244
+ Inflate: typeof Inflate;
245
+ DeflateRaw: typeof DeflateRaw;
246
+ InflateRaw: typeof InflateRaw;
247
+ BrotliCompress: typeof BrotliCompress;
248
+ BrotliDecompress: typeof BrotliDecompress;
249
+ createGzip: (_opts?: ZlibOptions) => Gzip;
250
+ createGunzip: (_opts?: ZlibOptions) => Gunzip;
251
+ createDeflate: (_opts?: ZlibOptions) => Deflate;
252
+ createInflate: (_opts?: ZlibOptions) => Inflate;
253
+ createDeflateRaw: (_opts?: ZlibOptions) => DeflateRaw;
254
+ createInflateRaw: (_opts?: ZlibOptions) => InflateRaw;
255
+ createBrotliCompress: (_opts?: ZlibOptions) => BrotliCompress;
256
+ createBrotliDecompress: (_opts?: ZlibOptions) => BrotliDecompress;
257
+ createUnzip: (_opts?: ZlibOptions) => Gunzip;
258
+ };
259
+ export default zlibDefault;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -23,6 +23,10 @@ export declare function brotliCompress(data: string | Uint8Array | ArrayBuffer,
23
23
  export declare function brotliDecompress(data: string | Uint8Array | ArrayBuffer, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
24
24
  export declare function brotliCompressSync(_data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
25
25
  export declare function brotliDecompressSync(_data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
26
+ export declare function zstdCompress(data: string | Uint8Array | ArrayBuffer, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
27
+ export declare function zstdDecompress(data: string | Uint8Array | ArrayBuffer, optionsOrCallback: ZlibOptions | ZlibCallback, callback?: ZlibCallback): void;
28
+ export declare function zstdCompressSync(_data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
29
+ export declare function zstdDecompressSync(_data: string | Uint8Array | ArrayBuffer, _options?: ZlibOptions): Uint8Array;
26
30
  export declare const constants: {
27
31
  Z_NO_FLUSH: number;
28
32
  Z_PARTIAL_FLUSH: number;
@@ -51,7 +55,8 @@ export declare const constants: {
51
55
  Z_DEFAULT_STRATEGY: number;
52
56
  Z_DEFLATED: number;
53
57
  };
54
- import { createGzip, createGunzip, createDeflate, createInflate, createDeflateRaw, createInflateRaw, createUnzip, createBrotliCompress, createBrotliDecompress } from './transform-streams.js';
58
+ import { createGzip, createGunzip, createDeflate, createInflate, createDeflateRaw, createInflateRaw, createUnzip, createBrotliCompress, createBrotliDecompress, createZstdCompress, createZstdDecompress } from './transform-streams.js';
59
+ export { createZstdCompress, createZstdDecompress } from './transform-streams.js';
55
60
  declare const _default: {
56
61
  gzip: typeof gzip;
57
62
  gunzip: typeof gunzip;
@@ -69,6 +74,10 @@ declare const _default: {
69
74
  brotliDecompress: typeof brotliDecompress;
70
75
  brotliCompressSync: typeof brotliCompressSync;
71
76
  brotliDecompressSync: typeof brotliDecompressSync;
77
+ zstdCompress: typeof zstdCompress;
78
+ zstdDecompress: typeof zstdDecompress;
79
+ zstdCompressSync: typeof zstdCompressSync;
80
+ zstdDecompressSync: typeof zstdDecompressSync;
72
81
  createGzip: typeof createGzip;
73
82
  createGunzip: typeof createGunzip;
74
83
  createDeflate: typeof createDeflate;
@@ -78,6 +87,8 @@ declare const _default: {
78
87
  createUnzip: typeof createUnzip;
79
88
  createBrotliCompress: typeof createBrotliCompress;
80
89
  createBrotliDecompress: typeof createBrotliDecompress;
90
+ createZstdCompress: typeof createZstdCompress;
91
+ createZstdDecompress: typeof createZstdDecompress;
81
92
  constants: {
82
93
  Z_NO_FLUSH: number;
83
94
  Z_PARTIAL_FLUSH: number;
@@ -20,4 +20,6 @@ export declare function createInflateRaw(options?: ZlibOptions): ZlibTransform;
20
20
  export declare function createUnzip(options?: ZlibOptions): ZlibTransform;
21
21
  export declare function createBrotliCompress(_options?: ZlibOptions): never;
22
22
  export declare function createBrotliDecompress(_options?: ZlibOptions): never;
23
+ export declare function createZstdCompress(_options?: ZlibOptions): never;
24
+ export declare function createZstdDecompress(_options?: ZlibOptions): never;
23
25
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/zlib",
3
- "version": "0.4.35",
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",
@@ -12,6 +12,10 @@
12
12
  ".": {
13
13
  "types": "./lib/types/index.d.ts",
14
14
  "default": "./lib/esm/index.js"
15
+ },
16
+ "./browser": {
17
+ "types": "./lib/types/browser.d.ts",
18
+ "default": "./lib/esm/browser.js"
15
19
  }
16
20
  },
17
21
  "scripts": {
@@ -23,6 +27,7 @@
23
27
  "build:test": "gjsify run build:test:gjs && gjsify run build:test:node",
24
28
  "build:test:gjs": "gjsify build src/test.mts --app gjs --outfile test.gjs.mjs",
25
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",
26
31
  "test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:node && gjsify run test:gjs",
27
32
  "test:gjs": "gjsify run test.gjs.mjs",
28
33
  "test:node": "node test.node.mjs"
@@ -33,20 +38,32 @@
33
38
  "zlib"
34
39
  ],
35
40
  "dependencies": {
36
- "@girs/gio-2.0": "2.88.0-4.0.1",
37
- "@girs/glib-2.0": "2.88.0-4.0.1"
41
+ "@girs/gio-2.0": "2.88.0-4.0.4",
42
+ "@girs/glib-2.0": "2.88.0-4.0.4"
38
43
  },
39
44
  "devDependencies": {
40
- "@gjsify/cli": "^0.4.35",
41
- "@gjsify/unit": "^0.4.35",
45
+ "@gjsify/cli": "^0.4.37",
46
+ "@gjsify/stream": "^0.4.37",
47
+ "@gjsify/unit": "^0.4.37",
42
48
  "@types/node": "^25.9.1",
43
- "typescript": "^6.0.3"
49
+ "typescript": "^5.9.3"
44
50
  },
45
51
  "gjsify": {
46
52
  "runtimes": {
47
53
  "gjs": "polyfill",
48
54
  "node": "none",
49
- "browser": "none"
55
+ "browser": "partial",
56
+ "nativescript": "none"
50
57
  }
51
- }
58
+ },
59
+ "license": "MIT",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/gjsify/gjsify.git",
63
+ "directory": "packages/node/zlib"
64
+ },
65
+ "bugs": {
66
+ "url": "https://github.com/gjsify/gjsify/issues"
67
+ },
68
+ "homepage": "https://github.com/gjsify/gjsify/tree/main/packages/node/zlib#readme"
52
69
  }