node-liblzma 2.2.0 → 3.0.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 (48) hide show
  1. package/README.md +379 -778
  2. package/lib/cli/nxz.js +176 -84
  3. package/lib/cli/nxz.js.map +1 -1
  4. package/lib/lzma.browser.d.ts +24 -0
  5. package/lib/lzma.browser.d.ts.map +1 -0
  6. package/lib/lzma.browser.js +30 -0
  7. package/lib/lzma.browser.js.map +1 -0
  8. package/lib/lzma.inline.d.ts +30 -0
  9. package/lib/lzma.inline.d.ts.map +1 -0
  10. package/lib/lzma.inline.js +68 -0
  11. package/lib/lzma.inline.js.map +1 -0
  12. package/lib/wasm/bindings.d.ts +109 -0
  13. package/lib/wasm/bindings.d.ts.map +1 -0
  14. package/lib/wasm/bindings.js +307 -0
  15. package/lib/wasm/bindings.js.map +1 -0
  16. package/lib/wasm/compress.d.ts +32 -0
  17. package/lib/wasm/compress.d.ts.map +1 -0
  18. package/lib/wasm/compress.js +47 -0
  19. package/lib/wasm/compress.js.map +1 -0
  20. package/lib/wasm/decompress.d.ts +32 -0
  21. package/lib/wasm/decompress.d.ts.map +1 -0
  22. package/lib/wasm/decompress.js +45 -0
  23. package/lib/wasm/decompress.js.map +1 -0
  24. package/lib/wasm/index.d.ts +14 -0
  25. package/lib/wasm/index.d.ts.map +1 -0
  26. package/lib/wasm/index.js +18 -0
  27. package/lib/wasm/index.js.map +1 -0
  28. package/lib/wasm/liblzma.inline.d.ts +10 -0
  29. package/lib/wasm/liblzma.inline.d.ts.map +1 -0
  30. package/lib/wasm/liblzma.inline.js +10 -0
  31. package/lib/wasm/liblzma.inline.js.map +1 -0
  32. package/lib/wasm/memory.d.ts +57 -0
  33. package/lib/wasm/memory.d.ts.map +1 -0
  34. package/lib/wasm/memory.js +108 -0
  35. package/lib/wasm/memory.js.map +1 -0
  36. package/lib/wasm/stream.d.ts +35 -0
  37. package/lib/wasm/stream.d.ts.map +1 -0
  38. package/lib/wasm/stream.js +164 -0
  39. package/lib/wasm/stream.js.map +1 -0
  40. package/lib/wasm/types.d.ts +77 -0
  41. package/lib/wasm/types.d.ts.map +1 -0
  42. package/lib/wasm/types.js +55 -0
  43. package/lib/wasm/types.js.map +1 -0
  44. package/lib/wasm/utils.d.ts +62 -0
  45. package/lib/wasm/utils.d.ts.map +1 -0
  46. package/lib/wasm/utils.js +162 -0
  47. package/lib/wasm/utils.js.map +1 -0
  48. package/package.json +24 -3
@@ -0,0 +1,109 @@
1
+ /**
2
+ * TypeScript bindings for the Emscripten-compiled liblzma WASM module.
3
+ *
4
+ * Provides typed wrappers around the raw C functions exported by liblzma.wasm,
5
+ * with proper memory management and error handling.
6
+ */
7
+ import { type WasmLzmaStream } from './memory.js';
8
+ import { type LZMAModule } from './types.js';
9
+ /**
10
+ * Initialize the WASM module. Must be called before any operation.
11
+ *
12
+ * The module is loaded once and cached. Subsequent calls return
13
+ * the same instance. Can be called with a custom loader for
14
+ * inline/bundled WASM scenarios.
15
+ *
16
+ * @param loader - Optional custom module loader (for inline WASM)
17
+ * @returns The initialized Emscripten module
18
+ */
19
+ export declare function initModule(loader?: () => Promise<LZMAModule>): Promise<LZMAModule>;
20
+ /**
21
+ * Get the initialized module, throwing if not yet loaded.
22
+ */
23
+ export declare function getModule(): LZMAModule;
24
+ /**
25
+ * Reset module state (for testing purposes).
26
+ */
27
+ export declare function resetModule(): void;
28
+ /**
29
+ * Initialize an easy encoder on the given lzma_stream.
30
+ *
31
+ * @param stream - Allocated WasmLzmaStream
32
+ * @param preset - Compression preset (0-9, optionally OR'd with EXTREME flag)
33
+ * @param check - Integrity check type (default: CRC64)
34
+ * @throws LZMAError on initialization failure
35
+ */
36
+ export declare function encoderInit(stream: WasmLzmaStream, preset: number, check?: number): void;
37
+ /**
38
+ * Initialize a stream decoder on the given lzma_stream.
39
+ *
40
+ * @param stream - Allocated WasmLzmaStream
41
+ * @param memlimit - Memory limit in bytes (default: 256MB)
42
+ * @throws LZMAError on initialization failure
43
+ */
44
+ export declare function decoderInit(stream: WasmLzmaStream, memlimit?: number | bigint): void;
45
+ /**
46
+ * Initialize an auto decoder (detects format) on the given lzma_stream.
47
+ *
48
+ * @param stream - Allocated WasmLzmaStream
49
+ * @param memlimit - Memory limit in bytes (default: 256MB)
50
+ * @throws LZMAError on initialization failure
51
+ */
52
+ export declare function autoDecoderInit(stream: WasmLzmaStream, memlimit?: number | bigint): void;
53
+ /**
54
+ * Run lzma_code on a stream (one step of encoding/decoding).
55
+ *
56
+ * @param stream - Active WasmLzmaStream
57
+ * @param action - LZMA_RUN, LZMA_FINISH, etc.
58
+ * @returns The lzma return code (LZMA_OK, LZMA_STREAM_END, or error)
59
+ */
60
+ export declare function code(stream: WasmLzmaStream, action: number): number;
61
+ /**
62
+ * Finalize a stream and free its internal resources.
63
+ */
64
+ export declare function end(stream: WasmLzmaStream): void;
65
+ /**
66
+ * Get the memory usage of a stream (in bytes).
67
+ */
68
+ export declare function memusage(stream: WasmLzmaStream): number;
69
+ /**
70
+ * Compress a buffer using lzma_easy_buffer_encode.
71
+ *
72
+ * @param input - Data to compress
73
+ * @param preset - Compression preset (0-9)
74
+ * @param check - Integrity check type (default: CRC64)
75
+ * @returns Compressed data
76
+ * @throws LZMAError on compression failure
77
+ */
78
+ export declare function easyBufferEncode(input: Uint8Array, preset: number, check?: number): Uint8Array;
79
+ /**
80
+ * Decompress a buffer using lzma_stream_buffer_decode.
81
+ *
82
+ * @param input - XZ compressed data
83
+ * @param memlimit - Memory limit in bytes (default: 256MB)
84
+ * @returns Decompressed data
85
+ * @throws LZMAError on decompression failure
86
+ */
87
+ export declare function streamBufferDecode(input: Uint8Array, memlimit?: number | bigint): Uint8Array;
88
+ /**
89
+ * Process a full input buffer through an initialized encoder/decoder stream,
90
+ * collecting all output chunks.
91
+ *
92
+ * This is used by the buffer APIs (xzAsync/unxzAsync) for streaming
93
+ * encoding/decoding within a single call.
94
+ *
95
+ * @param stream - Initialized WasmLzmaStream (encoder or decoder)
96
+ * @param input - Input data
97
+ * @returns Concatenated output
98
+ * @throws LZMAError on processing failure
99
+ */
100
+ export declare function processStream(stream: WasmLzmaStream, input: Uint8Array): Uint8Array;
101
+ /**
102
+ * Get the liblzma version string (e.g. "5.6.3").
103
+ */
104
+ export declare function versionString(): string;
105
+ /**
106
+ * Check if a given integrity check type is supported.
107
+ */
108
+ export declare function checkIsSupported(check: number): boolean;
109
+ //# sourceMappingURL=bindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../../src/wasm/bindings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAA4B,KAAK,cAAc,EAAuB,MAAM,aAAa,CAAC;AACjG,OAAO,EAOL,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAWpB;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CA4BxF;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,UAAU,CAKtC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAGlC;AAID;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,EACd,KAAK,SAAmB,GACvB,IAAI,CAMN;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,EACtB,QAAQ,GAAE,MAAM,GAAG,MAAyB,GAC3C,IAAI,CAON;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EACtB,QAAQ,GAAE,MAAM,GAAG,MAAyB,GAC3C,IAAI,CAON;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAGhD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAGvD;AAID;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,KAAK,SAAmB,GACvB,UAAU,CAoCZ;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,UAAU,EACjB,QAAQ,GAAE,MAAM,GAAG,MAAyB,GAC3C,UAAU,CA0DZ;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU,CAoDnF;AAID;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAStC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGvD"}
@@ -0,0 +1,307 @@
1
+ /**
2
+ * TypeScript bindings for the Emscripten-compiled liblzma WASM module.
3
+ *
4
+ * Provides typed wrappers around the raw C functions exported by liblzma.wasm,
5
+ * with proper memory management and error handling.
6
+ */
7
+ import { createLZMAError, LZMAError } from '../errors.js';
8
+ import { copyFromWasm, copyToWasm, wasmAlloc, wasmFree } from './memory.js';
9
+ import { LZMA_BUF_ERROR, LZMA_CHECK_CRC64, LZMA_FINISH, LZMA_OK, LZMA_RUN, LZMA_STREAM_END, } from './types.js';
10
+ // Default output buffer size for streaming operations (256KB)
11
+ const DEFAULT_OUT_BUF_SIZE = 256 * 1024;
12
+ // Maximum memory limit for decoder (256MB, matching WASM max)
13
+ const DEFAULT_MEMLIMIT = BigInt(256 * 1024 * 1024);
14
+ /** Singleton module instance (lazy-initialized) */
15
+ let moduleInstance = null;
16
+ let modulePromise = null;
17
+ /**
18
+ * Initialize the WASM module. Must be called before any operation.
19
+ *
20
+ * The module is loaded once and cached. Subsequent calls return
21
+ * the same instance. Can be called with a custom loader for
22
+ * inline/bundled WASM scenarios.
23
+ *
24
+ * @param loader - Optional custom module loader (for inline WASM)
25
+ * @returns The initialized Emscripten module
26
+ */
27
+ export async function initModule(loader) {
28
+ if (moduleInstance) {
29
+ return moduleInstance;
30
+ }
31
+ if (modulePromise) {
32
+ return modulePromise;
33
+ }
34
+ modulePromise = (async () => {
35
+ if (loader) {
36
+ moduleInstance = await loader();
37
+ }
38
+ else {
39
+ // Dynamic import of the Emscripten glue code
40
+ const { default: createLZMA } = await import('./liblzma.js');
41
+ moduleInstance = (await createLZMA());
42
+ }
43
+ return moduleInstance;
44
+ })();
45
+ try {
46
+ return await modulePromise;
47
+ }
48
+ catch (err) {
49
+ modulePromise = null;
50
+ throw new LZMAError(`Failed to load WASM module: ${err instanceof Error ? err.message : String(err)}`, -1);
51
+ }
52
+ }
53
+ /**
54
+ * Get the initialized module, throwing if not yet loaded.
55
+ */
56
+ export function getModule() {
57
+ if (!moduleInstance) {
58
+ throw new LZMAError('WASM module not initialized. Call initModule() first.', -1);
59
+ }
60
+ return moduleInstance;
61
+ }
62
+ /**
63
+ * Reset module state (for testing purposes).
64
+ */
65
+ export function resetModule() {
66
+ moduleInstance = null;
67
+ modulePromise = null;
68
+ }
69
+ // --- Encoding ---
70
+ /**
71
+ * Initialize an easy encoder on the given lzma_stream.
72
+ *
73
+ * @param stream - Allocated WasmLzmaStream
74
+ * @param preset - Compression preset (0-9, optionally OR'd with EXTREME flag)
75
+ * @param check - Integrity check type (default: CRC64)
76
+ * @throws LZMAError on initialization failure
77
+ */
78
+ export function encoderInit(stream, preset, check = LZMA_CHECK_CRC64) {
79
+ const module = getModule();
80
+ const ret = module._lzma_easy_encoder(stream.ptr, preset, check);
81
+ if (ret !== LZMA_OK) {
82
+ throw createLZMAError(ret);
83
+ }
84
+ }
85
+ /**
86
+ * Initialize a stream decoder on the given lzma_stream.
87
+ *
88
+ * @param stream - Allocated WasmLzmaStream
89
+ * @param memlimit - Memory limit in bytes (default: 256MB)
90
+ * @throws LZMAError on initialization failure
91
+ */
92
+ export function decoderInit(stream, memlimit = DEFAULT_MEMLIMIT) {
93
+ const module = getModule();
94
+ const limit = typeof memlimit === 'number' ? BigInt(memlimit) : memlimit;
95
+ const ret = module._lzma_stream_decoder(stream.ptr, limit, 0);
96
+ if (ret !== LZMA_OK) {
97
+ throw createLZMAError(ret);
98
+ }
99
+ }
100
+ /**
101
+ * Initialize an auto decoder (detects format) on the given lzma_stream.
102
+ *
103
+ * @param stream - Allocated WasmLzmaStream
104
+ * @param memlimit - Memory limit in bytes (default: 256MB)
105
+ * @throws LZMAError on initialization failure
106
+ */
107
+ export function autoDecoderInit(stream, memlimit = DEFAULT_MEMLIMIT) {
108
+ const module = getModule();
109
+ const limit = typeof memlimit === 'number' ? BigInt(memlimit) : memlimit;
110
+ const ret = module._lzma_auto_decoder(stream.ptr, limit, 0);
111
+ if (ret !== LZMA_OK) {
112
+ throw createLZMAError(ret);
113
+ }
114
+ }
115
+ /**
116
+ * Run lzma_code on a stream (one step of encoding/decoding).
117
+ *
118
+ * @param stream - Active WasmLzmaStream
119
+ * @param action - LZMA_RUN, LZMA_FINISH, etc.
120
+ * @returns The lzma return code (LZMA_OK, LZMA_STREAM_END, or error)
121
+ */
122
+ export function code(stream, action) {
123
+ const module = getModule();
124
+ return module._lzma_code(stream.ptr, action);
125
+ }
126
+ /**
127
+ * Finalize a stream and free its internal resources.
128
+ */
129
+ export function end(stream) {
130
+ const module = getModule();
131
+ module._lzma_end(stream.ptr);
132
+ }
133
+ /**
134
+ * Get the memory usage of a stream (in bytes).
135
+ */
136
+ export function memusage(stream) {
137
+ const module = getModule();
138
+ return Number(module._lzma_memusage(stream.ptr));
139
+ }
140
+ // --- Buffer API (one-shot) ---
141
+ /**
142
+ * Compress a buffer using lzma_easy_buffer_encode.
143
+ *
144
+ * @param input - Data to compress
145
+ * @param preset - Compression preset (0-9)
146
+ * @param check - Integrity check type (default: CRC64)
147
+ * @returns Compressed data
148
+ * @throws LZMAError on compression failure
149
+ */
150
+ export function easyBufferEncode(input, preset, check = LZMA_CHECK_CRC64) {
151
+ const module = getModule();
152
+ const inPtr = copyToWasm(module, input);
153
+ // Worst case: XZ header (12) + block header (~32) + data + padding + index + footer
154
+ // For incompressible data, output can be slightly larger than input
155
+ const outSize = input.byteLength + 1024;
156
+ const outPtr = wasmAlloc(module, outSize);
157
+ const outPosPtr = wasmAlloc(module, 4);
158
+ try {
159
+ // outPos starts at 0
160
+ module.setValue(outPosPtr, 0, 'i32');
161
+ const ret = module._lzma_easy_buffer_encode(preset, check, 0, // allocator (NULL = default)
162
+ inPtr, input.byteLength, outPtr, outPosPtr, outSize);
163
+ if (ret !== LZMA_OK) {
164
+ throw createLZMAError(ret);
165
+ }
166
+ const outPos = module.getValue(outPosPtr, 'i32');
167
+ return copyFromWasm(module, outPtr, outPos);
168
+ }
169
+ finally {
170
+ wasmFree(module, inPtr);
171
+ wasmFree(module, outPtr);
172
+ wasmFree(module, outPosPtr);
173
+ }
174
+ }
175
+ /**
176
+ * Decompress a buffer using lzma_stream_buffer_decode.
177
+ *
178
+ * @param input - XZ compressed data
179
+ * @param memlimit - Memory limit in bytes (default: 256MB)
180
+ * @returns Decompressed data
181
+ * @throws LZMAError on decompression failure
182
+ */
183
+ export function streamBufferDecode(input, memlimit = DEFAULT_MEMLIMIT) {
184
+ const module = getModule();
185
+ const inPtr = copyToWasm(module, input);
186
+ const inPosPtr = wasmAlloc(module, 4);
187
+ const outPosPtr = wasmAlloc(module, 4);
188
+ const memlimitPtr = wasmAlloc(module, 8);
189
+ // Start with 4x input size as estimate, will grow if needed
190
+ let outSize = input.byteLength * 4;
191
+ if (outSize < 4096)
192
+ outSize = 4096;
193
+ let outPtr = wasmAlloc(module, outSize);
194
+ try {
195
+ const limit = typeof memlimit === 'number' ? BigInt(memlimit) : memlimit;
196
+ module.setValue(memlimitPtr, limit, 'i64');
197
+ // Retry with larger buffer if BUF_ERROR
198
+ for (let attempt = 0; attempt < 5; attempt++) {
199
+ module.setValue(inPosPtr, 0, 'i32');
200
+ module.setValue(outPosPtr, 0, 'i32');
201
+ const ret = module._lzma_stream_buffer_decode(memlimitPtr, 0, // flags
202
+ 0, // allocator (NULL)
203
+ inPtr, inPosPtr, input.byteLength, outPtr, outPosPtr, outSize);
204
+ if (ret === LZMA_OK) {
205
+ const outPos = module.getValue(outPosPtr, 'i32');
206
+ return copyFromWasm(module, outPtr, outPos);
207
+ }
208
+ // Buffer too small — grow and retry
209
+ if (ret === LZMA_BUF_ERROR) {
210
+ wasmFree(module, outPtr);
211
+ outSize *= 4;
212
+ outPtr = wasmAlloc(module, outSize);
213
+ continue;
214
+ }
215
+ throw createLZMAError(ret);
216
+ }
217
+ throw new LZMAError('Decompression failed: output buffer exhausted', 10);
218
+ }
219
+ finally {
220
+ wasmFree(module, inPtr);
221
+ wasmFree(module, outPtr);
222
+ wasmFree(module, inPosPtr);
223
+ wasmFree(module, outPosPtr);
224
+ wasmFree(module, memlimitPtr);
225
+ }
226
+ }
227
+ // --- Streaming helpers ---
228
+ /**
229
+ * Process a full input buffer through an initialized encoder/decoder stream,
230
+ * collecting all output chunks.
231
+ *
232
+ * This is used by the buffer APIs (xzAsync/unxzAsync) for streaming
233
+ * encoding/decoding within a single call.
234
+ *
235
+ * @param stream - Initialized WasmLzmaStream (encoder or decoder)
236
+ * @param input - Input data
237
+ * @returns Concatenated output
238
+ * @throws LZMAError on processing failure
239
+ */
240
+ export function processStream(stream, input) {
241
+ const module = getModule();
242
+ const inPtr = copyToWasm(module, input);
243
+ const outBufSize = DEFAULT_OUT_BUF_SIZE;
244
+ const outPtr = wasmAlloc(module, outBufSize);
245
+ try {
246
+ stream.setInput(inPtr, input.byteLength);
247
+ const chunks = [];
248
+ let action = LZMA_RUN;
249
+ while (true) {
250
+ // Once all input consumed, switch to FINISH
251
+ if (stream.availIn === 0) {
252
+ action = LZMA_FINISH;
253
+ }
254
+ stream.setOutput(outPtr, outBufSize);
255
+ const ret = code(stream, action);
256
+ // Collect output produced
257
+ const produced = outBufSize - stream.availOut;
258
+ if (produced > 0) {
259
+ chunks.push(copyFromWasm(module, outPtr, produced));
260
+ }
261
+ if (ret === LZMA_STREAM_END) {
262
+ break;
263
+ }
264
+ if (ret !== LZMA_OK) {
265
+ throw createLZMAError(ret);
266
+ }
267
+ }
268
+ // Concatenate all output chunks
269
+ const totalSize = chunks.reduce((sum, c) => sum + c.byteLength, 0);
270
+ const result = new Uint8Array(totalSize);
271
+ let offset = 0;
272
+ for (const chunk of chunks) {
273
+ result.set(chunk, offset);
274
+ offset += chunk.byteLength;
275
+ }
276
+ return result;
277
+ }
278
+ finally {
279
+ wasmFree(module, inPtr);
280
+ wasmFree(module, outPtr);
281
+ end(stream);
282
+ stream.free();
283
+ }
284
+ }
285
+ // --- Utility bindings ---
286
+ /**
287
+ * Get the liblzma version string (e.g. "5.6.3").
288
+ */
289
+ export function versionString() {
290
+ const module = getModule();
291
+ const ptr = module._lzma_version_string();
292
+ // Read null-terminated C string from WASM memory
293
+ const bytes = module.HEAPU8;
294
+ let end = ptr;
295
+ while (bytes[end] !== 0)
296
+ end++;
297
+ const decoder = new TextDecoder();
298
+ return decoder.decode(bytes.subarray(ptr, end));
299
+ }
300
+ /**
301
+ * Check if a given integrity check type is supported.
302
+ */
303
+ export function checkIsSupported(check) {
304
+ const module = getModule();
305
+ return module._lzma_check_is_supported(check) !== 0;
306
+ }
307
+ //# sourceMappingURL=bindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bindings.js","sourceRoot":"","sources":["../../src/wasm/bindings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAuB,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,QA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AC,GAAG,CAAC,KAAK,CAAC;QAAE,GAAG,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAClD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,OAAO,MAAM,CAAC,wBAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * WASM compression functions for browser usage.
3
+ *
4
+ * Provides xzAsync, xz (callback), and xzSync (throws in browser)
5
+ * matching the Node.js API signatures.
6
+ */
7
+ import type { CompressionCallback, LZMAOptions } from '../types.js';
8
+ /**
9
+ * Compress a buffer to XZ format (async, Promise-based).
10
+ *
11
+ * @param buffer - Data to compress (Uint8Array, ArrayBuffer, or string)
12
+ * @param opts - Compression options (preset, check)
13
+ * @returns Compressed XZ data
14
+ */
15
+ export declare function xzAsync(buffer: Uint8Array | ArrayBuffer | string, opts?: LZMAOptions): Promise<Uint8Array>;
16
+ /**
17
+ * Compress a buffer to XZ format (callback-based).
18
+ *
19
+ * @param buffer - Data to compress
20
+ * @param optsOrCallback - Options or callback
21
+ * @param callback - Callback (if opts provided)
22
+ */
23
+ export declare function xz(buffer: Uint8Array | ArrayBuffer | string, callback: CompressionCallback): void;
24
+ export declare function xz(buffer: Uint8Array | ArrayBuffer | string, opts: LZMAOptions, callback: CompressionCallback): void;
25
+ /**
26
+ * Synchronous XZ compression — **throws in browser**.
27
+ *
28
+ * Sync operations are not supported in WASM because they would block
29
+ * the main thread. Use xzAsync() instead.
30
+ */
31
+ export declare function xzSync(_buffer: Uint8Array | ArrayBuffer | string, _opts?: LZMAOptions): never;
32
+ //# sourceMappingURL=compress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.d.ts","sourceRoot":"","sources":["../../src/wasm/compress.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAKpE;;;;;;GAMG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EACzC,IAAI,CAAC,EAAE,WAAW,GACjB,OAAO,CAAC,UAAU,CAAC,CAMrB;AAED;;;;;;GAMG;AACH,wBAAgB,EAAE,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EAAE,QAAQ,EAAE,mBAAmB,GAAG,IAAI,CAAC;AACnG,wBAAgB,EAAE,CAChB,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EACzC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,mBAAmB,GAC5B,IAAI,CAAC;AAsBR;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAE7F"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WASM compression functions for browser usage.
3
+ *
4
+ * Provides xzAsync, xz (callback), and xzSync (throws in browser)
5
+ * matching the Node.js API signatures.
6
+ */
7
+ import { LZMAError } from '../errors.js';
8
+ import { easyBufferEncode, initModule } from './bindings.js';
9
+ import { LZMA_CHECK_CRC64 } from './types.js';
10
+ import { toUint8Array } from './utils.js';
11
+ /**
12
+ * Compress a buffer to XZ format (async, Promise-based).
13
+ *
14
+ * @param buffer - Data to compress (Uint8Array, ArrayBuffer, or string)
15
+ * @param opts - Compression options (preset, check)
16
+ * @returns Compressed XZ data
17
+ */
18
+ export async function xzAsync(buffer, opts) {
19
+ await initModule();
20
+ const input = toUint8Array(buffer);
21
+ const preset = opts?.preset ?? 6;
22
+ const check = opts?.check ?? LZMA_CHECK_CRC64;
23
+ return easyBufferEncode(input, preset, check);
24
+ }
25
+ export function xz(buffer, optsOrCallback, callback) {
26
+ let opts;
27
+ let cb;
28
+ if (typeof optsOrCallback === 'function') {
29
+ cb = optsOrCallback;
30
+ opts = {};
31
+ }
32
+ else {
33
+ opts = optsOrCallback;
34
+ cb = callback;
35
+ }
36
+ xzAsync(buffer, opts).then((result) => cb(null, result), (error) => cb(error instanceof Error ? error : new Error(String(error))));
37
+ }
38
+ /**
39
+ * Synchronous XZ compression — **throws in browser**.
40
+ *
41
+ * Sync operations are not supported in WASM because they would block
42
+ * the main thread. Use xzAsync() instead.
43
+ */
44
+ export function xzSync(_buffer, _opts) {
45
+ throw new LZMAError('Sync operations not supported in browser. Use xzAsync() instead.', -1);
46
+ }
47
+ //# sourceMappingURL=compress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.js","sourceRoot":"","sources":["../../src/wasm/compress.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,MAAyC,EACzC,IAAkB;IAElB,MAAM,UAAU,EAAE,CAAC;IACnB,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,MAAM,MAAM,GAAG,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,EAAE,KAAK,IAAI,gBAAgB,CAAC;IAC9C,OAAO,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAChD,CAAC;AAeD,MAAM,UAAU,EAAE,CAChB,MAAyC,EACzC,cAAiD,EACjD,QAA8B;IAE9B,IAAI,IAAiB,CAAC;IACtB,IAAI,EAAuB,CAAC;IAC5B,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;QACzC,EAAE,GAAG,cAAc,CAAC;QACpB,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,cAAc,CAAC;QACtB,EAAE,GAAG,QAA+B,CAAC;IACvC,CAAC;IAED,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CACxB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAA2B,CAAC,EACjD,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,OAA0C,EAAE,KAAmB;IACpF,MAAM,IAAI,SAAS,CAAC,kEAAkE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * WASM decompression functions for browser usage.
3
+ *
4
+ * Provides unxzAsync, unxz (callback), and unxzSync (throws in browser)
5
+ * matching the Node.js API signatures.
6
+ */
7
+ import type { CompressionCallback, LZMAOptions } from '../types.js';
8
+ /**
9
+ * Decompress XZ data (async, Promise-based).
10
+ *
11
+ * @param buffer - XZ compressed data
12
+ * @param opts - Decompression options (memlimit)
13
+ * @returns Decompressed data
14
+ */
15
+ export declare function unxzAsync(buffer: Uint8Array | ArrayBuffer | string, _opts?: LZMAOptions): Promise<Uint8Array>;
16
+ /**
17
+ * Decompress XZ data (callback-based).
18
+ *
19
+ * @param buffer - XZ compressed data
20
+ * @param optsOrCallback - Options or callback
21
+ * @param callback - Callback (if opts provided)
22
+ */
23
+ export declare function unxz(buffer: Uint8Array | ArrayBuffer | string, callback: CompressionCallback): void;
24
+ export declare function unxz(buffer: Uint8Array | ArrayBuffer | string, opts: LZMAOptions, callback: CompressionCallback): void;
25
+ /**
26
+ * Synchronous XZ decompression — **throws in browser**.
27
+ *
28
+ * Sync operations are not supported in WASM because they would block
29
+ * the main thread. Use unxzAsync() instead.
30
+ */
31
+ export declare function unxzSync(_buffer: Uint8Array | ArrayBuffer | string, _opts?: LZMAOptions): never;
32
+ //# sourceMappingURL=decompress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.d.ts","sourceRoot":"","sources":["../../src/wasm/decompress.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIpE;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EACzC,KAAK,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,UAAU,CAAC,CAKrB;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EACzC,QAAQ,EAAE,mBAAmB,GAC5B,IAAI,CAAC;AACR,wBAAgB,IAAI,CAClB,MAAM,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EACzC,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,mBAAmB,GAC5B,IAAI,CAAC;AAsBR;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,EAAE,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAE/F"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * WASM decompression functions for browser usage.
3
+ *
4
+ * Provides unxzAsync, unxz (callback), and unxzSync (throws in browser)
5
+ * matching the Node.js API signatures.
6
+ */
7
+ import { LZMAError } from '../errors.js';
8
+ import { initModule, streamBufferDecode } from './bindings.js';
9
+ import { toUint8Array } from './utils.js';
10
+ /**
11
+ * Decompress XZ data (async, Promise-based).
12
+ *
13
+ * @param buffer - XZ compressed data
14
+ * @param opts - Decompression options (memlimit)
15
+ * @returns Decompressed data
16
+ */
17
+ export async function unxzAsync(buffer, _opts) {
18
+ await initModule();
19
+ const input = toUint8Array(buffer);
20
+ // TODO: pass opts.memlimit when LZMAOptions supports it
21
+ return streamBufferDecode(input);
22
+ }
23
+ export function unxz(buffer, optsOrCallback, callback) {
24
+ let opts;
25
+ let cb;
26
+ if (typeof optsOrCallback === 'function') {
27
+ cb = optsOrCallback;
28
+ opts = {};
29
+ }
30
+ else {
31
+ opts = optsOrCallback;
32
+ cb = callback;
33
+ }
34
+ unxzAsync(buffer, opts).then((result) => cb(null, result), (error) => cb(error instanceof Error ? error : new Error(String(error))));
35
+ }
36
+ /**
37
+ * Synchronous XZ decompression — **throws in browser**.
38
+ *
39
+ * Sync operations are not supported in WASM because they would block
40
+ * the main thread. Use unxzAsync() instead.
41
+ */
42
+ export function unxzSync(_buffer, _opts) {
43
+ throw new LZMAError('Sync operations not supported in browser. Use unxzAsync() instead.', -1);
44
+ }
45
+ //# sourceMappingURL=decompress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decompress.js","sourceRoot":"","sources":["../../src/wasm/decompress.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAyC,EACzC,KAAmB;IAEnB,MAAM,UAAU,EAAE,CAAC;IACnB,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,wDAAwD;IACxD,OAAO,kBAAkB,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAkBD,MAAM,UAAU,IAAI,CAClB,MAAyC,EACzC,cAAiD,EACjD,QAA8B;IAE9B,IAAI,IAAiB,CAAC;IACtB,IAAI,EAAuB,CAAC;IAC5B,IAAI,OAAO,cAAc,KAAK,UAAU,EAAE,CAAC;QACzC,EAAE,GAAG,cAAc,CAAC;QACpB,IAAI,GAAG,EAAE,CAAC;IACZ,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,cAAc,CAAC;QACtB,EAAE,GAAG,QAA+B,CAAC;IACvC,CAAC;IAED,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAC1B,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,MAA2B,CAAC,EACjD,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CACzE,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAA0C,EAAE,KAAmB;IACtF,MAAM,IAAI,SAAS,CAAC,oEAAoE,EAAE,CAAC,CAAC,CAAC,CAAC;AAChG,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * WASM liblzma module — public API.
3
+ *
4
+ * This module provides TypeScript bindings to the Emscripten-compiled
5
+ * liblzma WASM binary, enabling XZ/LZMA2 compression in browsers.
6
+ */
7
+ export { autoDecoderInit, checkIsSupported, code, decoderInit, easyBufferEncode, encoderInit, end, getModule, initModule, memusage, processStream, resetModule, streamBufferDecode, versionString as wasmVersionString, } from './bindings.js';
8
+ export { xz, xzAsync, xzSync } from './compress.js';
9
+ export { unxz, unxzAsync, unxzSync } from './decompress.js';
10
+ export { copyFromWasm, copyToWasm, WasmLzmaStream } from './memory.js';
11
+ export { createUnxz, createXz } from './stream.js';
12
+ export { LZMA_BUF_ERROR, LZMA_CHECK_CRC32, LZMA_CHECK_CRC64, LZMA_CHECK_NONE, LZMA_CHECK_SHA256, LZMA_DATA_ERROR, LZMA_FINISH, LZMA_FORMAT_ERROR, LZMA_FULL_FLUSH, LZMA_GET_CHECK, LZMA_MEM_ERROR, LZMA_MEMLIMIT_ERROR, LZMA_NO_CHECK, LZMA_OK, LZMA_OPTIONS_ERROR, LZMA_PROG_ERROR, LZMA_RUN, LZMA_STREAM_END, LZMA_SYNC_FLUSH, LZMA_UNSUPPORTED_CHECK, type LZMAModule, } from './types.js';
13
+ export { easyDecoderMemusage, easyEncoderMemusage, isXZ, parseFileIndex, toUint8Array, versionNumber, versionString, type XZFileIndex, } from './utils.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wasm/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,GAAG,EACH,SAAS,EACT,UAAU,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,aAAa,IAAI,iBAAiB,GACnC,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,sBAAsB,EACtB,KAAK,UAAU,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,EACb,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * WASM liblzma module — public API.
3
+ *
4
+ * This module provides TypeScript bindings to the Emscripten-compiled
5
+ * liblzma WASM binary, enabling XZ/LZMA2 compression in browsers.
6
+ */
7
+ // --- Block 2: Low-level bindings ---
8
+ export { autoDecoderInit, checkIsSupported, code, decoderInit, easyBufferEncode, encoderInit, end, getModule, initModule, memusage, processStream, resetModule, streamBufferDecode, versionString as wasmVersionString, } from './bindings.js';
9
+ // --- Block 3: Buffer API (high-level) ---
10
+ export { xz, xzAsync, xzSync } from './compress.js';
11
+ export { unxz, unxzAsync, unxzSync } from './decompress.js';
12
+ export { copyFromWasm, copyToWasm, WasmLzmaStream } from './memory.js';
13
+ // --- Block 4: Streaming API (Web Streams) ---
14
+ export { createUnxz, createXz } from './stream.js';
15
+ export { LZMA_BUF_ERROR, LZMA_CHECK_CRC32, LZMA_CHECK_CRC64, LZMA_CHECK_NONE, LZMA_CHECK_SHA256, LZMA_DATA_ERROR, LZMA_FINISH, LZMA_FORMAT_ERROR, LZMA_FULL_FLUSH, LZMA_GET_CHECK, LZMA_MEM_ERROR, LZMA_MEMLIMIT_ERROR, LZMA_NO_CHECK, LZMA_OK, LZMA_OPTIONS_ERROR, LZMA_PROG_ERROR, LZMA_RUN, LZMA_STREAM_END, LZMA_SYNC_FLUSH, LZMA_UNSUPPORTED_CHECK, } from './types.js';
16
+ // --- Block 5: Utility functions ---
17
+ export { easyDecoderMemusage, easyEncoderMemusage, isXZ, parseFileIndex, toUint8Array, versionNumber, versionString, } from './utils.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/wasm/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,sCAAsC;AACtC,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,GAAG,EACH,SAAS,EACT,UAAU,EACV,QAAQ,EACR,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,aAAa,IAAI,iBAAiB,GACnC,MAAM,eAAe,CAAC;AACvB,2CAA2C;AAC3C,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACvE,+CAA+C;AAC/C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,eAAe,EACf,eAAe,EACf,sBAAsB,GAEvB,MAAM,YAAY,CAAC;AAEpB,qCAAqC;AACrC,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,IAAI,EACJ,cAAc,EACd,YAAY,EACZ,aAAa,EACb,aAAa,GAEd,MAAM,YAAY,CAAC"}