node-liblzma 2.0.3 → 2.2.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 (46) hide show
  1. package/README.md +263 -67
  2. package/index.d.ts +60 -3
  3. package/lib/cli/nxz.d.ts +7 -0
  4. package/lib/cli/nxz.d.ts.map +1 -0
  5. package/lib/cli/nxz.js +486 -0
  6. package/lib/cli/nxz.js.map +1 -0
  7. package/lib/errors.d.ts.map +1 -1
  8. package/lib/errors.js +26 -15
  9. package/lib/errors.js.map +1 -1
  10. package/lib/lzma.d.ts +319 -2
  11. package/lib/lzma.d.ts.map +1 -1
  12. package/lib/lzma.js +303 -39
  13. package/lib/lzma.js.map +1 -1
  14. package/lib/pool.d.ts.map +1 -1
  15. package/lib/pool.js +9 -3
  16. package/lib/pool.js.map +1 -1
  17. package/lib/types.d.ts +68 -1
  18. package/lib/types.d.ts.map +1 -1
  19. package/package.json +32 -12
  20. package/scripts/build_xz_with_cmake.py +23 -26
  21. package/src/bindings/module.cpp +196 -0
  22. package/src/bindings/node-liblzma.cpp +40 -4
  23. package/src/bindings/node-liblzma.hpp +2 -1
  24. package/xz-version.json +3 -3
  25. package/.gitattributes +0 -3
  26. package/.release-it.json +0 -7
  27. package/.release-it.manual.json +0 -7
  28. package/.release-it.retry.json +0 -3
  29. package/CHANGELOG.md +0 -271
  30. package/History.md +0 -79
  31. package/RELEASING.md +0 -131
  32. package/biome.json +0 -81
  33. package/pnpm-workspace.yaml +0 -3
  34. package/prebuilds/darwin-x64/node-liblzma.node +0 -0
  35. package/prebuilds/linux-x64/node-liblzma.node +0 -0
  36. package/prebuilds/win32-x64/node-liblzma.node +0 -0
  37. package/scripts/analyze-coverage.js +0 -132
  38. package/scripts/compare-coverage-tools.js +0 -93
  39. package/src/errors.ts +0 -167
  40. package/src/lzma.ts +0 -839
  41. package/src/pool.ts +0 -228
  42. package/src/types.ts +0 -30
  43. package/tsconfig.json +0 -50
  44. package/vitest.config.istanbul.ts +0 -29
  45. package/vitest.config.monocart.ts +0 -44
  46. package/vitest.config.ts +0 -52
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'fs';
4
- import path from 'path';
5
-
6
- const COVERAGE_FILE = './coverage/coverage-final.json';
7
- const SOURCE_FILE = './src/lzma.ts';
8
-
9
- if (!fs.existsSync(COVERAGE_FILE)) {
10
- console.log("❌ Fichier de coverage non trouvé. Lancez `pnpm test -- --coverage` d'abord.");
11
- process.exit(1);
12
- }
13
-
14
- const coverage = JSON.parse(fs.readFileSync(COVERAGE_FILE, 'utf8'));
15
- const sourceLines = fs.readFileSync(SOURCE_FILE, 'utf8').split('\n');
16
-
17
- // Analyser le fichier principal
18
- const filePath = path.resolve(SOURCE_FILE);
19
- const data = coverage[filePath] || coverage[Object.keys(coverage)[0]];
20
-
21
- if (!data) {
22
- console.log('❌ Données de coverage non trouvées');
23
- process.exit(1);
24
- }
25
-
26
- console.log('🔍 ANALYSE DE PRÉCISION DU COVERAGE\n');
27
-
28
- // Fonctions non couvertes
29
- const uncoveredFunctions = Object.entries(data.f).filter(([, count]) => count === 0);
30
- console.log(`📊 FONCTIONS NON COUVERTES (${uncoveredFunctions.length}):`);
31
- uncoveredFunctions.forEach(([key, count]) => {
32
- const fn = data.fnMap[key];
33
- const startLine = fn.loc.start.line;
34
- const endLine = fn.loc.end.line;
35
-
36
- console.log(` Function ${key}: "${fn.name}" (lignes ${startLine}-${endLine})`);
37
- console.log(` Code: ${sourceLines[startLine - 1]?.trim() || 'N/A'}`);
38
-
39
- // Vérifier si c'est un artefact
40
- const isArtifact =
41
- sourceLines[startLine - 1]?.includes('/* v8 ignore') ||
42
- sourceLines[startLine - 1]?.includes('export const') ||
43
- fn.name.includes('anonymous');
44
-
45
- if (isArtifact) {
46
- console.log(` ⚠️ Probablement un artefact V8`);
47
- } else {
48
- console.log(` 🎯 VRAIE fonction non testée`);
49
- }
50
- console.log('');
51
- });
52
-
53
- // Statements non couverts
54
- const uncoveredStatements = Object.entries(data.s).filter(([, count]) => count === 0);
55
- console.log(`📊 STATEMENTS NON COUVERTS (${uncoveredStatements.length}):`);
56
- uncoveredStatements.slice(0, 10).forEach(([key, count]) => {
57
- const stmt = data.statementMap[key];
58
- const line = stmt.start.line;
59
-
60
- console.log(` Statement ${key}: ligne ${line}`);
61
- console.log(` Code: ${sourceLines[line - 1]?.trim() || 'N/A'}`);
62
-
63
- // Vérifier si c'est vraiment du code exécutable
64
- const codeLine = sourceLines[line - 1]?.trim() || '';
65
- const isIgnorable =
66
- codeLine.includes('/* v8 ignore') ||
67
- codeLine === '' ||
68
- codeLine.includes('//') ||
69
- codeLine === '}' ||
70
- codeLine === '{' ||
71
- codeLine.includes('export const');
72
-
73
- if (isIgnorable) {
74
- console.log(` ⚠️ Ligne probablement ignorable`);
75
- } else {
76
- console.log(` 🎯 VRAI code non testé`);
77
- }
78
- console.log('');
79
- });
80
-
81
- // Branches critiques non couvertes
82
- const uncoveredBranches = Object.entries(data.b)
83
- .filter(([, counts]) => counts.includes(0))
84
- .filter(([key]) => {
85
- const branch = data.branchMap[key];
86
- const line = sourceLines[branch.line - 1]?.trim() || '';
87
- return !line.includes('/* v8 ignore') && line.length > 0;
88
- });
89
-
90
- console.log(`📊 BRANCHES CRITIQUES NON COUVERTES (${uncoveredBranches.length}):`);
91
- uncoveredBranches.slice(0, 10).forEach(([key, counts]) => {
92
- const branch = data.branchMap[key];
93
- const line = branch.line;
94
-
95
- console.log(` Branch ${key}: ligne ${line} - ${counts}`);
96
- console.log(` Code: ${sourceLines[line - 1]?.trim() || 'N/A'}`);
97
- console.log(` Type: ${branch.type}`);
98
- console.log(` 🎯 VRAIE condition non testée`);
99
- console.log('');
100
- });
101
-
102
- console.log('💡 RÉSUMÉ:');
103
- console.log(
104
- ` - Fonctions vraiment non testées: ${
105
- uncoveredFunctions.filter(([key]) => {
106
- const fn = data.fnMap[key];
107
- return (
108
- !fn.name.includes('anonymous') &&
109
- !sourceLines[fn.loc.start.line - 1]?.includes('export const')
110
- );
111
- }).length
112
- }`
113
- );
114
-
115
- console.log(
116
- ` - Statements vraiment non testés: ${
117
- uncoveredStatements.filter(([key]) => {
118
- const stmt = data.statementMap[key];
119
- const codeLine = sourceLines[stmt.start.line - 1]?.trim() || '';
120
- return (
121
- !codeLine.includes('/* v8 ignore') &&
122
- codeLine !== '' &&
123
- !codeLine.includes('//') &&
124
- codeLine !== '}' &&
125
- codeLine !== '{' &&
126
- !codeLine.includes('export const')
127
- );
128
- }).length
129
- }`
130
- );
131
-
132
- console.log(` - Branches vraiment non testées: ${uncoveredBranches.length}`);
@@ -1,93 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from 'fs';
4
- import path from 'path';
5
-
6
- const V8_COVERAGE = './coverage/coverage-final.json';
7
- const MONOCART_DATA = './coverage-reports/coverage-data.js';
8
- const SOURCE_FILE = './src/lzma.ts';
9
-
10
- console.log('🔍 COMPARAISON V8 vs MONOCART\n');
11
-
12
- // Lire V8
13
- if (!fs.existsSync(V8_COVERAGE)) {
14
- console.log('❌ V8 coverage manquant');
15
- process.exit(1);
16
- }
17
- const v8Coverage = JSON.parse(fs.readFileSync(V8_COVERAGE, 'utf8'));
18
- const sourceLines = fs.readFileSync(SOURCE_FILE, 'utf8').split('\n');
19
- const filePath = path.resolve(SOURCE_FILE);
20
- const v8Data = v8Coverage[filePath] || v8Coverage[Object.keys(v8Coverage)[0]];
21
-
22
- // Lire Monocart
23
- if (!fs.existsSync(MONOCART_DATA)) {
24
- console.log('❌ Monocart data manquant');
25
- process.exit(1);
26
- }
27
-
28
- // Extraire les données Monocart du fichier JS
29
- const monocartContent = fs.readFileSync(MONOCART_DATA, 'utf8');
30
- const monocartMatch = monocartContent.match(/window\.reportData\s*=\s*'([^']+)'/);
31
- if (!monocartMatch) {
32
- console.log('❌ Format Monocart non reconnu');
33
- process.exit(1);
34
- }
35
-
36
- // Monocart utilise un format compressé, on doit le décoder
37
- console.log('⚠️ Monocart utilise un format de données compressé, analyse simplifiée...');
38
- const monocartData = { summary: null };
39
- const summaryData = monocartData.summary;
40
-
41
- console.log('📊 COMPARAISON GLOBALE:');
42
- console.log(
43
- `V8 : ${v8Data.s ? Object.values(v8Data.s).filter((x) => x > 0).length : 0} statements couverts / ${v8Data.s ? Object.keys(v8Data.s).length : 0} total`
44
- );
45
- console.log(
46
- `Monocart : ${summaryData.statements.covered} statements couverts / ${summaryData.statements.total} total`
47
- );
48
- console.log('');
49
-
50
- console.log(
51
- `V8 : ${v8Data.b ? Object.values(v8Data.b).filter((arr) => arr.every((x) => x > 0)).length : 0} branches couvertes / ${v8Data.b ? Object.keys(v8Data.b).length : 0} total`
52
- );
53
- console.log(
54
- `Monocart : ${summaryData.branches.covered} branches couvertes / ${summaryData.branches.total} total`
55
- );
56
- console.log('');
57
-
58
- console.log(
59
- `V8 : ${v8Data.f ? Object.values(v8Data.f).filter((x) => x > 0).length : 0} fonctions couvertes / ${v8Data.f ? Object.keys(v8Data.f).length : 0} total`
60
- );
61
- console.log(
62
- `Monocart : ${summaryData.functions.covered} fonctions couvertes / ${summaryData.functions.total} total`
63
- );
64
- console.log('');
65
-
66
- // Analyse des statements non couverts
67
- const v8UncoveredStmts = Object.entries(v8Data.s || {}).filter(([, count]) => count === 0);
68
- console.log(`🎯 V8 STATEMENTS NON COUVERTS: ${v8UncoveredStmts.length}`);
69
- v8UncoveredStmts.slice(0, 5).forEach(([key]) => {
70
- const stmt = v8Data.statementMap[key];
71
- const line = stmt.start.line;
72
- console.log(` Ligne ${line}: ${sourceLines[line - 1]?.trim() || 'N/A'}`);
73
- });
74
-
75
- console.log('\n💡 VERDICT:');
76
- if (summaryData.statements.total !== Object.keys(v8Data.s || {}).length) {
77
- console.log('⚠️ Monocart détecte un nombre différent de statements');
78
- }
79
-
80
- const v8Pct = (
81
- (Object.values(v8Data.s || {}).filter((x) => x > 0).length / Object.keys(v8Data.s || {}).length) *
82
- 100
83
- ).toFixed(2);
84
- const monocartPct = summaryData.statements.pct;
85
-
86
- console.log(`V8 : ${v8Pct}% statements coverage`);
87
- console.log(`Monocart : ${monocartPct}% statements coverage`);
88
-
89
- if (Math.abs(parseFloat(monocartPct) - parseFloat(v8Pct)) > 1) {
90
- console.log('✨ Monocart montre une différence significative !');
91
- } else {
92
- console.log('📊 Résultats similaires entre V8 et Monocart');
93
- }
package/src/errors.ts DELETED
@@ -1,167 +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
- /**
20
- * Base class for all LZMA-related errors
21
- */
22
- export class LZMAError extends Error {
23
- public readonly errno: number;
24
- public readonly code: number;
25
-
26
- constructor(message: string, errno: number) {
27
- super(message);
28
- this.name = 'LZMAError';
29
- this.errno = errno;
30
- this.code = errno;
31
- Error.captureStackTrace(this, this.constructor);
32
- }
33
- }
34
-
35
- /**
36
- * Memory allocation error - thrown when LZMA cannot allocate required memory
37
- */
38
- export class LZMAMemoryError extends LZMAError {
39
- constructor(errno: number) {
40
- super('Cannot allocate memory', errno);
41
- this.name = 'LZMAMemoryError';
42
- }
43
- }
44
-
45
- /**
46
- * Memory limit error - thrown when operation would exceed memory usage limit
47
- */
48
- export class LZMAMemoryLimitError extends LZMAError {
49
- constructor(errno: number) {
50
- super('Memory usage limit was reached', errno);
51
- this.name = 'LZMAMemoryLimitError';
52
- }
53
- }
54
-
55
- /**
56
- * Format error - thrown when file format is not recognized
57
- */
58
- export class LZMAFormatError extends LZMAError {
59
- constructor(errno: number) {
60
- super('File format not recognized', errno);
61
- this.name = 'LZMAFormatError';
62
- }
63
- }
64
-
65
- /**
66
- * Options error - thrown when invalid or unsupported options are provided
67
- */
68
- export class LZMAOptionsError extends LZMAError {
69
- constructor(errno: number) {
70
- super('Invalid or unsupported options', errno);
71
- this.name = 'LZMAOptionsError';
72
- }
73
- }
74
-
75
- /**
76
- * Data error - thrown when compressed data is corrupt
77
- */
78
- export class LZMADataError extends LZMAError {
79
- constructor(errno: number) {
80
- super('Data is corrupt', errno);
81
- this.name = 'LZMADataError';
82
- }
83
- }
84
-
85
- /**
86
- * Buffer error - thrown when no progress is possible (e.g., buffer too small)
87
- */
88
- export class LZMABufferError extends LZMAError {
89
- constructor(errno: number) {
90
- super('No progress is possible', errno);
91
- this.name = 'LZMABufferError';
92
- }
93
- }
94
-
95
- /**
96
- * Programming error - thrown when there's an internal programming error
97
- */
98
- export class LZMAProgrammingError extends LZMAError {
99
- constructor(errno: number) {
100
- super('Programming error', errno);
101
- this.name = 'LZMAProgrammingError';
102
- }
103
- }
104
-
105
- /**
106
- * Factory function to create appropriate error instance based on errno
107
- */
108
- export function createLZMAError(errno: number, message?: string): LZMAError {
109
- // LZMA error codes mapping
110
- const LZMA_OK = 0;
111
- const LZMA_STREAM_END = 1;
112
- const LZMA_NO_CHECK = 2;
113
- const LZMA_UNSUPPORTED_CHECK = 3;
114
- const LZMA_GET_CHECK = 4;
115
- const LZMA_MEM_ERROR = 5;
116
- const LZMA_MEMLIMIT_ERROR = 6;
117
- const LZMA_FORMAT_ERROR = 7;
118
- const LZMA_OPTIONS_ERROR = 8;
119
- const LZMA_DATA_ERROR = 9;
120
- const LZMA_BUF_ERROR = 10;
121
- const LZMA_PROG_ERROR = 11;
122
-
123
- switch (errno) {
124
- case LZMA_MEM_ERROR:
125
- return new LZMAMemoryError(errno);
126
- case LZMA_MEMLIMIT_ERROR:
127
- return new LZMAMemoryLimitError(errno);
128
- case LZMA_FORMAT_ERROR:
129
- return new LZMAFormatError(errno);
130
- case LZMA_OPTIONS_ERROR:
131
- return new LZMAOptionsError(errno);
132
- case LZMA_DATA_ERROR:
133
- return new LZMADataError(errno);
134
- case LZMA_BUF_ERROR:
135
- return new LZMABufferError(errno);
136
- case LZMA_PROG_ERROR:
137
- return new LZMAProgrammingError(errno);
138
- default: {
139
- // For success codes and unknown errors, use base LZMAError
140
- const errorMessage = message || getErrorMessage(errno);
141
- return new LZMAError(errorMessage, errno);
142
- }
143
- }
144
- }
145
-
146
- /**
147
- * Get error message for a given errno
148
- */
149
- function getErrorMessage(errno: number): string {
150
- const messages = [
151
- 'Operation completed successfully',
152
- 'End of stream was reached',
153
- 'Input stream has no integrity check',
154
- 'Cannot calculate the integrity check',
155
- 'Integrity check type is not available',
156
- 'Cannot allocate memory',
157
- 'Memory usage limit was reached',
158
- 'File format not recognized',
159
- 'Invalid or unsupported options',
160
- 'Data is corrupt',
161
- 'No progress is possible',
162
- 'Programming error',
163
- ];
164
-
165
- const messageIndex = Math.max(0, Math.min(errno, messages.length - 1));
166
- return messages[messageIndex];
167
- }