@lakutata/builder 3.1.1 → 3.1.5
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 +11 -1
- package/README.zh-CN.md +5 -1
- package/dist/esm/index.js +3 -0
- package/dist/esm/lib/Archive.js +3 -2
- package/dist/esm/lib/Bundle.js +12 -5
- package/dist/esm/lib/Directories.js +18 -0
- package/dist/esm/lib/Executable.js +27 -6
- package/dist/esm/lib/Files.js +44 -5
- package/dist/esm/lib/Installer.js +26 -12
- package/dist/esm/lib/Native.js +58 -4
- package/dist/esm/lib/NativeRuntime.js +2 -0
- package/dist/esm/lib/linux/Linux.js +57 -8
- package/dist/esm/lib/mac/Mac.js +39 -11
- package/dist/esm/lib/nwjs/Addons.js +307 -0
- package/dist/esm/lib/nwjs/Package.js +149 -0
- package/dist/esm/lib/nwjs/Runtime.js +214 -0
- package/dist/esm/lib/nwjs/Stage.js +92 -0
- package/dist/esm/lib/win/Windows.js +63 -41
- package/dist/types/index.d.ts +4 -0
- package/dist/types/lib/Bundle.d.ts +5 -0
- package/dist/types/lib/Directories.d.ts +8 -0
- package/dist/types/lib/Executable.d.ts +7 -0
- package/dist/types/lib/Files.d.ts +11 -1
- package/dist/types/lib/Installer.d.ts +33 -4
- package/dist/types/lib/Native.d.ts +23 -1
- package/dist/types/lib/mac/Mac.d.ts +1 -1
- package/dist/types/lib/nwjs/Addons.d.ts +51 -0
- package/dist/types/lib/nwjs/Package.d.ts +52 -0
- package/dist/types/lib/nwjs/Runtime.d.ts +116 -0
- package/dist/types/lib/nwjs/Stage.d.ts +104 -0
- package/dist/types/lib/win/Windows.d.ts +28 -0
- package/package.json +2 -2
|
@@ -12,8 +12,8 @@ export const WINDOWS_TARGETS = ['nsis', 'msi', 'zip'];
|
|
|
12
12
|
/**
|
|
13
13
|
* The architecture of the packages (the one of the executable)
|
|
14
14
|
*/
|
|
15
|
-
function packageArch() {
|
|
16
|
-
return
|
|
15
|
+
function packageArch(plan) {
|
|
16
|
+
return { arm64: 'arm64', ia32: 'x86' }[plan.arch] ?? 'x64';
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* A text of XML
|
|
@@ -164,8 +164,9 @@ function numericVersion(version) {
|
|
|
164
164
|
* @param stage the files it installs
|
|
165
165
|
* @param file
|
|
166
166
|
* @param scripts the scripts of the application (written with the mark of UTF-8, which Windows PowerShell reads them by)
|
|
167
|
+
* @internal
|
|
167
168
|
*/
|
|
168
|
-
function nsisScript(plan, stage, file, scripts) {
|
|
169
|
+
export function nsisScript(plan, stage, file, scripts) {
|
|
169
170
|
const uninstallKey = `Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${plan.appId}`;
|
|
170
171
|
//A text given (its $ are not variables of NSIS), a path of NSIS (its variables: $INSTDIR)
|
|
171
172
|
const string = (value) => `"${value.replace(/\$/g, '$$$$').replace(/"/g, '$\\"')}"`;
|
|
@@ -187,15 +188,20 @@ function nsisScript(plan, stage, file, scripts) {
|
|
|
187
188
|
const macro = (name) => scripts.include ? [` !ifmacrodef ${name}`, ` !insertmacro ${name}`, ' !endif'] : [];
|
|
188
189
|
//The directory of the application, given to its scripts
|
|
189
190
|
const environment = ' System::Call \'Kernel32::SetEnvironmentVariable(t "LAKUTATA_INSTALL_DIR", t "$INSTDIR")i\'';
|
|
191
|
+
//A desktop application: shortcuts to its executable, no installation script (PowerShell) of the service and of the PATH
|
|
192
|
+
const desktop = plan.desktop;
|
|
193
|
+
const shortcuts = desktop ? [`$SMPROGRAMS\\${plan.productName}.lnk`, `$DESKTOP\\${plan.productName}.lnk`] : [];
|
|
194
|
+
//A 32-bit program (Windows 7 32-bit) in the programs of 32 bits, with the 32-bit registry
|
|
195
|
+
const wide = plan.arch !== 'ia32';
|
|
190
196
|
return [
|
|
191
197
|
'Unicode true',
|
|
192
198
|
'ManifestDPIAware true',
|
|
193
|
-
'!include "x64.nsh"',
|
|
199
|
+
...wide ? ['!include "x64.nsh"'] : [],
|
|
194
200
|
`Name ${string(plan.productName)}`,
|
|
195
201
|
`OutFile ${string(file)}`,
|
|
196
202
|
//The icon of the application
|
|
197
203
|
...plan.icon ? [`Icon ${string(plan.icon)}`, `UninstallIcon ${string(plan.icon)}`] : [],
|
|
198
|
-
`InstallDir ${variables(`$PROGRAMFILES64\\${plan.name}`)}`,
|
|
204
|
+
`InstallDir ${variables(`${wide ? '$PROGRAMFILES64' : '$PROGRAMFILES'}\\${plan.name}`)}`,
|
|
199
205
|
'RequestExecutionLevel admin',
|
|
200
206
|
'SetCompressor /SOLID lzma',
|
|
201
207
|
'ShowInstDetails show',
|
|
@@ -210,13 +216,11 @@ function nsisScript(plan, stage, file, scripts) {
|
|
|
210
216
|
'',
|
|
211
217
|
'; The 64-bit registry and system (the installer is a 32-bit program)',
|
|
212
218
|
'Function .onInit',
|
|
213
|
-
' SetRegView 64',
|
|
214
|
-
' ${DisableX64FSRedirection}',
|
|
219
|
+
...wide ? [' SetRegView 64', ' ${DisableX64FSRedirection}'] : [],
|
|
215
220
|
...macro('customInit'),
|
|
216
221
|
'FunctionEnd',
|
|
217
222
|
'Function un.onInit',
|
|
218
|
-
' SetRegView 64',
|
|
219
|
-
' ${DisableX64FSRedirection}',
|
|
223
|
+
...wide ? [' SetRegView 64', ' ${DisableX64FSRedirection}'] : [],
|
|
220
224
|
...macro('customUnInit'),
|
|
221
225
|
'FunctionEnd',
|
|
222
226
|
'',
|
|
@@ -225,32 +229,36 @@ function nsisScript(plan, stage, file, scripts) {
|
|
|
225
229
|
environment,
|
|
226
230
|
' ; An upgrade replaces the application installed',
|
|
227
231
|
' StrCpy $R9 "install"',
|
|
228
|
-
|
|
232
|
+
` IfFileExists ${variables(`$INSTDIR\\${desktop ? desktop.executable : 'installer.ps1'}`)} 0 +2`,
|
|
229
233
|
' StrCpy $R9 "upgrade"',
|
|
230
234
|
...hook('preinstall'),
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
...desktop ? [] : [
|
|
236
|
+
' ; The service of the version replaced is stopped: its files are replaced',
|
|
237
|
+
' IfFileExists "$INSTDIR\\installer.ps1" 0 +3',
|
|
238
|
+
` ${script('stop')}`,
|
|
239
|
+
' Pop $0'
|
|
240
|
+
],
|
|
235
241
|
' SetOutPath "$INSTDIR"',
|
|
236
242
|
` File /r ${string(`${stage}\\*.*`)}`,
|
|
243
|
+
...shortcuts.map((shortcut) => ` CreateShortCut ${variables(shortcut)} ${variables(`$INSTDIR\\${desktop.executable}`)}`),
|
|
237
244
|
' WriteUninstaller "$INSTDIR\\uninstall.exe"',
|
|
238
245
|
` WriteRegStr HKLM ${string(uninstallKey)} "DisplayName" ${string(plan.productName)}`,
|
|
239
246
|
` WriteRegStr HKLM ${string(uninstallKey)} "DisplayVersion" ${string(plan.version)}`,
|
|
240
247
|
` WriteRegStr HKLM ${string(uninstallKey)} "Publisher" ${string(plan.vendor ?? plan.maintainer)}`,
|
|
241
248
|
` WriteRegStr HKLM ${string(uninstallKey)} "InstallLocation" "$INSTDIR"`,
|
|
242
|
-
` WriteRegStr HKLM ${string(uninstallKey)} "DisplayIcon" ${variables(`$INSTDIR\\${plan.program}.exe`)}`,
|
|
249
|
+
` WriteRegStr HKLM ${string(uninstallKey)} "DisplayIcon" ${variables(`$INSTDIR\\${desktop ? desktop.executable : `${plan.program}.exe`}`)}`,
|
|
243
250
|
` WriteRegStr HKLM ${string(uninstallKey)} "UninstallString" '"$INSTDIR\\uninstall.exe"'`,
|
|
244
251
|
` WriteRegStr HKLM ${string(uninstallKey)} "QuietUninstallString" '"$INSTDIR\\uninstall.exe" /S'`,
|
|
245
252
|
` WriteRegDWORD HKLM ${string(uninstallKey)} "NoModify" 1`,
|
|
246
253
|
` WriteRegDWORD HKLM ${string(uninstallKey)} "NoRepair" 1`,
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
254
|
+
...desktop ? [] : [
|
|
255
|
+
` ${script('install')}`,
|
|
256
|
+
' Pop $0',
|
|
257
|
+
' StrCmp $0 "0" +2',
|
|
258
|
+
' Abort "The installation failed ($0)"'
|
|
259
|
+
],
|
|
251
260
|
...hook('postinstall'),
|
|
252
|
-
` ${script('start')}`,
|
|
253
|
-
' Pop $0',
|
|
261
|
+
...desktop ? [] : [` ${script('start')}`, ' Pop $0'],
|
|
254
262
|
...macro('customInstall'),
|
|
255
263
|
'SectionEnd',
|
|
256
264
|
'',
|
|
@@ -259,8 +267,7 @@ function nsisScript(plan, stage, file, scripts) {
|
|
|
259
267
|
environment,
|
|
260
268
|
' StrCpy $R9 "remove"',
|
|
261
269
|
...macro('customUnInstall'),
|
|
262
|
-
` ${script('uninstall')}`,
|
|
263
|
-
' Pop $0',
|
|
270
|
+
...desktop ? shortcuts.map((shortcut) => ` Delete ${variables(shortcut)}`) : [` ${script('uninstall')}`, ' Pop $0'],
|
|
264
271
|
...hook('preremove'),
|
|
265
272
|
' RMDir /r "$INSTDIR"',
|
|
266
273
|
` DeleteRegKey HKLM ${string(uninstallKey)}`,
|
|
@@ -341,9 +348,11 @@ function msiScripts(hooks) {
|
|
|
341
348
|
* @param stage the files it installs
|
|
342
349
|
* @param serviceDirectory the files of its service (WinSW and its configuration)
|
|
343
350
|
* @param environment the environment file
|
|
351
|
+
* @internal
|
|
344
352
|
*/
|
|
345
|
-
function wixSource(plan, stage, serviceDirectory, environment) {
|
|
353
|
+
export function wixSource(plan, stage, serviceDirectory, environment) {
|
|
346
354
|
const scripts = msiScripts(plan.scripts.msi?.hooks ?? {});
|
|
355
|
+
const desktop = plan.desktop;
|
|
347
356
|
const id = (prefix, value) => `${prefix}${createHash('sha1').update(value).digest('hex').slice(0, 30)}`;
|
|
348
357
|
const components = [];
|
|
349
358
|
const directory = (absolute, relative, depth) => {
|
|
@@ -379,20 +388,33 @@ function wixSource(plan, stage, serviceDirectory, environment) {
|
|
|
379
388
|
...plan.icon ? [` <Icon Id="ProductIcon.ico" SourceFile="${xml(plan.icon)}"/>`, ' <Property Id="ARPPRODUCTICON" Value="ProductIcon.ico"/>'] : [],
|
|
380
389
|
` <Property Id="ARPINSTALLLOCATION" Value="[INSTALLDIR]"/>`,
|
|
381
390
|
' <Directory Id="TARGETDIR" Name="SourceDir">',
|
|
382
|
-
|
|
391
|
+
` <Directory Id="${plan.arch === 'ia32' ? 'ProgramFilesFolder' : 'ProgramFiles64Folder'}">`,
|
|
383
392
|
` <Directory Id="INSTALLDIR" Name="${xml(plan.name)}">`,
|
|
384
393
|
...files,
|
|
385
394
|
' </Directory>',
|
|
386
395
|
' </Directory>',
|
|
387
|
-
' <Directory Id="
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
396
|
+
...desktop ? [' <Directory Id="ProgramMenuFolder"/>', ' <Directory Id="DesktopFolder"/>'] : [
|
|
397
|
+
' <Directory Id="CommonAppDataFolder">',
|
|
398
|
+
` <Directory Id="DATADIR" Name="${xml(plan.name)}">`,
|
|
399
|
+
' <Directory Id="LOGSDIR" Name="logs"/>',
|
|
400
|
+
' </Directory>',
|
|
401
|
+
' </Directory>'
|
|
402
|
+
],
|
|
392
403
|
' </Directory>',
|
|
393
|
-
//The data, the logs and the environment file are kept by the removals
|
|
394
|
-
|
|
395
|
-
|
|
404
|
+
//The data, the logs and the environment file are kept by the removals (a service, a program of the command line)
|
|
405
|
+
...desktop ? [] : [
|
|
406
|
+
` <Component Id="Data" Directory="DATADIR" Guid="${namedUuid(`${plan.appId}:data`)}" Permanent="yes" KeyPath="yes"><CreateFolder/></Component>`,
|
|
407
|
+
` <Component Id="Logs" Directory="LOGSDIR" Guid="${namedUuid(`${plan.appId}:logs`)}" Permanent="yes" KeyPath="yes"><CreateFolder/></Component>`
|
|
408
|
+
],
|
|
409
|
+
//The shortcuts of a desktop application, their key a value of the registry of the user installing (the ones of
|
|
410
|
+
//the menus and of the desktop must be of HKCU: ICE43, ICE57)
|
|
411
|
+
...desktop ? [
|
|
412
|
+
` <Component Id="Shortcuts" Directory="INSTALLDIR" Guid="${namedUuid(`${plan.appId}:shortcuts`)}">`,
|
|
413
|
+
` <Shortcut Id="ProgramMenuShortcut" Directory="ProgramMenuFolder" Name="${xml(plan.productName)}" Target="[INSTALLDIR]${xml(desktop.executable)}" WorkingDirectory="INSTALLDIR"/>`,
|
|
414
|
+
` <Shortcut Id="DesktopShortcut" Directory="DesktopFolder" Name="${xml(plan.productName)}" Target="[INSTALLDIR]${xml(desktop.executable)}" WorkingDirectory="INSTALLDIR"/>`,
|
|
415
|
+
` <RegistryValue Root="HKCU" Key="Software\\${xml(plan.appId)}" Name="Shortcuts" Type="integer" Value="1" KeyPath="yes"/>`,
|
|
416
|
+
' </Component>'
|
|
417
|
+
] : [],
|
|
396
418
|
...environment ? [` <Component Id="Environment" Directory="DATADIR" Guid="${namedUuid(`${plan.appId}:environment`)}" Permanent="yes" NeverOverwrite="yes"><File Id="EnvironmentFile" Name="${xml(`${plan.name}.env`)}" Source="${xml(environment)}" KeyPath="yes"/></Component>`] : [],
|
|
397
419
|
...plan.addToPath ? [` <Component Id="Path" Directory="INSTALLDIR" Guid="${namedUuid(`${plan.appId}:path`)}" KeyPath="yes"><Environment Id="Path" Name="PATH" Value="[INSTALLDIR]" Permanent="no" Part="last" Action="set" System="yes"/></Component>`] : [],
|
|
398
420
|
...service ? [
|
|
@@ -419,8 +441,7 @@ function wixSource(plan, stage, serviceDirectory, environment) {
|
|
|
419
441
|
] : [],
|
|
420
442
|
' <Feature Id="Application" Level="1">',
|
|
421
443
|
...components.map((component) => ` <ComponentRef Id="${component}"/>`),
|
|
422
|
-
' <ComponentRef Id="Data"/>',
|
|
423
|
-
' <ComponentRef Id="Logs"/>',
|
|
444
|
+
...desktop ? [' <ComponentRef Id="Shortcuts"/>'] : [' <ComponentRef Id="Data"/>', ' <ComponentRef Id="Logs"/>'],
|
|
424
445
|
...environment ? [' <ComponentRef Id="Environment"/>'] : [],
|
|
425
446
|
...plan.addToPath ? [' <ComponentRef Id="Path"/>'] : [],
|
|
426
447
|
...service ? [' <ComponentRef Id="Service"/>'] : [],
|
|
@@ -467,7 +488,7 @@ export async function buildWindowsPackages(plan, targets, work, outdir) {
|
|
|
467
488
|
}
|
|
468
489
|
for (const target of targets) {
|
|
469
490
|
if (target === 'zip') {
|
|
470
|
-
const base = `${plan.name}-${plan.version}-win-${packageArch()}`;
|
|
491
|
+
const base = `${plan.name}-${plan.version}-win-${packageArch(plan)}`;
|
|
471
492
|
await rm(path.join(work, base), { recursive: true, force: true });
|
|
472
493
|
await cp(plan.directory, path.join(work, base), { recursive: true });
|
|
473
494
|
const file = path.join(outdir, `${base}.zip`);
|
|
@@ -485,8 +506,9 @@ export async function buildWindowsPackages(plan, targets, work, outdir) {
|
|
|
485
506
|
if (service)
|
|
486
507
|
for (const name of readdirSync(serviceDirectory).filter((name) => !name.endsWith('.env')))
|
|
487
508
|
await copyFile(path.join(serviceDirectory, name), path.join(stage, name));
|
|
488
|
-
//Windows PowerShell reads the scripts of UTF-8 by their mark
|
|
489
|
-
|
|
509
|
+
//Windows PowerShell reads the scripts of UTF-8 by their mark (a desktop application has none)
|
|
510
|
+
if (!plan.desktop)
|
|
511
|
+
await writeFile(path.join(stage, 'installer.ps1'), `\ufeff${installerScript(plan)}`);
|
|
490
512
|
//The scripts of the application, extracted by the installer when it runs them
|
|
491
513
|
const own = plan.scripts.nsis;
|
|
492
514
|
const hooks = {};
|
|
@@ -502,7 +524,7 @@ export async function buildWindowsPackages(plan, targets, work, outdir) {
|
|
|
502
524
|
include = path.join(directory, 'include.nsh');
|
|
503
525
|
await writeFile(include, own.include.content);
|
|
504
526
|
}
|
|
505
|
-
const file = path.join(outdir, `${plan.name}-${plan.version}-${packageArch()}-setup.exe`);
|
|
527
|
+
const file = path.join(outdir, `${plan.name}-${plan.version}-${packageArch(plan)}-setup.exe`);
|
|
506
528
|
await rm(file, { force: true });
|
|
507
529
|
const script = path.join(work, 'installer.nsi');
|
|
508
530
|
await writeFile(script, `\ufeff${nsisScript(plan, stage, file, { hooks: hooks, include: include })}`);
|
|
@@ -515,9 +537,9 @@ export async function buildWindowsPackages(plan, targets, work, outdir) {
|
|
|
515
537
|
await writeFile(source, wixSource(plan, plan.directory, serviceDirectory, environment));
|
|
516
538
|
const candle = await ensureTool('wix');
|
|
517
539
|
const light = path.join(path.dirname(candle), 'light.exe');
|
|
518
|
-
const file = path.join(outdir, `${plan.name}-${plan.version}-${packageArch()}.msi`);
|
|
540
|
+
const file = path.join(outdir, `${plan.name}-${plan.version}-${packageArch(plan)}.msi`);
|
|
519
541
|
await rm(file, { force: true });
|
|
520
|
-
await must(candle, ['-nologo', '-arch', packageArch(), '-ext', 'WixUtilExtension', '-out', path.join(work, 'package.wixobj'), source], work, 'The package of Windows Installer');
|
|
542
|
+
await must(candle, ['-nologo', '-arch', packageArch(plan), '-ext', 'WixUtilExtension', '-out', path.join(work, 'package.wixobj'), source], work, 'The package of Windows Installer');
|
|
521
543
|
await must(light, ['-nologo', '-ext', 'WixUtilExtension', '-spdb', '-out', file, path.join(work, 'package.wixobj')], work, 'The package of Windows Installer');
|
|
522
544
|
files.push({ target: target, file: file, size: (await stat(file)).size });
|
|
523
545
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -11,3 +11,7 @@ export { INSTALLER_HOOKS, NATIVE_HOOKS, type InstallerHook, type InstallerScript
|
|
|
11
11
|
export { detectLibc } from './lib/Platform.js';
|
|
12
12
|
export { WINDOWS_TARGETS, type WindowsTarget } from './lib/win/Windows.js';
|
|
13
13
|
export { MAC_TARGETS, type MacTarget } from './lib/mac/Mac.js';
|
|
14
|
+
export { downloadNwjs, nwjsPlatform, nwjsRelease, nwjsReleases, type NwjsFlavor, type NwjsRelease, type NwjsRuntime, type NwjsRuntimeOptions } from './lib/nwjs/Runtime.js';
|
|
15
|
+
export { stageNwjsApp, type NwjsConfig, type NwjsStage, type NwjsStageOptions } from './lib/nwjs/Stage.js';
|
|
16
|
+
export type { NwjsAddons } from './lib/nwjs/Addons.js';
|
|
17
|
+
export { buildNwjsApp, type NwjsApp, type NwjsAppOptions } from './lib/nwjs/Package.js';
|
|
@@ -32,6 +32,11 @@ export type BundleOptions = {
|
|
|
32
32
|
* The runtime running the bundle: node (by default), or bun (the executables of Bun, which bundle it again)
|
|
33
33
|
*/
|
|
34
34
|
runtime?: 'node' | 'bun';
|
|
35
|
+
/**
|
|
36
|
+
* The version of Node.js running the bundle ("18.10", the one of NW.js 0.70): the bundle is written in the syntax that
|
|
37
|
+
* version reads; the version running the build by default
|
|
38
|
+
*/
|
|
39
|
+
node?: string;
|
|
35
40
|
/**
|
|
36
41
|
* Whether the bundle is the one of an executable (buildExecutable): it runs the scripts of its tree it is started
|
|
37
42
|
* for, in both layouts, and on Node.js it loads the modules left out of it from next to the executable
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copy a directory into another one, its links kept as they are: cp -a on macOS and Linux (the copy of Node.js turns
|
|
3
|
+
* the relative links into absolute ones before Node.js 18.17 and 20.2: its option verbatimSymlinks), the copy of Node.js
|
|
4
|
+
* on Windows (its directories have no links)
|
|
5
|
+
* @param source
|
|
6
|
+
* @param target
|
|
7
|
+
*/
|
|
8
|
+
export declare function copyDirectory(source: string, target: string): Promise<void>;
|
|
@@ -11,6 +11,13 @@ export type ExecutableOptions = Omit<BundleOptions, 'outfile' | 'native' | 'dire
|
|
|
11
11
|
* installers, the images)
|
|
12
12
|
*/
|
|
13
13
|
layout?: 'file' | 'directory';
|
|
14
|
+
/**
|
|
15
|
+
* The node program embedded in the executable, which also makes its single executable application. Another Node.js
|
|
16
|
+
* than the one running the build (20.12, 21.7 or later, which have the assets of the single executable applications),
|
|
17
|
+
* so that an older Node.js can run the build; the bundle is written in the syntax of the node program. The one
|
|
18
|
+
* running the build by default.
|
|
19
|
+
*/
|
|
20
|
+
nodeProgram?: string;
|
|
14
21
|
};
|
|
15
22
|
export type ExecutableResult = {
|
|
16
23
|
name: string;
|
|
@@ -27,6 +27,14 @@ type ScriptPath = {
|
|
|
27
27
|
*/
|
|
28
28
|
base?: string;
|
|
29
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* The packages sharing the framework and holding addons, bundled with the application: the package of a file, the
|
|
32
|
+
* native files of one of its directories (shipped by the paths to its own directories)
|
|
33
|
+
*/
|
|
34
|
+
export type AddonPackages = {
|
|
35
|
+
packageOf(file: string): string | undefined;
|
|
36
|
+
nativeFilesOf(root: string, directory: string): string[];
|
|
37
|
+
};
|
|
30
38
|
/**
|
|
31
39
|
* What a path from a module gives: the directory of its pattern, the parts from it, the scripts to bundle and the files
|
|
32
40
|
* to copy (the files of its directories of data), or why it cannot be shipped
|
|
@@ -54,6 +62,7 @@ type Targets = {
|
|
|
54
62
|
* paths their users give)
|
|
55
63
|
*/
|
|
56
64
|
export declare class FileCollector {
|
|
65
|
+
protected readonly addons?: AddonPackages | undefined;
|
|
57
66
|
/**
|
|
58
67
|
* The scripts: their paths in the native tree, and their files
|
|
59
68
|
*/
|
|
@@ -71,8 +80,9 @@ export declare class FileCollector {
|
|
|
71
80
|
/**
|
|
72
81
|
* @param project The directory of the project: the scripts are named from it (as the modules the bundler gives, its
|
|
73
82
|
* real path)
|
|
83
|
+
* @param addons The packages sharing the framework and holding addons
|
|
74
84
|
*/
|
|
75
|
-
constructor(project: string);
|
|
85
|
+
constructor(project: string, addons?: AddonPackages | undefined);
|
|
76
86
|
/**
|
|
77
87
|
* The key of a directory in the tree ("/" separated): its path from the project; outside of the project (the
|
|
78
88
|
* packages of a workspace, linked), its path from the node_modules holding it, else a hash of its path (the paths of
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NwjsApp } from './nwjs/Package.js';
|
|
1
2
|
import { type ExecutableResult } from './Executable.js';
|
|
2
3
|
import { type InstallerScripts, type NativeScripts, type TargetScripts } from './Scripts.js';
|
|
3
4
|
import { type LinuxTarget } from './linux/Linux.js';
|
|
@@ -63,9 +64,10 @@ export type InstallerConfig = {
|
|
|
63
64
|
vendor?: string;
|
|
64
65
|
/**
|
|
65
66
|
* The runtime of the executable: node (by default) or bun; electron for the Electron applications, whose installers
|
|
66
|
-
* are made by electron-builder
|
|
67
|
+
* are made by electron-builder; nwjs for the applications of NW.js (lakutata.nwjs: its version), installed as desktop
|
|
68
|
+
* applications (shortcuts, /Applications, desktop entries)
|
|
67
69
|
*/
|
|
68
|
-
runtime?: 'node' | 'bun' | 'electron';
|
|
70
|
+
runtime?: 'node' | 'bun' | 'electron' | 'nwjs';
|
|
69
71
|
/**
|
|
70
72
|
* The configuration of electron-builder of an Electron application, merged over the one made from lakutata.installer
|
|
71
73
|
*/
|
|
@@ -168,6 +170,15 @@ export type InstallerOptions = {
|
|
|
168
170
|
* The directory of the packages, dist/installer by default
|
|
169
171
|
*/
|
|
170
172
|
outdir?: string;
|
|
173
|
+
/**
|
|
174
|
+
* The node program embedded in the executable (nodeProgram of buildExecutable), the one running the build by default
|
|
175
|
+
*/
|
|
176
|
+
nodeProgram?: string;
|
|
177
|
+
/**
|
|
178
|
+
* The architecture of an application of NW.js (process.arch), the one of the machine by default: ia32 for the 32-bit
|
|
179
|
+
* systems of Windows (Windows 7)
|
|
180
|
+
*/
|
|
181
|
+
arch?: string;
|
|
171
182
|
};
|
|
172
183
|
export type InstallerResult = {
|
|
173
184
|
name: string;
|
|
@@ -181,9 +192,13 @@ export type InstallerResult = {
|
|
|
181
192
|
size: number;
|
|
182
193
|
}[];
|
|
183
194
|
/**
|
|
184
|
-
* The executable they install
|
|
195
|
+
* The executable they install, undefined for the applications of NW.js
|
|
196
|
+
*/
|
|
197
|
+
executable?: ExecutableResult;
|
|
198
|
+
/**
|
|
199
|
+
* The application of NW.js they install (runtime nwjs)
|
|
185
200
|
*/
|
|
186
|
-
|
|
201
|
+
nwjs?: NwjsApp;
|
|
187
202
|
warnings: string[];
|
|
188
203
|
};
|
|
189
204
|
/**
|
|
@@ -231,6 +246,20 @@ export type InstallerPlan = {
|
|
|
231
246
|
* (lakutata.icon), none without it
|
|
232
247
|
*/
|
|
233
248
|
icon?: string;
|
|
249
|
+
/**
|
|
250
|
+
* The architecture of the program (process.arch: x64, ia32, arm64), which names the packages and, on Windows, the
|
|
251
|
+
* directory of the programs it is installed into
|
|
252
|
+
*/
|
|
253
|
+
arch: string;
|
|
254
|
+
/**
|
|
255
|
+
* A desktop application (NW.js): its executable in the directory (<product>.exe, <product>.app, <program>), given
|
|
256
|
+
* shortcuts (Windows), a desktop entry and icons (Linux), installed into /Applications (macOS); without service and
|
|
257
|
+
* outside the PATH by default; its icon (a PNG image: lakutata.icon), which the icons of Linux are made of
|
|
258
|
+
*/
|
|
259
|
+
desktop?: {
|
|
260
|
+
executable: string;
|
|
261
|
+
icon?: string;
|
|
262
|
+
};
|
|
234
263
|
};
|
|
235
264
|
/**
|
|
236
265
|
* Make the installers of the application for the platform it is made on (the installers of the other platforms are
|
|
@@ -121,10 +121,32 @@ export declare class NativeCollector {
|
|
|
121
121
|
}[];
|
|
122
122
|
/**
|
|
123
123
|
* Whether a package is left out of the bundle: it holds addons, or one of its dependencies does (it loads them,
|
|
124
|
-
* with computed paths often), and it is
|
|
124
|
+
* with computed paths often), and it is neither the project nor a package sharing the framework
|
|
125
125
|
* @param root
|
|
126
126
|
*/
|
|
127
127
|
protected isNative(root: string | undefined): root is string;
|
|
128
|
+
/**
|
|
129
|
+
* The package sharing the framework and holding addons a file belongs to: bundled with the application, the paths
|
|
130
|
+
* to its own directories ship their native files (its addons, its manifest, its data)
|
|
131
|
+
* @param file
|
|
132
|
+
* @returns its directory, undefined for a file of another package
|
|
133
|
+
*/
|
|
134
|
+
addonPackageOf(file: string): string | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* The native files of a directory of a package holding addons: the files node loads at run time (its addons, its
|
|
137
|
+
* libraries, its manifest, its data), without its scripts (bundled) and what node never loads
|
|
138
|
+
* @param root the directory of the package
|
|
139
|
+
* @param directory
|
|
140
|
+
*/
|
|
141
|
+
nativeFilesOf(root: string, directory: string): string[];
|
|
142
|
+
/**
|
|
143
|
+
* The addons of the packages sharing the framework bundled with the application which are not shipped: none of
|
|
144
|
+
* their addons is loaded by a require or a path the bundler follows (they would not be found at run time)
|
|
145
|
+
* @param inputs the files bundled
|
|
146
|
+
* @param shipped the files of the tree (the addons loaded by a require, the files read by a path from a module)
|
|
147
|
+
* @returns the warnings, one by package
|
|
148
|
+
*/
|
|
149
|
+
unshippedAddons(inputs: Iterable<string>, shipped: Iterable<string>): string[];
|
|
128
150
|
/**
|
|
129
151
|
* Resolve an import as esbuild does
|
|
130
152
|
* @param build
|
|
@@ -2,7 +2,7 @@ import type { InstallerPlan } from '../Installer.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* The installers of macOS: the package of its installer, and the archive of the directory of the executable
|
|
4
4
|
*/
|
|
5
|
-
export declare const MAC_TARGETS: readonly ["pkg", "tar.gz"];
|
|
5
|
+
export declare const MAC_TARGETS: readonly ["pkg", "dmg", "tar.gz"];
|
|
6
6
|
export type MacTarget = typeof MAC_TARGETS[number];
|
|
7
7
|
/**
|
|
8
8
|
* Make the installers of macOS of an application: the package installed by its installer (pkgbuild, productbuild), the
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { NativeFile } from '../Native.js';
|
|
2
|
+
import { type NwjsRelease } from './Runtime.js';
|
|
3
|
+
/**
|
|
4
|
+
* Make an addon of Windows load in NW.js: the libraries it imports (imported or delay-loaded) named node.exe are named
|
|
5
|
+
* node.dll, the library of NW.js holding the functions of Node.js (Node-API). The delay-load hook of node-gyp gives an
|
|
6
|
+
* addon the executable when it loads node.exe, which in NW.js does not export them: the addon fails to load ("A dynamic
|
|
7
|
+
* link library (DLL) initialization routine failed"), or blocks NW.js. Named node.dll, the library is the one NW.js
|
|
8
|
+
* loaded. The addon is changed in place (its other bytes are kept); it then loads in NW.js only, not in Node.js.
|
|
9
|
+
* @param file the content of the addon (a .node file of Windows)
|
|
10
|
+
* @returns the names changed: 0 when it imports no node.exe (an addon built for NW.js, or loading Node.js otherwise)
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare function nameNwjsNode(file: Buffer): number;
|
|
14
|
+
/**
|
|
15
|
+
* The architectures of a native binary (Mach-O, possibly universal; ELF; PE) as node names them: x64, ia32, arm64, arm
|
|
16
|
+
* @param file
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare function binaryArchitectures(file: Buffer): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether an addon uses the C++ API of V8 (NAN, v8.h) rather than Node-API: the names of the functions of V8 it imports
|
|
22
|
+
* (mangled by the Itanium ABI or by MSVC). Built for the V8 of Node.js, it does not run in the one of NW.js (Chromium)
|
|
23
|
+
* @param file
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare function usesV8Api(file: Buffer): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* What {@link prepareNwjsAddons} did to the addons of the native tree
|
|
29
|
+
*/
|
|
30
|
+
export type NwjsAddons = {
|
|
31
|
+
/**
|
|
32
|
+
* The addons whose node.exe was named node.dll (Windows)
|
|
33
|
+
*/
|
|
34
|
+
renamed: string[];
|
|
35
|
+
/**
|
|
36
|
+
* The packages built again from their sources: for the architecture of the runtime, or with the headers of NW.js
|
|
37
|
+
*/
|
|
38
|
+
rebuilt: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Make the addons of the native tree of an application of NW.js load in its runtime: the packages whose addons are not
|
|
42
|
+
* for the architecture of the runtime (built with the headers of its Node.js), or use V8 (NW.js 0.111.3 and later: the
|
|
43
|
+
* headers of NW.js), built again from their sources; on Windows, the node.exe they import named node.dll
|
|
44
|
+
* @param project
|
|
45
|
+
* @param directory the native tree
|
|
46
|
+
* @param files the files of the tree (their sources)
|
|
47
|
+
* @param release
|
|
48
|
+
* @param platform the build of NW.js (win-x64, osx-arm64…)
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export declare function prepareNwjsAddons(project: string, directory: string, files: NativeFile[], release: NwjsRelease, platform: string): Promise<NwjsAddons>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type NwjsRuntime } from './Runtime.js';
|
|
2
|
+
import { type NwjsStage, type NwjsStageOptions } from './Stage.js';
|
|
3
|
+
/**
|
|
4
|
+
* The options of {@link buildNwjsApp}
|
|
5
|
+
*/
|
|
6
|
+
export type NwjsAppOptions = Omit<NwjsStageOptions, 'outdir'> & {
|
|
7
|
+
/**
|
|
8
|
+
* The directory of the application made (dist/nwjs by default): <program>-<build of NW.js> in it
|
|
9
|
+
*/
|
|
10
|
+
outdir?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The application of NW.js made by {@link buildNwjsApp}, distributed as it is or by its installers
|
|
14
|
+
*/
|
|
15
|
+
export type NwjsApp = {
|
|
16
|
+
/**
|
|
17
|
+
* Its directory: the runtime of NW.js and the application (Windows, Linux), the bundle of macOS (<product>.app)
|
|
18
|
+
*/
|
|
19
|
+
directory: string;
|
|
20
|
+
/**
|
|
21
|
+
* Its executable, named after the program (<program>.exe, <product>.app/Contents/MacOS/nwjs, <program>)
|
|
22
|
+
*/
|
|
23
|
+
executable: string;
|
|
24
|
+
/**
|
|
25
|
+
* The name of its program and of its product
|
|
26
|
+
*/
|
|
27
|
+
program: string;
|
|
28
|
+
productName: string;
|
|
29
|
+
runtime: NwjsRuntime;
|
|
30
|
+
/**
|
|
31
|
+
* The application staged (its release, its addons): its directory is removed once copied
|
|
32
|
+
*/
|
|
33
|
+
stage: NwjsStage;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Make the application of NW.js of a project for this system: the runtime of NW.js (normal) with the application
|
|
37
|
+
* (stageNwjsApp: its bundle, its native addons made to load in NW.js, its resources, its manifest), named after it.
|
|
38
|
+
* On Windows and Linux, the files of the application are next to its executable (nw.exe, nw renamed after its program:
|
|
39
|
+
* the name of its installers, lakutata.installer.name, else the program of its package; on Windows, its icon and its
|
|
40
|
+
* version information are the ones of the application); on macOS, they are in the bundle
|
|
41
|
+
* (<product>.app/Contents/Resources/app.nw), whose Info.plist gives its name, its identifier (the appId of the
|
|
42
|
+
* installer), its version and its icon, signed again (ad hoc). The icon is lakutata.icon. Its files are readable by
|
|
43
|
+
* every user, its programs runnable (once installed by root, the application runs for the users)
|
|
44
|
+
* @param options
|
|
45
|
+
* @example
|
|
46
|
+
* import {buildNwjsApp} from '@lakutata/builder'
|
|
47
|
+
*
|
|
48
|
+
* //dist/nwjs/desk-osx-arm64/Desk.app on a Mac with Apple silicon
|
|
49
|
+
* const app = await buildNwjsApp({})
|
|
50
|
+
* console.log(app.directory, app.runtime.version)
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildNwjsApp(options: NwjsAppOptions): Promise<NwjsApp>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A release of NW.js: its version and the ones of the Node.js and the Chromium it embeds, the systems it is built for
|
|
3
|
+
*/
|
|
4
|
+
export type NwjsRelease = {
|
|
5
|
+
/**
|
|
6
|
+
* The version of NW.js (0.119.2)
|
|
7
|
+
*/
|
|
8
|
+
version: string;
|
|
9
|
+
/**
|
|
10
|
+
* The day it was released (2026/10/22)
|
|
11
|
+
*/
|
|
12
|
+
date: string;
|
|
13
|
+
/**
|
|
14
|
+
* The version of the Node.js it embeds (26.12.1)
|
|
15
|
+
*/
|
|
16
|
+
node: string;
|
|
17
|
+
/**
|
|
18
|
+
* The version of the Chromium it embeds (156.0.8078.48)
|
|
19
|
+
*/
|
|
20
|
+
chromium: string;
|
|
21
|
+
/**
|
|
22
|
+
* The systems it is built for: win-x64, win-ia32, win-arm64, osx-x64, osx-arm64, linux-x64, linux-ia32, linux-arm64
|
|
23
|
+
*/
|
|
24
|
+
platforms: string[];
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The flavors of NW.js: normal (the one shipped), sdk (with the developer tools, for the development)
|
|
28
|
+
*/
|
|
29
|
+
export type NwjsFlavor = 'normal' | 'sdk';
|
|
30
|
+
/**
|
|
31
|
+
* The options of {@link downloadNwjs}
|
|
32
|
+
*/
|
|
33
|
+
export type NwjsRuntimeOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* The version of NW.js: a version (0.72.0), latest (the latest release) or win7 (0.72.0, the last one running on
|
|
36
|
+
* Windows 7, 8 and 8.1)
|
|
37
|
+
*/
|
|
38
|
+
version: string;
|
|
39
|
+
/**
|
|
40
|
+
* normal (by default) or sdk
|
|
41
|
+
*/
|
|
42
|
+
flavor?: NwjsFlavor;
|
|
43
|
+
/**
|
|
44
|
+
* The system (process.platform: win32, darwin, linux), the one of the machine by default
|
|
45
|
+
*/
|
|
46
|
+
platform?: NodeJS.Platform;
|
|
47
|
+
/**
|
|
48
|
+
* The architecture (process.arch: x64, ia32, arm64), the one of the machine by default. On a Mac with Apple silicon,
|
|
49
|
+
* a release without osx-arm64 (before 0.77) is the x64 one, run by Rosetta
|
|
50
|
+
*/
|
|
51
|
+
arch?: string;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A runtime of NW.js, downloaded into the cache
|
|
55
|
+
*/
|
|
56
|
+
export type NwjsRuntime = NwjsRelease & {
|
|
57
|
+
flavor: NwjsFlavor;
|
|
58
|
+
/**
|
|
59
|
+
* Its system and its architecture as NW.js names them (osx-arm64)
|
|
60
|
+
*/
|
|
61
|
+
platform: string;
|
|
62
|
+
/**
|
|
63
|
+
* The directory of the runtime: nw.exe and its libraries, nwjs.app, nw and its libraries
|
|
64
|
+
*/
|
|
65
|
+
directory: string;
|
|
66
|
+
/**
|
|
67
|
+
* Its executable: nw.exe, nwjs.app/Contents/MacOS/nwjs, nw
|
|
68
|
+
*/
|
|
69
|
+
executable: string;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Compare two versions (1.2.3)
|
|
73
|
+
* @param left
|
|
74
|
+
* @param right
|
|
75
|
+
*/
|
|
76
|
+
export declare function compareVersions(left: string, right: string): number;
|
|
77
|
+
/**
|
|
78
|
+
* The releases of NW.js, newest first: the list of nwjs.io (LAKUTATA_NWJS_VERSIONS), kept a day in the cache; the
|
|
79
|
+
* cached one when it cannot be read
|
|
80
|
+
* @example
|
|
81
|
+
* import {nwjsReleases} from '@lakutata/builder'
|
|
82
|
+
*
|
|
83
|
+
* for (const release of (await nwjsReleases()).slice(0, 3)) console.log(release.version, release.node, release.chromium)
|
|
84
|
+
*/
|
|
85
|
+
export declare function nwjsReleases(): Promise<NwjsRelease[]>;
|
|
86
|
+
/**
|
|
87
|
+
* A release of NW.js: a version, latest (the latest release) or win7 (0.72.0, the last one running on Windows 7, 8
|
|
88
|
+
* and 8.1). Refused when it embeds a Node.js older than the one lakutata runs on (18.10)
|
|
89
|
+
* @param version
|
|
90
|
+
* @example
|
|
91
|
+
* import {nwjsRelease} from '@lakutata/builder'
|
|
92
|
+
*
|
|
93
|
+
* const release = await nwjsRelease('win7')
|
|
94
|
+
* console.log(release.version, release.node, release.chromium) //0.72.0 19.3.0 109.0.5414.87
|
|
95
|
+
*/
|
|
96
|
+
export declare function nwjsRelease(version: string): Promise<NwjsRelease>;
|
|
97
|
+
/**
|
|
98
|
+
* The system and the architecture of a release as NW.js names them (osx-arm64), the x64 build on a Mac with Apple
|
|
99
|
+
* silicon when the release has no arm64 one
|
|
100
|
+
* @param release
|
|
101
|
+
* @param platform
|
|
102
|
+
* @param arch
|
|
103
|
+
*/
|
|
104
|
+
export declare function nwjsPlatform(release: NwjsRelease, platform?: NodeJS.Platform, arch?: string): string;
|
|
105
|
+
/**
|
|
106
|
+
* A runtime of NW.js for a system, downloaded once into the cache (~/.cache/lakutata/nwjs, LAKUTATA_CACHE_DIR) from
|
|
107
|
+
* dl.nwjs.io (LAKUTATA_NWJS_MIRROR: a mirror of it) and checked with the SHASUMS256.txt of its release
|
|
108
|
+
* @param options
|
|
109
|
+
* @example
|
|
110
|
+
* import {downloadNwjs} from '@lakutata/builder'
|
|
111
|
+
*
|
|
112
|
+
* //The NW.js of the development (its developer tools), for the machine
|
|
113
|
+
* const runtime = await downloadNwjs({version: 'latest', flavor: 'sdk'})
|
|
114
|
+
* console.log(runtime.executable, runtime.node)
|
|
115
|
+
*/
|
|
116
|
+
export declare function downloadNwjs(options: NwjsRuntimeOptions): Promise<NwjsRuntime>;
|