xz-compat 0.3.0 → 0.3.1
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/dist/cjs/native.d.cts +0 -3
- package/dist/cjs/native.d.ts +0 -3
- package/dist/cjs/native.js +13 -66
- package/dist/cjs/native.js.map +1 -1
- package/dist/esm/native.d.ts +0 -3
- package/dist/esm/native.js +15 -70
- package/dist/esm/native.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/native.d.cts
CHANGED
|
@@ -24,8 +24,5 @@ interface NativeModule {
|
|
|
24
24
|
* Returns null if not available or Node version is too old
|
|
25
25
|
*/
|
|
26
26
|
export declare function tryLoadNative(): NativeModule | null;
|
|
27
|
-
/**
|
|
28
|
-
* Check if native acceleration is available
|
|
29
|
-
*/
|
|
30
27
|
export declare function isNativeAvailable(): boolean;
|
|
31
28
|
export {};
|
package/dist/cjs/native.d.ts
CHANGED
|
@@ -24,8 +24,5 @@ interface NativeModule {
|
|
|
24
24
|
* Returns null if not available or Node version is too old
|
|
25
25
|
*/
|
|
26
26
|
export declare function tryLoadNative(): NativeModule | null;
|
|
27
|
-
/**
|
|
28
|
-
* Check if native acceleration is available
|
|
29
|
-
*/
|
|
30
27
|
export declare function isNativeAvailable(): boolean;
|
|
31
28
|
export {};
|
package/dist/cjs/native.js
CHANGED
|
@@ -35,83 +35,30 @@ var _require = typeof require === 'undefined' ? _module.default.createRequire(re
|
|
|
35
35
|
var __dirname = _path.default.dirname(typeof __filename !== 'undefined' ? __filename : _url.default.fileURLToPath(require("url").pathToFileURL(__filename).toString()));
|
|
36
36
|
// Get node_modules path (go up from dist/cjs to package root, then to node_modules)
|
|
37
37
|
var nodeModulesPath = _path.default.join(__dirname, '..', '..', 'node_modules');
|
|
38
|
+
var major = +process.versions.node.split('.')[0];
|
|
38
39
|
// Cache for native module loading result
|
|
39
|
-
var nativeModule;
|
|
40
|
-
var nodeVersionChecked = false;
|
|
41
|
-
var nodeVersionSupported = false;
|
|
40
|
+
var nativeModule = null;
|
|
42
41
|
var installationAttempted = false;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
if (nodeVersionChecked) return nodeVersionSupported;
|
|
47
|
-
nodeVersionChecked = true;
|
|
48
|
-
try {
|
|
49
|
-
var version = process.versions.node;
|
|
50
|
-
var major = parseInt(version.split('.')[0], 10);
|
|
51
|
-
nodeVersionSupported = major >= 14;
|
|
52
|
-
} catch (unused) {
|
|
53
|
-
nodeVersionSupported = false;
|
|
54
|
-
}
|
|
55
|
-
return nodeVersionSupported;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Install @napi-rs/lzma using install-module-linked
|
|
59
|
-
*/ function installNativeModule(callback) {
|
|
60
|
-
// Only attempt installation once
|
|
61
|
-
if (installationAttempted) {
|
|
62
|
-
callback(new Error('Installation already attempted'));
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
42
|
+
function tryLoadNative() {
|
|
43
|
+
if (major < 14) return null;
|
|
44
|
+
if (installationAttempted) return nativeModule;
|
|
65
45
|
installationAttempted = true;
|
|
46
|
+
// check if installed already
|
|
66
47
|
try {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (err) {
|
|
72
|
-
console.warn('Failed to install @napi-rs/lzma:', err.message);
|
|
73
|
-
} else {
|
|
74
|
-
console.log('Successfully installed @napi-rs/lzma');
|
|
75
|
-
}
|
|
76
|
-
callback(err);
|
|
77
|
-
});
|
|
78
|
-
} catch (err) {
|
|
79
|
-
callback(err);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function tryLoadNative() {
|
|
83
|
-
// Return cached result
|
|
84
|
-
if (nativeModule !== undefined) return nativeModule;
|
|
85
|
-
// Check Node version first
|
|
86
|
-
if (!checkNodeVersion()) {
|
|
87
|
-
nativeModule = null;
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
// Try to load native module (it should be installed at module load time)
|
|
48
|
+
nativeModule = _require('@napi-rs/lzma');
|
|
49
|
+
return nativeModule;
|
|
50
|
+
} catch (unused) {}
|
|
51
|
+
// try to install
|
|
91
52
|
try {
|
|
92
|
-
|
|
53
|
+
console.log('Installing @napi-rs/lzma for native acceleration...');
|
|
54
|
+
var installModule = _require('install-module-linked').default;
|
|
55
|
+
installModule.sync('@napi-rs/lzma', nodeModulesPath, {});
|
|
93
56
|
nativeModule = _require('@napi-rs/lzma');
|
|
94
57
|
return nativeModule;
|
|
95
58
|
} catch (unused) {
|
|
96
|
-
// Module not installed yet - return null
|
|
97
|
-
nativeModule = null;
|
|
98
59
|
return null;
|
|
99
60
|
}
|
|
100
61
|
}
|
|
101
|
-
// At module load time, attempt to install @napi-rs/lzma on Node 14+
|
|
102
|
-
// This is done asynchronously so it doesn't block module initialization
|
|
103
|
-
if (checkNodeVersion()) {
|
|
104
|
-
installNativeModule(function() {
|
|
105
|
-
// Installation complete - clear cache and try to load
|
|
106
|
-
nativeModule = undefined; // Clear cache to force re-check
|
|
107
|
-
try {
|
|
108
|
-
nativeModule = _require('@napi-rs/lzma');
|
|
109
|
-
} catch (unused) {
|
|
110
|
-
// Module still not available
|
|
111
|
-
nativeModule = null;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
62
|
function isNativeAvailable() {
|
|
116
63
|
return tryLoadNative() !== null;
|
|
117
64
|
}
|
package/dist/cjs/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/xz-compat/src/native.ts"],"sourcesContent":["/**\n * Native Acceleration Module\n *\n * Provides optional native acceleration via @napi-rs/lzma on Node.js 14+.\n * Falls back gracefully to pure JS implementation on older Node versions\n * or when the native module is not available.\n */\n\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\n// Get __dirname for ES modules\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n// Get node_modules path (go up from dist/cjs to package root, then to node_modules)\nconst nodeModulesPath = path.join(__dirname, '..', '..', 'node_modules');\n\n// Cache for native module loading result\nlet nativeModule: NativeModule | null
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/xz-compat/src/native.ts"],"sourcesContent":["/**\n * Native Acceleration Module\n *\n * Provides optional native acceleration via @napi-rs/lzma on Node.js 14+.\n * Falls back gracefully to pure JS implementation on older Node versions\n * or when the native module is not available.\n */\n\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\n// Get __dirname for ES modules\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n// Get node_modules path (go up from dist/cjs to package root, then to node_modules)\nconst nodeModulesPath = path.join(__dirname, '..', '..', 'node_modules');\nconst major = +process.versions.node.split('.')[0];\n\n// Cache for native module loading result\nlet nativeModule: NativeModule | null = null;\nlet installationAttempted = false;\n\ninterface NativeModule {\n xz: {\n decompressSync(input: Uint8Array): Buffer;\n decompress(input: Uint8Array, signal?: AbortSignal | null): Promise<Buffer>;\n };\n lzma: {\n decompressSync(input: Uint8Array): Buffer;\n decompress(input: Uint8Array, signal?: AbortSignal | null): Promise<Buffer>;\n };\n lzma2: {\n decompressSync(input: Uint8Array): Buffer;\n decompress(input: Uint8Array, signal?: AbortSignal | null): Promise<Buffer>;\n };\n}\n\n/**\n * Try to load the native @napi-rs/lzma module\n * Returns null if not available or Node version is too old\n */\nexport function tryLoadNative(): NativeModule | null {\n if (major < 14) return null;\n if (installationAttempted) return nativeModule;\n installationAttempted = true;\n\n // check if installed already\n try {\n nativeModule = _require('@napi-rs/lzma') as NativeModule;\n return nativeModule;\n } catch {}\n\n // try to install\n try {\n console.log('Installing @napi-rs/lzma for native acceleration...');\n const installModule = _require('install-module-linked').default;\n installModule.sync('@napi-rs/lzma', nodeModulesPath, {});\n nativeModule = _require('@napi-rs/lzma') as NativeModule;\n return nativeModule;\n } catch {\n return null;\n }\n}\n\nexport function isNativeAvailable(): boolean {\n return tryLoadNative() !== null;\n}\n"],"names":["isNativeAvailable","tryLoadNative","_require","require","Module","createRequire","__dirname","path","dirname","__filename","url","fileURLToPath","nodeModulesPath","join","major","process","versions","node","split","nativeModule","installationAttempted","console","log","installModule","default","sync"],"mappings":"AAAA;;;;;;CAMC;;;;;;;;;;;QA4DeA;eAAAA;;QAvBAC;eAAAA;;;6DAnCG;2DACF;0DACD;;;;;;AAEhB,+BAA+B;AAC/B,IAAMC,WAAW,OAAOC,YAAY,cAAcC,eAAM,CAACC,aAAa,CAAC,uDAAmBF;AAC1F,IAAMG,YAAYC,aAAI,CAACC,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaC,YAAG,CAACC,aAAa,CAAC;AAElG,oFAAoF;AACpF,IAAMC,kBAAkBL,aAAI,CAACM,IAAI,CAACP,WAAW,MAAM,MAAM;AACzD,IAAMQ,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,yCAAyC;AACzC,IAAIC,eAAoC;AACxC,IAAIC,wBAAwB;AAqBrB,SAASnB;IACd,IAAIa,QAAQ,IAAI,OAAO;IACvB,IAAIM,uBAAuB,OAAOD;IAClCC,wBAAwB;IAExB,6BAA6B;IAC7B,IAAI;QACFD,eAAejB,SAAS;QACxB,OAAOiB;IACT,EAAE,eAAM,CAAC;IAET,iBAAiB;IACjB,IAAI;QACFE,QAAQC,GAAG,CAAC;QACZ,IAAMC,gBAAgBrB,SAAS,yBAAyBsB,OAAO;QAC/DD,cAAcE,IAAI,CAAC,iBAAiBb,iBAAiB,CAAC;QACtDO,eAAejB,SAAS;QACxB,OAAOiB;IACT,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEO,SAASnB;IACd,OAAOC,oBAAoB;AAC7B"}
|
package/dist/esm/native.d.ts
CHANGED
|
@@ -24,8 +24,5 @@ interface NativeModule {
|
|
|
24
24
|
* Returns null if not available or Node version is too old
|
|
25
25
|
*/
|
|
26
26
|
export declare function tryLoadNative(): NativeModule | null;
|
|
27
|
-
/**
|
|
28
|
-
* Check if native acceleration is available
|
|
29
|
-
*/
|
|
30
27
|
export declare function isNativeAvailable(): boolean;
|
|
31
28
|
export {};
|
package/dist/esm/native.js
CHANGED
|
@@ -12,88 +12,33 @@ const _require = typeof require === 'undefined' ? Module.createRequire(import.me
|
|
|
12
12
|
const __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));
|
|
13
13
|
// Get node_modules path (go up from dist/cjs to package root, then to node_modules)
|
|
14
14
|
const nodeModulesPath = path.join(__dirname, '..', '..', 'node_modules');
|
|
15
|
+
const major = +process.versions.node.split('.')[0];
|
|
15
16
|
// Cache for native module loading result
|
|
16
|
-
let nativeModule;
|
|
17
|
-
let nodeVersionChecked = false;
|
|
18
|
-
let nodeVersionSupported = false;
|
|
17
|
+
let nativeModule = null;
|
|
19
18
|
let installationAttempted = false;
|
|
20
|
-
/**
|
|
21
|
-
* Check if Node.js version supports native module (14+)
|
|
22
|
-
*/ function checkNodeVersion() {
|
|
23
|
-
if (nodeVersionChecked) return nodeVersionSupported;
|
|
24
|
-
nodeVersionChecked = true;
|
|
25
|
-
try {
|
|
26
|
-
const version = process.versions.node;
|
|
27
|
-
const major = parseInt(version.split('.')[0], 10);
|
|
28
|
-
nodeVersionSupported = major >= 14;
|
|
29
|
-
} catch {
|
|
30
|
-
nodeVersionSupported = false;
|
|
31
|
-
}
|
|
32
|
-
return nodeVersionSupported;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Install @napi-rs/lzma using install-module-linked
|
|
36
|
-
*/ function installNativeModule(callback) {
|
|
37
|
-
// Only attempt installation once
|
|
38
|
-
if (installationAttempted) {
|
|
39
|
-
callback(new Error('Installation already attempted'));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
installationAttempted = true;
|
|
43
|
-
try {
|
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
45
|
-
const installModule = _require('install-module-linked').default;
|
|
46
|
-
console.log('Installing @napi-rs/lzma for native acceleration...');
|
|
47
|
-
installModule('@napi-rs/lzma', nodeModulesPath, {}, (err)=>{
|
|
48
|
-
if (err) {
|
|
49
|
-
console.warn('Failed to install @napi-rs/lzma:', err.message);
|
|
50
|
-
} else {
|
|
51
|
-
console.log('Successfully installed @napi-rs/lzma');
|
|
52
|
-
}
|
|
53
|
-
callback(err);
|
|
54
|
-
});
|
|
55
|
-
} catch (err) {
|
|
56
|
-
callback(err);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
19
|
/**
|
|
60
20
|
* Try to load the native @napi-rs/lzma module
|
|
61
21
|
* Returns null if not available or Node version is too old
|
|
62
22
|
*/ export function tryLoadNative() {
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
if
|
|
67
|
-
nativeModule = null;
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
// Try to load native module (it should be installed at module load time)
|
|
23
|
+
if (major < 14) return null;
|
|
24
|
+
if (installationAttempted) return nativeModule;
|
|
25
|
+
installationAttempted = true;
|
|
26
|
+
// check if installed already
|
|
71
27
|
try {
|
|
72
|
-
|
|
28
|
+
nativeModule = _require('@napi-rs/lzma');
|
|
29
|
+
return nativeModule;
|
|
30
|
+
} catch {}
|
|
31
|
+
// try to install
|
|
32
|
+
try {
|
|
33
|
+
console.log('Installing @napi-rs/lzma for native acceleration...');
|
|
34
|
+
const installModule = _require('install-module-linked').default;
|
|
35
|
+
installModule.sync('@napi-rs/lzma', nodeModulesPath, {});
|
|
73
36
|
nativeModule = _require('@napi-rs/lzma');
|
|
74
37
|
return nativeModule;
|
|
75
38
|
} catch {
|
|
76
|
-
// Module not installed yet - return null
|
|
77
|
-
nativeModule = null;
|
|
78
39
|
return null;
|
|
79
40
|
}
|
|
80
41
|
}
|
|
81
|
-
|
|
82
|
-
// This is done asynchronously so it doesn't block module initialization
|
|
83
|
-
if (checkNodeVersion()) {
|
|
84
|
-
installNativeModule(()=>{
|
|
85
|
-
// Installation complete - clear cache and try to load
|
|
86
|
-
nativeModule = undefined; // Clear cache to force re-check
|
|
87
|
-
try {
|
|
88
|
-
nativeModule = _require('@napi-rs/lzma');
|
|
89
|
-
} catch {
|
|
90
|
-
// Module still not available
|
|
91
|
-
nativeModule = null;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Check if native acceleration is available
|
|
97
|
-
*/ export function isNativeAvailable() {
|
|
42
|
+
export function isNativeAvailable() {
|
|
98
43
|
return tryLoadNative() !== null;
|
|
99
44
|
}
|
package/dist/esm/native.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/xz-compat/src/native.ts"],"sourcesContent":["/**\n * Native Acceleration Module\n *\n * Provides optional native acceleration via @napi-rs/lzma on Node.js 14+.\n * Falls back gracefully to pure JS implementation on older Node versions\n * or when the native module is not available.\n */\n\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\n// Get __dirname for ES modules\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n// Get node_modules path (go up from dist/cjs to package root, then to node_modules)\nconst nodeModulesPath = path.join(__dirname, '..', '..', 'node_modules');\n\n// Cache for native module loading result\nlet nativeModule: NativeModule | null
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/xz-compat/src/native.ts"],"sourcesContent":["/**\n * Native Acceleration Module\n *\n * Provides optional native acceleration via @napi-rs/lzma on Node.js 14+.\n * Falls back gracefully to pure JS implementation on older Node versions\n * or when the native module is not available.\n */\n\nimport Module from 'module';\nimport path from 'path';\nimport url from 'url';\n\n// Get __dirname for ES modules\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\nconst __dirname = path.dirname(typeof __filename !== 'undefined' ? __filename : url.fileURLToPath(import.meta.url));\n\n// Get node_modules path (go up from dist/cjs to package root, then to node_modules)\nconst nodeModulesPath = path.join(__dirname, '..', '..', 'node_modules');\nconst major = +process.versions.node.split('.')[0];\n\n// Cache for native module loading result\nlet nativeModule: NativeModule | null = null;\nlet installationAttempted = false;\n\ninterface NativeModule {\n xz: {\n decompressSync(input: Uint8Array): Buffer;\n decompress(input: Uint8Array, signal?: AbortSignal | null): Promise<Buffer>;\n };\n lzma: {\n decompressSync(input: Uint8Array): Buffer;\n decompress(input: Uint8Array, signal?: AbortSignal | null): Promise<Buffer>;\n };\n lzma2: {\n decompressSync(input: Uint8Array): Buffer;\n decompress(input: Uint8Array, signal?: AbortSignal | null): Promise<Buffer>;\n };\n}\n\n/**\n * Try to load the native @napi-rs/lzma module\n * Returns null if not available or Node version is too old\n */\nexport function tryLoadNative(): NativeModule | null {\n if (major < 14) return null;\n if (installationAttempted) return nativeModule;\n installationAttempted = true;\n\n // check if installed already\n try {\n nativeModule = _require('@napi-rs/lzma') as NativeModule;\n return nativeModule;\n } catch {}\n\n // try to install\n try {\n console.log('Installing @napi-rs/lzma for native acceleration...');\n const installModule = _require('install-module-linked').default;\n installModule.sync('@napi-rs/lzma', nodeModulesPath, {});\n nativeModule = _require('@napi-rs/lzma') as NativeModule;\n return nativeModule;\n } catch {\n return null;\n }\n}\n\nexport function isNativeAvailable(): boolean {\n return tryLoadNative() !== null;\n}\n"],"names":["Module","path","url","_require","require","createRequire","__dirname","dirname","__filename","fileURLToPath","nodeModulesPath","join","major","process","versions","node","split","nativeModule","installationAttempted","tryLoadNative","console","log","installModule","default","sync","isNativeAvailable"],"mappings":"AAAA;;;;;;CAMC,GAED,OAAOA,YAAY,SAAS;AAC5B,OAAOC,UAAU,OAAO;AACxB,OAAOC,SAAS,MAAM;AAEtB,+BAA+B;AAC/B,MAAMC,WAAW,OAAOC,YAAY,cAAcJ,OAAOK,aAAa,CAAC,YAAYH,GAAG,IAAIE;AAC1F,MAAME,YAAYL,KAAKM,OAAO,CAAC,OAAOC,eAAe,cAAcA,aAAaN,IAAIO,aAAa,CAAC,YAAYP,GAAG;AAEjH,oFAAoF;AACpF,MAAMQ,kBAAkBT,KAAKU,IAAI,CAACL,WAAW,MAAM,MAAM;AACzD,MAAMM,QAAQ,CAACC,QAAQC,QAAQ,CAACC,IAAI,CAACC,KAAK,CAAC,IAAI,CAAC,EAAE;AAElD,yCAAyC;AACzC,IAAIC,eAAoC;AACxC,IAAIC,wBAAwB;AAiB5B;;;CAGC,GACD,OAAO,SAASC;IACd,IAAIP,QAAQ,IAAI,OAAO;IACvB,IAAIM,uBAAuB,OAAOD;IAClCC,wBAAwB;IAExB,6BAA6B;IAC7B,IAAI;QACFD,eAAed,SAAS;QACxB,OAAOc;IACT,EAAE,OAAM,CAAC;IAET,iBAAiB;IACjB,IAAI;QACFG,QAAQC,GAAG,CAAC;QACZ,MAAMC,gBAAgBnB,SAAS,yBAAyBoB,OAAO;QAC/DD,cAAcE,IAAI,CAAC,iBAAiBd,iBAAiB,CAAC;QACtDO,eAAed,SAAS;QACxB,OAAOc;IACT,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,OAAO,SAASQ;IACd,OAAON,oBAAoB;AAC7B"}
|