node-liblzma 1.1.9 → 2.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 (76) hide show
  1. package/.claude/settings.local.json +92 -0
  2. package/.gitattributes +3 -0
  3. package/.release-it.json +6 -0
  4. package/CHANGELOG.md +209 -0
  5. package/History.md +20 -0
  6. package/README.md +750 -30
  7. package/RELEASING.md +131 -0
  8. package/binding.gyp +159 -438
  9. package/biome.json +81 -0
  10. package/coverage/base.css +224 -0
  11. package/coverage/block-navigation.js +87 -0
  12. package/coverage/errors.ts.html +586 -0
  13. package/coverage/favicon.png +0 -0
  14. package/coverage/index.html +146 -0
  15. package/coverage/lcov-report/base.css +224 -0
  16. package/coverage/lcov-report/block-navigation.js +87 -0
  17. package/coverage/lcov-report/errors.ts.html +586 -0
  18. package/coverage/lcov-report/favicon.png +0 -0
  19. package/coverage/lcov-report/index.html +146 -0
  20. package/coverage/lcov-report/lzma.ts.html +2596 -0
  21. package/coverage/lcov-report/pool.ts.html +769 -0
  22. package/coverage/lcov-report/prettify.css +1 -0
  23. package/coverage/lcov-report/prettify.js +2 -0
  24. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  25. package/coverage/lcov-report/sorter.js +210 -0
  26. package/coverage/lcov.info +636 -0
  27. package/coverage/lzma.ts.html +2596 -0
  28. package/coverage/pool.ts.html +769 -0
  29. package/coverage/prettify.css +1 -0
  30. package/coverage/prettify.js +2 -0
  31. package/coverage/sort-arrow-sprite.png +0 -0
  32. package/coverage/sorter.js +210 -0
  33. package/coverage-reports/assets/monocart-coverage-app.js +2 -0
  34. package/coverage-reports/coverage-data.js +1 -0
  35. package/coverage-reports/index.html +48 -0
  36. package/err.log +26 -0
  37. package/index.d.ts +254 -0
  38. package/lib/errors.d.ts +72 -0
  39. package/lib/errors.d.ts.map +1 -0
  40. package/lib/errors.js +153 -0
  41. package/lib/errors.js.map +1 -0
  42. package/lib/lzma.d.ts +245 -0
  43. package/lib/lzma.d.ts.map +1 -0
  44. package/lib/lzma.js +626 -345
  45. package/lib/lzma.js.map +1 -0
  46. package/lib/pool.d.ts +123 -0
  47. package/lib/pool.d.ts.map +1 -0
  48. package/lib/pool.js +188 -0
  49. package/lib/pool.js.map +1 -0
  50. package/lib/types.d.ts +27 -0
  51. package/lib/types.d.ts.map +1 -0
  52. package/lib/types.js +5 -0
  53. package/lib/types.js.map +1 -0
  54. package/package.json +60 -21
  55. package/pnpm-workspace.yaml +3 -0
  56. package/scripts/analyze-coverage.js +132 -0
  57. package/scripts/build_xz_with_cmake.py +390 -0
  58. package/scripts/compare-coverage-tools.js +93 -0
  59. package/scripts/copy_dll.py +51 -0
  60. package/scripts/download_xz_from_github.py +375 -0
  61. package/src/bindings/node-liblzma.cpp +411 -229
  62. package/src/bindings/node-liblzma.hpp +101 -48
  63. package/src/errors.ts +167 -0
  64. package/src/lzma.ts +839 -0
  65. package/src/pool.ts +228 -0
  66. package/src/types.ts +30 -0
  67. package/tsconfig.json +50 -0
  68. package/vitest.config.istanbul.ts +29 -0
  69. package/vitest.config.monocart.ts +44 -0
  70. package/vitest.config.ts +44 -0
  71. package/xz-version.json +8 -0
  72. package/prebuilds/darwin-x64/node.napi.node +0 -0
  73. package/prebuilds/linux-x64/node.napi.node +0 -0
  74. package/prebuilds/win32-x64/node.napi.node +0 -0
  75. package/scripts/download_extract_deps.py +0 -29
  76. package/src/lzma.coffee +0 -344
@@ -0,0 +1,92 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(node:*)",
5
+ "WebSearch",
6
+ "Bash(npm run build:*)",
7
+ "Bash(pnpm install:*)",
8
+ "Bash(pnpm run:*)",
9
+ "Bash(pnpm add:*)",
10
+ "Bash(pnpm test:*)",
11
+ "Bash(xz:*)",
12
+ "Bash(pnpm exec:*)",
13
+ "Bash(pnpm lint:*)",
14
+ "Bash(pnpm check:write:*)",
15
+ "Bash(pnpm build:*)",
16
+ "Bash(pnpm type-check:*)",
17
+ "Bash(pnpm check:*)",
18
+ "Bash(pnpm format:write:*)",
19
+ "Bash(pnpm tsc:*)",
20
+ "Bash(sed:*)",
21
+ "Bash(grep:*)",
22
+ "WebFetch(domain:github.com)",
23
+ "Bash(git rm:*)",
24
+ "Bash(git add:*)",
25
+ "WebFetch(domain:api.github.com)",
26
+ "Bash(python3:*)",
27
+ "Bash(chmod:*)",
28
+ "WebFetch(domain:raw.githubusercontent.com)",
29
+ "Bash(cmake:*)",
30
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=yes pnpm install)",
31
+ "Bash(gh act:*)",
32
+ "Bash(npx node-gyp:*)",
33
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=no pnpm install --frozen-lockfile)",
34
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=yes pnpm install --frozen-lockfile)",
35
+ "mcp__github__get_job_logs",
36
+ "Bash(XZ_VERSION=v5.4.0 python3 scripts/download_xz_from_github.py /tmp/test_xz.tar.gz /tmp/test_extract --verbose)",
37
+ "Bash(RUNTIME_LINK=shared node -p \"process.env.RUNTIME_LINK || ''static''\")",
38
+ "Bash(RUNTIME_LINK=shared rm -rf build/Release deps)",
39
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=shared rm -rf build/Release deps prebuilds)",
40
+ "Bash(pnpm rebuild:*)",
41
+ "Bash(RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=yes python3 scripts/build_xz_with_cmake.py --help)",
42
+ "Bash(gh run view:*)",
43
+ "Bash(RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=yes python3 scripts/build_xz_with_cmake.py deps/xz build/liblzma_test --verbose)",
44
+ "Bash(USE_GLOBAL=true pnpm test)",
45
+ "Bash(RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=no USE_GLOBAL=false pnpm run build)",
46
+ "Bash(RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=yes USE_GLOBAL=false python3 scripts/build_xz_with_cmake.py /tmp/test_cmake /tmp/test_install --verbose)",
47
+ "Bash(npx tsc:*)",
48
+ "Bash(yamllint:*)",
49
+ "Bash(./test-ci-logic.sh:*)",
50
+ "Bash(find:*)",
51
+ "Read(/tmp/**)",
52
+ "Read(/tmp/**)",
53
+ "Read(/tmp/**)",
54
+ "Read(/tmp/**)",
55
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=yes pnpm install --frozen-lockfile)",
56
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=yes rm -rf build/Release deps)",
57
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=yes rm -rf build/Release)",
58
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=no rm -rf build/Release)",
59
+ "Bash(USE_GLOBAL=false RUNTIME_LINK=static ENABLE_THREAD_SUPPORT=no pnpm rebuild)",
60
+ "WebFetch(domain:www.npmjs.com)",
61
+ "Bash(xargs ls:*)",
62
+ "Bash(pnpm vitest run:*)",
63
+ "Bash(pnpm outdated:*)",
64
+ "Bash(pnpm audit:*)",
65
+ "Bash(pnpm test:coverage:*)",
66
+ "Bash(cat:*)",
67
+ "mcp__github__get_workflow_run",
68
+ "mcp__github__list_workflow_runs",
69
+ "mcp__github__list_workflows",
70
+ "Bash(gh run list:*)",
71
+ "Bash(node-gyp rebuild:*)",
72
+ "Bash(USE_GLOBAL=true RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=yes pnpm rebuild)",
73
+ "Bash(export USE_GLOBAL=true RUNTIME_LINK=shared ENABLE_THREAD_SUPPORT=yes)",
74
+ "Bash(npm:*)",
75
+ "Bash(pnpm list:*)",
76
+ "Read(//home/o2/.cache/node-gyp/22.15.0/include/node/**)",
77
+ "Bash(pkg-config:*)",
78
+ "Bash(g++:*)",
79
+ "Read(//home/o2/.cache/node-gyp/22.15.0/**)",
80
+ "Read(//tmp/**)",
81
+ "mcp__github__list_workflow_jobs",
82
+ "Bash(otool:*)",
83
+ "Bash(git log:*)",
84
+ "mcp__github__get_me",
85
+ "mcp__github__list_tags",
86
+ "mcp__github__get_commit",
87
+ "mcp__github__get_file_contents"
88
+ ],
89
+ "deny": [],
90
+ "ask": []
91
+ }
92
+ }
package/.gitattributes ADDED
@@ -0,0 +1,3 @@
1
+ * text=auto eol=lf
2
+ *.{cmd,[cC][mM][dD]} text eol=crlf
3
+ *.{bat,[bB][aA][tT]} text eol=crlf
@@ -0,0 +1,6 @@
1
+ {
2
+ "git": {
3
+ "requireBranch": "master",
4
+ "requireCleanWorkingDir": true
5
+ }
6
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,209 @@
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
+ ### Added
11
+ - **TypeScript Support**: Complete migration from CoffeeScript to TypeScript for better type safety and developer experience
12
+ - **Promise APIs**: New async functions `xzAsync()` and `unxzAsync()` with Promise support
13
+ - **Typed Error Classes**: 8 specialized error classes (`LZMAMemoryError`, `LZMADataError`, `LZMAFormatError`, etc.) with factory pattern for precise error handling
14
+ - **Concurrency Control**: `LZMAPool` class with EventEmitter-based monitoring for production environments
15
+ - Automatic backpressure and queue management
16
+ - Configurable concurrency limits
17
+ - Real-time metrics (`active`, `queued`, `completed`, `failed`)
18
+ - Events: `queue`, `start`, `complete`, `error-task`, `metrics`
19
+ - **File Helpers**: Simplified `xzFile()` and `unxzFile()` functions for file-based compression
20
+ - **Modern Testing**: Migrated from Mocha to Vitest with improved performance and TypeScript integration
21
+ - **100% Code Coverage**: Comprehensive test suite (320+ tests) covering all statements, branches, functions, and lines
22
+ - **Enhanced Tooling**:
23
+ - [Biome](https://biomejs.dev/) for fast linting and formatting
24
+ - Pre-commit hooks with nano-staged and simple-git-hooks
25
+ - pnpm as package manager for better dependency management
26
+ - **Security**:
27
+ - Fixed FunctionReference memory leak using smart pointers with custom deleter
28
+ - Added 512MB buffer size validation to prevent DoS attacks
29
+ - CodeQL workflow for continuous security scanning
30
+ - Dependabot configuration for automated dependency updates
31
+ - Enhanced tarball extraction with path validation and safety checks against path traversal
32
+ - **Thread Support**: Multi-threaded compression with configurable thread count
33
+ - **Automatic Filter Reordering**: LZMA2 filter automatically moved to end as required by liblzma
34
+ - **Factory Functions**: `createXz()` and `createUnxz()` to avoid circular dependencies in ESM
35
+ - **XZ Version Management**: Automated version tracking and update workflows for XZ Utils
36
+ - **CI/CD Enhancements**:
37
+ - Unified CI pipeline with smart smoke/full test detection
38
+ - Conditional test execution based on PR vs push vs schedule
39
+ - Composite GitHub Actions for dependency installation and environment setup
40
+ - XZ source caching with GitHub token support
41
+ - Upgraded to setup-node v5 across all workflows
42
+ - GITHUB_TOKEN environment variable for authenticated downloads
43
+ - **.gitattributes**: Line ending normalization for cross-platform consistency
44
+
45
+ ### Changed
46
+ - **Breaking**: Requires Node.js >= 16 (updated from >= 12)
47
+ - **Breaking**: Module is now ESM-only (`"type": "module"`)
48
+ - **Build System**: Modernized to use CMake for XZ Utils compilation
49
+ - Environment variable configuration for runtime linking (`RUNTIME_LINK=static|shared`)
50
+ - Threading support configuration (`ENABLE_THREAD_SUPPORT=yes|no`)
51
+ - Global liblzma usage option (`USE_GLOBAL=true|false`)
52
+ - Disabled CLI tools to avoid libintl dependency on macOS
53
+ - **XZ Utils**: Updated from 5.6.3 to 5.8.1 with complete CMake support
54
+ - **macOS Support**: Enhanced dylib handling with proper RPATH configuration
55
+ - Smart install_name verification and fixing for shared libraries
56
+ - Proper linker flags via xcode_settings
57
+ - Only applies install_name fixes to shared library builds
58
+ - **Windows Support**: Improved threading and DLL handling
59
+ - Thread support now works with both static and shared builds
60
+ - Fixed kernel32.lib linking for MSVC
61
+ - Automated library name fixing for binding.gyp compatibility
62
+ - Python-based DLL copying for better reliability
63
+ - **Vitest Configuration**: Fork-based worker pool on macOS to avoid IPC channel errors
64
+ - **CI Workflows**:
65
+ - Consolidated from 5 workflows to 1 unified pipeline
66
+ - Smoke tests and full tests are now mutually exclusive
67
+ - Proper handling of skipped job states in CI summary
68
+ - Enhanced caching strategy and matrix testing
69
+ - Path filters to avoid unnecessary runs
70
+ - **Code Quality**: Simplified instance data management and improved buffer handling
71
+ - Standardized error messages (removed "BUG?" prefixes) for production-ready error handling
72
+ - Improved async callback handling and error management
73
+ - Enhanced TypeScript configuration for better test reliability
74
+
75
+ ### Fixed
76
+ - **macOS Build Issues**:
77
+ - Fixed dylib loading errors (`Library not loaded: @rpath/liblzma.5.dylib`)
78
+ - Resolved libintl dependency issues by disabling XZ CLI tools
79
+ - Fixed RPATH configuration in binding.gyp and CMake
80
+ - Corrected install_name verification for shared vs static builds
81
+ - **Windows Build Issues**:
82
+ - Fixed NAPI_VERSION redefinition error
83
+ - Resolved DLL loading for shared library builds
84
+ - Fixed threading support configuration
85
+ - Corrected Windows library naming for compatibility
86
+ - **CI/CD Issues**:
87
+ - Fixed pipeline failure when smoke test is skipped
88
+ - Fixed conditional check for global liblzma usage
89
+ - Removed unnecessary shell specifications
90
+ - Fixed caching strategy and matrix configuration
91
+ - **Test Issues**:
92
+ - Skip negative threads test if threading not supported
93
+ - Fixed TypeScript error handling in tests
94
+ - **Code Issues**:
95
+ - Resolved C++ exception handling with `NAPI_DISABLE_CPP_EXCEPTIONS`
96
+ - Corrected memory management in async operations (Ref/Unref balance)
97
+ - Fixed filter validation bug causing `LZMA_OPTIONS_ERROR` with multiple filters
98
+ - Fixed memory leak in FunctionReference lifecycle management
99
+ - Fixed memory leaks and race conditions in C++ bindings
100
+ - Fixed filters array mutation by cloning in LZMAOptions
101
+ - Fixed XzStream destructuring for clarity
102
+ - Fixed LZMA2 filter ordering to ensure it's always last
103
+ - **General**:
104
+ - Fixed download script symbolic link safety checks
105
+ - Added `*.log` to .gitignore
106
+ - Fixed tsconfig formatting
107
+ - Improved code formatting consistency
108
+
109
+ ## [1.1.9] - Previous Release
110
+
111
+ ### Fixed
112
+ - Fix building if no prebuilt binary found
113
+
114
+ ## [1.1.7]
115
+
116
+ ### Fixed
117
+ - Fix build system
118
+ - Fix release system
119
+ - Fix documentation
120
+
121
+ ## [1.1.0]
122
+
123
+ ### Changed
124
+ - Refactor to deprecate Nan in favor of N-API
125
+ - Drop UBS building system to use standard `node-gyp`
126
+ - Support building on Linux, MacOSX and Windows
127
+ - Ability to build from preinstalled libraries as well as download from XZ website
128
+ - Deprecate Travis CI and AppVeyor to use GitHub Workflows
129
+
130
+ ## [1.0.5]
131
+
132
+ ### Added
133
+ - Added CI for OSX and Windows
134
+ - Implemented use of node-pre-gyp instead of node-gyp
135
+
136
+ ### Fixed
137
+ - Better build script, bug fixing
138
+
139
+ ## [1.0.3]
140
+
141
+ ### Changed
142
+ - Updated to latest versions of dependencies
143
+
144
+ ### Added
145
+ - NodeJS 6.x is now supported
146
+
147
+ ## [1.0.2]
148
+
149
+ ### Fixed
150
+ - Fixed build.yml to work with new UBS 0.6.1
151
+
152
+ ## [1.0.1]
153
+
154
+ ### Fixed
155
+ - Fixed minor bugs
156
+
157
+ ## [1.0.0]
158
+
159
+ ### Changed
160
+ - JS Library has been renamed to `lzma`
161
+
162
+ ### Fixed
163
+ - All known bugs have been fixed
164
+
165
+ ## [0.5.0]
166
+
167
+ ### Changed
168
+ - Rewrote large parts with Nan so now it supports 0.12+, 3+, 4+
169
+
170
+ ### Fixed
171
+ - Fixed syntax in XzStream.coffee
172
+
173
+ ### Removed
174
+ - Apparently not anymore 0.10 support
175
+
176
+ ## [0.4.3]
177
+
178
+ ### Changed
179
+ - Changes in build system (now using ubs to compile/run tests)
180
+
181
+ ### Fixed
182
+ - Applied a fix for 'availInAfter' in stream callback, after [#6032](https://github.com/joyent/node/issues/6032)
183
+ - Fixed bad variable init in binding module
184
+
185
+ ## [0.3.0]
186
+
187
+ ### Added
188
+ - Added multithread support
189
+ - ENABLE_MT is now available to compile with thread support
190
+ - Added new test cases
191
+
192
+ ## [0.2.0]
193
+
194
+ ### Added
195
+ - Full sync support
196
+ - Added new test cases (sync/async)
197
+
198
+ ### Changed
199
+ - Completed import of NodeJS Zlib API
200
+
201
+ ### Fixed
202
+ - Bug fixes
203
+
204
+ ## [0.1.0] - Initial Release
205
+
206
+ ### Added
207
+ - Initial version
208
+ - C++ binding support ENCODE/DECODE
209
+ - Async support
package/History.md CHANGED
@@ -1,3 +1,23 @@
1
+ # History.md
2
+
3
+ > **Note**: This file is deprecated. Please see [CHANGELOG.md](./CHANGELOG.md) for the current changelog following the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) format.
4
+
5
+ # 2.0.0
6
+ * **Breaking**: Modernized testing framework from Mocha to Vitest
7
+ * **Breaking**: Modernized stack from Coffeescript to Typescript
8
+ * **Feature**: Added 100% code coverage (51 tests covering all statements, branches, functions, and lines)
9
+ * **Feature**: Implemented automatic filter reordering (LZMA2 filter automatically moved to end as required by liblzma)
10
+ * **Fix**: Resolved C++ exception handling issues with NAPI_DISABLE_CPP_EXCEPTIONS for better performance
11
+ * **Fix**: Corrected memory management in async operations (Ref/Unref balance)
12
+ * **Fix**: Fixed filter validation bug causing LZMA_OPTIONS_ERROR with multiple filters
13
+ * **CI**: Consolidated GitHub Actions workflows from 5 separate workflows to 1 unified pipeline
14
+ * **CI**: Enhanced caching strategy and matrix testing with conditional execution
15
+ * **CI**: Added path filters to avoid unnecessary CI runs for documentation-only changes
16
+ * **CI**: Optimized XZ source downloading with single download shared across all jobs
17
+ * **Performance**: Improved async callback handling and error management
18
+ * **Testing**: Added comprehensive edge case coverage including malformed inputs and threading tests
19
+ * **Testing**: Enhanced TypeScript configuration for better test reliability
20
+
1
21
  # 1.1.9
2
22
  * Fix building if no prebuilt binary found
3
23