@gjsify/zlib 0.39.0 → 0.41.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.
Files changed (2) hide show
  1. package/lib/esm/index.js +1 -1
  2. package/package.json +5 -5
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";import{compressWithGio as e,decompressStreamWithGio as t,gunzipWithGio as n}from"./gio-codec.js";import{BrotliCompress as r,BrotliDecompress as i,Deflate as a,DeflateRaw as o,Gunzip as s,Gzip as c,Inflate as l,InflateRaw as u,Unzip as d,ZlibBase as f,ZstdCompress as p,ZstdDecompress as m,createBrotliCompress as h,createBrotliDecompress as g,createDeflate as _,createDeflateRaw as v,createGunzip as y,createGzip as b,createInflate as x,createInflateRaw as S,createUnzip as C,createZstdCompress as w,createZstdDecompress as T}from"./transform-streams.js";const E=globalThis.CompressionStream!==void 0;function decompressWithGio(e,r){return r===`gzip`?n(e):t(e,r)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let a=r.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of r)o.set(e,s),s+=e.length;return o}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}async function compress(t,n){return E?compressWithWeb(t,n):e(t,n)}async function decompress(e,t){return E?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(t,n){return e(toUint8Array(t),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(t,n){return e(toUint8Array(t),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(t,n){return e(toUint8Array(t),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array(e),`deflate-raw`)}const D=new Uint8Array;function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),D)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),D)}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,D)}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,D)}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 O={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 k={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip:c,Gunzip:s,Deflate:a,Inflate:l,DeflateRaw:o,InflateRaw:u,Unzip:d,BrotliCompress:r,BrotliDecompress:i,ZstdCompress:p,ZstdDecompress:m,createGzip:b,createGunzip:y,createDeflate:_,createInflate:x,createDeflateRaw:v,createInflateRaw:S,createUnzip:C,createBrotliCompress:h,createBrotliDecompress:g,createZstdCompress:w,createZstdDecompress:T,constants:O};export{r as BrotliCompress,i as BrotliDecompress,a as Deflate,o as DeflateRaw,s as Gunzip,c as Gzip,l as Inflate,u as InflateRaw,d as Unzip,f as ZlibTransform,p as ZstdCompress,m as ZstdDecompress,brotliCompress,brotliCompressSync,brotliDecompress,brotliDecompressSync,O as constants,h as createBrotliCompress,g as createBrotliDecompress,_ as createDeflate,v as createDeflateRaw,y as createGunzip,b as createGzip,x as createInflate,S as createInflateRaw,C as createUnzip,w as createZstdCompress,T as createZstdDecompress,k as default,deflate,deflateRaw,deflateRawSync,deflateSync,gunzip,gunzipSync,gzip,gzipSync,inflate,inflateRaw,inflateRawSync,inflateSync,zstdCompress,zstdCompressSync,zstdDecompress,zstdDecompressSync};
1
+ import"./_virtual/_rolldown/runtime.js";import{compressWithGio as e,decompressStreamWithGio as t,gunzipWithGio as n}from"./gio-codec.js";import{BrotliCompress as r,BrotliDecompress as i,Deflate as a,DeflateRaw as o,Gunzip as s,Gzip as c,Inflate as l,InflateRaw as u,Unzip as d,ZlibBase as f,ZstdCompress as p,ZstdDecompress as m,createBrotliCompress as h,createBrotliDecompress as g,createDeflate as _,createDeflateRaw as v,createGunzip as y,createGzip as b,createInflate as x,createInflateRaw as S,createUnzip as C,createZstdCompress as w,createZstdDecompress as T}from"./transform-streams.js";const hasWebCompression=()=>globalThis.CompressionStream!==void 0;function decompressWithGio(e,r){return r===`gzip`?n(e):t(e,r)}async function runWebTransform(e,t){let n=new ReadableStream({start(t){t.enqueue(new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),t.close()}}),r=[],i=n.pipeThrough(t).getReader();for(;;){let{done:e,value:t}=await i.read();if(e)break;r.push(t)}let a=r.reduce((e,t)=>e+t.length,0),o=new Uint8Array(a),s=0;for(let e of r)o.set(e,s),s+=e.length;return o}async function compressWithWeb(e,t){return runWebTransform(e,new CompressionStream(t))}async function decompressWithWeb(e,t){return runWebTransform(e,new DecompressionStream(t))}async function compress(t,n){return hasWebCompression()?compressWithWeb(t,n):e(t,n)}async function decompress(e,t){if(hasWebCompression())try{return await decompressWithWeb(e,t)}catch(n){if(t!==`gzip`)throw n;return decompressWithGio(e,t)}return 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(t,n){return e(toUint8Array(t),`gzip`)}function gunzipSync(e,t){return decompressWithGio(toUint8Array(e),`gzip`)}function deflateSync(t,n){return e(toUint8Array(t),`deflate`)}function inflateSync(e,t){return decompressWithGio(toUint8Array(e),`deflate`)}function deflateRawSync(t,n){return e(toUint8Array(t),`deflate-raw`)}function inflateRawSync(e,t){return decompressWithGio(toUint8Array(e),`deflate-raw`)}const E=new Uint8Array;function brotliCompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliCompress: Brotli is not supported in this environment`),E)}function brotliDecompress(e,t,n){(typeof t==`function`?t:n)(Error(`brotliDecompress: Brotli is not supported in this environment`),E)}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,E)}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,E)}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 D={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 O={gzip,gunzip,deflate,inflate,deflateRaw,inflateRaw,gzipSync,gunzipSync,deflateSync,inflateSync,deflateRawSync,inflateRawSync,brotliCompress,brotliDecompress,brotliCompressSync,brotliDecompressSync,zstdCompress,zstdDecompress,zstdCompressSync,zstdDecompressSync,Gzip:c,Gunzip:s,Deflate:a,Inflate:l,DeflateRaw:o,InflateRaw:u,Unzip:d,BrotliCompress:r,BrotliDecompress:i,ZstdCompress:p,ZstdDecompress:m,createGzip:b,createGunzip:y,createDeflate:_,createInflate:x,createDeflateRaw:v,createInflateRaw:S,createUnzip:C,createBrotliCompress:h,createBrotliDecompress:g,createZstdCompress:w,createZstdDecompress:T,constants:D};export{r as BrotliCompress,i as BrotliDecompress,a as Deflate,o as DeflateRaw,s as Gunzip,c as Gzip,l as Inflate,u as InflateRaw,d as Unzip,f as ZlibTransform,p as ZstdCompress,m as ZstdDecompress,brotliCompress,brotliCompressSync,brotliDecompress,brotliDecompressSync,D as constants,h as createBrotliCompress,g as createBrotliDecompress,_ as createDeflate,v as createDeflateRaw,y as createGunzip,b as createGzip,x as createInflate,S as createInflateRaw,C as createUnzip,w as createZstdCompress,T as createZstdDecompress,O as default,deflate,deflateRaw,deflateRawSync,deflateSync,gunzip,gunzipSync,gzip,gzipSync,inflate,inflateRaw,inflateRawSync,inflateSync,zstdCompress,zstdCompressSync,zstdDecompress,zstdDecompressSync};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/zlib",
3
- "version": "0.39.0",
3
+ "version": "0.41.0",
4
4
  "description": "Node.js zlib module for Gjs",
5
5
  "module": "lib/esm/index.js",
6
6
  "types": "lib/types/index.d.ts",
@@ -40,12 +40,12 @@
40
40
  "dependencies": {
41
41
  "@girs/gio-2.0": "^4.1.0",
42
42
  "@girs/glib-2.0": "^4.1.0",
43
- "@gjsify/stream": "^0.39.0"
43
+ "@gjsify/stream": "^0.41.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@gjsify/cli": "^0.39.0",
47
- "@gjsify/unit": "^0.39.0",
48
- "@gjsify/util": "^0.39.0",
46
+ "@gjsify/cli": "^0.41.0",
47
+ "@gjsify/unit": "^0.41.0",
48
+ "@gjsify/util": "^0.41.0",
49
49
  "@types/node": "^25.9.2",
50
50
  "typescript": "^6.0.3"
51
51
  },