node-liblzma 2.0.3 → 2.1.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.
- package/README.md +156 -63
- package/index.d.ts +26 -3
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +26 -15
- package/lib/errors.js.map +1 -1
- package/lib/lzma.d.ts +236 -2
- package/lib/lzma.d.ts.map +1 -1
- package/lib/lzma.js +225 -39
- package/lib/lzma.js.map +1 -1
- package/lib/pool.d.ts.map +1 -1
- package/lib/pool.js +9 -3
- package/lib/pool.js.map +1 -1
- package/lib/types.d.ts +68 -1
- package/lib/types.d.ts.map +1 -1
- package/package.json +29 -12
- package/scripts/build_xz_with_cmake.py +23 -26
- package/src/bindings/node-liblzma.cpp +40 -4
- package/src/bindings/node-liblzma.hpp +2 -1
- package/xz-version.json +3 -3
- package/.gitattributes +0 -3
- package/.release-it.json +0 -7
- package/.release-it.manual.json +0 -7
- package/.release-it.retry.json +0 -3
- package/CHANGELOG.md +0 -271
- package/History.md +0 -79
- package/RELEASING.md +0 -131
- package/biome.json +0 -81
- package/pnpm-workspace.yaml +0 -3
- package/prebuilds/darwin-x64/node-liblzma.node +0 -0
- package/prebuilds/linux-x64/node-liblzma.node +0 -0
- package/prebuilds/win32-x64/node-liblzma.node +0 -0
- package/scripts/analyze-coverage.js +0 -132
- package/scripts/compare-coverage-tools.js +0 -93
- package/src/errors.ts +0 -167
- package/src/lzma.ts +0 -839
- package/src/pool.ts +0 -228
- package/src/types.ts +0 -30
- package/tsconfig.json +0 -50
- package/vitest.config.istanbul.ts +0 -29
- package/vitest.config.monocart.ts +0 -44
- package/vitest.config.ts +0 -52
package/lib/types.d.ts
CHANGED
|
@@ -17,11 +17,78 @@ export interface LZMAOptions {
|
|
|
17
17
|
/** Flush flag to use */
|
|
18
18
|
flushFlag?: number;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Callback function for asynchronous compression/decompression operations.
|
|
22
|
+
* @param error - Error object if operation failed, null otherwise
|
|
23
|
+
* @param result - Compressed or decompressed data buffer
|
|
24
|
+
*/
|
|
20
25
|
export type CompressionCallback = (error: Error | null, result?: Buffer) => void;
|
|
26
|
+
/**
|
|
27
|
+
* LZMA action type for stream operations.
|
|
28
|
+
* - `0` (RUN): Normal processing
|
|
29
|
+
* - `1` (SYNC_FLUSH): Flush pending output
|
|
30
|
+
* - `2` (FULL_FLUSH): Flush and reset encoder state
|
|
31
|
+
* - `3` (FINISH): Finish the stream
|
|
32
|
+
*/
|
|
21
33
|
export type LZMAActionType = 0 | 1 | 2 | 3;
|
|
34
|
+
/**
|
|
35
|
+
* LZMA status codes returned by operations.
|
|
36
|
+
* - `0` (OK): Operation completed successfully
|
|
37
|
+
* - `1` (STREAM_END): End of stream reached
|
|
38
|
+
* - `2` (NO_CHECK): Input has no integrity check
|
|
39
|
+
* - `3` (UNSUPPORTED_CHECK): Cannot calculate integrity check
|
|
40
|
+
* - `4` (GET_CHECK): Integrity check available
|
|
41
|
+
* - `5` (MEM_ERROR): Memory allocation failed
|
|
42
|
+
* - `6` (MEMLIMIT_ERROR): Memory limit reached
|
|
43
|
+
* - `7` (FORMAT_ERROR): File format not recognized
|
|
44
|
+
* - `8` (OPTIONS_ERROR): Invalid options
|
|
45
|
+
* - `9` (DATA_ERROR): Data is corrupt
|
|
46
|
+
* - `10` (BUF_ERROR): No progress possible
|
|
47
|
+
* - `11` (PROG_ERROR): Programming error
|
|
48
|
+
*/
|
|
22
49
|
export type LZMAStatusType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;
|
|
50
|
+
/**
|
|
51
|
+
* Integrity check type for XZ streams.
|
|
52
|
+
* - `0` (NONE): No integrity check
|
|
53
|
+
* - `1` (CRC32): 32-bit CRC
|
|
54
|
+
* - `4` (CRC64): 64-bit CRC (recommended)
|
|
55
|
+
* - `10` (SHA256): SHA-256 hash
|
|
56
|
+
*/
|
|
23
57
|
export type CheckType = 0 | 1 | 4 | 10;
|
|
24
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Compression preset level (0-9), optionally combined with EXTREME flag.
|
|
60
|
+
* Higher values = better compression but slower.
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const preset = 6; // Default compression
|
|
64
|
+
* const extreme = 6 | 0x80000000; // Default with extreme flag
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export type PresetType = number;
|
|
68
|
+
/**
|
|
69
|
+
* Filter type for LZMA2 compression chain.
|
|
70
|
+
* - `0x21` (LZMA2): Main compression filter
|
|
71
|
+
* - `0x03` (X86): BCJ filter for x86 executables
|
|
72
|
+
* - `0x04` (POWERPC): BCJ filter for PowerPC
|
|
73
|
+
* - `0x06` (IA64): BCJ filter for IA-64
|
|
74
|
+
* - `0x07` (ARM): BCJ filter for ARM
|
|
75
|
+
* - `0x08` (ARMTHUMB): BCJ filter for ARM-Thumb
|
|
76
|
+
* - `0x09` (SPARC): BCJ filter for SPARC
|
|
77
|
+
*/
|
|
25
78
|
export type FilterType = 0x21 | 0x03 | 0x04 | 0x06 | 0x07 | 0x08 | 0x09;
|
|
79
|
+
/**
|
|
80
|
+
* Compression mode.
|
|
81
|
+
* - `1` (FAST): Faster compression, less memory
|
|
82
|
+
* - `2` (NORMAL): Better compression ratio
|
|
83
|
+
*/
|
|
26
84
|
export type ModeType = 1 | 2;
|
|
85
|
+
/**
|
|
86
|
+
* Progress event data emitted during compression/decompression
|
|
87
|
+
*/
|
|
88
|
+
export interface ProgressInfo {
|
|
89
|
+
/** Total bytes read from input so far */
|
|
90
|
+
bytesRead: number;
|
|
91
|
+
/** Total bytes written to output so far */
|
|
92
|
+
bytesWritten: number;
|
|
93
|
+
}
|
|
27
94
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,uBAAuB;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wBAAwB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE3C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC;AAE7E;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;AAEvC;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;;;;;;GASG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAExE;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAC;AAE7B;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;CACtB"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-liblzma",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "NodeJS wrapper for liblzma",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/lzma.js",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./lib/lzma.js",
|
|
10
|
-
"types": "./index.d.ts"
|
|
10
|
+
"types": "./index.d.ts",
|
|
11
|
+
"default": "./lib/lzma.js"
|
|
11
12
|
}
|
|
12
13
|
},
|
|
13
14
|
"scripts": {
|
|
@@ -21,6 +22,7 @@
|
|
|
21
22
|
"test:watch": "vitest",
|
|
22
23
|
"test:coverage": "vitest run --config vitest.config.monocart.ts --coverage",
|
|
23
24
|
"test:coverage-v8": "vitest run --coverage",
|
|
25
|
+
"test:ui": "vitest --ui",
|
|
24
26
|
"type-check": "tsc --noEmit",
|
|
25
27
|
"clean": "rm -rf lib",
|
|
26
28
|
"lint": "biome lint",
|
|
@@ -32,28 +34,43 @@
|
|
|
32
34
|
"release": "release-it-preset default",
|
|
33
35
|
"release:manual": "release-it-preset --config .release-it.manual.json",
|
|
34
36
|
"release:hotfix": "release-it-preset hotfix",
|
|
35
|
-
"changelog:update": "release-it-preset changelog-only"
|
|
37
|
+
"changelog:update": "release-it-preset changelog-only",
|
|
38
|
+
"typedoc": "typedoc",
|
|
39
|
+
"typedoc:watch": "typedoc --watch"
|
|
36
40
|
},
|
|
37
41
|
"dependencies": {
|
|
38
42
|
"node-addon-api": "^8.5.0",
|
|
39
43
|
"node-gyp-build": "^4.8.4"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
|
-
"@biomejs/biome": "^2.
|
|
46
|
+
"@biomejs/biome": "^2.3.12",
|
|
43
47
|
"@oorabona/release-it-preset": "^0.9.0",
|
|
44
48
|
"@oorabona/vitest-monocart-coverage": "^2.0.1",
|
|
45
|
-
"@types/node": "^
|
|
46
|
-
"@vitest/coverage-istanbul": "^
|
|
47
|
-
"@vitest/coverage-v8": "^
|
|
48
|
-
"@vitest/ui": "
|
|
49
|
-
"nano-staged": "^0.
|
|
50
|
-
"release-it": "^19.
|
|
49
|
+
"@types/node": "^25.0.10",
|
|
50
|
+
"@vitest/coverage-istanbul": "^4.0.18",
|
|
51
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
52
|
+
"@vitest/ui": "4.0.18",
|
|
53
|
+
"nano-staged": "^0.9.0",
|
|
54
|
+
"release-it": "^19.2.4",
|
|
51
55
|
"simple-git-hooks": "^2.13.1",
|
|
52
56
|
"tsd": "^0.33.0",
|
|
53
|
-
"
|
|
54
|
-
"
|
|
57
|
+
"typedoc": "^0.28.16",
|
|
58
|
+
"typedoc-material-theme": "^1.4.1",
|
|
59
|
+
"typescript": "^5.9.3",
|
|
60
|
+
"vitest": "^4.0.18"
|
|
55
61
|
},
|
|
56
62
|
"types": "index.d.ts",
|
|
63
|
+
"files": [
|
|
64
|
+
"lib/",
|
|
65
|
+
"src/bindings/",
|
|
66
|
+
"scripts/build_xz_with_cmake.py",
|
|
67
|
+
"scripts/download_xz_from_github.py",
|
|
68
|
+
"scripts/copy_dll.py",
|
|
69
|
+
"scripts/walk_sources.py",
|
|
70
|
+
"binding.gyp",
|
|
71
|
+
"index.d.ts",
|
|
72
|
+
"xz-version.json"
|
|
73
|
+
],
|
|
57
74
|
"engines": {
|
|
58
75
|
"node": ">=16.0.0"
|
|
59
76
|
},
|
|
@@ -282,16 +282,20 @@ def main():
|
|
|
282
282
|
parser = argparse.ArgumentParser(
|
|
283
283
|
description='Build XZ Utils using CMake',
|
|
284
284
|
epilog='''
|
|
285
|
-
|
|
286
|
-
RUNTIME_LINK: 'static' or 'shared'
|
|
287
|
-
|
|
288
|
-
|
|
285
|
+
Optional environment variables (with sensible defaults matching binding.gyp):
|
|
286
|
+
RUNTIME_LINK: 'static' or 'shared'
|
|
287
|
+
Default: 'static' on Windows, 'shared' on Linux/macOS
|
|
288
|
+
ENABLE_THREAD_SUPPORT: 'yes' or 'no'
|
|
289
|
+
Default: 'yes'
|
|
290
|
+
USE_GLOBAL: 'true' or 'false'
|
|
291
|
+
Default: 'false' on Windows, 'true' on Linux/macOS
|
|
289
292
|
|
|
290
293
|
Examples:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
294
|
+
# Use defaults (recommended)
|
|
295
|
+
python3 build_xz_with_cmake.py deps/xz build/liblzma
|
|
296
|
+
|
|
297
|
+
# Override specific values
|
|
298
|
+
RUNTIME_LINK=static USE_GLOBAL=false \\
|
|
295
299
|
python3 build_xz_with_cmake.py deps/xz build/liblzma
|
|
296
300
|
''',
|
|
297
301
|
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
@@ -304,24 +308,17 @@ Examples:
|
|
|
304
308
|
|
|
305
309
|
args = parser.parse_args()
|
|
306
310
|
|
|
307
|
-
# Get configuration from environment variables with
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
print("[ERROR] ENABLE_THREAD_SUPPORT environment variable must be explicitly set ('yes' or 'no')")
|
|
319
|
-
return 1
|
|
320
|
-
|
|
321
|
-
if use_global is None:
|
|
322
|
-
print("[ERROR] USE_GLOBAL environment variable must be explicitly set ('true' or 'false')")
|
|
323
|
-
return 1
|
|
324
|
-
|
|
311
|
+
# Get configuration from environment variables with sensible defaults
|
|
312
|
+
# Defaults match binding.gyp for consistency
|
|
313
|
+
is_windows = sys.platform == 'win32'
|
|
314
|
+
|
|
315
|
+
# Default: 'shared' on Linux/macOS, 'static' on Windows
|
|
316
|
+
runtime_link = os.environ.get('RUNTIME_LINK') or ('static' if is_windows else 'shared')
|
|
317
|
+
# Default: 'yes' (threading enabled)
|
|
318
|
+
enable_threads = os.environ.get('ENABLE_THREAD_SUPPORT') or 'yes'
|
|
319
|
+
# Default: 'false' on Windows, 'true' on Linux/macOS (use system library)
|
|
320
|
+
use_global = os.environ.get('USE_GLOBAL') or ('false' if is_windows else 'true')
|
|
321
|
+
|
|
325
322
|
# Validate values
|
|
326
323
|
if runtime_link not in ['static', 'shared']:
|
|
327
324
|
print(f"[ERROR] Invalid RUNTIME_LINK: {runtime_link}. Must be 'static' or 'shared'")
|
|
@@ -29,6 +29,12 @@ Napi::Value LZMA::Close(const Napi::CallbackInfo &info)
|
|
|
29
29
|
|
|
30
30
|
Napi::Value LZMA::Close(const Napi::Env &env)
|
|
31
31
|
{
|
|
32
|
+
// F-006: Idempotency guard - prevent double-subtract of external memory
|
|
33
|
+
if (_closed)
|
|
34
|
+
{
|
|
35
|
+
return env.Undefined();
|
|
36
|
+
}
|
|
37
|
+
_closed = true;
|
|
32
38
|
Napi::MemoryManagement::AdjustExternalMemory(env, -int64_t(sizeof(LZMA)));
|
|
33
39
|
|
|
34
40
|
if (_wip)
|
|
@@ -63,7 +69,7 @@ void LZMA::Init(Napi::Env env, Napi::Object exports)
|
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
LZMA::LZMA(const Napi::CallbackInfo &info) : Napi::ObjectWrap<LZMA>(info), _stream(LZMA_STREAM_INIT),
|
|
66
|
-
_wip(false), _pending_close(false), _worker(nullptr)
|
|
72
|
+
_wip(false), _pending_close(false), _closed(false), _worker(nullptr)
|
|
67
73
|
{
|
|
68
74
|
Napi::Env env = info.Env();
|
|
69
75
|
|
|
@@ -103,7 +109,7 @@ LZMA::LZMA(const Napi::CallbackInfo &info) : Napi::ObjectWrap<LZMA>(info), _stre
|
|
|
103
109
|
switch (mode)
|
|
104
110
|
{
|
|
105
111
|
case STREAM_DECODE:
|
|
106
|
-
success = InitializeDecoder();
|
|
112
|
+
success = InitializeDecoder(env);
|
|
107
113
|
break;
|
|
108
114
|
case STREAM_ENCODE:
|
|
109
115
|
success = InitializeEncoder(opts, preset, check);
|
|
@@ -163,6 +169,13 @@ LZMA::~LZMA()
|
|
|
163
169
|
template <bool async>
|
|
164
170
|
Napi::Value LZMA::Code(const Napi::CallbackInfo &info)
|
|
165
171
|
{
|
|
172
|
+
// F-001: Guard against concurrent calls - liblzma is not thread-safe per stream
|
|
173
|
+
if (this->_wip)
|
|
174
|
+
{
|
|
175
|
+
Napi::Error::New(info.Env(), "Stream is busy - concurrent operations not allowed").ThrowAsJavaScriptException();
|
|
176
|
+
return info.Env().Undefined();
|
|
177
|
+
}
|
|
178
|
+
|
|
166
179
|
// Setup with manual guard (safer than RAII for JS exceptions)
|
|
167
180
|
this->_wip = true;
|
|
168
181
|
this->Ref();
|
|
@@ -285,6 +298,14 @@ bool LZMA::ValidateAndPrepareBuffers(const Napi::CallbackInfo &info, BufferConte
|
|
|
285
298
|
}
|
|
286
299
|
|
|
287
300
|
ctx.out_off = info[5].ToNumber().Uint32Value();
|
|
301
|
+
|
|
302
|
+
// F-002: Validate output offset bounds to prevent underflow in out_len calculation
|
|
303
|
+
if (ctx.out_off > out_max)
|
|
304
|
+
{
|
|
305
|
+
Napi::RangeError::New(env, "Output offset exceeds buffer length").ThrowAsJavaScriptException();
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
|
|
288
309
|
ctx.out_len = out_max - ctx.out_off;
|
|
289
310
|
ctx.out = out_buf + ctx.out_off;
|
|
290
311
|
|
|
@@ -461,10 +482,18 @@ bool LZMA::InitializeEncoder(const Napi::Object &opts, uint32_t preset, lzma_che
|
|
|
461
482
|
return true;
|
|
462
483
|
}
|
|
463
484
|
|
|
464
|
-
bool LZMA::InitializeDecoder()
|
|
485
|
+
bool LZMA::InitializeDecoder(const Napi::Env &env)
|
|
465
486
|
{
|
|
466
487
|
lzma_ret ret = lzma_stream_decoder(&this->_stream, UINT64_MAX, LZMA_CONCATENATED);
|
|
467
|
-
|
|
488
|
+
|
|
489
|
+
// F-005: Throw exception on decoder init failure (consistent with InitializeEncoder)
|
|
490
|
+
if (ret != LZMA_OK)
|
|
491
|
+
{
|
|
492
|
+
Napi::Error::New(env, "LZMA decoder failure, returned " + std::to_string(ret)).ThrowAsJavaScriptException();
|
|
493
|
+
return false;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
return true;
|
|
468
497
|
}
|
|
469
498
|
|
|
470
499
|
void LZMA::AfterCommon(const Napi::Env &env)
|
|
@@ -515,8 +544,15 @@ void LZMA::After(const Napi::Env &env, const Napi::Function &cb)
|
|
|
515
544
|
Napi::Number avail_in = Napi::Number::New(env, this->_stream.avail_in);
|
|
516
545
|
Napi::Number avail_out = Napi::Number::New(env, this->_stream.avail_out);
|
|
517
546
|
|
|
547
|
+
// F-001: Clear _wip BEFORE callback so callback can call code() again for iterative processing
|
|
548
|
+
// Note: Buffer refs are released after callback in case callback needs to access them
|
|
549
|
+
this->_wip = false;
|
|
550
|
+
|
|
518
551
|
// Call the provided JS callback with the three numeric results
|
|
552
|
+
// The callback may call code() again for iterative processing (this is the normal pattern)
|
|
519
553
|
cb.Call({ret, avail_in, avail_out});
|
|
520
554
|
|
|
555
|
+
// F-004: Ensure cleanup runs even if callback threw an exception
|
|
556
|
+
// With NAPI_DISABLE_CPP_EXCEPTIONS, exceptions are pending rather than thrown
|
|
521
557
|
AfterCommon(env);
|
|
522
558
|
}
|
|
@@ -81,7 +81,7 @@ private:
|
|
|
81
81
|
bool ValidateConstructorArgs(const Napi::CallbackInfo &info, uint32_t &mode, Napi::Object &opts);
|
|
82
82
|
bool InitializeFilters(const Napi::Object &opts, uint32_t preset);
|
|
83
83
|
bool InitializeEncoder(const Napi::Object &opts, uint32_t preset, lzma_check check);
|
|
84
|
-
bool InitializeDecoder();
|
|
84
|
+
bool InitializeDecoder(const Napi::Env &env);
|
|
85
85
|
|
|
86
86
|
// Common cleanup operations for both sync and async completion
|
|
87
87
|
void AfterCommon(const Napi::Env &env);
|
|
@@ -95,6 +95,7 @@ private:
|
|
|
95
95
|
lzma_stream _stream;
|
|
96
96
|
bool _wip;
|
|
97
97
|
bool _pending_close;
|
|
98
|
+
bool _closed; // F-006: Prevent double-subtract in AdjustExternalMemory
|
|
98
99
|
|
|
99
100
|
LZMAWorker *_worker;
|
|
100
101
|
|
package/xz-version.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "v5.8.
|
|
3
|
-
"comment": "
|
|
4
|
-
"last_checked": "
|
|
2
|
+
"version": "v5.8.2",
|
|
3
|
+
"comment": "Stable version tested and validated for production. Auto-updated by GitHub Actions.",
|
|
4
|
+
"last_checked": "2026-01-25",
|
|
5
5
|
"allow_override": true,
|
|
6
6
|
"repository": "tukaani-project/xz",
|
|
7
7
|
"changelog": "https://github.com/tukaani-project/xz/releases/tag/v5.8.1"
|
package/.gitattributes
DELETED
package/.release-it.json
DELETED
package/.release-it.manual.json
DELETED
package/.release-it.retry.json
DELETED
package/CHANGELOG.md
DELETED
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
## [2.0.3] - 2025-10-07
|
|
11
|
-
|
|
12
|
-
### Fixed
|
|
13
|
-
- create dedicated .release-it.retry.json for publish workflow (ci) ([007ec61](https://github.com/oorabona/node-liblzma/commit/007ec61))
|
|
14
|
-
- ignore local .release-it.json in publish workflow (ci) ([0958cc3](https://github.com/oorabona/node-liblzma/commit/0958cc3))
|
|
15
|
-
- use correct release-it-preset CLI syntax (ci) ([210343e](https://github.com/oorabona/node-liblzma/commit/210343e))
|
|
16
|
-
- use npm config set for authentication (ci) ([8e6abcc](https://github.com/oorabona/node-liblzma/commit/8e6abcc))
|
|
17
|
-
- configure npm authentication in publish workflow (ci) ([5b085e4](https://github.com/oorabona/node-liblzma/commit/5b085e4))
|
|
18
|
-
- use tar.gz archives for cross-platform prebuild distribution (ci) ([bc6c213](https://github.com/oorabona/node-liblzma/commit/bc6c213))
|
|
19
|
-
- preserve prebuild directory structure to prevent file overwriting (ci) ([ac8f364](https://github.com/oorabona/node-liblzma/commit/ac8f364))
|
|
20
|
-
- remove build duplication and fix release-it command in publish workflow (ci) ([b0588ca](https://github.com/oorabona/node-liblzma/commit/b0588ca))
|
|
21
|
-
- skip build scripts in publish workflow (ci) ([eb7ab76](https://github.com/oorabona/node-liblzma/commit/eb7ab76))
|
|
22
|
-
- force bash shell for XZ download step on Windows (ci) ([73b6839](https://github.com/oorabona/node-liblzma/commit/73b6839))
|
|
23
|
-
|
|
24
|
-
## [2.0.2] - 2025-10-07
|
|
25
|
-
|
|
26
|
-
### Added
|
|
27
|
-
- refactor release workflow to use Pull Request strategy (ci) ([b2797fd](https://github.com/oorabona/node-liblzma/commit/b2797fd))
|
|
28
|
-
- optimize XZ management with artifacts and move prebuildify to CI-only (ci) ([de7d825](https://github.com/oorabona/node-liblzma/commit/de7d825))
|
|
29
|
-
- optimize XZ source management with artifacts and fix prebuildify PATH (ci) ([3984e19](https://github.com/oorabona/node-liblzma/commit/3984e19))
|
|
30
|
-
- optimize XZ source management with GitHub Actions artifacts (ci) ([0dec8f8](https://github.com/oorabona/node-liblzma/commit/0dec8f8))
|
|
31
|
-
- simplify republish workflow by removing target options and using boolean for npm publish (workflows) ([d1e188d](https://github.com/oorabona/node-liblzma/commit/d1e188d))
|
|
32
|
-
|
|
33
|
-
### Fixed
|
|
34
|
-
- remove CHANGELOG update and dry-run validation steps since default handles both directly (release) ([8ff80f8](https://github.com/oorabona/node-liblzma/commit/8ff80f8))
|
|
35
|
-
- skip native module compilation in release workflow (ci) ([53fc871](https://github.com/oorabona/node-liblzma/commit/53fc871))
|
|
36
|
-
- correct gyp staleness detection to prevent unconditional XZ downloads (build) ([6ed20dd](https://github.com/oorabona/node-liblzma/commit/6ed20dd))
|
|
37
|
-
- prevent double compilation and ensure prebuildify executes (ci) ([4dece66](https://github.com/oorabona/node-liblzma/commit/4dece66))
|
|
38
|
-
- add tag normalization and fix checkout refs for reproducible builds (workflows) ([2c7beee](https://github.com/oorabona/node-liblzma/commit/2c7beee))
|
|
39
|
-
- add automatic 'v' prefix normalization to prevent tag mismatch (workflows) ([862dd89](https://github.com/oorabona/node-liblzma/commit/862dd89))
|
|
40
|
-
|
|
41
|
-
## [2.0.1] - 2025-10-07
|
|
42
|
-
|
|
43
|
-
### Changed
|
|
44
|
-
- **Vitest Configuration**: Universal fork-based worker pool with increased timeouts to resolve Vitest bug #8201
|
|
45
|
-
- Changed from conditional forks (macOS only) to universal forks for all platforms
|
|
46
|
-
- Increased testTimeout from 5000ms to 10000ms
|
|
47
|
-
- Added hookTimeout of 10000ms
|
|
48
|
-
- Configured singleFork and isolate options for better stability
|
|
49
|
-
- Increased workflow retry attempts from 3 to 5 for better reliability
|
|
50
|
-
- **CI/CD Workflow Architecture**:
|
|
51
|
-
- Extracted hardcoded Node.js version to environment variable (NODE_VERSION: '22')
|
|
52
|
-
- Added retry mechanism for all test executions (5 attempts with 10-minute timeout)
|
|
53
|
-
- Changed `tags-ignore` to `tags` in ci-unified.yml to allow CI validation before releases
|
|
54
|
-
- Removed duplicate test execution from release.yml (violates DRY and SRP principles)
|
|
55
|
-
- Added check-ci job to verify CI passed before building prebuilds and publishing
|
|
56
|
-
|
|
57
|
-
### Fixed
|
|
58
|
-
- **Test Stability**: Fixed "Channel closed" (ERR_IPC_CHANNEL_CLOSED) errors on GitHub Actions macOS runners
|
|
59
|
-
- **Workflow Duplication**: Eliminated duplicate test execution between ci-unified.yml and release.yml
|
|
60
|
-
- **Release Safety**: Added CI verification step to ensure all checks pass before publishing to npm
|
|
61
|
-
|
|
62
|
-
## [2.0.0] - 2025-10-06
|
|
63
|
-
|
|
64
|
-
### Added
|
|
65
|
-
- **TypeScript Support**: Complete migration from CoffeeScript to TypeScript for better type safety and developer experience
|
|
66
|
-
- **Promise APIs**: New async functions `xzAsync()` and `unxzAsync()` with Promise support
|
|
67
|
-
- **Typed Error Classes**: 8 specialized error classes (`LZMAMemoryError`, `LZMADataError`, `LZMAFormatError`, etc.) with factory pattern for precise error handling
|
|
68
|
-
- **Concurrency Control**: `LZMAPool` class with EventEmitter-based monitoring for production environments
|
|
69
|
-
- Automatic backpressure and queue management
|
|
70
|
-
- Configurable concurrency limits
|
|
71
|
-
- Real-time metrics (`active`, `queued`, `completed`, `failed`)
|
|
72
|
-
- Events: `queue`, `start`, `complete`, `error-task`, `metrics`
|
|
73
|
-
- **File Helpers**: Simplified `xzFile()` and `unxzFile()` functions for file-based compression
|
|
74
|
-
- **Modern Testing**: Migrated from Mocha to Vitest with improved performance and TypeScript integration
|
|
75
|
-
- **100% Code Coverage**: Comprehensive test suite (320+ tests) covering all statements, branches, functions, and lines
|
|
76
|
-
- **Enhanced Tooling**:
|
|
77
|
-
- [Biome](https://biomejs.dev/) for fast linting and formatting
|
|
78
|
-
- Pre-commit hooks with nano-staged and simple-git-hooks
|
|
79
|
-
- pnpm as package manager for better dependency management
|
|
80
|
-
- **Security**:
|
|
81
|
-
- Fixed FunctionReference memory leak using smart pointers with custom deleter
|
|
82
|
-
- Added 512MB buffer size validation to prevent DoS attacks
|
|
83
|
-
- CodeQL workflow for continuous security scanning
|
|
84
|
-
- Dependabot configuration for automated dependency updates
|
|
85
|
-
- Enhanced tarball extraction with path validation and safety checks against path traversal
|
|
86
|
-
- **Thread Support**: Multi-threaded compression with configurable thread count
|
|
87
|
-
- **Automatic Filter Reordering**: LZMA2 filter automatically moved to end as required by liblzma
|
|
88
|
-
- **Factory Functions**: `createXz()` and `createUnxz()` to avoid circular dependencies in ESM
|
|
89
|
-
- **XZ Version Management**: Automated version tracking and update workflows for XZ Utils
|
|
90
|
-
- **CI/CD Enhancements**:
|
|
91
|
-
- Unified CI pipeline with smart smoke/full test detection
|
|
92
|
-
- Conditional test execution based on PR vs push vs schedule
|
|
93
|
-
- Composite GitHub Actions for dependency installation and environment setup
|
|
94
|
-
- XZ source caching with GitHub token support
|
|
95
|
-
- Upgraded to setup-node v5 across all workflows
|
|
96
|
-
- GITHUB_TOKEN environment variable for authenticated downloads
|
|
97
|
-
- **.gitattributes**: Line ending normalization for cross-platform consistency
|
|
98
|
-
|
|
99
|
-
### Changed
|
|
100
|
-
- **Breaking**: Requires Node.js >= 16 (updated from >= 12)
|
|
101
|
-
- **Breaking**: Module is now ESM-only (`"type": "module"`)
|
|
102
|
-
- **Build System**: Modernized to use CMake for XZ Utils compilation
|
|
103
|
-
- Environment variable configuration for runtime linking (`RUNTIME_LINK=static|shared`)
|
|
104
|
-
- Threading support configuration (`ENABLE_THREAD_SUPPORT=yes|no`)
|
|
105
|
-
- Global liblzma usage option (`USE_GLOBAL=true|false`)
|
|
106
|
-
- Disabled CLI tools to avoid libintl dependency on macOS
|
|
107
|
-
- **XZ Utils**: Updated from 5.6.3 to 5.8.1 with complete CMake support
|
|
108
|
-
- **macOS Support**: Enhanced dylib handling with proper RPATH configuration
|
|
109
|
-
- Smart install_name verification and fixing for shared libraries
|
|
110
|
-
- Proper linker flags via xcode_settings
|
|
111
|
-
- Only applies install_name fixes to shared library builds
|
|
112
|
-
- **Windows Support**: Improved threading and DLL handling
|
|
113
|
-
- Thread support now works with both static and shared builds
|
|
114
|
-
- Fixed kernel32.lib linking for MSVC
|
|
115
|
-
- Automated library name fixing for binding.gyp compatibility
|
|
116
|
-
- Python-based DLL copying for better reliability
|
|
117
|
-
- **Vitest Configuration**: Fork-based worker pool on macOS to avoid IPC channel errors
|
|
118
|
-
- **CI Workflows**:
|
|
119
|
-
- Consolidated from 5 workflows to 1 unified pipeline
|
|
120
|
-
- Smoke tests and full tests are now mutually exclusive
|
|
121
|
-
- Proper handling of skipped job states in CI summary
|
|
122
|
-
- Enhanced caching strategy and matrix testing
|
|
123
|
-
- Path filters to avoid unnecessary runs
|
|
124
|
-
- **Code Quality**: Simplified instance data management and improved buffer handling
|
|
125
|
-
- Standardized error messages (removed "BUG?" prefixes) for production-ready error handling
|
|
126
|
-
- Improved async callback handling and error management
|
|
127
|
-
- Enhanced TypeScript configuration for better test reliability
|
|
128
|
-
|
|
129
|
-
### Fixed
|
|
130
|
-
- **macOS Build Issues**:
|
|
131
|
-
- Fixed dylib loading errors (`Library not loaded: @rpath/liblzma.5.dylib`)
|
|
132
|
-
- Resolved libintl dependency issues by disabling XZ CLI tools
|
|
133
|
-
- Fixed RPATH configuration in binding.gyp and CMake
|
|
134
|
-
- Corrected install_name verification for shared vs static builds
|
|
135
|
-
- **Windows Build Issues**:
|
|
136
|
-
- Fixed NAPI_VERSION redefinition error
|
|
137
|
-
- Resolved DLL loading for shared library builds
|
|
138
|
-
- Fixed threading support configuration
|
|
139
|
-
- Corrected Windows library naming for compatibility
|
|
140
|
-
- **CI/CD Issues**:
|
|
141
|
-
- Fixed pipeline failure when smoke test is skipped
|
|
142
|
-
- Fixed conditional check for global liblzma usage
|
|
143
|
-
- Removed unnecessary shell specifications
|
|
144
|
-
- Fixed caching strategy and matrix configuration
|
|
145
|
-
- **Test Issues**:
|
|
146
|
-
- Skip negative threads test if threading not supported
|
|
147
|
-
- Fixed TypeScript error handling in tests
|
|
148
|
-
- **Code Issues**:
|
|
149
|
-
- Resolved C++ exception handling with `NAPI_DISABLE_CPP_EXCEPTIONS`
|
|
150
|
-
- Corrected memory management in async operations (Ref/Unref balance)
|
|
151
|
-
- Fixed filter validation bug causing `LZMA_OPTIONS_ERROR` with multiple filters
|
|
152
|
-
- Fixed memory leak in FunctionReference lifecycle management
|
|
153
|
-
- Fixed memory leaks and race conditions in C++ bindings
|
|
154
|
-
- Fixed filters array mutation by cloning in LZMAOptions
|
|
155
|
-
- Fixed XzStream destructuring for clarity
|
|
156
|
-
- Fixed LZMA2 filter ordering to ensure it's always last
|
|
157
|
-
- **General**:
|
|
158
|
-
- Fixed download script symbolic link safety checks
|
|
159
|
-
- Added `*.log` to .gitignore
|
|
160
|
-
- Fixed tsconfig formatting
|
|
161
|
-
- Improved code formatting consistency
|
|
162
|
-
|
|
163
|
-
## [1.1.9] - Previous Release
|
|
164
|
-
|
|
165
|
-
### Fixed
|
|
166
|
-
- Fix building if no prebuilt binary found
|
|
167
|
-
|
|
168
|
-
## [1.1.7]
|
|
169
|
-
|
|
170
|
-
### Fixed
|
|
171
|
-
- Fix build system
|
|
172
|
-
- Fix release system
|
|
173
|
-
- Fix documentation
|
|
174
|
-
|
|
175
|
-
## [1.1.0]
|
|
176
|
-
|
|
177
|
-
### Changed
|
|
178
|
-
- Refactor to deprecate Nan in favor of N-API
|
|
179
|
-
- Drop UBS building system to use standard `node-gyp`
|
|
180
|
-
- Support building on Linux, MacOSX and Windows
|
|
181
|
-
- Ability to build from preinstalled libraries as well as download from XZ website
|
|
182
|
-
- Deprecate Travis CI and AppVeyor to use GitHub Workflows
|
|
183
|
-
|
|
184
|
-
## [1.0.5]
|
|
185
|
-
|
|
186
|
-
### Added
|
|
187
|
-
- Added CI for OSX and Windows
|
|
188
|
-
- Implemented use of node-pre-gyp instead of node-gyp
|
|
189
|
-
|
|
190
|
-
### Fixed
|
|
191
|
-
- Better build script, bug fixing
|
|
192
|
-
|
|
193
|
-
## [1.0.3]
|
|
194
|
-
|
|
195
|
-
### Changed
|
|
196
|
-
- Updated to latest versions of dependencies
|
|
197
|
-
|
|
198
|
-
### Added
|
|
199
|
-
- NodeJS 6.x is now supported
|
|
200
|
-
|
|
201
|
-
## [1.0.2]
|
|
202
|
-
|
|
203
|
-
### Fixed
|
|
204
|
-
- Fixed build.yml to work with new UBS 0.6.1
|
|
205
|
-
|
|
206
|
-
## [1.0.1]
|
|
207
|
-
|
|
208
|
-
### Fixed
|
|
209
|
-
- Fixed minor bugs
|
|
210
|
-
|
|
211
|
-
## [1.0.0]
|
|
212
|
-
|
|
213
|
-
### Changed
|
|
214
|
-
- JS Library has been renamed to `lzma`
|
|
215
|
-
|
|
216
|
-
### Fixed
|
|
217
|
-
- All known bugs have been fixed
|
|
218
|
-
|
|
219
|
-
## [0.5.0]
|
|
220
|
-
|
|
221
|
-
### Changed
|
|
222
|
-
- Rewrote large parts with Nan so now it supports 0.12+, 3+, 4+
|
|
223
|
-
|
|
224
|
-
### Fixed
|
|
225
|
-
- Fixed syntax in XzStream.coffee
|
|
226
|
-
|
|
227
|
-
### Removed
|
|
228
|
-
- Apparently not anymore 0.10 support
|
|
229
|
-
|
|
230
|
-
## [0.4.3]
|
|
231
|
-
|
|
232
|
-
### Changed
|
|
233
|
-
- Changes in build system (now using ubs to compile/run tests)
|
|
234
|
-
|
|
235
|
-
### Fixed
|
|
236
|
-
- Applied a fix for 'availInAfter' in stream callback, after [#6032](https://github.com/joyent/node/issues/6032)
|
|
237
|
-
- Fixed bad variable init in binding module
|
|
238
|
-
|
|
239
|
-
## [0.3.0]
|
|
240
|
-
|
|
241
|
-
### Added
|
|
242
|
-
- Added multithread support
|
|
243
|
-
- ENABLE_MT is now available to compile with thread support
|
|
244
|
-
- Added new test cases
|
|
245
|
-
|
|
246
|
-
## [0.2.0]
|
|
247
|
-
|
|
248
|
-
### Added
|
|
249
|
-
- Full sync support
|
|
250
|
-
- Added new test cases (sync/async)
|
|
251
|
-
|
|
252
|
-
### Changed
|
|
253
|
-
- Completed import of NodeJS Zlib API
|
|
254
|
-
|
|
255
|
-
### Fixed
|
|
256
|
-
- Bug fixes
|
|
257
|
-
|
|
258
|
-
## [0.1.0] - Initial Release
|
|
259
|
-
|
|
260
|
-
### Added
|
|
261
|
-
- Initial version
|
|
262
|
-
- C++ binding support ENCODE/DECODE
|
|
263
|
-
- Async support
|
|
264
|
-
|
|
265
|
-
[Unreleased]: https://github.com/oorabona/node-liblzma/compare/v2.0.3...HEAD
|
|
266
|
-
[v2.0.1]: https://github.com/oorabona/node-liblzma/releases/tag/v2.0.1
|
|
267
|
-
[2.0.1]: https://github.com/oorabona/node-liblzma/releases/tag/v2.0.1
|
|
268
|
-
[v2.0.2]: https://github.com/oorabona/node-liblzma/releases/tag/v2.0.2
|
|
269
|
-
[2.0.2]: https://github.com/oorabona/node-liblzma/releases/tag/v2.0.2
|
|
270
|
-
[v2.0.3]: https://github.com/oorabona/node-liblzma/releases/tag/v2.0.3
|
|
271
|
-
[2.0.3]: https://github.com/oorabona/node-liblzma/releases/tag/v2.0.3
|