eth-compress 0.3.0 → 0.3.1

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 CHANGED
@@ -1,15 +1,16 @@
1
1
  ## eth-compress
2
2
 
3
- Compact client-side module for compressing Ethereum JSON-RPC requests, targeting **lower latency** and gas-efficient **read-only calls** with large calldata.
3
+ A compact client-side module for compressing Ethereum JSON-RPC requests, targeting **lower latency** and gas-efficient **read-only calls** with large calldata.
4
4
 
5
- It combines [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.3)-compliant negotiation for client-to-server compression, with optional JIT-compiled calldata compression for `eth_call`s.
5
+ It combines [RFC 9110](https://www.rfc-editor.org/rfc/rfc9110.html#section-12.5.3)-compliant negotiation for client-to-server compression, with optional JIT-compiled calldata compression.
6
6
 
7
- _Plug'n Play with viem & with a simple API_
7
+ _Plug 'n' play with viem and a simple API_
8
8
 
9
9
  ### Scope
10
- - Only **read-only** `eth_call`s.
11
- - Only compresses above a size threshold, and only when it **strictly** reduces request size (HTTP: >1150 bytes; JIT calldata has a similar gate).
12
- - HTTP uses standard `Content-Encoding` negotiation (e.g. gzip/deflate). EVM mode routes eligible `eth_call`s through a temporary decompressor contract and forwards to the original `to` via state overrides.
10
+ - **Read-only** `eth_call`s.
11
+ - Min. input threshold: > 1150 bytes.
12
+ - HTTP: Uses RFC 9110-compliant `Content-Encoding` negotiation (gzip/deflate).
13
+ - EVM/JIT: Routes `eth_call`s through a transient decompressor contract.
13
14
 
14
15
  ### Installation
15
16
 
@@ -17,9 +18,9 @@ _Plug'n Play with viem & with a simple API_
17
18
  npm i eth-compress
18
19
  ```
19
20
  ---
20
- ### HTTP request compression (transport-level)
21
+ ### HTTP request compression
21
22
 
22
- `eth-compress` exposes a `fetch`-compatible function that transparently compresses JSON-RPC request bodies using the CompressionStreams API, when the target RPC endpoint supports it and the payload is large enough to benefit.
23
+ Transparently compresses request bodies using the [CompressionStream API](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream).
23
24
 
24
25
  ```ts
25
26
  import { compressModule } from 'eth-compress';
@@ -72,18 +73,6 @@ const client = createPublicClient({
72
73
  });
73
74
  ```
74
75
 
75
- Proactive:
76
- ```ts
77
- import { compressModule } from 'eth-compress';
78
-
79
- const client = createPublicClient({
80
- chain: base,
81
- transport: http(rpcUrl, {
82
- fetchFn: (url, init) => compressModule(url, init, 'proactive'),
83
- }),
84
- });
85
- ```
86
-
87
76
  JIT calldata compression:
88
77
  ```ts
89
78
  import { compressModule } from 'eth-compress';
@@ -96,19 +85,19 @@ const client = createPublicClient({
96
85
  }),
97
86
  });
98
87
  ```
99
- #### thats it.
100
88
  ----
101
89
  ### Compatibility
102
- - Preserves viem semantics: responses and error handling are unchanged; only the request path is compressed.
103
- - Works in Node and modern browsers that support the `CompressionStreams API` (Chrome/Edge ≥ 80, Firefox ≥ 113, Safari/iOS ≥ 16.4).
90
+ - Preserves viem semantics: responses and error handling are unchanged; only the request body is compressed.
91
+ - Works in Node and modern browsers that support the CompressionStream API.
92
+ <br><a href="https://caniuse.com/mdn-api_compressionstream">Chrome/Edge ≥ 80; Firefox ≥ 113; Safari/iOS ≥ 16.4</a>
104
93
 
105
94
  <br>
106
95
 
107
96
  ----
108
97
 
109
- ### eth_call JIT calldata compression (application-level)
98
+ ### JIT calldata compression for `eth_call`
110
99
 
111
- Implemented purely at the application layer: the client rewrites eligible `eth_call`s and injects a JIT decompressor via `stateOverride`/`stateDiff`.
100
+ Eligible `eth_call`s are compiled into a transient decompressor contract (passed via `stateDiff`).
112
101
 
113
102
  ```ts
114
103
  import { compress_call } from 'eth-compress/compressor';
@@ -118,37 +107,35 @@ const payload = {
118
107
  params: [
119
108
  {
120
109
  to: '0x…',
121
- data: '0x…', // potentially large calldata
110
+ data: '0x…',
122
111
  },
123
112
  'latest',
124
113
  ],
125
114
  };
126
115
 
127
- const compressedPayload = compress_call(payload); // safe to send instead of `payload`
116
+ const compressedPayload = compress_call(payload);
128
117
  ```
129
118
 
130
- `compress_call` can be passed directly to `compressModule` as a custom transform. For eligible `eth_call`s it chooses between:
119
+ `compress_call` can be passed directly to `compressModule` as a custom transform. For eligible `eth_call`s, it chooses between:
131
120
 
132
121
  - **JIT**: Compiles just-in-time, a one-off decompressor contract that reconstructs calldata to forward the call.
133
- - **FLZ / CD**: Uses `LibZip.flzCompress` and `LibZip.cdCompress` from `solady` for fast LZ and calldata RLE compression.
134
-
135
- Selection logic (subject to change, but current behaviour):
122
+ - **FLZ / CD**: Uses `LibZip.flzCompress` and `LibZip.cdCompress` from `solady` for FastLZ / RLE compression.
136
123
 
137
124
  - **Size gating (JIT / EVM path)**:
138
125
  - `< 1150 bytes (effective payload)`: no EVM-level compression.
139
126
  - `≥ 1150 bytes`: compression considered.
140
127
  - `size ≤ ~3000 bytes or > ~8000 bytes`: JIT is preferred.
141
- - `~3000 ≤ size ≤ ~8000 bytes`: Best of 3
128
+ - `~3000 ≤ size ≤ ~8000 bytes`: Best-of-3.
142
129
 
143
130
  - **Algorithm choice**:
144
131
  - For mid-sized payloads, FLZ and CD are tried and the smaller output is chosen.
145
- - For larger payloads, JIT is used directly, prioritizing gas efficiency.
146
- - The thresholds are chosen with consideration for request header overhead & latency,
132
+ - For larger ones, JIT is used directly, prioritizing gas efficiency.
133
+ - The thresholds are chosen with request header overhead and latency in mind,
147
134
  aiming to keep the total request size within the [Ethernet MTU](https://en.wikipedia.org/wiki/Maximum_transmission_unit).
148
135
 
149
136
  ### Important considerations
150
137
 
151
- The JIT calldata compressor is **experimental** and intended for read-only `eth_call`s that fetch auxiliary/bulk dApp data (dashboards, analytics, non-critical views). Avoid using it for critical user flows. Ideally you use two viem clients if you intend to use that feature: one with JIT enabled for auxiliary reads, and one without for critical data.
138
+ The JIT calldata compressor is **experimental** and intended for auxiliary/bulk dApp read-only `eth_call`s. Use two viem clients to separate concerns.
152
139
 
153
140
  ### Compression Ratio & Gas
154
141
  | Tx Size Range | # Txns | Avg. Tx Size| JIT Ratio | FLZ Ratio | CD Ratio | JIT Gas | FLZ Gas | CD Gas |
@@ -157,16 +144,16 @@ The JIT calldata compressor is **experimental** and intended for read-only `eth_
157
144
  | **3–8 KB** | 260 | 4.82 kb | 2.77x | 2.59x | **2.81x** | **4.45k** | 138k | 88.9k |
158
145
  | **1.15–3 KB** | 599 | 2.02 kb | **2.89x** | 1.91x | 2.58x | **3.35k** | 68.4k | 35.8k |
159
146
 
160
- <sub>Excludes txns not compressible &lt;70% of original size.</sub>
147
+ <sub>Excludes txns not compressible to &lt;70% of original size.</sub>
161
148
 
162
- ### Compression flavours
163
- - **JIT calldata compiler (`compress_call` JIT mode)**: Views the calldata as a zero‑initialized memory image and synthesises bytecode that rebuilds it word-by-word in-place.
149
+ ### Compression flavors
150
+ - **JIT calldata compiler (`compress_call` JIT mode)**: Views calldata as a zero‑initialized memory image and synthesizes bytecode that rebuilds it word-by-word in-place.
164
151
 
165
152
  In the first pass it walks the data in 32-byte slices, detects non-zero segments per word, and for each word chooses the cheapest of three strategies: store a literal tail, assemble segments using SHL/OR, or reuse an earlier word via MLOAD/MSTORE.
166
-
167
- In the second pass it materialises this plan into concrete PUSH/MSTORE/SHL/OR/DUP opcodes, pre-seeds the stack with frequently used constants, and appends a small CALL/RETURNDATA stub that forwards the reconstructed calldata to the original `to` address.
168
-
169
- The execution is realized through a `stateDiff` passed together with the `eth_call`. The 4‑byte selector is right‑aligned in the first 32‑byte slot so that the rest of the calldata can be reconstructed on mostly word‑aligned boundaries, with the decompressor stateDiff being placed at `0x00000000000000000000000000000000000000e0` such that `0xe0` can be obtained from `ADDRESS` with a single opcode instead of an explicit literal.
170
153
 
171
- Both the FastLZ and calldata-RLE forwarders are minimally adopted from Solady's [`LibZip.sol`](https://github.com/Vectorized/solady/blob/main/src/utils/LibZip.sol) and inlined as raw bytecode. To avoid Solidity's wrapper overhead the code is compiled from pure yul.
154
+ In the second pass it materializes this plan into concrete PUSH/MSTORE/SHL/OR/DUP opcodes, pre-seeds the stack with frequently used constants, and appends a small CALL/RETURNDATA stub that forwards the reconstructed calldata to the original `to` address.
155
+
156
+ The 4‑byte selector is right‑aligned in the first 32‑byte slot so that the rest of the calldata can be reconstructed on mostly word‑aligned boundaries, with the decompressor stateDiff being placed at `0xe0` to obtain this common offset from `ADDRESS` with a single opcode instead of PUSH1 + literal.
157
+
158
+ Both the FastLZ and calldata-RLE forwarders are minimally adapted from Solady's [`LibZip.sol`](https://github.com/Vectorized/solady/blob/main/src/utils/LibZip.sol) and inlined as raw bytecode. To avoid Solidity's wrapper overhead the code is compiled from pure yul.
172
159
 
package/_cjs/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- var u=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var C=(n,e)=>{for(var o in e)u(n,o,{get:e[o],enumerable:!0})},E=(n,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of w(e))!R.call(n,t)&&t!==o&&u(n,t,{get:()=>e[t],enumerable:!(s=b(e,t))||s.enumerable});return n};var q=n=>E(u({},"__esModule",{value:!0}),n);var v={};C(v,{MIN_BODY_SIZE:()=>_,compressModule:()=>M});module.exports=q(v);var _=1150,S=new Map,I=["gzip","deflate"];async function M(n,e,o){let s=n instanceof Request?n:null,t=typeof n=="string"?n:n instanceof Request?n.url:n.toString(),r=typeof e?.body=="string"?e.body:null;if(typeof o=="function"){if(s&&!e)return fetch(s);let f=e?.body;if(r)try{let a=o(JSON.parse(r));a!==void 0&&(f=JSON.stringify(a))}catch{}return fetch(s??t,{...e,body:f})}let c=S.get(t),m=typeof CompressionStream<"u",g=o==="gzip"||o==="deflate",i=m?g?o:o==="proactive"?c===-1?null:c??"gzip":typeof c=="string"?c:null:null,y=!!i&&!!r&&r.length>=1150,p={...e,priority:"high"},h=new Headers(p.headers);y&&(p.body=await new Response(new Blob([r]).stream().pipeThrough(new CompressionStream(i))).blob(),h.set("Content-Encoding",i)),p.headers=h;let d=await fetch(s??t,p);if(!g&&c===void 0){let a=d.headers.get("Accept-Encoding")?.split(",").map(l=>l.trim()).find(l=>I.includes(l))??-1;S.set(t,o==="proactive"&&y&&d.ok?i:a)}return d}0&&(module.exports={MIN_BODY_SIZE,compressModule});
1
+ var u=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var R=(n,e)=>{for(var o in e)u(n,o,{get:e[o],enumerable:!0})},C=(n,e,o,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of b(e))!w.call(n,t)&&t!==o&&u(n,t,{get:()=>e[t],enumerable:!(s=m(e,t))||s.enumerable});return n};var E=n=>C(u({},"__esModule",{value:!0}),n);var v={};R(v,{MIN_BODY_SIZE:()=>_,compressModule:()=>M});module.exports=E(v);var _=1150,q=typeof CompressionStream<"u",S=new Map,I=["gzip","deflate"];async function M(n,e,o){let s=n instanceof Request?n:null,t=typeof n=="string"?n:n instanceof Request?n.url:n.toString(),r=typeof e?.body=="string"?e.body:null;if(typeof o=="function"){if(s&&!e)return fetch(s);let f=e?.body;if(r)try{let a=o(JSON.parse(r));a!==void 0&&(f=JSON.stringify(a))}catch{}return fetch(s??t,{...e,body:f})}let c=S.get(t),g=o==="gzip"||o==="deflate",i=q?g?o:o==="proactive"?c===-1?null:c??"gzip":typeof c=="string"?c:null:null,y=!!i&&!!r&&r.length>=1150,p={...e,priority:"high"},h=new Headers(p.headers);y&&(p.body=await new Response(new Blob([r]).stream().pipeThrough(new CompressionStream(i))).blob(),h.set("Content-Encoding",i)),p.headers=h;let d=await fetch(s??t,p);if(!g&&c===void 0){let a=d.headers.get("Accept-Encoding")?.split(",").map(l=>l.trim()).find(l=>I.includes(l))??-1;S.set(t,o==="proactive"&&y&&d.ok?i:a)}return d}0&&(module.exports={MIN_BODY_SIZE,compressModule});
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["export const MIN_BODY_SIZE = 1150;\n\nconst _cache = new Map<string, string | -1>();\nconst _enc = ['gzip', 'deflate'] as const;\ntype SupportedEncoding = (typeof _enc)[number];\n\nexport type PayloadTransform = (payload: unknown) => unknown;\nexport type CompressionMode = 'passive' | 'proactive' | 'gzip' | 'deflate' | PayloadTransform;\n\n/**\n * @param input - URL or Request\n * @param init - Request options\n * @param mode - Compression mode:\n * - 'passive' (default): discover support via Accept-Encoding header first\n * - 'proactive': compress with gzip first, adjust if server rejects\n * - 'gzip' | 'deflate': use specified encoding directly (known support)\n * - PayloadTransform function: transform payload, skip HTTP compression\n */\nexport async function compressModule(\n input: string | URL | Request,\n init?: RequestInit,\n mode?: CompressionMode,\n): Promise<Response> {\n const req = input instanceof Request ? input : null;\n const url =\n typeof input === 'string' ? input : input instanceof Request ? input.url : input.toString();\n const bodyStr = typeof init?.body === 'string' ? init.body : null;\n\n // Custom transform: apply and skip HTTP compression\n if (typeof mode === 'function') {\n if (req && !init) return fetch(req);\n let body = init?.body;\n if (bodyStr)\n try {\n const next = mode(JSON.parse(bodyStr));\n if (next !== undefined) body = JSON.stringify(next);\n } catch {}\n return fetch(req ?? url, { ...init, body });\n }\n\n const cached = _cache.get(url);\n const hasCS = typeof CompressionStream !== 'undefined';\n const known = mode === 'gzip' || mode === 'deflate';\n const encoding = !hasCS\n ? null\n : known\n ? (mode as SupportedEncoding)\n : mode === 'proactive'\n ? cached === -1\n ? null\n : (cached ?? 'gzip')\n : typeof cached === 'string'\n ? cached\n : null;\n\n const shouldCompress = !!encoding && !!bodyStr && bodyStr.length >= MIN_BODY_SIZE;\n const opts: RequestInit = { ...init, priority: 'high' as RequestPriority };\n const headers = new Headers(opts.headers);\n if (shouldCompress) {\n opts.body = await new Response(\n new Blob([bodyStr!])\n .stream()\n .pipeThrough(new CompressionStream(encoding as CompressionFormat)),\n ).blob();\n headers.set('Content-Encoding', encoding);\n }\n opts.headers = headers;\n\n const response = await fetch(req ?? url, opts);\n\n // Cache discovery for passive/proactive (not known modes)\n if (!known && cached === undefined) {\n const header = response.headers.get('Accept-Encoding');\n const discovered =\n header\n ?.split(',')\n .map((e) => e.trim())\n .find((e): e is SupportedEncoding => _enc.includes(e as SupportedEncoding)) ?? -1;\n _cache.set(\n url,\n mode === 'proactive' && shouldCompress ? (response.ok ? encoding! : discovered) : discovered,\n );\n }\n\n return response;\n}\n"],
5
- "mappings": "4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAAO,IAAME,EAAgB,KAEvBG,EAAS,IAAI,IACbC,EAAO,CAAC,OAAQ,SAAS,EAe/B,eAAsBH,EACpBI,EACAC,EACAC,EACmB,CACnB,IAAMC,EAAMH,aAAiB,QAAUA,EAAQ,KACzCI,EACJ,OAAOJ,GAAU,SAAWA,EAAQA,aAAiB,QAAUA,EAAM,IAAMA,EAAM,SAAS,EACtFK,EAAU,OAAOJ,GAAM,MAAS,SAAWA,EAAK,KAAO,KAG7D,GAAI,OAAOC,GAAS,WAAY,CAC9B,GAAIC,GAAO,CAACF,EAAM,OAAO,MAAME,CAAG,EAClC,IAAIG,EAAOL,GAAM,KACjB,GAAII,EACF,GAAI,CACF,IAAME,EAAOL,EAAK,KAAK,MAAMG,CAAO,CAAC,EACjCE,IAAS,SAAWD,EAAO,KAAK,UAAUC,CAAI,EACpD,MAAQ,CAAC,CACX,OAAO,MAAMJ,GAAOC,EAAK,CAAE,GAAGH,EAAM,KAAAK,CAAK,CAAC,CAC5C,CAEA,IAAME,EAASV,EAAO,IAAIM,CAAG,EACvBK,EAAQ,OAAO,kBAAsB,IACrCC,EAAQR,IAAS,QAAUA,IAAS,UACpCS,EAAYF,EAEdC,EACGR,EACDA,IAAS,YACPM,IAAW,GACT,KACCA,GAAU,OACb,OAAOA,GAAW,SAChBA,EACA,KATN,KAWEI,EAAiB,CAAC,CAACD,GAAY,CAAC,CAACN,GAAWA,EAAQ,QAAU,KAC9DQ,EAAoB,CAAE,GAAGZ,EAAM,SAAU,MAA0B,EACnEa,EAAU,IAAI,QAAQD,EAAK,OAAO,EACpCD,IACFC,EAAK,KAAO,MAAM,IAAI,SACpB,IAAI,KAAK,CAACR,CAAQ,CAAC,EAChB,OAAO,EACP,YAAY,IAAI,kBAAkBM,CAA6B,CAAC,CACrE,EAAE,KAAK,EACPG,EAAQ,IAAI,mBAAoBH,CAAQ,GAE1CE,EAAK,QAAUC,EAEf,IAAMC,EAAW,MAAM,MAAMZ,GAAOC,EAAKS,CAAI,EAG7C,GAAI,CAACH,GAASF,IAAW,OAAW,CAElC,IAAMQ,EADSD,EAAS,QAAQ,IAAI,iBAAiB,GAG/C,MAAM,GAAG,EACV,IAAKE,GAAMA,EAAE,KAAK,CAAC,EACnB,KAAMA,GAA8BlB,EAAK,SAASkB,CAAsB,CAAC,GAAK,GACnFnB,EAAO,IACLM,EACAF,IAAS,aAAeU,GAAkBG,EAAS,GAAKJ,EAA0BK,CACpF,CACF,CAEA,OAAOD,CACT",
6
- "names": ["index_exports", "__export", "MIN_BODY_SIZE", "compressModule", "__toCommonJS", "_cache", "_enc", "input", "init", "mode", "req", "url", "bodyStr", "body", "next", "cached", "hasCS", "known", "encoding", "shouldCompress", "opts", "headers", "response", "discovered", "e"]
4
+ "sourcesContent": ["export const MIN_BODY_SIZE = 1150;\n\nconst _hasCS = typeof CompressionStream !== 'undefined';\nconst _cache = new Map<string, string | -1>();\nconst _enc = ['gzip', 'deflate'] as const;\ntype SupportedEncoding = (typeof _enc)[number];\n\nexport type PayloadTransform = (payload: unknown) => unknown;\nexport type CompressionMode = 'passive' | 'proactive' | 'gzip' | 'deflate' | PayloadTransform;\n\n/**\n * @param input - URL or Request\n * @param init - Request options\n * @param mode - Compression mode:\n * - 'passive' (default): discover support via Accept-Encoding header first\n * - 'proactive': compress with gzip first, adjust if server rejects\n * - 'gzip' | 'deflate': use specified encoding directly (known support)\n * - PayloadTransform function: transform payload, skip HTTP compression\n */\nexport async function compressModule(\n input: string | URL | Request,\n init?: RequestInit,\n mode?: CompressionMode,\n): Promise<Response> {\n const req = input instanceof Request ? input : null;\n const url =\n typeof input === 'string' ? input : input instanceof Request ? input.url : input.toString();\n const bodyStr = typeof init?.body === 'string' ? init.body : null;\n\n // Custom transform: apply and skip HTTP compression\n if (typeof mode === 'function') {\n if (req && !init) return fetch(req);\n let body = init?.body;\n if (bodyStr)\n try {\n const next = mode(JSON.parse(bodyStr));\n if (next !== undefined) body = JSON.stringify(next);\n } catch {}\n return fetch(req ?? url, { ...init, body });\n }\n\n const cached = _cache.get(url);\n const known = mode === 'gzip' || mode === 'deflate';\n const encoding = !_hasCS\n ? null\n : known\n ? (mode as SupportedEncoding)\n : mode === 'proactive'\n ? cached === -1\n ? null\n : (cached ?? 'gzip')\n : typeof cached === 'string'\n ? cached\n : null;\n\n const shouldCompress = !!encoding && !!bodyStr && bodyStr.length >= MIN_BODY_SIZE;\n const opts: RequestInit = { ...init, priority: 'high' as RequestPriority };\n const headers = new Headers(opts.headers);\n if (shouldCompress) {\n opts.body = await new Response(\n new Blob([bodyStr!])\n .stream()\n .pipeThrough(new CompressionStream(encoding as CompressionFormat)),\n ).blob();\n headers.set('Content-Encoding', encoding);\n }\n opts.headers = headers;\n\n const response = await fetch(req ?? url, opts);\n\n // Cache discovery for passive/proactive (not known modes)\n if (!known && cached === undefined) {\n const header = response.headers.get('Accept-Encoding');\n const discovered =\n header\n ?.split(',')\n .map((e) => e.trim())\n .find((e): e is SupportedEncoding => _enc.includes(e as SupportedEncoding)) ?? -1;\n _cache.set(\n url,\n mode === 'proactive' && shouldCompress ? (response.ok ? encoding! : discovered) : discovered,\n );\n }\n\n return response;\n}\n"],
5
+ "mappings": "4ZAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAAO,IAAME,EAAgB,KAEvBG,EAAS,OAAO,kBAAsB,IACtCC,EAAS,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,IAAI,iBAAiB,GAG/C,MAAM,GAAG,EACV,IAAKE,GAAMA,EAAE,KAAK,CAAC,EACnB,KAAMA,GAA8BjB,EAAK,SAASiB,CAAsB,CAAC,GAAK,GACnFlB,EAAO,IACLM,EACAF,IAAS,aAAeS,GAAkBG,EAAS,GAAKJ,EAA0BK,CACpF,CACF,CAEA,OAAOD,CACT",
6
+ "names": ["index_exports", "__export", "MIN_BODY_SIZE", "compressModule", "__toCommonJS", "_hasCS", "_cache", "_enc", "input", "init", "mode", "req", "url", "bodyStr", "body", "next", "cached", "known", "encoding", "shouldCompress", "opts", "headers", "response", "discovered", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- var R=Object.create;var d=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var I=(t,s)=>{for(var e in s)d(t,e,{get:s[e],enumerable:!0})},b=(t,s,e,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of q(s))!E.call(t,o)&&o!==e&&d(t,o,{get:()=>s[o],enumerable:!(n=z(s,o))||n.enumerable});return t};var v=(t,s,e)=>(e=t!=null?R(D(t)):{},b(s||!t||!t.__esModule?d(e,"default",{value:t,enumerable:!0}):e,t)),T=t=>b(d({},"__esModule",{value:!0}),t);var M={};I(M,{MIN_BODY_SIZE:()=>k,compressModule:()=>x});module.exports=T(M);var r=v(require("node:zlib"),1);var k=1150,S=new Map,_=["gzip","deflate"];async function x(t,s,e){let n=t instanceof Request?t:null,o=typeof t=="string"?t:t instanceof Request?t.url:t.toString(),a=typeof s?.body=="string"?s.body:null;if(typeof e=="function"){if(n&&!s)return fetch(n);let g=s?.body;if(a)try{let c=e(JSON.parse(a));c!==void 0&&(g=JSON.stringify(c))}catch{}return fetch(n??o,{...s,body:g})}let i=S.get(o),C=typeof CompressionStream<"u",y=e==="gzip"||e==="deflate",l=C?y?e:e==="proactive"?i===-1?null:i??"gzip":typeof i=="string"?i:null:null,m=!!l&&!!a&&a.length>=1150,p={...s,priority:"high"},h=new Headers(p.headers);m&&(p.body=await new Response(new Blob([a]).stream().pipeThrough(new CompressionStream(l))).blob(),h.set("Content-Encoding",l)),p.headers=h;let f=await fetch(n??o,p);if(!y&&i===void 0){let c=f.headers.get("Accept-Encoding")?.split(",").map(u=>u.trim()).find(u=>_.includes(u))??-1;S.set(o,e==="proactive"&&m&&f.ok?l:c)}return f}var w=(t,s)=>Object.assign(t,{writable:new WritableStream({write(e){return s.write(e),Promise.resolve()},close(){return s.end(),Promise.resolve()}}),readable:new ReadableStream({type:"bytes",start(e){s.on("data",n=>e.enqueue(n)),s.once("end",()=>e.close())}})});globalThis.CompressionStream||(globalThis.CompressionStream=class{constructor(s){let e;s==="deflate"?e=r.default.createDeflate():s==="gzip"?e=r.default.createGzip():s==="br"?e=r.default.createBrotliCompress():e=r.default.createDeflateRaw(),w(this,e)}});globalThis.DecompressionStream||(globalThis.DecompressionStream=class{constructor(s){let e;s==="deflate"?e=r.default.createInflate():s==="gzip"?e=r.default.createGunzip():s==="br"?e=r.default.createBrotliDecompress():e=r.default.createInflateRaw(),w(this,e)}});0&&(module.exports={MIN_BODY_SIZE,compressModule});
1
+ var C=Object.create;var d=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var E=(t,s)=>{for(var e in s)d(t,e,{get:s[e],enumerable:!0})},b=(t,s,e,n)=>{if(s&&typeof s=="object"||typeof s=="function")for(let o of z(s))!D.call(t,o)&&o!==e&&d(t,o,{get:()=>s[o],enumerable:!(n=R(s,o))||n.enumerable});return t};var I=(t,s,e)=>(e=t!=null?C(q(t)):{},b(s||!t||!t.__esModule?d(e,"default",{value:t,enumerable:!0}):e,t)),_=t=>b(d({},"__esModule",{value:!0}),t);var M={};E(M,{MIN_BODY_SIZE:()=>k,compressModule:()=>x});module.exports=_(M);var r=I(require("node:zlib"),1);var k=1150,v=typeof CompressionStream<"u",S=new Map,T=["gzip","deflate"];async function x(t,s,e){let n=t instanceof Request?t:null,o=typeof t=="string"?t:t instanceof Request?t.url:t.toString(),a=typeof s?.body=="string"?s.body:null;if(typeof e=="function"){if(n&&!s)return fetch(n);let g=s?.body;if(a)try{let c=e(JSON.parse(a));c!==void 0&&(g=JSON.stringify(c))}catch{}return fetch(n??o,{...s,body:g})}let i=S.get(o),y=e==="gzip"||e==="deflate",l=v?y?e:e==="proactive"?i===-1?null:i??"gzip":typeof i=="string"?i:null:null,m=!!l&&!!a&&a.length>=1150,p={...s,priority:"high"},h=new Headers(p.headers);m&&(p.body=await new Response(new Blob([a]).stream().pipeThrough(new CompressionStream(l))).blob(),h.set("Content-Encoding",l)),p.headers=h;let f=await fetch(n??o,p);if(!y&&i===void 0){let c=f.headers.get("Accept-Encoding")?.split(",").map(u=>u.trim()).find(u=>T.includes(u))??-1;S.set(o,e==="proactive"&&m&&f.ok?l:c)}return f}var w=(t,s)=>Object.assign(t,{writable:new WritableStream({write(e){return s.write(e),Promise.resolve()},close(){return s.end(),Promise.resolve()}}),readable:new ReadableStream({type:"bytes",start(e){s.on("data",n=>e.enqueue(n)),s.once("end",()=>e.close())}})});globalThis.CompressionStream||(globalThis.CompressionStream=class{constructor(s){let e;s==="deflate"?e=r.default.createDeflate():s==="gzip"?e=r.default.createGzip():s==="br"?e=r.default.createBrotliCompress():e=r.default.createDeflateRaw(),w(this,e)}});globalThis.DecompressionStream||(globalThis.DecompressionStream=class{constructor(s){let e;s==="deflate"?e=r.default.createInflate():s==="gzip"?e=r.default.createGunzip():s==="br"?e=r.default.createBrotliDecompress():e=r.default.createInflateRaw(),w(this,e)}});0&&(module.exports={MIN_BODY_SIZE,compressModule});
2
2
  //# sourceMappingURL=index.node.cjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.node.ts", "../../src/index.ts"],
4
- "sourcesContent": ["import zlib from 'node:zlib';\n\n// Polyfill for CompressionStream/DecompressionStream in older versions of Node.js & Bun\nconst make = (ctx: any, handle: any) =>\n Object.assign(ctx, {\n writable: new WritableStream({\n write(chunk) {\n handle.write(chunk);\n return Promise.resolve();\n },\n close() {\n handle.end();\n return Promise.resolve();\n },\n }),\n readable: new ReadableStream({\n type: 'bytes',\n start(ctrl) {\n handle.on('data', (chunk: any) => ctrl.enqueue(chunk));\n handle.once('end', () => ctrl.close());\n },\n }),\n });\n\nif (!globalThis.CompressionStream) {\n globalThis.CompressionStream = class CompressionStream {\n constructor(format: string) {\n let handle;\n if (format === 'deflate') {\n handle = zlib.createDeflate();\n } else if (format === 'gzip') {\n handle = zlib.createGzip();\n } else if (format === 'br') {\n handle = zlib.createBrotliCompress();\n } else {\n handle = zlib.createDeflateRaw();\n }\n make(this, handle);\n }\n } as any;\n}\n\nif (!globalThis.DecompressionStream) {\n globalThis.DecompressionStream = class DecompressionStream {\n constructor(format: string) {\n let handle;\n if (format === 'deflate') {\n handle = zlib.createInflate();\n } else if (format === 'gzip') {\n handle = zlib.createGunzip();\n } else if (format === 'br') {\n handle = zlib.createBrotliDecompress();\n } else {\n handle = zlib.createInflateRaw();\n }\n make(this, handle);\n }\n } as any;\n}\n\nexport * from './index';\n", "export const MIN_BODY_SIZE = 1150;\n\nconst _cache = new Map<string, string | -1>();\nconst _enc = ['gzip', 'deflate'] as const;\ntype SupportedEncoding = (typeof _enc)[number];\n\nexport type PayloadTransform = (payload: unknown) => unknown;\nexport type CompressionMode = 'passive' | 'proactive' | 'gzip' | 'deflate' | PayloadTransform;\n\n/**\n * @param input - URL or Request\n * @param init - Request options\n * @param mode - Compression mode:\n * - 'passive' (default): discover support via Accept-Encoding header first\n * - 'proactive': compress with gzip first, adjust if server rejects\n * - 'gzip' | 'deflate': use specified encoding directly (known support)\n * - PayloadTransform function: transform payload, skip HTTP compression\n */\nexport async function compressModule(\n input: string | URL | Request,\n init?: RequestInit,\n mode?: CompressionMode,\n): Promise<Response> {\n const req = input instanceof Request ? input : null;\n const url =\n typeof input === 'string' ? input : input instanceof Request ? input.url : input.toString();\n const bodyStr = typeof init?.body === 'string' ? init.body : null;\n\n // Custom transform: apply and skip HTTP compression\n if (typeof mode === 'function') {\n if (req && !init) return fetch(req);\n let body = init?.body;\n if (bodyStr)\n try {\n const next = mode(JSON.parse(bodyStr));\n if (next !== undefined) body = JSON.stringify(next);\n } catch {}\n return fetch(req ?? url, { ...init, body });\n }\n\n const cached = _cache.get(url);\n const hasCS = typeof CompressionStream !== 'undefined';\n const known = mode === 'gzip' || mode === 'deflate';\n const encoding = !hasCS\n ? null\n : known\n ? (mode as SupportedEncoding)\n : mode === 'proactive'\n ? cached === -1\n ? null\n : (cached ?? 'gzip')\n : typeof cached === 'string'\n ? cached\n : null;\n\n const shouldCompress = !!encoding && !!bodyStr && bodyStr.length >= MIN_BODY_SIZE;\n const opts: RequestInit = { ...init, priority: 'high' as RequestPriority };\n const headers = new Headers(opts.headers);\n if (shouldCompress) {\n opts.body = await new Response(\n new Blob([bodyStr!])\n .stream()\n .pipeThrough(new CompressionStream(encoding as CompressionFormat)),\n ).blob();\n headers.set('Content-Encoding', encoding);\n }\n opts.headers = headers;\n\n const response = await fetch(req ?? url, opts);\n\n // Cache discovery for passive/proactive (not known modes)\n if (!known && cached === undefined) {\n const header = response.headers.get('Accept-Encoding');\n const discovered =\n header\n ?.split(',')\n .map((e) => e.trim())\n .find((e): e is SupportedEncoding => _enc.includes(e as SupportedEncoding)) ?? -1;\n _cache.set(\n url,\n mode === 'proactive' && shouldCompress ? (response.ok ? encoding! : discovered) : discovered,\n );\n }\n\n return response;\n}\n"],
5
- "mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,mBAAAE,EAAA,mBAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAAiB,0BCAV,IAAMC,EAAgB,KAEvBC,EAAS,IAAI,IACbC,EAAO,CAAC,OAAQ,SAAS,EAe/B,eAAsBC,EACpBC,EACAC,EACAC,EACmB,CAC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AMA,EAAE,KAAK,CAAC,EACnB,KAAMA,GAA8BnB,EAAK,SAASmB,CAAsB,CAAC,GAAK,GACnFpB,EAAO,IACLO,EACAF,IAAS,aAAeU,GAAkBG,EAAS,GAAKJ,EAA0BK,CACpF,CACF,CAEA,OAAOD,CACT,CDlFA,IAAMG,EAAO,CAACC,EAAUC,IACtB,OAAO,OAAOD,EAAK,CACjB,SAAU,IAAI,eAAe,CAC3B,MAAME,EAAO,CACX,OAAAD,EAAO,MAAMC,CAAK,EACX,QAAQ,QAAQ,CACzB,EACA,OAAQ,CACN,OAAAD,EAAO,IAAI,EACJ,QAAQ,QAAQ,CACzB,CACF,CAAC,EACD,SAAU,IAAI,eAAe,CAC3B,KAAM,QACN,MAAME,EAAM,CACVF,EAAO,GAAG,OAASC,GAAeC,EAAK,QAAQD,CAAK,CAAC,EACrDD,EAAO,KAAK,MAAO,IAAME,EAAK,MAAM,CAAC,CACvC,CACF,CAAC,CACH,CAAC,EAEE,WAAW,oBACd,WAAW,kBAAoB,KAAwB,CACrD,YAAYC,EAAgB,CAC1B,IAAIH,EACAG,IAAW,UACbH,EAAS,EAAAI,QAAK,cAAc,EACnBD,IAAW,OACpBH,EAAS,EAAAI,QAAK,WAAW,EAChBD,IAAW,KACpBH,EAAS,EAAAI,QAAK,qBAAqB,EAEnCJ,EAAS,EAAAI,QAAK,iBAAiB,EAEjCN,EAAK,KAAME,CAAM,CACnB,CACF,GAGG,WAAW,sBACd,WAAW,oBAAsB,KAA0B,CACzD,YAAYG,EAAgB,CAC1B,IAAIH,EACAG,IAAW,UACbH,EAAS,EAAAI,QAAK,cAAc,EACnBD,IAAW,OACpBH,EAAS,EAAAI,QAAK,aAAa,EAClBD,IAAW,KACpBH,EAAS,EAAAI,QAAK,uBAAuB,EAErCJ,EAAS,EAAAI,QAAK,iBAAiB,EAEjCN,EAAK,KAAME,CAAM,CACnB,CACF",
6
- "names": ["index_node_exports", "__export", "MIN_BODY_SIZE", "compressModule", "__toCommonJS", "import_node_zlib", "MIN_BODY_SIZE", "_cache", "_enc", "compressModule", "input", "init", "mode", "req", "url", "bodyStr", "body", "next", "cached", "hasCS", "known", "encoding", "shouldCompress", "opts", "headers", "response", "discovered", "e", "make", "ctx", "handle", "chunk", "ctrl", "format", "zlib"]
4
+ "sourcesContent": ["import zlib from 'node:zlib';\n\n// Polyfill for CompressionStream/DecompressionStream in older versions of Node.js & Bun\nconst make = (ctx: any, handle: any) =>\n Object.assign(ctx, {\n writable: new WritableStream({\n write(chunk) {\n handle.write(chunk);\n return Promise.resolve();\n },\n close() {\n handle.end();\n return Promise.resolve();\n },\n }),\n readable: new ReadableStream({\n type: 'bytes',\n start(ctrl) {\n handle.on('data', (chunk: any) => ctrl.enqueue(chunk));\n handle.once('end', () => ctrl.close());\n },\n }),\n });\n\nif (!globalThis.CompressionStream) {\n globalThis.CompressionStream = class CompressionStream {\n constructor(format: string) {\n let handle;\n if (format === 'deflate') {\n handle = zlib.createDeflate();\n } else if (format === 'gzip') {\n handle = zlib.createGzip();\n } else if (format === 'br') {\n handle = zlib.createBrotliCompress();\n } else {\n handle = zlib.createDeflateRaw();\n }\n make(this, handle);\n }\n } as any;\n}\n\nif (!globalThis.DecompressionStream) {\n globalThis.DecompressionStream = class DecompressionStream {\n constructor(format: string) {\n let handle;\n if (format === 'deflate') {\n handle = zlib.createInflate();\n } else if (format === 'gzip') {\n handle = zlib.createGunzip();\n } else if (format === 'br') {\n handle = zlib.createBrotliDecompress();\n } else {\n handle = zlib.createInflateRaw();\n }\n make(this, handle);\n }\n } as any;\n}\n\nexport * from './index';\n", "export const MIN_BODY_SIZE = 1150;\n\nconst _hasCS = typeof CompressionStream !== 'undefined';\nconst _cache = new Map<string, string | -1>();\nconst _enc = ['gzip', 'deflate'] as const;\ntype SupportedEncoding = (typeof _enc)[number];\n\nexport type PayloadTransform = (payload: unknown) => unknown;\nexport type CompressionMode = 'passive' | 'proactive' | 'gzip' | 'deflate' | PayloadTransform;\n\n/**\n * @param input - URL or Request\n * @param init - Request options\n * @param mode - Compression mode:\n * - 'passive' (default): discover support via Accept-Encoding header first\n * - 'proactive': compress with gzip first, adjust if server rejects\n * - 'gzip' | 'deflate': use specified encoding directly (known support)\n * - PayloadTransform function: transform payload, skip HTTP compression\n */\nexport async function compressModule(\n input: string | URL | Request,\n init?: RequestInit,\n mode?: CompressionMode,\n): Promise<Response> {\n const req = input instanceof Request ? input : null;\n const url =\n typeof input === 'string' ? input : input instanceof Request ? input.url : input.toString();\n const bodyStr = typeof init?.body === 'string' ? init.body : null;\n\n // Custom transform: apply and skip HTTP compression\n if (typeof mode === 'function') {\n if (req && !init) return fetch(req);\n let body = init?.body;\n if (bodyStr)\n try {\n const next = mode(JSON.parse(bodyStr));\n if (next !== undefined) body = JSON.stringify(next);\n } catch {}\n return fetch(req ?? url, { ...init, body });\n }\n\n const cached = _cache.get(url);\n const known = mode === 'gzip' || mode === 'deflate';\n const encoding = !_hasCS\n ? null\n : known\n ? (mode as SupportedEncoding)\n : mode === 'proactive'\n ? cached === -1\n ? null\n : (cached ?? 'gzip')\n : typeof cached === 'string'\n ? cached\n : null;\n\n const shouldCompress = !!encoding && !!bodyStr && bodyStr.length >= MIN_BODY_SIZE;\n const opts: RequestInit = { ...init, priority: 'high' as RequestPriority };\n const headers = new Headers(opts.headers);\n if (shouldCompress) {\n opts.body = await new Response(\n new Blob([bodyStr!])\n .stream()\n .pipeThrough(new CompressionStream(encoding as CompressionFormat)),\n ).blob();\n headers.set('Content-Encoding', encoding);\n }\n opts.headers = headers;\n\n const response = await fetch(req ?? url, opts);\n\n // Cache discovery for passive/proactive (not known modes)\n if (!known && cached === undefined) {\n const header = response.headers.get('Accept-Encoding');\n const discovered =\n header\n ?.split(',')\n .map((e) => e.trim())\n .find((e): e is SupportedEncoding => _enc.includes(e as SupportedEncoding)) ?? -1;\n _cache.set(\n url,\n mode === 'proactive' && shouldCompress ? (response.ok ? encoding! : discovered) : discovered,\n );\n }\n\n return response;\n}\n"],
5
+ "mappings": "6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OACpBH,EAAS,EAAAI,QAAK,aAAa,EAClBD,IAAW,KACpBH,EAAS,EAAAI,QAAK,uBAAuB,EAErCJ,EAAS,EAAAI,QAAK,iBAAiB,EAEjCN,EAAK,KAAME,CAAM,CACnB,CACF",
6
+ "names": ["index_node_exports", "__export", "MIN_BODY_SIZE", "compressModule", "__toCommonJS", "import_node_zlib", "MIN_BODY_SIZE", "_hasCS", "_cache", "_enc", "compressModule", "input", "init", "mode", "req", "url", "bodyStr", "body", "next", "cached", "known", "encoding", "shouldCompress", "opts", "headers", "response", "discovered", "e", "make", "ctx", "handle", "chunk", "ctrl", "format", "zlib"]
7
7
  }
@@ -1,3 +1,3 @@
1
- var rt=Object.defineProperty;var _t=Object.getOwnPropertyDescriptor;var Ot=Object.getOwnPropertyNames;var kt=Object.prototype.hasOwnProperty;var Wt=(s,o)=>{for(var l in o)rt(s,l,{get:o[l],enumerable:!0})},Ft=(s,o,l,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let f of Ot(o))!kt.call(s,f)&&f!==l&&rt(s,f,{get:()=>o[f],enumerable:!(m=_t(o,f))||m.enumerable});return s};var qt=s=>Ft(rt({},"__esModule",{value:!0}),s);var Ht={};Wt(Ht,{compress_call:()=>Lt});module.exports=qt(Ht);var at=require("solady");var mt=(1n<<128n)-1n,M=(1n<<256n)-1n;var tt=s=>~s&M;var dt=(s,o)=>s&o&M,xt=(s,o)=>(s|o)&M,ht=(s,o)=>(s^o)&M,pt=(s,o)=>s+o&M,st=(s,o)=>s-o&M,ot=(s,o)=>o<<s&M,it=(s,o)=>o>>s&M,ct=(s,o)=>{let l=Number(s)+1,m=(1n<<BigInt(l*8))-1n,f=1n<<BigInt(l*8-1),d=o&m;return((d&f)!==0n?d|~m&M:d)&M};var O=s=>s.replace(/^0x/,"").toLowerCase(),zt=s=>{let o=O(s),l=o.length,m=new Uint8Array(l/2);for(let f=0;f<l;f+=2)m[f/2]=Number.parseInt(o.slice(f,f+2),16);return m},Z=s=>{let o="";for(let l=0;l<s.length;l++)o+=s[l].toString(16).padStart(2,"0");return o},yt=(s,o)=>{let l=O(s),m=zt(l),f=new Uint8Array(o+m.length);f.set(m,o);let d=f.length,w=Math.ceil(d/32),k=w*32,N=new Array(w),I=new Array(w),z=new Map,S=new Map,p=null;for(let r=0;r<w;r++){let u=r*32,b=new Uint8Array(32);if(u<d){let c=Math.min(u+32,d);b.set(f.subarray(u,c),0)}N[r]=b;let C=Z(b),L=S.get(C),nt=p===C;if(L)L.freq+=1,nt||(L.normFreq+=1),L.lastWordIndex=r,L.lastOffset=u,z.set(C,L.freq);else{let c={freq:1,normFreq:1,firstWordIndex:r,lastWordIndex:r,firstOffset:u,lastOffset:u,reuseCost:-1};S.set(C,c),z.set(C,1)}p=C;let U=[];for(let c=0;c<32;){for(;c<32&&b[c]===0;)++c;if(c>=32)break;let q=c;for(;c<32&&b[c]!==0;)++c;U.push({s:q,e:c-1})}I[r]=U}for(let r of S.values()){let b=(r.firstOffset===0?0:Math.ceil(Math.log2(r.firstOffset+1)/8))+3,C=r.normFreq*32,L=r.normFreq*b;r.reuseCost=C>L?b:-1}let W=new Uint8Array(32),x=r=>r<0||r>=w?W:N[r],F=r=>r<0||r>=w?[]:I[r],j=r=>{let u=new Uint8Array(32);if(r<0||r>=d)return u;let b=Math.min(r+32,d);return u.set(f.slice(r,b),0),u},V=(r,u)=>{if(u<=0)return new Uint8Array(0);let b=new Uint8Array(u);if(r<0||r>=d)return b;let C=Math.min(r+u,d);return b.set(f.slice(r,C),0),b};return{hex:l,buffer:f,roundedLength:k,padding:o,dataLength:m.length,wordCount:w,wordFreq:z,wordStats:S,getWord:x,getSegments:F,mload:j,slice:V}};var ft=function(s,o,l){let m=28,f=yt(s,m),d=224n,w=O(o).padStart(16,"0"),k=l?BigInt("0x"+O(l)):96n,N=new Set([0n,32n,d,k,BigInt("0x"+w)]),I=2n,z=Array.from(f.wordFreq.entries()).map(([t,e])=>[BigInt("0x"+t),e]).filter(([t])=>!N.has(t));z.length>0&&(I=z.reduce((t,e)=>e[1]>t[1]?e:t)[0]);let{wordCount:S}=f,p=[],W=[],x=[],F=0,j=new Map,V=!0,r=t=>t+31&-32,u=t=>{let e=x.lastIndexOf(t);return e=e===-1?-1:x.length-1-e,e>15?-1:e},b=new Map,C=new Map,L=0,nt=(t,e,n)=>t.set(e,(t.get(e)||0)+n),U=(t,e)=>{p.push(t),W.push(e??null)},c=(t,e=1)=>{x.push(t),e!==0&&nt(b,t,e),++L,C.set(t,L)},q=()=>[x.pop(),x.pop()],lt=(t,e)=>{F=r(t+e)},D=(t,e)=>{if(t==128){let n=x[x.length-1];c(n,V?0:1)}if(t==80&&x.pop(),t==71&&c(I,0),t==48&&c(d,0),t==51&&c(k,0),t==54&&c(32n,0),t==89&&c(BigInt(F),0),t===11){let[n,i]=q();c(ct(n,i),1)}if(t==25){let n=x.pop();c(tt(n),0)}if(t===24){let[n,i]=q();c(ht(n,i),1)}if(t==22){let[n,i]=q();c(dt(n,i),1)}if(t==23){let[n,i]=q();c(xt(n,i),1)}if(t==1){let[n,i]=q();c(pt(n,i),1)}if(t===3){let[n,i]=q();c(st(i,n),1)}if(t==27){let[n,i]=q();c(ot(n,i),1)}if(t==28){let[n,i]=q();c(it(n,i),1)}if(t>=96&&t<=127||t===95){let n=0n;for(let g of e||[])n=n<<8n|BigInt(g);if(n==I){c(n,0),U(71);return}if(n==d){c(n,0),U(48);return}if(n==k){c(n,0),U(51);return}if(n==32n){c(n,0),U(54);return}if(n===BigInt(F)&&n!==0n){c(n,0),U(89);return}let i=u(n);if(i!==-1&&t!==95){c(n,V?1:0),U(128+i);return}if(n===M){c(n,0),U(95),U(25);return}c(n,1),U(t,e||null);return}if(t===81){let n=Number(x.pop());c(j.has(n)?j.get(n):0n,0)}if(t===82){let[n,i]=q(),g=Number(n);j.set(g,i&M),lt(g,32)}if(t===83){let[n,i]=q();lt(Number(n),1)}U(t,e||null)},$=t=>D(t),Bt=t=>{if(t===0n)return 0;let e=0,n=t<0n?-t:t;for(;n>0n;)++e,n>>=8n;return e},P=t=>t===0n?1:1+Bt(t),X=t=>{let e=typeof t=="bigint"?t:BigInt(t);if(e>0n&&e===BigInt(F))return D(89);if(e===32n)return D(54);if(e===0n)return D(95);let n=e,i=[];for(;n!==0n;)i.unshift(Number(n&0xffn)),n>>=8n;return D(95+i.length,i)},ut=t=>D(95+t.length,Array.from(t)),Y=[],B=t=>{Y.push({t:"num",v:t}),X(t)},bt=t=>{Y.push({t:"bytes",b:t}),ut(t)},y=t=>{Y.push({t:"op",o:t}),$(t)},At=t=>{let e=0,n=!0;for(let{s:i,e:g}of t)e+=1+(g-i+1),31-g>0&&(e+=3),n||(e+=1),n=!1;return e},gt=(t,e)=>{let n=t.slice(e[0].s),i=0n;for(let a of n)i=i<<8n|BigInt(a);let g=1+n.length,E=At(e),_=g,v=()=>bt(n),G=tt(i),J=P(G)+1;J<_&&(_=J,v=()=>{B(G),y(25)});let R=st(0n,i),h=1+P(R)+1;h<_&&(_=h,v=()=>{B(0),B(R),y(3)});for(let a=1;a<n.length;a++){let T=(1n<<BigInt(a*8))-1n,H=i&T;if(ct(BigInt(a-1),H)===i&&(H&1n<<BigInt(a*8-1))!==0n){let K=P(H)+2+1;K<_&&(_=K,v=()=>{B(H),B(a-1),y(11)});break}}for(let a=8;a<=248;a+=8){let T=it(BigInt(a),i);if(T===0n)break;let H=tt(T);if(ot(BigInt(a),H)===i){let K=P(H)+P(BigInt(a))+2;K<_&&(_=K,v=()=>{B(H),B(a),y(27),y(25)})}}return E<_&&(_=E,v=()=>{let a=!0;for(let{s:T,e:H}of e){let Q=31-H;bt(t.slice(T,H+1)),Q>0&&(B(Q*8),y(27)),a||y(23),a=!1}}),{literal:n,literalVal:i,bestCost:_,bestEmit:v,literalCost:g,shlCost:E}},A=0;for(;A<S;){let t=A*32,e=f.getWord(A),n=f.getSegments(A);if(!n.length){++A;continue}let i=Z(e),g=1;for(;A+g<S;){let h=f.getWord(A+g);if(!f.getSegments(A+g).length||Z(h)!==i)break;++g}if(g>=2){let{bestEmit:h}=gt(e,n);h(),y(128),B(t),y(82);for(let T=1;T<g;T++)y(128),y(89),y(82);let a=f.wordStats.get(i);a&&a.lastWordIndex<=A+g-1&&y(80),A+=g;continue}let{literalCost:E,shlCost:_,bestCost:v,bestEmit:G}=gt(e,n);if(E>8){let h=f.wordStats.get(i);if(h&&h.reuseCost!==-1&&A>h.firstWordIndex){let a=h.firstOffset===0?0:Math.ceil(Math.log2(h.firstOffset+1)/8);if(E>h.reuseCost+a){B(h.firstOffset),y(81),B(t),y(82),++A;continue}}}let J=n.every(({s:h,e:a})=>h===a),R=n.length*3;if(J&&R<v&&R<=_){for(let{s:h}of n)B(e[h]),B(t+h),y(83);++A;continue}G(),B(t),y(82),++A}let Mt=Y.slice();p=[],W=[],x=[],F=0,j=new Map,V=!1;let It=new Set([0n,32n,I,d,k]);Array.from(b.entries()).filter(([t,e])=>e>1&&!It.has(t)).map(([t,e])=>{let n=P(t),i=e*(n-1)-n;return{val:t,uses:e,net:i,p:n}}).sort((t,e)=>e.net!==t.net?e.net-t.net:e.uses!==t.uses?e.uses-t.uses:t.p-e.p).filter(t=>t.net>0&&t.val<=mt).slice(0,15).forEach(({val:t})=>{X(t)});for(let t of Mt)t.t==="num"?X(t.v):t.t==="bytes"?ut(t.b):t.t==="op"&&$(t.o);$(95),$(95),X(f.dataLength),X(m);let et=[];for(let t=0;t<p.length;++t)et.push(p[t]),p[t]>=96&&p[t]<=127&&W[t]&&et.push(...W[t]);let Ct="0x"+Z(new Uint8Array(et))+"345f355af13d5f5f3e3d5ff3",Ut="0x"+O(w).padStart(64,"0");return{bytecode:Ct,calldata:Ut,to:"0x"+d.toString(16).padStart(40,"0"),from:O(k.toString(16)).padStart(40,"0"),balance:I.toString(16)}};var wt=s=>`0x365f73${O(s)}815b838110602f575f80848134865af1503d5f803e3d5ff35b803590815f1a8060051c908115609857600190600783149285831a6007018118840218600201948383011a90601f1660081b0101808603906020811860208211021890815f5b80830151818a015201858110609257505050600201019201916018565b82906075565b6001929350829150019101925f5b82811060b3575001916018565b85851060c1575b60010160a6565b936001818192355f1a878501530194905060ba56`;var St=s=>`0x5f5f5b368110602d575f8083813473${O(s)}5af1503d5f803e3d5ff35b600180820192909160031981019035185f1a8015604c57815301906002565b505f19815282820192607f9060031981019035185f1a818111156072575b160101906002565b838101368437606a56`;var Lt=function(s,o){let{method:l,params:m}=s;if(l&&l!=="eth_call")return s;let f=m?.[0]||s,d=m?.[1],w=m?.[2];if(w&&Object.keys(w).length>0||!f?.to||!f?.data||Object.keys(f).some(r=>!["to","data","from"].includes(r)))return s;let k=f.data.length;if(k<1150)return s;let N="0x"+O(f.data),I=f.to,z=f.from,S,p,W,x,F;if(o==="jit"||!o&&(k<3e3||k>=8e3)){let r=ft(N,I,z);S=r.bytecode,p=r.calldata,W=r.to,x=r.from,F=r.balance}else{let r=o?null:ft(N,I,z),u=o==="flz"||!o?at.LibZip.flzCompress(N):null,b=o==="cd"||!o&&u?at.LibZip.cdCompress(N):null;o==="flz"||!o&&u&&(!b||u.length<b.length)?(p=u,S=wt(I)):(p=b,S=St(I)),W="0x"+224n.toString(16).padStart(40,"0"),x=z?O(z).padStart(16,"0"):void 0,F="0",!o&&r&&r.bytecode.length+r.calldata.length<S.length+p.length&&(S=r.bytecode,p=r.calldata,W=r.to,x=r.from,F=r.balance)}if(S.length+p.length>=k)return s;let j={code:S,balance:"0x"+F},V={to:W,data:p};return x&&(V.from="0x"+x),{...s,params:[V,d,{...w,[W]:j}]}};
1
+ var it=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Nt=Object.getOwnPropertyNames;var Ft=Object.prototype.hasOwnProperty;var Ot=(r,e)=>{for(var u in e)it(r,u,{get:e[u],enumerable:!0})},Tt=(r,e,u,y)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Nt(e))!Ft.call(r,a)&&a!==u&&it(r,a,{get:()=>e[a],enumerable:!(y=Lt(e,a))||y.enumerable});return r};var jt=r=>Tt(it({},"__esModule",{value:!0}),r);var $t={};Ot($t,{compress_call:()=>Zt});module.exports=jt($t);var mt=require("solady");var St=(1n<<128n)-1n,k=(1n<<256n)-1n;var et=r=>~r&k;var _t=(r,e)=>r&e&k,Bt=(r,e)=>(r|e)&k,It=(r,e)=>(r^e)&k,Mt=(r,e)=>r+e&k,ct=(r,e)=>r-e&k,ft=(r,e)=>e<<r&k,at=(r,e)=>e>>r&k,lt=(r,e)=>{if(r>=31n)return e&k;let u=Number((r+1n)*8n);return BigInt.asUintN(256,BigInt.asIntN(u,e))};var j=r=>(r.charCodeAt(0)===48&&(r.charCodeAt(1)|32)===120?r.slice(2):r).toLowerCase(),Vt=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0")),Ct=(()=>{let r=new Int8Array(103).fill(-1);for(let e=0;e<10;e++)r[48+e]=e;for(let e=0;e<6;e++)r[97+e]=10+e;return r})(),vt=r=>{let e=j(r),u=e.length,y=new Uint8Array(u/2);for(let a=0,H=0;a<u;a+=2)y[H++]=Ct[e.charCodeAt(a)]<<4|Ct[e.charCodeAt(a+1)];return y},ut=r=>{let e="";for(let u=0;u<r.length;u++)e+=Vt[r[u]];return e},Et=new Uint8Array(32),Pt=[],Ut=(r,e)=>{let u=j(r),y=vt(u),a=new Uint8Array(e+y.length);a.set(y,e);let H=a.length,A=Math.ceil(H/32),L=A*32;if(H!==L){let i=new Uint8Array(L);i.set(a,0),a=i}let M=new Array(A),C=new Array(A),m=new Map,d=null,b=i=>{let f=i<<5;return a.subarray(f,f+32)};for(let i=0;i<A;i++){let f=i<<5,x=b(i),W=ut(x);C[i]=W;let V=m.get(W),rt=d===W;if(V)V[0]+=1,rt||(V[1]+=1),V[3]=i,V[5]=f;else{let _=[1,1,i,i,f,f,-1];m.set(W,_)}d=W;let Y=[];for(let _=0;_<32;){for(;_<32&&x[_]===0;)++_;if(_>=32)break;let ot=_;for(;_<32&&x[_]!==0;)++_;Y.push(ot<<8|_-1)}M[i]=Y}for(let i of m.values()){let x=(i[4]===0?0:32-Math.clz32(i[4])+7>>3)+3;i[6]=32>x?x:-1}let U=i=>i<0||i>=A?Et:b(i),N=i=>i<0||i>=A?Pt:M[i],F=(i,f)=>{if(f<=0)return new Uint8Array(0);let x=new Uint8Array(f);if(i<0||i>=H)return x;let W=Math.min(i+f,H);return x.set(a.subarray(i,W),0),x},S=i=>F(i,32);return{hex:u,buffer:a,roundedLength:L,padding:e,dataLength:y.length,wordCount:A,wordHexes:C,wordStats:m,getWord:U,getSegments:N,mload:S,slice:F}};var bt="0x00000000000000000000000000000000000000e0",R=r=>r.padStart(64,"0"),qt=R("0"),Xt=R("20"),Rt=R("e0"),Kt="345f355af13d5f5f3e3d5ff3",gt=function(r,e,u){let y=u?j(u):null,a=28,H=null,A=0,L=j(e).padStart(16,"0"),M=y?BigInt("0x"+y):96n,C=2n,m=[],d=[],b=[],U=0,N=[],F=!0,S=Ut(r,a),{wordCount:i}=S,f=224n,x=new Map,W=Rt,V=R(y??M.toString(16)),rt=R(L);for(let[t,o]of S.wordStats){let n=o[0];t===qt||t===Xt||t===W||t===V||t===rt||n>A&&(A=n,H=t)}H&&(C=BigInt("0x"+H));let Y=t=>t+31&-32,_=t=>{for(let o=b.length-1,n=0;n<16&&o>=0;--o,++n)if(b[o]===t)return n;return-1},ot=(t,o,n)=>t.set(o,(t.get(o)||0)+n),O=(t,o)=>{m.push(t),d.push(o??null)},l=(t,o=1)=>{b.push(t),o!==0&&ot(x,t,o)},T=()=>[b.pop(),b.pop()],dt=(t,o)=>{U=Y(t+o)},P=(t,o)=>{if(t===128&&l(b[b.length-1],F?0:1),t===80&&b.pop(),t===71&&l(C,0),t===48&&l(f,0),t===51&&l(M,0),t===54&&l(32n,0),t===89&&l(BigInt(U),0),t===11){let[n,s]=T();l(lt(n,s),1)}if(t===25&&l(et(b.pop()),0),t===24){let[n,s]=T();l(It(n,s),1)}if(t===22){let[n,s]=T();l(_t(n,s),1)}if(t===23){let[n,s]=T();l(Bt(n,s),1)}if(t===1){let[n,s]=T();l(Mt(n,s),1)}if(t===3){let[n,s]=T();l(ct(s,n),1)}if(t===27){let[n,s]=T();l(ft(n,s),1)}if(t===28){let[n,s]=T();l(at(n,s),1)}if(t>=96&&t<=127||t===95){let n=0n;for(let g of o||[])n=n<<8n|BigInt(g);if(n===C){l(n,0),O(71);return}if(n===f){l(n,0),O(48);return}if(n===M){l(n,0),O(51);return}if(n===32n){l(n,0),O(54);return}if(n===BigInt(U)&&n!=0n){l(n,0),O(89);return}let s=_(n);if(s!=-1&&t!=95){l(n,F?1:0),O(128+s);return}if(n===k){l(n,0),O(95),O(25);return}l(n,1),O(t,o||null);return}if(t===81&&l(N[Number(b.pop())>>>5]??0n,0),t===82){let[n,s]=T(),g=Number(n);N[g>>>5]=s&k,dt(g,32)}if(t===83){let[n,s]=T();dt(Number(n),1)}O(t,o||null)},G=t=>P(t),xt=t=>{if(t===0n)return 0;let o=0,n=t<0n?-t:t;for(;n>0n;)++o,n>>=8n;return o},q=t=>t===0n?1:1+xt(t),K=t=>{let o=typeof t=="bigint"?t:BigInt(t);if(o>0n&&o===BigInt(U))return P(89);if(o===32n)return P(54);if(o===0n)return P(95);let n=o,s=xt(n),g=new Uint8Array(s);for(let D=s-1;D>=0;--D)g[D]=Number(n&0xffn),n>>=8n;return P(95+s,g)},ht=t=>P(95+t.length,t),J=[],B=t=>{J.push({t:"num",v:t}),K(t)},yt=t=>{J.push({t:"bytes",b:t}),ht(t)},p=t=>{J.push({t:"op",o:t}),G(t)},kt=t=>{let o=0,n=!0;for(let s=0;s<t.length;s++){let g=t[s],D=g>>>8,w=g&255;o+=1+(w-D+1),31-w>0&&(o+=3),n||(o+=1),n=!1}return o},pt=(t,o)=>{let n=t.subarray(o[0]>>>8),s=0n;for(let c=0;c<n.length;c++)s=s<<8n|BigInt(n[c]);let g=n.length+1,D=kt(o),w=g,v=()=>yt(n),tt=et(s),nt=q(tt)+1;nt<w&&(w=nt,v=()=>{B(tt),p(25)});let Z=ct(0n,s),$=q(Z)+2;$<w&&(w=$,v=()=>{B(0),B(Z),p(3)});for(let c=1;c<n.length;c++){let h=(1n<<BigInt(c*8))-1n,I=s&h;if(lt(BigInt(c-1),I)===s&&(I&1n<<BigInt(c*8-1))!==0n){let E=q(I)+3;E<w&&(w=E,v=()=>{B(I),B(c-1),p(11)});break}}for(let c=8;c<=248;c+=8){let h=at(BigInt(c),s);if(h===0n)break;let I=et(h);if(ft(BigInt(c),I)===s){let E=q(I)+q(BigInt(c))+2;E<w&&(w=E,v=()=>{B(I),B(c),p(27),p(25)})}}return D<w&&(w=D,v=()=>{let c=!0;for(let h=0;h<o.length;h++){let I=o[h],X=I>>>8,E=I&255,At=31-E;yt(t.subarray(X,E+1)),At>0&&(B(At*8),p(27)),c||p(23),c=!1}}),{literal:n,literalVal:s,bestCost:w,bestEmit:v,literalCost:g,shlCost:D}},z=0;for(;z<i;){let t=z*32,o=S.getWord(z),n=S.getSegments(z);if(!n.length){++z;continue}let s=S.wordHexes[z],g=z+1;for(;g<i&&!(!S.getSegments(g).length||S.wordHexes[g]!==s);)++g;let D=g-z;if(D>=2){let c=g-1,{bestEmit:h}=pt(o,n);h(),p(128),B(t),p(82);for(let X=1;X<D;X++)p(128),p(89),p(82);let I=S.wordStats.get(s);I&&I[3]<=c&&p(80),z=g;continue}let{literalCost:w,shlCost:v,bestCost:tt,bestEmit:nt}=pt(o,n);if(w>8){let c=S.wordStats.get(s);if(c&&c[6]!==-1&&z>c[2]){let h=c[4]===0?0:32-Math.clz32(c[4])+7>>3;if(w>c[6]+h){B(c[4]),p(81),B(t),p(82),++z;continue}}}let Z=!0;for(let c=0;c<n.length;c++){let h=n[c];if(h>>>8!==(h&255)){Z=!1;break}}let $=n.length*3;if(Z&&$<tt&&$<=v){for(let c=0;c<n.length;c++){let h=n[c]>>>8;B(o[h]),B(t+h),p(83)}++z;continue}nt(),B(t),p(82),++z}m=[],d=[],b=[],U=0,N=[],F=!1;let Q=[];for(let[t,o]of x)if(o>1&&t!==0n&&t!==32n&&t!==C&&t!==f&&t!==M&&t<=St){let n=q(t),s=o*(n-1)-n;s>0&&Q.push({val:t,uses:o,net:s,p:n})}Q.sort((t,o)=>o.net-t.net||o.uses-t.uses||t.p-o.p);for(let t=0;t<15&&t<Q.length;++t)K(Q[t].val);for(let t of J)t.t==="num"?K(t.v):t.t==="bytes"?ht(t.b):t.t==="op"&&G(t.o);G(95),G(95),K(S.dataLength),K(a);let wt=m.length;for(let t=0;t<m.length;++t)m[t]>=96&&m[t]<=127&&d[t]&&(wt+=d[t].length);let st=new Uint8Array(wt);for(let t=0,o=0;t<m.length;++t)st[o++]=m[t],m[t]>=96&&m[t]<=127&&d[t]&&(st.set(d[t],o),o+=d[t].length);let Ht="0x"+ut(st)+Kt,Dt="0x"+R(L);return{bytecode:Ht,calldata:Dt,to:bt,from:M.toString(16).padStart(40,"0"),balance:C.toString(16)}};var Wt=r=>`0x365f73${j(r)}815b838110602f575f80848134865af1503d5f803e3d5ff35b803590815f1a8060051c908115609857600190600783149285831a6007018118840218600201948383011a90601f1660081b0101808603906020811860208211021890815f5b80830151818a015201858110609257505050600201019201916018565b82906075565b6001929350829150019101925f5b82811060b3575001916018565b85851060c1575b60010160a6565b936001818192355f1a878501530194905060ba56`;var zt=r=>`0x5f5f5b368110602d575f8083813473${j(r)}5af1503d5f803e3d5ff35b600180820192909160031981019035185f1a8015604c57815301906002565b505f19815282820192607f9060031981019035185f1a818111156072575b160101906002565b838101368437606a56`;var Zt=function(r,e){let{method:u,params:y}=r;if(u&&u!=="eth_call")return r;let a=y?.[0]||r,H=y?.[1],A=y?.[2];if(!a?.to||!a?.data||(()=>{if(A)for(let f in A)return!0;for(let f in a)if(f!=="to"&&f!=="data"&&f!=="from")return!0;return!1})())return r;let L=a.data.length;if(L<1150)return r;let M=a.data,C=a.to,m=a.from,d,b,U,N,F;if(e==="jit"||!e&&(L<3e3||L>=8e3)){let f=gt(M,C,m);d=f.bytecode,b=f.calldata,U=f.to,N=f.from,F=f.balance}else{let f=e?null:gt(M,C,m),x=e==="flz"||!e?mt.LibZip.flzCompress(M):null,W=e==="cd"||!e&&x?mt.LibZip.cdCompress(M):null;e==="flz"||!e&&x&&(!W||x.length<W.length)?(b=x,d=Wt(C)):(b=W,d=zt(C)),U=bt,N=m?j(m).padStart(16,"0"):void 0,F="0",!e&&f&&f.bytecode.length+f.calldata.length<d.length+b.length&&(d=f.bytecode,b=f.calldata,U=f.to,N=f.from,F=f.balance)}if(d.length+b.length>=L)return r;let S={code:d,balance:"0x"+F},i={to:U,data:b};return N&&(i.from="0x"+N),{...r,params:[i,H,{...A,[U]:S}]}};
2
2
  //! @__PURE__
3
3
  //# sourceMappingURL=jit-compressor.cjs.map