nw-builder 4.16.0 → 4.17.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.
package/README.md CHANGED
@@ -122,7 +122,7 @@ Get Node headers if you have to rebuild Node addons.
122
122
  ```javascript
123
123
  nwbuild({
124
124
  mode: "get",
125
- nativeAddon: "gyp"
125
+ nativeAddon: true,
126
126
  });
127
127
  ```
128
128
 
@@ -182,27 +182,6 @@ nwbuild({
182
182
  });
183
183
  ```
184
184
 
185
- #### Rebuild Node addons
186
-
187
- > Currently this feature is disabled and it may be removed in the future.
188
-
189
- It only builds node addons which have a `binding.gyp` file in the `srcDir`. There are plans to support nan, cmake, ffi and gn and auto rebuild native addons which are installed as node modules.
190
-
191
- ```javascript
192
- nwbuild({
193
- mode: "build",
194
- nodeAddon: "gyp",
195
- });
196
- ```
197
-
198
- We recommend rebuilding Node addons for NW.js via `node-gyp` if you are using NW.js v0.83.0 or above.
199
-
200
- ```shell
201
- node-gyp rebuild --target=22.2.0 --nodedir=/path/to/nw/node/headers
202
- ```
203
-
204
- NW.js's Node version should match the Node version on the host machine due to [ABI differences in V8](https://github.com/nwjs/nw.js/issues/5025).
205
-
206
185
  ## API Reference
207
186
 
208
187
  Options
@@ -215,7 +194,7 @@ Options
215
194
  | platform | `"linux" \| "osx" \| "win"` | | Host platform |
216
195
  | arch | `"ia32" \| "x64" \| "arm64"` | | Host architecture |
217
196
  | downloadUrl | `"https://dl.nwjs.io" \| "https://npm.taobao.org/mirrors/nwjs" \| https://npmmirror.com/mirrors/nwjs \| "https://github.com/corwin-of-amber/nw.js/releases/"` | `"https://dl.nwjs.io"` | Download server. Supports file systems too (for example `file:///home/localghost/nwjs_mirror`) |
218
- | manifestUrl | `"https://nwjs.io/versions.json" \| "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"` | `"https://nwjs.io/versions.json"` | Versions manifest |
197
+ | manifestUrl | `"https://nwjs.io/versions.json" \| "https://raw.githubusercontent.com/nwutils/nw-builder/main/src/util/osx.arm.versions.json"` | `"https://nwjs.io/versions.json"` | Versions manifest URI, gotten via https or local file |
219
198
  | cacheDir | `string` | `"./cache"` | Directory to cache NW binaries |
220
199
  | cache | `boolean` | `true`| If true the existing cache is used. Otherwise it removes and redownloads it. |
221
200
  | ffmpeg | `boolean` | `false`| If true the chromium ffmpeg is replaced by community version with proprietary codecs. |
@@ -226,7 +205,7 @@ Options
226
205
  | glob | `boolean` | `true`| If true file globbing is enabled when parsing `srcDir`. |
227
206
  | outDir | `string` | `"./out"` | Directory to store build artifacts |
228
207
  | managedManifest | `boolean \| string \| object` | `false` | Managed manifest |
229
- | nodeAddon | `false \| "gyp"` | `false` | Rebuild Node native addons |
208
+ | nodeAddon | `boolean` | `false` | Rebuild Node native addons |
230
209
  | zip | `boolean \| "zip" \| "tar" \| "tgz"` | `false`| If true, "zip", "tar" or "tgz" the `outDir` directory is compressed. |
231
210
  | app | `LinuxRc \| WinRc \| OsxRc` | Additional options for each platform. (See below.)
232
211
 
@@ -343,18 +322,6 @@ nwbuild({
343
322
  });
344
323
  ```
345
324
 
346
- ### Let `nw-builder` manage your native addons
347
-
348
- > Note: this behaviour is buggy and quite limited. This guide is to show what will be possible in the coming minor releases.
349
-
350
- ```javascript
351
- nwbuild({
352
- mode: "build",
353
- managedManifest: true,
354
- nativeAddon: "gyp",
355
- });
356
- ```
357
-
358
325
  ## Contributing
359
326
 
360
327
  ### External contributor
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nw-builder",
3
- "version": "4.16.0",
3
+ "version": "4.17.0",
4
4
  "description": "Build NW.js desktop applications for MacOS, Windows and Linux.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -55,30 +55,29 @@
55
55
  "demo:cli": "nwbuild --mode=build --flavor=sdk --glob=false --cacheDir=./node_modules/nw --logLevel=debug --managedManifest=./tests/fixtures/app/package.json --outDir=./tests/fixtures/out/linux --app.name=Demo --app.icon=./tests/fixtures/app/icon.png ./tests/fixtures/app"
56
56
  },
57
57
  "devDependencies": {
58
- "@eslint/js": "^9.37.0",
59
- "@vitest/coverage-v8": "^3.2.4",
58
+ "@eslint/js": "^9.39.2",
59
+ "@vitest/coverage-v8": "^4.0.16",
60
60
  "base-volta-off-of-nwjs": "^1.0.5",
61
- "eslint": "^9.37.0",
62
- "eslint-plugin-jsdoc": "^60.8.1",
63
- "globals": "^16.4.0",
64
- "nw": "^0.104.0",
65
- "selenium-webdriver": "^4.36.0",
66
- "vitest": "^3.0.7"
61
+ "eslint": "^9.39.2",
62
+ "eslint-plugin-jsdoc": "^61.5.0",
63
+ "globals": "^17.0.0",
64
+ "nw": "^0.106.1",
65
+ "selenium-webdriver": "^4.39.0",
66
+ "vitest": "^4.0.14"
67
67
  },
68
68
  "dependencies": {
69
69
  "archiver": "^7.0.1",
70
- "axios": "^1.12.2",
71
- "commander": "^14.0.1",
72
- "glob": "^11.0.3",
73
- "node-gyp": "^11.4.2",
70
+ "axios": "^1.13.2",
71
+ "commander": "^14.0.2",
72
+ "glob": "^13.0.0",
74
73
  "plist": "^3.1.0",
75
- "resedit": "^2.0.3",
76
- "semver": "^7.7.2",
77
- "tar": "^7.5.1",
74
+ "resedit": "^3.0.1",
75
+ "semver": "^7.7.3",
76
+ "tar": "^7.5.2",
78
77
  "yauzl-promise": "^4.0.0"
79
78
  },
80
79
  "volta": {
81
- "node": "24.7.0",
82
- "npm": "11.5.2"
80
+ "node": "25.2.1",
81
+ "npm": "11.7.0"
83
82
  }
84
83
  }
package/src/bld.js CHANGED
@@ -89,14 +89,13 @@ import setOsxConfig from './bld/osx.js';
89
89
  * @property {"normal" | "sdk"} [flavor = "normal"] Build flavor
90
90
  * @property {"linux" | "osx" | "win"} [platform] Target platform
91
91
  * @property {"ia32" | "x64" | "arm64"} [arch] Target arch
92
- * @property {string} [manifestUrl = "https://nwjs.io/versions.json"] Manifest URL
92
+ * @property {string} [manifestUrl = "https://nwjs.io/versions.json"] Versions manifest URI, https or file path
93
93
  * @property {string} [srcDir = "./src"] Source directory
94
94
  * @property {string} [cacheDir = "./cache"] Cache directory
95
95
  * @property {string} [outDir = "./out"] Out directory
96
96
  * @property {LinuxRc | WinRc | OsxRc} [app] Platform specific rc
97
97
  * @property {boolean} [glob = true] File globbing
98
98
  * @property {boolean | string | object} [managedManifest = false] Manage manifest
99
- * @property {false | "gyp"} [nativeAddon = false] Rebuild native modules
100
99
  * @property {false | "zip" | "tar" | "tgz"} [zip = false] Compress built artifacts
101
100
  * @property {object} [releaseInfo = {}] Version specific release metadata.
102
101
  */
@@ -119,7 +118,6 @@ async function bld({
119
118
  app,
120
119
  glob = true,
121
120
  managedManifest = false,
122
- nativeAddon = false,
123
121
  zip = false,
124
122
  releaseInfo = {},
125
123
  }) {
@@ -190,11 +188,6 @@ async function bld({
190
188
  await setOsxConfig({ app, outDir, releaseInfo });
191
189
  }
192
190
 
193
- if (nativeAddon === 'gyp') {
194
- throw new Error('Rebuilding Node addons functionality is broken and has been disabled. This functionality may be removed in the future.');
195
- // buildNativeAddon({ cacheDir, version, platform, arch, outDir, nodeVersion });
196
- }
197
-
198
191
  if (zip !== false) {
199
192
  await compress({ zip, outDir });
200
193
  }
@@ -354,20 +347,6 @@ const setWinConfig = async ({ app, outDir }) => {
354
347
  await fs.promises.writeFile(outDirAppExe, outBuffer);
355
348
  };
356
349
 
357
- /*
358
- const buildNativeAddon = ({ cacheDir, version, platform, arch, outDir, nodeVersion }) => {
359
- let nodePath = path.resolve(cacheDir, `node-v${version}-${platform}-${arch}`);
360
- const cwd = path.resolve(
361
- outDir,
362
- platform !== 'osx'
363
- ? 'package.nw'
364
- : 'nwjs.app/Contents/Resources/app.nw',
365
- );
366
-
367
- child_process.execFileSync('node-gyp', ['rebuild', `--target=${nodeVersion}`, `--nodedir=${nodePath}`], { cwd });
368
- };
369
- */
370
-
371
350
  const compress = async ({
372
351
  zip,
373
352
  outDir,
package/src/cli.js CHANGED
@@ -14,7 +14,7 @@ program
14
14
  .option('--platform <string>', 'NW.js supported platform', util.PLATFORM_KV[process.platform])
15
15
  .option('--arch <string>', 'NW.js supported architecture', util.ARCH_KV[process.arch])
16
16
  .option('--downloadUrl <string>', 'NW.js download server', 'https://dl.nwjs.io')
17
- .option('--manifestUrl <string>', 'NW.js version info', 'https://nwjs.io/versions.json')
17
+ .option('--manifestUrl <string>', 'NW.js versions manifest URI', 'https://nwjs.io/versions.json')
18
18
  .option('--cacheDir <string>', 'Cache NW.js binaries', './cache')
19
19
  .option('--outDir <string>', 'NW.js build artifacts', './out')
20
20
  .option('--app <object>', 'Platform specific app metadata. Refer to docs for more info', {})
@@ -22,7 +22,7 @@ program
22
22
  .option('--ffmpeg <boolean>', 'Enable/disable community ffmpeg', false)
23
23
  .option('--glob <boolean>', 'Enable/disable globbing', true)
24
24
  .option('--logLevel <string>', 'Specify log level', 'info')
25
- .option('--shaSum <string>', 'Enable/disable shasum', true)
25
+ .option('--shaSum <boolean>', 'Enable/disable shasum', true)
26
26
  .option('--zip <string>', 'Enable/disable compression', false)
27
27
  .option('--managedManifest <string>', 'Managed manifest mode', false)
28
28
  .option('--nodeAddon <boolean>', 'Download NW.js Node headers', false)
package/src/get/index.js CHANGED
@@ -20,7 +20,7 @@ import util from '../util.js';
20
20
  * @property {string} [cacheDir = "./cache"] Cache directory
21
21
  * @property {boolean} [cache = true] If false, remove cache and redownload.
22
22
  * @property {boolean} [ffmpeg = false] If true, ffmpeg is not downloaded.
23
- * @property {false | "gyp"} [nativeAddon = false] Rebuild native modules
23
+ * @property {boolean} [nativeAddon = false] Download Node headers for native addons.
24
24
  * @property {string} [logLevel = 'info'] User defined log level.
25
25
  * @property {boolean} [shaSum = true] If true shasum is enabled, otherwise disabled.
26
26
  */
@@ -183,7 +183,7 @@ async function get(options) {
183
183
 
184
184
  }
185
185
 
186
- if (options.nativeAddon === 'gyp') {
186
+ if (options.nativeAddon === true) {
187
187
 
188
188
  /**
189
189
  * File path to NW'js Node headers tarball.
package/src/index.js CHANGED
@@ -16,7 +16,7 @@ import util from './util.js';
16
16
  * @property {"linux" | "osx" | "win"} platform Host platform
17
17
  * @property {"ia32" | "x64" | "arm64"} arch Host architecture
18
18
  * @property {"https://dl.nwjs.io" | string} [downloadUrl="https://dl.nwjs.io"] Download server
19
- * @property {"https://nwjs.io/versions.json" | string} [manifestUrl="https://nwjs.io/versions.json"] Versions manifest
19
+ * @property {"https://nwjs.io/versions.json" | string} [manifestUrl="https://nwjs.io/versions.json"] Versions manifest URI, https or file path
20
20
  * @property {"./cache" | string} [cacheDir="./cache"] Directory to cache NW binaries
21
21
  * @property {"./" | string} [srcDir="./"] File paths to application code
22
22
  * @property {"./out" | string} [outDir="./out"] Directory to store build artifacts
@@ -28,7 +28,7 @@ import util from './util.js';
28
28
  * @property {boolean} [shaSum = true] If true, shasum is enabled. Otherwise, disabled.
29
29
  * @property {boolean | "zip" | "tar" | "tgz"} [zip=false] If true, "zip", "tar" or "tgz" the outDir directory is compressed.
30
30
  * @property {boolean | string | object} [managedManifest = false] Managed manifest mode
31
- * @property {false | "gyp"} [nodeAddon = false] Rebuild Node native addons
31
+ * @property {boolean} [nodeAddon = false] Get Node native addons
32
32
  * @property {boolean} [cli=false] If true the CLI is used to parse options. This option is used internally.
33
33
  */
34
34
 
@@ -139,7 +139,6 @@ async function nwbuild(options) {
139
139
  app: options.app,
140
140
  glob: options.glob,
141
141
  managedManifest: options.managedManifest,
142
- nativeAddon: options.nativeAddon,
143
142
  zip: options.zip,
144
143
  releaseInfo: releaseInfo,
145
144
  });
package/src/util.js CHANGED
@@ -3,18 +3,23 @@ import fs from 'node:fs';
3
3
  import https from 'node:https';
4
4
  import path from 'node:path';
5
5
  import process from 'node:process';
6
+ import url from 'node:url';
6
7
 
7
8
  import * as GlobModule from 'glob';
8
- import semver from 'semver';
9
9
 
10
10
  /**
11
11
  * Get manifest (array of NW release metadata) from URL.
12
- * @param {string} manifestUrl Url to manifest
13
- * @returns {Promise<string>} - Manifest object
12
+ * @param {string} manifestUrl Versions manifest URI, https or file path
13
+ * @returns {string} - Manifest object
14
14
  */
15
15
  function getManifest(manifestUrl) {
16
16
  let chunks = '';
17
17
 
18
+ if (manifestUrl.startsWith('file://')) {
19
+ const filePath = url.fileURLToPath(manifestUrl);
20
+ return fs.readFileSync(filePath, 'utf-8');
21
+ }
22
+
18
23
  return new Promise((resolve) => {
19
24
  const req = https.get(manifestUrl, (response) => {
20
25
  response.on('data', (chunk) => {
@@ -43,8 +48,8 @@ function getManifest(manifestUrl) {
43
48
  * @param {string} platform NW platform
44
49
  * @param {string} arch NW architecture
45
50
  * @param {string} cacheDir Directory to store NW binaries
46
- * @param {string} manifestUrl Url to manifest
47
- * @returns {object} Version specific release info
51
+ * @param {string} manifestUrl Versions manifest URI, https or file path
52
+ * @returns {Promise<object>} Version specific release info
48
53
  */
49
54
  async function getReleaseInfo(
50
55
  version,
@@ -209,7 +214,7 @@ export const parse = async (options, pkg) => {
209
214
  options.cache = str2Bool(options.cache ?? true);
210
215
  options.ffmpeg = str2Bool(options.ffmpeg ?? false);
211
216
  options.logLevel = options.logLevel ?? 'info';
212
- options.shaSum = options.shaSum ?? true;
217
+ options.shaSum = str2Bool(options.shaSum ?? true);
213
218
 
214
219
  if (options.mode === 'get') {
215
220
  return { ...options };
@@ -344,8 +349,8 @@ export const validate = async (options, releaseInfo) => {
344
349
  if (typeof options.downloadUrl === 'string' && !options.downloadUrl.startsWith('http') && !options.downloadUrl.startsWith('file')) {
345
350
  throw new Error('Expected options.downloadUrl to be a string and starts with `http` or `file`.');
346
351
  }
347
- if (typeof options.manifestUrl === 'string' && !options.manifestUrl.startsWith('http') && !options.manifestUrl.startsWith('file')) {
348
- throw new Error('Expected options.manifestUrl to be a string and starts with `http` or `file`.');
352
+ if (typeof options.manifestUrl === 'string' && !options.manifestUrl.startsWith('https') && !options.manifestUrl.startsWith('file')) {
353
+ throw new Error('Expected options.manifestUrl to be a string and starts with `https` or `file`.');
349
354
  }
350
355
  if (typeof options.cacheDir !== 'string') {
351
356
  throw new Error('Expected options.cacheDir to be a string. Got ' + typeof options.cacheDir);
@@ -426,20 +431,14 @@ export const validate = async (options, releaseInfo) => {
426
431
  }
427
432
 
428
433
  if (typeof options.nativeAddon !== 'boolean') {
429
- if (typeof options.nativeAddon !== 'boolean' && typeof options.nativeAddon !== 'string') {
430
- throw new Error('Expected options.nativeAddon to be a boolean or string type. Got ' + typeof options.nativeAddon);
431
- }
432
-
433
- if (semver.parse(options.version).minor >= '83' && options.nativeAddon !== false) {
434
- throw new Error('Native addons are not supported for NW.js v0.82.0 and below');
435
- }
434
+ throw new Error('Expected options.nativeAddon to be a boolean. Got ' + typeof options.nativeAddon);
435
+ }
436
436
 
437
- if (typeof options.zip !== 'boolean' &
438
- options.zip !== 'zip' &&
439
- options.zip !== 'tar' &&
440
- options.zip !== 'tgz') {
441
- throw new Error('Expected options.zip to be a boolean, `zip`, `tar` or `tgz`. Got ' + typeof options.zip);
442
- }
437
+ if (typeof options.zip !== 'boolean' &
438
+ options.zip !== 'zip' &&
439
+ options.zip !== 'tar' &&
440
+ options.zip !== 'tgz') {
441
+ throw new Error('Expected options.zip to be a boolean, `zip`, `tar` or `tgz`. Got ' + typeof options.zip);
443
442
  }
444
443
 
445
444
  if (options.platform === 'linux') {
@@ -671,4 +670,4 @@ function log(severity, logLevel, message) {
671
670
  return stdout;
672
671
  }
673
672
 
674
- export default { fileExists, getReleaseInfo, getPath, PLATFORM_KV, ARCH_KV, EXE_NAME, globFiles, getNodeManifest, parse, validate, log };
673
+ export default { fileExists, getReleaseInfo, getManifest, getPath, PLATFORM_KV, ARCH_KV, EXE_NAME, globFiles, getNodeManifest, parse, validate, log };