@nwutils/getter 0.2.0 → 0.2.3
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/package.json +15 -8
- package/src/decompress.js +1 -0
- package/src/ffmpeg.js +1 -0
- package/src/main.js +6 -3
- package/src/node.js +1 -0
- package/src/request.js +1 -1
- package/types/decompress.d.ts +10 -0
- package/types/ffmpeg.d.ts +13 -0
- package/types/main.d.ts +69 -0
- package/types/node.d.ts +11 -0
- package/types/nw.d.ts +14 -0
- package/types/request.d.ts +7 -0
- package/types/verify.d.ts +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwutils/getter",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Get NW.js and related binaries for Linux, MacOS and Windows.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"NW.js",
|
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
],
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"main": "./src/main.js",
|
|
29
|
+
"types": "types",
|
|
29
30
|
"type": "module",
|
|
30
31
|
"files": [
|
|
31
32
|
"LICENSE",
|
|
32
|
-
"src"
|
|
33
|
+
"src",
|
|
34
|
+
"types"
|
|
33
35
|
],
|
|
34
36
|
"homepage": "https://github.com/nwutils/getter",
|
|
35
37
|
"repository": {
|
|
@@ -38,6 +40,7 @@
|
|
|
38
40
|
},
|
|
39
41
|
"scripts": {
|
|
40
42
|
"lint": "eslint .",
|
|
43
|
+
"type": "tsc",
|
|
41
44
|
"test": "node --test --experimental-test-coverage --test-coverage-exclude=\"tests/**/*\" \"tests/specs/*.test.js\""
|
|
42
45
|
},
|
|
43
46
|
"volta": {
|
|
@@ -45,14 +48,18 @@
|
|
|
45
48
|
"npm": "11.7.0"
|
|
46
49
|
},
|
|
47
50
|
"dependencies": {
|
|
48
|
-
"semver": "^7.7.
|
|
49
|
-
"tar": "^7.5.
|
|
51
|
+
"semver": "^7.7.4",
|
|
52
|
+
"tar": "^7.5.11",
|
|
50
53
|
"yauzl-promise": "^4.0.0"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
53
|
-
"@eslint/js": "^
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
56
|
+
"@eslint/js": "^10.0.1",
|
|
57
|
+
"@types/node": "^25.3.3",
|
|
58
|
+
"@types/semver": "^7.7.1",
|
|
59
|
+
"@types/yauzl-promise": "^4.0.1",
|
|
60
|
+
"eslint": "^10.0.2",
|
|
61
|
+
"eslint-plugin-jsdoc": "^62.7.1",
|
|
62
|
+
"globals": "^17.4.0",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
57
64
|
}
|
|
58
65
|
}
|
package/src/decompress.js
CHANGED
|
@@ -87,6 +87,7 @@ async function unzip(zippedFile, cacheDir) {
|
|
|
87
87
|
for (const symlinkEntry of symlinks) {
|
|
88
88
|
let entryPathAbs = path.join(cacheDir, symlinkEntry.filename);
|
|
89
89
|
const readStream = await symlinkEntry.openReadStream();
|
|
90
|
+
/** @type {Buffer[]} */
|
|
90
91
|
const chunks = [];
|
|
91
92
|
readStream.on('data', (chunk) => chunks.push(chunk));
|
|
92
93
|
await new Promise(resolve => readStream.on('end', resolve));
|
package/src/ffmpeg.js
CHANGED
package/src/main.js
CHANGED
|
@@ -54,10 +54,13 @@ async function get(options) {
|
|
|
54
54
|
|| options.version === "lts"
|
|
55
55
|
) {
|
|
56
56
|
options.version = manifestData[options.version].slice(1);
|
|
57
|
-
} else if (semver.valid(semver.coerce(options.version))) {
|
|
58
|
-
options.version = semver.coerce(options.version).version;
|
|
59
57
|
} else {
|
|
60
|
-
|
|
58
|
+
const coerced = semver.coerce(options.version);
|
|
59
|
+
if (coerced && semver.valid(coerced)) {
|
|
60
|
+
options.version = coerced.version;
|
|
61
|
+
} else {
|
|
62
|
+
throw new Error('Expected "options.version" to be "latest", "stable", "lts" or a valid semver version. Received: ' + options.version);
|
|
63
|
+
}
|
|
61
64
|
}
|
|
62
65
|
|
|
63
66
|
if (options.flavor !== "normal" && options.flavor !== "sdk") {
|
package/src/node.js
CHANGED
package/src/request.js
CHANGED
|
@@ -44,7 +44,7 @@ export default function request(url, filePath) {
|
|
|
44
44
|
},
|
|
45
45
|
(res) => {
|
|
46
46
|
/* Redirect handling */
|
|
47
|
-
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
47
|
+
if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
48
48
|
cleanup();
|
|
49
49
|
|
|
50
50
|
const redirectedUrl = new URL(res.headers.location, parsedUrl).toString();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decompresses a file at `filePath` to `cacheDir` directory.
|
|
3
|
+
* @async
|
|
4
|
+
* @function
|
|
5
|
+
* @param {string} filePath - file path to compressed binary
|
|
6
|
+
* @param {string} cacheDir - directory to decompress into
|
|
7
|
+
* @throws {Error}
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
export default function decompress(filePath: string, cacheDir: string): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Download community FFmpeg binary from `https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt`.
|
|
3
|
+
* @async
|
|
4
|
+
* @function
|
|
5
|
+
* @param {string} downloadUrl - Download server
|
|
6
|
+
* @param {string} version - Runtime version
|
|
7
|
+
* @param {string} platform - NW supported platform
|
|
8
|
+
* @param {string} arch - NW supported architecture
|
|
9
|
+
* @param {string} cacheDir - Directory to store FFmpeg binary
|
|
10
|
+
* @throws {Error} - When download fails
|
|
11
|
+
* @returns {Promise<string>} - Path of compressed file which containscommunity FFmpeg binary.
|
|
12
|
+
*/
|
|
13
|
+
export default function ffmpeg(downloadUrl: string, version: string, platform: string, arch: string, cacheDir: string): Promise<string>;
|
package/types/main.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export default get;
|
|
2
|
+
export type Options = {
|
|
3
|
+
/**
|
|
4
|
+
* Runtime version
|
|
5
|
+
*/
|
|
6
|
+
version: string | "latest" | "stable" | "lts";
|
|
7
|
+
/**
|
|
8
|
+
* Build flavor
|
|
9
|
+
*/
|
|
10
|
+
flavor: "normal" | "sdk";
|
|
11
|
+
/**
|
|
12
|
+
* Target platform
|
|
13
|
+
*/
|
|
14
|
+
platform: "linux" | "osx" | "win";
|
|
15
|
+
/**
|
|
16
|
+
* Target architecture
|
|
17
|
+
*/
|
|
18
|
+
arch: "ia32" | "x64" | "arm64";
|
|
19
|
+
/**
|
|
20
|
+
* Download server, accepts http and https
|
|
21
|
+
*/
|
|
22
|
+
downloadUrl: "https://dl.nwjs.io";
|
|
23
|
+
/**
|
|
24
|
+
* Manifest URI, accepts file, http and https
|
|
25
|
+
*/
|
|
26
|
+
manifestUrl: "https://nwjs.io/versions.json";
|
|
27
|
+
/**
|
|
28
|
+
* Cache directory
|
|
29
|
+
*/
|
|
30
|
+
cacheDir: string;
|
|
31
|
+
/**
|
|
32
|
+
* If false, remove cache and redownload.
|
|
33
|
+
*/
|
|
34
|
+
cache: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* If true, ffmpeg is not downloaded.
|
|
37
|
+
*/
|
|
38
|
+
ffmpeg: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true, download node headers.
|
|
41
|
+
*/
|
|
42
|
+
nativeAddon: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* If true shasum is enabled, otherwise disabled.
|
|
45
|
+
*/
|
|
46
|
+
shaSum: boolean;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* @typedef {object} Options
|
|
50
|
+
* @property {string | "latest" | "stable" | "lts"} version Runtime version
|
|
51
|
+
* @property {"normal" | "sdk"} flavor Build flavor
|
|
52
|
+
* @property {"linux" | "osx" | "win"} platform Target platform
|
|
53
|
+
* @property {"ia32" | "x64" | "arm64"} arch Target architecture
|
|
54
|
+
* @property {"https://dl.nwjs.io"} downloadUrl Download server, accepts http and https
|
|
55
|
+
* @property {"https://nwjs.io/versions.json"} manifestUrl Manifest URI, accepts file, http and https
|
|
56
|
+
* @property {string} cacheDir Cache directory
|
|
57
|
+
* @property {boolean} cache If false, remove cache and redownload.
|
|
58
|
+
* @property {boolean} ffmpeg If true, ffmpeg is not downloaded.
|
|
59
|
+
* @property {boolean} nativeAddon If true, download node headers.
|
|
60
|
+
* @property {boolean} shaSum If true shasum is enabled, otherwise disabled.
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Get NW.js and related binaries for Linux, MacOS and Windows.
|
|
64
|
+
* @async
|
|
65
|
+
* @function
|
|
66
|
+
* @param {Options} options Get mode options
|
|
67
|
+
* @returns {Promise<void>}
|
|
68
|
+
*/
|
|
69
|
+
declare function get(options: Options): Promise<void>;
|
package/types/node.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Download NW.js's Node.js headers.
|
|
3
|
+
* @async
|
|
4
|
+
* @function
|
|
5
|
+
* @param {string} downloadUrl - Download server
|
|
6
|
+
* @param {string} version - Runtime version
|
|
7
|
+
* @param {string} cacheDir - Directory to store NW binaries
|
|
8
|
+
* @throws {Error} - When download fails
|
|
9
|
+
* @returns {Promise<string>} - path of compressed file which contains the Node headers.
|
|
10
|
+
*/
|
|
11
|
+
export default function nw(downloadUrl: string, version: string, cacheDir: string): Promise<string>;
|
package/types/nw.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Download NW.js binary.
|
|
3
|
+
* @async
|
|
4
|
+
* @function
|
|
5
|
+
* @param {string} downloadUrl - Download server
|
|
6
|
+
* @param {string} version - Runtime version
|
|
7
|
+
* @param {string} flavor - Runtime build flavor
|
|
8
|
+
* @param {string} platform - NW supported platform
|
|
9
|
+
* @param {string} arch - NW supported architecture
|
|
10
|
+
* @param {string} cacheDir - Directory to store NW binaries
|
|
11
|
+
* @throws {Error} - When download fails
|
|
12
|
+
* @returns {Promise<string>} - Path of compressed file which contains NW.js binaries.
|
|
13
|
+
*/
|
|
14
|
+
export default function nw(downloadUrl: string, version: string, flavor: string, platform: string, arch: string, cacheDir: string): Promise<string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verify the SHA256 checksum of downloaded artifacts.
|
|
3
|
+
* @async
|
|
4
|
+
* @function
|
|
5
|
+
* @param {string} shaUrl - URL to get the shasum text file from.
|
|
6
|
+
* @param {string} shaOut - File path to shasum text file.
|
|
7
|
+
* @param {string} cacheDir - File path to cache directory.
|
|
8
|
+
* @param {boolean} ffmpeg - Toggle between community (true) and official (false) ffmpeg binary
|
|
9
|
+
* @param {boolean} shaSum - Throws error if true, otherwise logs a warning.
|
|
10
|
+
* @throws {Error}
|
|
11
|
+
* @returns {Promise<boolean>} - Returns true if the checksums match.
|
|
12
|
+
*/
|
|
13
|
+
export default function verify(shaUrl: string, shaOut: string, cacheDir: string, ffmpeg: boolean, shaSum: boolean): Promise<boolean>;
|