node-liblzma 2.0.0 → 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.
Files changed (67) hide show
  1. package/README.md +156 -63
  2. package/binding.gyp +7 -2
  3. package/index.d.ts +26 -3
  4. package/lib/errors.d.ts.map +1 -1
  5. package/lib/errors.js +26 -15
  6. package/lib/errors.js.map +1 -1
  7. package/lib/lzma.d.ts +236 -2
  8. package/lib/lzma.d.ts.map +1 -1
  9. package/lib/lzma.js +225 -39
  10. package/lib/lzma.js.map +1 -1
  11. package/lib/pool.d.ts.map +1 -1
  12. package/lib/pool.js +9 -3
  13. package/lib/pool.js.map +1 -1
  14. package/lib/types.d.ts +68 -1
  15. package/lib/types.d.ts.map +1 -1
  16. package/package.json +34 -17
  17. package/scripts/build_xz_with_cmake.py +23 -26
  18. package/scripts/download_xz_from_github.py +14 -13
  19. package/src/bindings/node-liblzma.cpp +40 -4
  20. package/src/bindings/node-liblzma.hpp +2 -1
  21. package/xz-version.json +3 -3
  22. package/.claude/settings.local.json +0 -92
  23. package/.gitattributes +0 -3
  24. package/.release-it.json +0 -6
  25. package/CHANGELOG.md +0 -209
  26. package/History.md +0 -79
  27. package/RELEASING.md +0 -131
  28. package/biome.json +0 -81
  29. package/coverage/base.css +0 -224
  30. package/coverage/block-navigation.js +0 -87
  31. package/coverage/errors.ts.html +0 -586
  32. package/coverage/favicon.png +0 -0
  33. package/coverage/index.html +0 -146
  34. package/coverage/lcov-report/base.css +0 -224
  35. package/coverage/lcov-report/block-navigation.js +0 -87
  36. package/coverage/lcov-report/errors.ts.html +0 -586
  37. package/coverage/lcov-report/favicon.png +0 -0
  38. package/coverage/lcov-report/index.html +0 -146
  39. package/coverage/lcov-report/lzma.ts.html +0 -2596
  40. package/coverage/lcov-report/pool.ts.html +0 -769
  41. package/coverage/lcov-report/prettify.css +0 -1
  42. package/coverage/lcov-report/prettify.js +0 -2
  43. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  44. package/coverage/lcov-report/sorter.js +0 -210
  45. package/coverage/lcov.info +0 -636
  46. package/coverage/lzma.ts.html +0 -2596
  47. package/coverage/pool.ts.html +0 -769
  48. package/coverage/prettify.css +0 -1
  49. package/coverage/prettify.js +0 -2
  50. package/coverage/sort-arrow-sprite.png +0 -0
  51. package/coverage/sorter.js +0 -210
  52. package/coverage-reports/assets/monocart-coverage-app.js +0 -2
  53. package/coverage-reports/coverage-data.js +0 -1
  54. package/coverage-reports/index.html +0 -48
  55. package/err.log +0 -26
  56. package/pnpm-workspace.yaml +0 -3
  57. package/scripts/analyze-coverage.js +0 -132
  58. package/scripts/compare-coverage-tools.js +0 -93
  59. package/scripts/prebuildify.py +0 -13
  60. package/src/errors.ts +0 -167
  61. package/src/lzma.ts +0 -839
  62. package/src/pool.ts +0 -228
  63. package/src/types.ts +0 -30
  64. package/tsconfig.json +0 -50
  65. package/vitest.config.istanbul.ts +0 -29
  66. package/vitest.config.monocart.ts +0 -44
  67. package/vitest.config.ts +0 -44
package/src/pool.ts DELETED
@@ -1,228 +0,0 @@
1
- /**
2
- * node-liblzma - Node.js bindings for liblzma
3
- * Copyright (C) Olivier Orabona <olivier.orabona@gmail.com>
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU Lesser General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU Lesser General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
-
19
- import { EventEmitter } from 'node:events';
20
- import { type LZMAOptions, unxzAsync, xzAsync } from './lzma.js';
21
-
22
- /**
23
- * Metrics for pool monitoring
24
- */
25
- export interface PoolMetrics {
26
- /** Number of currently active compression/decompression operations */
27
- active: number;
28
- /** Number of operations waiting in the queue */
29
- queued: number;
30
- /** Total number of successfully completed operations */
31
- completed: number;
32
- /** Total number of failed operations */
33
- failed: number;
34
- }
35
-
36
- /**
37
- * Task in the queue
38
- */
39
- interface QueuedTask {
40
- fn: () => Promise<Buffer>;
41
- resolve: (value: Buffer) => void;
42
- reject: (error: Error) => void;
43
- }
44
-
45
- /**
46
- * LZMA Pool with concurrency control and event monitoring
47
- *
48
- * Provides rate limiting and backpressure for LZMA operations.
49
- * Emits events for monitoring and metrics collection in production.
50
- *
51
- * @example
52
- * ```typescript
53
- * const pool = new LZMAPool(10); // Max 10 concurrent operations
54
- *
55
- * pool.on('metrics', (metrics) => {
56
- * console.log(`Active: ${metrics.active}, Queued: ${metrics.queued}`);
57
- * });
58
- *
59
- * const compressed = await pool.compress(buffer);
60
- * ```
61
- *
62
- * Events:
63
- * - 'queue': Emitted when task added to queue
64
- * - 'start': Emitted when task starts processing
65
- * - 'complete': Emitted when task completes successfully
66
- * - 'error-task': Emitted when task fails
67
- * - 'metrics': Emitted after each state change with current metrics
68
- */
69
- export class LZMAPool extends EventEmitter {
70
- private queue: QueuedTask[] = [];
71
-
72
- private metrics: PoolMetrics = {
73
- active: 0,
74
- queued: 0,
75
- completed: 0,
76
- failed: 0,
77
- };
78
-
79
- /**
80
- * Create a new LZMA pool
81
- * @param maxConcurrent Maximum number of concurrent operations (default: 10)
82
- */
83
- constructor(private maxConcurrent = 10) {
84
- super();
85
-
86
- if (maxConcurrent < 1) {
87
- throw new RangeError('maxConcurrent must be at least 1');
88
- }
89
- }
90
-
91
- /**
92
- * Compress data with automatic queue management
93
- * @param data Buffer to compress
94
- * @param opts LZMA compression options
95
- * @returns Promise that resolves to compressed buffer
96
- */
97
- async compress(data: Buffer, opts?: LZMAOptions): Promise<Buffer> {
98
- return this.enqueue(() => xzAsync(data, opts));
99
- }
100
-
101
- /**
102
- * Decompress data with automatic queue management
103
- * @param data Compressed buffer to decompress
104
- * @param opts LZMA decompression options
105
- * @returns Promise that resolves to decompressed buffer
106
- */
107
- async decompress(data: Buffer, opts?: LZMAOptions): Promise<Buffer> {
108
- return this.enqueue(() => unxzAsync(data, opts));
109
- }
110
-
111
- /**
112
- * Get current pool metrics
113
- * @returns Copy of current metrics
114
- */
115
- getMetrics(): Readonly<PoolMetrics> {
116
- return { ...this.metrics };
117
- }
118
-
119
- /**
120
- * Get number of tasks waiting in queue
121
- * @returns Queue length
122
- */
123
- get queueLength(): number {
124
- return this.queue.length;
125
- }
126
-
127
- /**
128
- * Get number of currently active tasks
129
- * @returns Active task count
130
- */
131
- get activeCount(): number {
132
- return this.metrics.active;
133
- }
134
-
135
- /**
136
- * Check if pool is at maximum capacity
137
- * @returns True if at capacity
138
- */
139
- get isAtCapacity(): boolean {
140
- return this.metrics.active >= this.maxConcurrent;
141
- }
142
-
143
- /**
144
- * Enqueue a task for execution
145
- * @param fn Task function returning Promise<Buffer>
146
- * @returns Promise that resolves when task completes
147
- */
148
- private async enqueue(fn: () => Promise<Buffer>): Promise<Buffer> {
149
- return new Promise((resolve, reject) => {
150
- this.queue.push({ fn, resolve, reject });
151
- this.metrics.queued = this.queue.length;
152
- this.emit('queue', { ...this.metrics });
153
- this.processQueue();
154
- });
155
- }
156
-
157
- /**
158
- * Process tasks from queue respecting concurrency limit
159
- */
160
- private processQueue(): void {
161
- // Don't start new tasks if at capacity or queue empty
162
- if (this.metrics.active >= this.maxConcurrent || this.queue.length === 0) {
163
- return;
164
- }
165
-
166
- const item = this.queue.shift();
167
- if (!item) return;
168
-
169
- this.metrics.active++;
170
- this.metrics.queued = this.queue.length;
171
- this.emit('start', { ...this.metrics });
172
-
173
- // Execute task
174
- item
175
- .fn()
176
- .then((result) => {
177
- this.metrics.completed++;
178
- item.resolve(result);
179
- this.emit('complete', { ...this.metrics });
180
- })
181
- .catch((error: Error) => {
182
- this.metrics.failed++;
183
- item.reject(error);
184
- this.emit('error-task', error, { ...this.metrics });
185
- })
186
- .finally(() => {
187
- this.metrics.active--;
188
- this.emit('metrics', { ...this.metrics });
189
-
190
- // Process next task in queue
191
- this.processQueue();
192
- });
193
- }
194
-
195
- /**
196
- * Wait for all active tasks to complete
197
- * Does not process new tasks added while waiting
198
- * @returns Promise that resolves when all active tasks are done
199
- */
200
- async drain(): Promise<void> {
201
- if (this.metrics.active === 0) {
202
- return Promise.resolve();
203
- }
204
-
205
- return new Promise((resolve) => {
206
- const checkDrained = () => {
207
- if (this.metrics.active === 0) {
208
- this.off('metrics', checkDrained);
209
- resolve();
210
- }
211
- };
212
- this.on('metrics', checkDrained);
213
- });
214
- }
215
-
216
- /**
217
- * Clear all pending tasks from the queue
218
- * Active tasks will continue to run
219
- * @returns Number of tasks removed from queue
220
- */
221
- clearQueue(): number {
222
- const cleared = this.queue.length;
223
- this.queue = [];
224
- this.metrics.queued = 0;
225
- this.emit('metrics', { ...this.metrics });
226
- return cleared;
227
- }
228
- }
package/src/types.ts DELETED
@@ -1,30 +0,0 @@
1
- /**
2
- * Shared TypeScript types for node-liblzma
3
- */
4
-
5
- export interface LZMAOptions {
6
- /** Integrity check type */
7
- check?: number;
8
- /** Compression preset level */
9
- preset?: number;
10
- /** Array of filters to use */
11
- filters?: number[];
12
- /** Compression mode */
13
- mode?: number;
14
- /** Number of threads for compression (encoding only) */
15
- threads?: number;
16
- /** Chunk size for processing */
17
- chunkSize?: number;
18
- /** Flush flag to use */
19
- flushFlag?: number;
20
- }
21
-
22
- export type CompressionCallback = (error: Error | null, result?: Buffer) => void;
23
-
24
- // Union types for better type safety and validation
25
- export type LZMAActionType = 0 | 1 | 2 | 3; // RUN | SYNC_FLUSH | FULL_FLUSH | FINISH
26
- export type LZMAStatusType = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11; // All LZMA status codes
27
- export type CheckType = 0 | 1 | 4 | 10; // NONE | CRC32 | CRC64 | SHA256
28
- export type PresetType = 6 | 9; // DEFAULT | EXTREME
29
- export type FilterType = 0x21 | 0x03 | 0x04 | 0x06 | 0x07 | 0x08 | 0x09; // LZMA2 | X86 | POWERPC | IA64 | ARM | ARMTHUMB | SPARC
30
- export type ModeType = 1 | 2; // FAST | NORMAL
package/tsconfig.json DELETED
@@ -1,50 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Language and Environment */
4
- "target": "ES2020",
5
- "lib": ["ES2020", "ES2020.Promise"],
6
- "module": "nodenext",
7
- "moduleResolution": "nodenext",
8
-
9
- /* Output */
10
- "outDir": "./lib",
11
- "rootDir": "./src",
12
- "declaration": true,
13
- "declarationMap": true,
14
- "sourceMap": true,
15
- "removeComments": false,
16
- "importHelpers": false,
17
-
18
- /* Interop Constraints */
19
- "esModuleInterop": true,
20
- "allowSyntheticDefaultImports": true,
21
- "forceConsistentCasingInFileNames": true,
22
-
23
- /* Type Checking */
24
- "strict": true,
25
- "noImplicitAny": true,
26
- "strictNullChecks": true,
27
- "strictFunctionTypes": true,
28
- "strictBindCallApply": true,
29
- "strictPropertyInitialization": true,
30
- "noImplicitReturns": true,
31
- "noFallthroughCasesInSwitch": true,
32
- "noUncheckedIndexedAccess": false,
33
- "noImplicitOverride": true,
34
-
35
- /* Completeness */
36
- "skipLibCheck": true,
37
- "resolveJsonModule": true,
38
-
39
- /* Node.js specific */
40
- "types": ["node", "vitest"],
41
-
42
- /* Emit */
43
- "noEmitOnError": true
44
- },
45
- "include": ["src/**/*"],
46
- "exclude": ["node_modules", "lib", "build", "test", "**/*.coffee", "**/*.d.ts"],
47
- "ts-node": {
48
- "esm": true
49
- }
50
- }
@@ -1,29 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- // Include TypeScript and JavaScript test files, but exclude utils files
6
- include: ['test/**/*.{ts,js,tsx,jsx}'],
7
- exclude: ['test/**/*.utils.{ts,js}'],
8
-
9
- // Timeout for tests (similar to Mocha config)
10
- testTimeout: 5000,
11
-
12
- // Coverage configuration with Istanbul
13
- coverage: {
14
- provider: 'istanbul',
15
- reporter: ['text', 'json', 'html'],
16
- include: ['src/**/*.{ts,js}', 'lib/**/*.js'],
17
- exclude: ['test/**/*', 'node_modules/**/*', '**/*.d.ts'],
18
- reportsDirectory: './coverage-istanbul',
19
- },
20
-
21
- // Allow tests to run in Node environment
22
- environment: 'node',
23
-
24
- // TypeScript support
25
- typecheck: {
26
- enabled: true,
27
- },
28
- },
29
- });
@@ -1,44 +0,0 @@
1
- import { withMonocartProvider } from '@oorabona/vitest-monocart-coverage';
2
- import { defineConfig } from 'vitest/config';
3
-
4
- export default withMonocartProvider(
5
- defineConfig({
6
- test: {
7
- // Include TypeScript and JavaScript test files, but exclude utils files
8
- include: ['test/**/*.{ts,js,tsx,jsx}'],
9
- exclude: ['test/**/*.utils.{ts,js}'],
10
-
11
- // Timeout for tests (similar to Mocha config)
12
- testTimeout: 5000,
13
-
14
- // Coverage configuration with Monocart
15
- coverage: {
16
- enabled: true,
17
- reporter: ['console-details', 'json', 'html', 'lcov'],
18
- include: ['src/**/*.{ts,js}'],
19
- exclude: ['test/**/*', 'node_modules/**/*', '**/*.d.ts', 'lib/**/*.js'],
20
- // Configurations V8 pour précision maximale
21
- cleanOnRerun: true,
22
- all: false, // N'inclut que les fichiers qui sont réellement chargés
23
- skipFull: true, // Plus rapide et plus précis
24
- // Nouvelle option Vitest 3.2+ pour améliorer la précision
25
- experimentalAstAwareRemapping: true,
26
- ignoreEmptyLines: true,
27
-
28
- // Options Monocart spécifiques
29
- clean: true,
30
- },
31
-
32
- // Allow tests to run in Node environment
33
- environment: 'node',
34
-
35
- // TypeScript support
36
- typecheck: {
37
- enabled: true,
38
- },
39
- },
40
- }),
41
- {
42
- reports: ['html', 'console-details', 'lcov'],
43
- }
44
- );
package/vitest.config.ts DELETED
@@ -1,44 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- // Include TypeScript and JavaScript test files, but exclude utils files
6
- include: ['test/**/*.{ts,js,tsx,jsx}'],
7
- exclude: ['test/**/*.utils.{ts,js}'],
8
-
9
- // Timeout for tests (similar to Mocha config)
10
- testTimeout: 5000,
11
-
12
- // Use forks instead of threads on macOS to avoid IPC channel issues
13
- pool: process.platform === 'darwin' ? 'forks' : 'threads',
14
- poolOptions: {
15
- forks: {
16
- singleFork: true,
17
- },
18
- },
19
-
20
- // Coverage configuration - V8 optimisé pour précision max
21
- coverage: {
22
- provider: 'v8',
23
- reporter: ['text', 'json', 'html', 'lcov'],
24
- include: ['src/**/*.{ts,js}'],
25
- exclude: ['test/**/*', 'node_modules/**/*', '**/*.d.ts', 'lib/**/*.js'],
26
- // Configurations V8 pour précision maximale
27
- cleanOnRerun: true,
28
- all: false, // N'inclut que les fichiers qui sont réellement chargés
29
- skipFull: true, // Plus rapide et plus précis
30
- // Nouvelle option Vitest 3.2+ pour améliorer la précision
31
- experimentalAstAwareRemapping: true,
32
- ignoreEmptyLines: true,
33
- // Pas de thresholds pour l'instant - focus sur la précision
34
- },
35
-
36
- // Allow tests to run in Node environment
37
- environment: 'node',
38
-
39
- // TypeScript support
40
- typecheck: {
41
- enabled: true,
42
- },
43
- },
44
- });