@nwutils/builder 0.1.0 → 0.1.2

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/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021-2024 NW.js Utilities
4
- Copyright (c) 2014-2021 Steffen Müller
3
+ Copyright (c) 2026 NW.js Utilities and contributors
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
7
6
  this software and associated documentation files (the "Software"), to deal in
package/README.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # @nwutils/builder
2
2
 
3
- Build NW.js applications for Linux, MacOS and Windows: assembles the app source and a cached NW.js runtime into a distributable package, and applies platform-specific metadata (Linux `.desktop` entry, Windows executable resources, MacOS `Info.plist` and helper app bundles).
3
+ [![npm](https://img.shields.io/npm/v/@nwutils/builder/latest)](https://www.npmjs.com/package/@nwutils/builder/v/latest)
4
4
 
5
- Extracted from [nw-builder](../nw-builder)'s own build implementation so it can be developed, tested and versioned independently, the same way `@nwutils/getter` and `@nwutils/runner` already are. `nw-builder` depends on this package for its `build` mode; most users should keep using `nw-builder` (or `@nwutils/cli`) directly rather than this package on its own.
5
+ Build NW.js applications for Linux, MacOS and Windows.
6
+
7
+ ## Getting Started
8
+
9
+ 1. `npm i` to install third party dependencies
10
+
11
+ ## Usage
12
+
13
+ ```js
14
+ import build from "@nwutils/builder";
15
+
16
+ await build({
17
+ version: "0.115.0",
18
+ flavor: "normal",
19
+ platform: "linux",
20
+ arch: "x64",
21
+ srcDir: "./src",
22
+ cacheDir: "./cache",
23
+ outDir: "./out",
24
+ app: {
25
+ name: "Demo",
26
+ },
27
+ glob: true,
28
+ managedManifest: false,
29
+ zip: false,
30
+ // The release info is from https://nwjs.io/versions.json
31
+ releaseInfo: {
32
+ ...,
33
+ components: {
34
+ "node": "26.7.0",
35
+ "chromium": "152.0.7977.42"
36
+ },
37
+ },
38
+ });
39
+ ```
40
+
41
+ ## API Reference
42
+
43
+ Options
44
+
45
+ | Name | Type | Description |
46
+ | --------------- | ----------------------------------------- | --------------------------------------------------------------------------------------------------------- |
47
+ | version | `string \| "latest" \| "stable" \| "lts"` | Runtime version |
48
+ | flavor | `"normal" \| "sdk"` | Build flavor |
49
+ | platform | `"linux" \| "osx" \| "win"` | Target platform |
50
+ | arch | `"ia32" \| "x64" \| "arm64"` | Target architecture |
51
+ | srcDir | `string` | Source directory |
52
+ | cacheDir | `string` | Directory the target NW.js runtime is cached in (populated ahead of time by `@nwutils/getter`) |
53
+ | outDir | `string` | Directory to write the built application to |
54
+ | app | `object` | Platform specific app metadata - see the `nw-builder` docs for the full shape per platform |
55
+ | glob | `boolean` | If true, `srcDir` is resolved via file globbing rather than copied as-is |
56
+ | managedManifest | `boolean \| string \| object` | Managed manifest mode |
57
+ | zip | `false \| "zip" \| "tar" \| "tgz"` | Compress the built application |
58
+ | releaseInfo | `object` | Version specific release metadata for the target runtime, e.g. `releaseInfo.components.chromium` on MacOS |
59
+
60
+ ## Contributing
61
+
62
+ ### External contributor
63
+
64
+ - Use Node.js standard libraries whenever possible.
65
+ - Prefer to use syncronous APIs over modern APIs which have been introduced in later versions.
66
+
67
+ ### Maintainer
68
+
69
+ - npm Trusted Publishing with OIDC is used for releases
70
+ - A package is released when a maintainer creates a release note for a specific version
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nwutils/builder",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Build NW.js applications for Linux, MacOS and Windows.",
5
5
  "keywords": [
6
6
  "NW.js",
@@ -27,18 +27,22 @@
27
27
  "license": "MIT",
28
28
  "main": "./src/main.js",
29
29
  "type": "module",
30
+ "types": "types/main.d.ts",
30
31
  "files": [
31
32
  "LICENSE",
32
- "src"
33
+ "src",
34
+ "types"
33
35
  ],
34
36
  "homepage": "https://github.com/nwutils/nw-builder",
35
37
  "repository": {
36
38
  "type": "git",
37
- "url": "git+https://github.com/nwutils/nw-builder.git"
39
+ "url": "git+https://github.com/nwutils/nw-builder.git",
40
+ "directory": "./packages/builder"
38
41
  },
39
42
  "scripts": {
40
43
  "lint": "eslint . ../../tests/specs/builder",
41
44
  "lint:fix": "eslint . ../../tests/specs/builder --fix",
45
+ "type": "tsc",
42
46
  "test": "node --test \"../../tests/specs/builder/*.test.js\""
43
47
  },
44
48
  "dependencies": {
@@ -51,6 +55,7 @@
51
55
  "tar": "^7.5.22"
52
56
  },
53
57
  "devDependencies": {
58
+ "@types/archiver": "^8.0.0",
54
59
  "base-volta-off-of-nwjs": "^1.0.5",
55
60
  "nw": "^0.115.0",
56
61
  "selenium-webdriver": "^4.47.0"
package/src/main.js CHANGED
@@ -56,6 +56,7 @@ import setOsxConfig from "./osx.js";
56
56
  * @property {string} CFBundleShortVersionString The release or version number of the bundle.
57
57
  * @property {string} NSHumanReadableCopyright A human-readable copyright notice for the bundle.
58
58
  * @property {string} NSLocalNetworkUsageDescription A human-readable description of why the application needs access to the local network.
59
+ * @property {boolean} LSFileQuarantineEnabled Whether the app is subject to Gatekeeper file quarantine. See https://github.com/nwjs/nw.js/issues/7646
59
60
  */
60
61
 
61
62
  /**
@@ -80,7 +81,7 @@ import setOsxConfig from "./osx.js";
80
81
  * @property {string} productName Name of the product with which the file is distributed. This string is required.
81
82
  * @property {string} productVersion Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. This string is required.
82
83
  * @property {string} specialBuild Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. This string should be present only if VS_FF_SPECIALBUILD is specified in the fileflags parameter of the root block.
83
- * @property {string} languageCode Language of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
84
+ * @property {number} languageCode Language identifier (LCID) of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
84
85
  */
85
86
 
86
87
  /**
@@ -96,7 +97,7 @@ import setOsxConfig from "./osx.js";
96
97
  * @property {LinuxRc | WinRc | OsxRc} [app] Platform specific rc
97
98
  * @property {boolean} [glob = true] File globbing
98
99
  * @property {boolean | string | object} [managedManifest = false] Manage manifest
99
- * @property {false | "zip" | "tar" | "tgz"} [zip = false] Compress built artifacts
100
+ * @property {boolean | "zip" | "tar" | "tgz"} [zip = false] Compress built artifacts
100
101
  * @property {object} [releaseInfo = {}] Version specific release metadata.
101
102
  */
102
103
 
@@ -110,8 +111,14 @@ import setOsxConfig from "./osx.js";
110
111
  async function build({
111
112
  version = "latest",
112
113
  flavor = "normal",
113
- platform = util.PLATFORM_KV[process.platform],
114
- arch = util.ARCH_KV[process.arch],
114
+ platform = /** @type {"linux" | "osx" | "win"} */ (
115
+ util.PLATFORM_KV[
116
+ /** @type {"darwin" | "linux" | "win32"} */ (process.platform)
117
+ ]
118
+ ),
119
+ arch = /** @type {"ia32" | "x64" | "arm64"} */ (
120
+ util.ARCH_KV[/** @type {"x64" | "ia32" | "arm64"} */ (process.arch)]
121
+ ),
115
122
  srcDir = "./src",
116
123
  cacheDir = "./cache",
117
124
  outDir = "./out",
@@ -142,7 +149,7 @@ async function build({
142
149
  await fs.promises.mkdir(nwProjectDir, { recursive: true });
143
150
 
144
151
  if (glob) {
145
- for (let file of files) {
152
+ for (let file of /** @type {string[]} */ (files)) {
146
153
  const stats = await fs.promises.stat(file);
147
154
  if (stats.isDirectory()) {
148
155
  continue;
@@ -153,10 +160,14 @@ async function build({
153
160
  });
154
161
  }
155
162
  } else {
156
- await fs.promises.cp(files, path.resolve(nwProjectDir), {
157
- recursive: true,
158
- verbatimSymlinks: true,
159
- });
163
+ await fs.promises.cp(
164
+ /** @type {string} */ (files),
165
+ path.resolve(nwProjectDir),
166
+ {
167
+ recursive: true,
168
+ verbatimSymlinks: true,
169
+ },
170
+ );
160
171
  }
161
172
 
162
173
  const builtManifest = JSON.parse(
@@ -168,7 +179,7 @@ async function build({
168
179
 
169
180
  /* Set `product_string` in manifest for MacOS. This is used in renaming the Helper apps. */
170
181
  if (platform === "osx") {
171
- builtManifest.product_string = app.name;
182
+ builtManifest.product_string = /** @type {OsxRc} */ (app).name;
172
183
  await fs.promises.writeFile(
173
184
  path.resolve(nwProjectDir, "package.json"),
174
185
  JSON.stringify(builtManifest, null, 2),
@@ -189,11 +200,16 @@ async function build({
189
200
  }
190
201
 
191
202
  if (platform === "linux") {
192
- await setLinuxConfig({ app, outDir });
203
+ await setLinuxConfig({ app: /** @type {LinuxRc} */ (app), outDir });
193
204
  } else if (platform === "win") {
194
- await setWinConfig({ app, outDir });
205
+ await setWinConfig({ app: /** @type {WinRc} */ (app), outDir });
195
206
  } else if (platform === "osx") {
196
- await setOsxConfig({ version, app, outDir, releaseInfo });
207
+ await setOsxConfig({
208
+ version,
209
+ app: /** @type {OsxRc} */ (app),
210
+ outDir,
211
+ releaseInfo,
212
+ });
197
213
  }
198
214
 
199
215
  if (zip !== false) {
@@ -201,6 +217,14 @@ async function build({
201
217
  }
202
218
  }
203
219
 
220
+ /**
221
+ * @param {object} options
222
+ * @param {object} options.nwPkg Manifest built into the output NW.js app
223
+ * @param {boolean | string | object} options.managedManifest Managed manifest mode
224
+ * @param {string} options.outDir Output directory
225
+ * @param {"linux" | "osx" | "win"} options.platform Target platform
226
+ * @returns {Promise<void>}
227
+ */
204
228
  const manageManifest = async ({ nwPkg, managedManifest, outDir, platform }) => {
205
229
  let manifest = undefined;
206
230
 
@@ -213,7 +237,7 @@ const manageManifest = async ({ nwPkg, managedManifest, outDir, platform }) => {
213
237
  }
214
238
 
215
239
  if (typeof managedManifest === "string") {
216
- manifest = JSON.parse(await fs.promises.readFile(managedManifest));
240
+ manifest = JSON.parse(await fs.promises.readFile(managedManifest, "utf8"));
217
241
  }
218
242
 
219
243
  if (manifest.devDependencies) {
@@ -245,12 +269,19 @@ const manageManifest = async ({ nwPkg, managedManifest, outDir, platform }) => {
245
269
  }
246
270
  };
247
271
 
272
+ /**
273
+ * @param {object} options
274
+ * @param {LinuxRc} options.app Linux app configuration
275
+ * @param {string} options.outDir Output directory
276
+ * @returns {Promise<void>}
277
+ */
248
278
  const setLinuxConfig = async ({ app, outDir }) => {
249
279
  if (process.platform === "win32") {
250
280
  console.warn(
251
281
  "Linux apps built on Windows platform do not preserve all file permissions. See #716",
252
282
  );
253
283
  }
284
+ /** @type {Record<string, unknown>} */
254
285
  let desktopEntryFile = {
255
286
  Type: "Application",
256
287
  Version: "1.5",
@@ -290,7 +321,14 @@ const setLinuxConfig = async ({ app, outDir }) => {
290
321
  await fs.promises.writeFile(filePath, fileContent);
291
322
  };
292
323
 
324
+ /**
325
+ * @param {object} options
326
+ * @param {WinRc} options.app Windows app configuration
327
+ * @param {string} options.outDir Output directory
328
+ * @returns {Promise<void>}
329
+ */
293
330
  const setWinConfig = async ({ app, outDir }) => {
331
+ /** @type {Record<string, string>} */
294
332
  let versionString = {
295
333
  Comments: app.comments,
296
334
  CompanyName: app.company,
@@ -358,6 +396,12 @@ const setWinConfig = async ({ app, outDir }) => {
358
396
  await fs.promises.writeFile(outDirAppExe, outBuffer);
359
397
  };
360
398
 
399
+ /**
400
+ * @param {object} options
401
+ * @param {boolean | "zip" | "tar" | "tgz"} options.zip Compression format
402
+ * @param {string} options.outDir Directory to compress
403
+ * @returns {Promise<void>}
404
+ */
361
405
  const compress = async ({ zip, outDir }) => {
362
406
  if (zip === true || zip === "zip") {
363
407
  const archive = new ZipArchive();
package/src/osx.js CHANGED
@@ -12,7 +12,7 @@ import semver from "semver";
12
12
  * @param {string} helperName - Helper App Name
13
13
  * @param {string} helperId - Helper App ID
14
14
  * @param {string} appCFBundleIdentifier - options.app.CFBundleIdentifier
15
- * @param {string} LSFileQuarantineEnabled - options.app.LSFileQuarantineEnabled
15
+ * @param {boolean} LSFileQuarantineEnabled - options.app.LSFileQuarantineEnabled
16
16
  */
17
17
  async function updateHelperPlist(
18
18
  plistPath,
@@ -22,6 +22,7 @@ async function updateHelperPlist(
22
22
  LSFileQuarantineEnabled,
23
23
  ) {
24
24
  const plistFullPath = path.resolve(plistPath, "Contents/Info.plist");
25
+ /** @type {any} */
25
26
  const plistJson = parse(await fs.promises.readFile(plistFullPath, "utf-8"));
26
27
  plistJson.CFBundleDisplayName = helperName;
27
28
  plistJson.CFBundleName = helperName;
@@ -35,9 +36,9 @@ async function updateHelperPlist(
35
36
  *
36
37
  * @param {object} options - Options.
37
38
  * @param {string} options.version - NW.js version.
38
- * @param {object} options.app - Application configuration.
39
+ * @param {import("./main.js").OsxRc} options.app - Application configuration.
39
40
  * @param {string} options.outDir - Output directory.
40
- * @param {string} options.releaseInfo - Release information.
41
+ * @param {any} options.releaseInfo - Release information, shaped by https://nwjs.io/versions.json.
41
42
  * @returns {Promise<void>} - Promise.
42
43
  */
43
44
  export default async function setOsxConfig({
@@ -165,7 +166,7 @@ export default async function setOsxConfig({
165
166
 
166
167
  /**
167
168
  * JSON from `nwjs.app/Contents/Info.plist`
168
- * @type {object}
169
+ * @type {any}
169
170
  */
170
171
  const contentsInfoPlistJson = parse(
171
172
  await fs.promises.readFile(contentsInfoPlistPath, "utf-8"),
package/src/util.js CHANGED
@@ -19,7 +19,7 @@ const ARCH_KV = {
19
19
  * @param {object} options - glob file options
20
20
  * @param {string | string[]} options.srcDir - app src dir
21
21
  * @param {boolean} options.glob - glob flag
22
- * @returns {Promise<string[]>} - Returns array of file paths
22
+ * @returns {Promise<string[] | string>} - Returns array of file paths, or `srcDir` as-is when `glob` is false
23
23
  */
24
24
  async function globFiles({ srcDir, glob }) {
25
25
  let files;
@@ -0,0 +1,353 @@
1
+ export type LinuxRc = {
2
+ /**
3
+ * Name of the application
4
+ */
5
+ name: string;
6
+ /**
7
+ * Generic name of the application
8
+ */
9
+ genericName: string;
10
+ /**
11
+ * If true the application is not displayed
12
+ */
13
+ noDisplay: boolean;
14
+ /**
15
+ * Tooltip for the entry, for example "View sites on the Internet".
16
+ */
17
+ comment: string;
18
+ /**
19
+ * Icon to display in file manager, menus, etc.
20
+ */
21
+ icon: string;
22
+ /**
23
+ * TBD
24
+ */
25
+ hidden: boolean;
26
+ /**
27
+ * A list of strings identifying the desktop environments that should (/not) display a given desktop entry
28
+ */
29
+ onlyShowIn: string[];
30
+ /**
31
+ * A list of strings identifying the desktop environments that should (/not) display a given desktop entry
32
+ */
33
+ notShowIn: string[];
34
+ /**
35
+ * A boolean value specifying if D-Bus activation is supported for this application
36
+ */
37
+ dBusActivatable: boolean;
38
+ /**
39
+ * Path to an executable file on disk used to determine if the program is actually installed
40
+ */
41
+ tryExec: string;
42
+ /**
43
+ * Program to execute, possibly with arguments.
44
+ */
45
+ exec: string;
46
+ /**
47
+ * If entry is of type Application, the working directory to run the program in.
48
+ */
49
+ path: string;
50
+ /**
51
+ * Whether the program runs in a terminal window.
52
+ */
53
+ terminal: boolean;
54
+ /**
55
+ * Identifiers for application actions.
56
+ */
57
+ actions: string[];
58
+ /**
59
+ * The MIME type(s) supported by this application.
60
+ */
61
+ mimeType: string[];
62
+ /**
63
+ * Categories in which the entry should be shown in a menu
64
+ */
65
+ categories: string[];
66
+ /**
67
+ * A list of interfaces that this application implements.
68
+ */
69
+ implements: string[];
70
+ /**
71
+ * A list of strings which may be used in addition to other metadata to describe this entry.
72
+ */
73
+ keywords: string[];
74
+ /**
75
+ * If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all.
76
+ */
77
+ startupNotify: boolean;
78
+ /**
79
+ * If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hin
80
+ */
81
+ startupWMClass: string;
82
+ /**
83
+ * If true, the application prefers to be run on a more powerful discrete GPU if available.
84
+ */
85
+ prefersNonDefaultGPU: boolean;
86
+ /**
87
+ * If true, the application has a single main window, and does not support having an additional one opened.
88
+ */
89
+ singleMainWindow: string;
90
+ };
91
+ export type OsxRc = {
92
+ /**
93
+ * The name of the application
94
+ */
95
+ name: string;
96
+ /**
97
+ * The path to the icon file. It should be a .icns file.
98
+ */
99
+ icon: string;
100
+ /**
101
+ * The category that best describes your app for the App Store.
102
+ */
103
+ LSApplicationCategoryType: string;
104
+ /**
105
+ * A unique identifier for a bundle usually in reverse DNS format.
106
+ */
107
+ CFBundleIdentifier: string;
108
+ /**
109
+ * A user-visible short name for the bundle.
110
+ */
111
+ CFBundleName: string;
112
+ /**
113
+ * The user-visible name for the bundle.
114
+ */
115
+ CFBundleDisplayName: string;
116
+ /**
117
+ * A replacement for the app name in text-to-speech operations.
118
+ */
119
+ CFBundleSpokenName: string;
120
+ /**
121
+ * The version of the build that identifies an iteration of the bundle.
122
+ */
123
+ CFBundleVersion: string;
124
+ /**
125
+ * The release or version number of the bundle.
126
+ */
127
+ CFBundleShortVersionString: string;
128
+ /**
129
+ * A human-readable copyright notice for the bundle.
130
+ */
131
+ NSHumanReadableCopyright: string;
132
+ /**
133
+ * A human-readable description of why the application needs access to the local network.
134
+ */
135
+ NSLocalNetworkUsageDescription: string;
136
+ /**
137
+ * Whether the app is subject to Gatekeeper file quarantine. See https://github.com/nwjs/nw.js/issues/7646
138
+ */
139
+ LSFileQuarantineEnabled: boolean;
140
+ };
141
+ export type WinRc = {
142
+ /**
143
+ * The name of the application
144
+ */
145
+ name: string;
146
+ /**
147
+ * The version of the application
148
+ */
149
+ version: string;
150
+ /**
151
+ * Additional information that should be displayed for diagnostic purposes.
152
+ */
153
+ comments: string;
154
+ /**
155
+ * Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required.
156
+ */
157
+ company: string;
158
+ /**
159
+ * File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required.
160
+ */
161
+ fileDescription: string;
162
+ /**
163
+ * Version number of the file. For example, 3.10 or 5.00.RC2. This string is required.
164
+ */
165
+ fileVersion: string;
166
+ /**
167
+ * The path to the icon file. It should be a .ico file.
168
+ */
169
+ icon: string;
170
+ /**
171
+ * Internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required.
172
+ */
173
+ internalName: string;
174
+ /**
175
+ * Copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on. This string is optional.
176
+ */
177
+ legalCopyright: string;
178
+ /**
179
+ * Trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on. This string is optional.
180
+ */
181
+ legalTrademark: string;
182
+ /**
183
+ * Original name of the file, not including a path. This information enables an application to determine whether a file has been renamed by a user. The format of the name depends on the file system for which the file was created. This string is required.
184
+ */
185
+ originalFilename: string;
186
+ /**
187
+ * Information about a private version of the file—for example, Built by TESTER1 on \\TESTBED. This string should be present only if VS_FF_PRIVATEBUILD is specified in the fileflags parameter of the root block.
188
+ */
189
+ privateBuild: string;
190
+ /**
191
+ * Name of the product with which the file is distributed. This string is required.
192
+ */
193
+ productName: string;
194
+ /**
195
+ * Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. This string is required.
196
+ */
197
+ productVersion: string;
198
+ /**
199
+ * Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. This string should be present only if VS_FF_SPECIALBUILD is specified in the fileflags parameter of the root block.
200
+ */
201
+ specialBuild: string;
202
+ /**
203
+ * Language identifier (LCID) of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
204
+ */
205
+ languageCode: number;
206
+ };
207
+ export type BuildOptions = {
208
+ /**
209
+ * Runtime version
210
+ */
211
+ version?: string | "latest" | "stable" | "lts";
212
+ /**
213
+ * Build flavor
214
+ */
215
+ flavor?: "normal" | "sdk";
216
+ /**
217
+ * Target platform
218
+ */
219
+ platform?: "linux" | "osx" | "win";
220
+ /**
221
+ * Target arch
222
+ */
223
+ arch?: "ia32" | "x64" | "arm64";
224
+ /**
225
+ * Versions manifest URI, https or file path
226
+ */
227
+ manifestUrl?: string;
228
+ /**
229
+ * Source directory
230
+ */
231
+ srcDir?: string;
232
+ /**
233
+ * Cache directory
234
+ */
235
+ cacheDir?: string;
236
+ /**
237
+ * Out directory
238
+ */
239
+ outDir?: string;
240
+ /**
241
+ * Platform specific rc
242
+ */
243
+ app?: LinuxRc | WinRc | OsxRc;
244
+ /**
245
+ * File globbing
246
+ */
247
+ glob?: boolean;
248
+ /**
249
+ * Manage manifest
250
+ */
251
+ managedManifest?: boolean | string | object;
252
+ /**
253
+ * Compress built artifacts
254
+ */
255
+ zip?: boolean | "zip" | "tar" | "tgz";
256
+ /**
257
+ * Version specific release metadata.
258
+ */
259
+ releaseInfo?: object;
260
+ };
261
+ /**
262
+ * References:
263
+ * https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
264
+ * @typedef {object} LinuxRc Linux configuration options
265
+ * @property {string} name Name of the application
266
+ * @property {string} genericName Generic name of the application
267
+ * @property {boolean} noDisplay If true the application is not displayed
268
+ * @property {string} comment Tooltip for the entry, for example "View sites on the Internet".
269
+ * @property {string} icon Icon to display in file manager, menus, etc.
270
+ * @property {boolean} hidden TBD
271
+ * @property {string[]} onlyShowIn A list of strings identifying the desktop environments that should (/not) display a given desktop entry
272
+ * @property {string[]} notShowIn A list of strings identifying the desktop environments that should (/not) display a given desktop entry
273
+ * @property {boolean} dBusActivatable A boolean value specifying if D-Bus activation is supported for this application
274
+ * @property {string} tryExec Path to an executable file on disk used to determine if the program is actually installed
275
+ * @property {string} exec Program to execute, possibly with arguments.
276
+ * @property {string} path If entry is of type Application, the working directory to run the program in.
277
+ * @property {boolean} terminal Whether the program runs in a terminal window.
278
+ * @property {string[]} actions Identifiers for application actions.
279
+ * @property {string[]} mimeType The MIME type(s) supported by this application.
280
+ * @property {string[]} categories Categories in which the entry should be shown in a menu
281
+ * @property {string[]} implements A list of interfaces that this application implements.
282
+ * @property {string[]} keywords A list of strings which may be used in addition to other metadata to describe this entry.
283
+ * @property {boolean} startupNotify If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all.
284
+ * @property {string} startupWMClass If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hin
285
+ * @property {boolean} prefersNonDefaultGPU If true, the application prefers to be run on a more powerful discrete GPU if available.
286
+ * @property {string} singleMainWindow If true, the application has a single main window, and does not support having an additional one opened.
287
+ */
288
+ /**
289
+ * References:
290
+ * https://developer.apple.com/documentation/bundleresources/information_property_list
291
+ * @typedef {object} OsxRc OSX resource configuration options
292
+ * @property {string} name The name of the application
293
+ * @property {string} icon The path to the icon file. It should be a .icns file.
294
+ * @property {string} LSApplicationCategoryType The category that best describes your app for the App Store.
295
+ * @property {string} CFBundleIdentifier A unique identifier for a bundle usually in reverse DNS format.
296
+ * @property {string} CFBundleName A user-visible short name for the bundle.
297
+ * @property {string} CFBundleDisplayName The user-visible name for the bundle.
298
+ * @property {string} CFBundleSpokenName A replacement for the app name in text-to-speech operations.
299
+ * @property {string} CFBundleVersion The version of the build that identifies an iteration of the bundle.
300
+ * @property {string} CFBundleShortVersionString The release or version number of the bundle.
301
+ * @property {string} NSHumanReadableCopyright A human-readable copyright notice for the bundle.
302
+ * @property {string} NSLocalNetworkUsageDescription A human-readable description of why the application needs access to the local network.
303
+ * @property {boolean} LSFileQuarantineEnabled Whether the app is subject to Gatekeeper file quarantine. See https://github.com/nwjs/nw.js/issues/7646
304
+ */
305
+ /**
306
+ * References:
307
+ * https://learn.microsoft.com/en-us/windows/win32/msi/version
308
+ * https://learn.microsoft.com/en-gb/windows/win32/sbscs/application-manifests
309
+ * https://learn.microsoft.com/en-us/visualstudio/deployment/trustinfo-element-clickonce-application?view=vs-2022#requestedexecutionlevel
310
+ * https://learn.microsoft.com/en-gb/windows/win32/menurc/versioninfo-resource
311
+ * @typedef {object} WinRc Windows configuration options. More info
312
+ * @property {string} name The name of the application
313
+ * @property {string} version The version of the application
314
+ * @property {string} comments Additional information that should be displayed for diagnostic purposes.
315
+ * @property {string} company Company that produced the file—for example, Microsoft Corporation or Standard Microsystems Corporation, Inc. This string is required.
316
+ * @property {string} fileDescription File description to be presented to users. This string may be displayed in a list box when the user is choosing files to install. For example, Keyboard Driver for AT-Style Keyboards. This string is required.
317
+ * @property {string} fileVersion Version number of the file. For example, 3.10 or 5.00.RC2. This string is required.
318
+ * @property {string} icon The path to the icon file. It should be a .ico file.
319
+ * @property {string} internalName Internal name of the file, if one exists—for example, a module name if the file is a dynamic-link library. If the file has no internal name, this string should be the original filename, without extension. This string is required.
320
+ * @property {string} legalCopyright Copyright notices that apply to the file. This should include the full text of all notices, legal symbols, copyright dates, and so on. This string is optional.
321
+ * @property {string} legalTrademark Trademarks and registered trademarks that apply to the file. This should include the full text of all notices, legal symbols, trademark numbers, and so on. This string is optional.
322
+ * @property {string} originalFilename Original name of the file, not including a path. This information enables an application to determine whether a file has been renamed by a user. The format of the name depends on the file system for which the file was created. This string is required.
323
+ * @property {string} privateBuild Information about a private version of the file—for example, Built by TESTER1 on \\TESTBED. This string should be present only if VS_FF_PRIVATEBUILD is specified in the fileflags parameter of the root block.
324
+ * @property {string} productName Name of the product with which the file is distributed. This string is required.
325
+ * @property {string} productVersion Version of the product with which the file is distributed—for example, 3.10 or 5.00.RC2. This string is required.
326
+ * @property {string} specialBuild Text that specifies how this version of the file differs from the standard version—for example, Private build for TESTER1 solving mouse problems on M250 and M250E computers. This string should be present only if VS_FF_SPECIALBUILD is specified in the fileflags parameter of the root block.
327
+ * @property {number} languageCode Language identifier (LCID) of the file, defined by Microsoft, see: https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
328
+ */
329
+ /**
330
+ * @typedef {object} BuildOptions
331
+ * @property {string | "latest" | "stable" | "lts"} [version = "latest"] Runtime version
332
+ * @property {"normal" | "sdk"} [flavor = "normal"] Build flavor
333
+ * @property {"linux" | "osx" | "win"} [platform] Target platform
334
+ * @property {"ia32" | "x64" | "arm64"} [arch] Target arch
335
+ * @property {string} [manifestUrl = "https://nwjs.io/versions.json"] Versions manifest URI, https or file path
336
+ * @property {string} [srcDir = "./src"] Source directory
337
+ * @property {string} [cacheDir = "./cache"] Cache directory
338
+ * @property {string} [outDir = "./out"] Out directory
339
+ * @property {LinuxRc | WinRc | OsxRc} [app] Platform specific rc
340
+ * @property {boolean} [glob = true] File globbing
341
+ * @property {boolean | string | object} [managedManifest = false] Manage manifest
342
+ * @property {boolean | "zip" | "tar" | "tgz"} [zip = false] Compress built artifacts
343
+ * @property {object} [releaseInfo = {}] Version specific release metadata.
344
+ */
345
+ /**
346
+ * Build NW.js application.
347
+ * @async
348
+ * @function
349
+ * @param {BuildOptions} options - Build options
350
+ * @returns {Promise<void>}
351
+ */
352
+ declare function build({ version, flavor, platform, arch, srcDir, cacheDir, outDir, app, glob, managedManifest, zip, releaseInfo, }: BuildOptions): Promise<void>;
353
+ export default build;
package/types/osx.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ *
3
+ * @param {object} options - Options.
4
+ * @param {string} options.version - NW.js version.
5
+ * @param {import("./main.js").OsxRc} options.app - Application configuration.
6
+ * @param {string} options.outDir - Output directory.
7
+ * @param {any} options.releaseInfo - Release information, shaped by https://nwjs.io/versions.json.
8
+ * @returns {Promise<void>} - Promise.
9
+ */
10
+ export default function setOsxConfig({ version, app, outDir, releaseInfo, }: {
11
+ version: string;
12
+ app: import("./main.js").OsxRc;
13
+ outDir: string;
14
+ releaseInfo: any;
15
+ }): Promise<void>;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Glob files.
3
+ * @async
4
+ * @function
5
+ * @param {object} options - glob file options
6
+ * @param {string | string[]} options.srcDir - app src dir
7
+ * @param {boolean} options.glob - glob flag
8
+ * @returns {Promise<string[] | string>} - Returns array of file paths, or `srcDir` as-is when `glob` is false
9
+ */
10
+ declare function globFiles({ srcDir, glob }: {
11
+ srcDir: string | string[];
12
+ glob: boolean;
13
+ }): Promise<string[] | string>;
14
+ declare const _default: {
15
+ PLATFORM_KV: {
16
+ darwin: string;
17
+ linux: string;
18
+ win32: string;
19
+ };
20
+ ARCH_KV: {
21
+ x64: string;
22
+ ia32: string;
23
+ arm64: string;
24
+ };
25
+ globFiles: typeof globFiles;
26
+ };
27
+ export default _default;