@lakutata/builder 3.1.3 → 3.1.6

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.
Files changed (39) hide show
  1. package/README.md +24 -1
  2. package/README.zh-CN.md +7 -1
  3. package/dist/esm/index.js +5 -0
  4. package/dist/esm/lib/Archive.js +3 -2
  5. package/dist/esm/lib/Bundle.js +2 -1
  6. package/dist/esm/lib/Directories.js +18 -0
  7. package/dist/esm/lib/Executable.js +27 -6
  8. package/dist/esm/lib/Installer.js +28 -14
  9. package/dist/esm/lib/NativeRuntime.js +27 -3
  10. package/dist/esm/lib/Processes.js +3 -2
  11. package/dist/esm/lib/Tools.js +98 -19
  12. package/dist/esm/lib/linux/Linux.js +60 -10
  13. package/dist/esm/lib/mac/Mac.js +39 -11
  14. package/dist/esm/lib/mobile/Addons.js +675 -0
  15. package/dist/esm/lib/mobile/Node.js +190 -0
  16. package/dist/esm/lib/mobile/Stage.js +180 -0
  17. package/dist/esm/lib/nwjs/Addons.js +310 -0
  18. package/dist/esm/lib/nwjs/Package.js +149 -0
  19. package/dist/esm/lib/nwjs/Runtime.js +188 -0
  20. package/dist/esm/lib/nwjs/Stage.js +92 -0
  21. package/dist/esm/lib/win/Windows.js +68 -45
  22. package/dist/types/index.d.ts +7 -0
  23. package/dist/types/lib/Bundle.d.ts +5 -0
  24. package/dist/types/lib/Directories.d.ts +8 -0
  25. package/dist/types/lib/Executable.d.ts +7 -0
  26. package/dist/types/lib/Installer.d.ts +37 -4
  27. package/dist/types/lib/Processes.d.ts +2 -1
  28. package/dist/types/lib/Tools.d.ts +47 -1
  29. package/dist/types/lib/linux/Linux.d.ts +2 -1
  30. package/dist/types/lib/mac/Mac.d.ts +1 -1
  31. package/dist/types/lib/mobile/Addons.d.ts +154 -0
  32. package/dist/types/lib/mobile/Node.d.ts +89 -0
  33. package/dist/types/lib/mobile/Stage.d.ts +111 -0
  34. package/dist/types/lib/nwjs/Addons.d.ts +69 -0
  35. package/dist/types/lib/nwjs/Package.d.ts +56 -0
  36. package/dist/types/lib/nwjs/Runtime.d.ts +120 -0
  37. package/dist/types/lib/nwjs/Stage.d.ts +104 -0
  38. package/dist/types/lib/win/Windows.d.ts +30 -1
  39. package/package.json +2 -2
@@ -0,0 +1,154 @@
1
+ import type { NativeFile } from '../Native.js';
2
+ import { type AndroidAbi } from './Node.js';
3
+ /**
4
+ * The SDKs of iOS the native addons are built for: the architectures built and the slice of the framework of the
5
+ * Node.js of the application (NodeMobile.xcframework) they link
6
+ */
7
+ declare const IOS_SDKS: {
8
+ readonly iphoneos: {
9
+ readonly archs: "arm64";
10
+ readonly slice: "ios-arm64";
11
+ readonly platform: "iPhoneOS";
12
+ };
13
+ readonly iphonesimulator: {
14
+ readonly archs: "arm64";
15
+ readonly slice: "ios-arm64-simulator";
16
+ readonly platform: "iPhoneSimulator";
17
+ };
18
+ };
19
+ /**
20
+ * A SDK of iOS: iphoneos (the devices) or iphonesimulator (the simulators of the Macs of Apple silicon)
21
+ */
22
+ export type IosSdk = keyof typeof IOS_SDKS;
23
+ /**
24
+ * The file of a Node.js project mapping the placeholders of its addons (their paths in the native tree) to the libraries
25
+ * the system loads instead (the frameworks of the application on iOS, the libraries of the HAP on HarmonyOS):
26
+ * {directory, files}, the directory relative to the project or absolute
27
+ */
28
+ export declare const MOBILE_ADDONS_FILE: string;
29
+ /**
30
+ * What was done to the native addons of a mobile application
31
+ */
32
+ export type MobileAddons = {
33
+ /**
34
+ * The packages built from their sources (now, or before: the cache), with the target built for:
35
+ * `@lakutata/math (arm64-v8a)`
36
+ */
37
+ built: string[];
38
+ /**
39
+ * The packages whose prebuilt addons of the system were kept (prebuilds/android-<arch>)
40
+ */
41
+ prebuilt: string[];
42
+ /**
43
+ * The frameworks made of the addons (iOS), for each SDK: `iphonesimulator/lakutata-math-math.framework`
44
+ */
45
+ frameworks: string[];
46
+ /**
47
+ * The libraries made of the addons (HarmonyOS), in the libraries of the HAP: `liblakutata-math-math.so`
48
+ */
49
+ libraries: string[];
50
+ };
51
+ /**
52
+ * The options of the native addons of a mobile application
53
+ */
54
+ export type MobileAddonOptions = {
55
+ /**
56
+ * The architectures of Android built for, the ones of libnode by default
57
+ */
58
+ abis?: AndroidAbi[];
59
+ /**
60
+ * The SDKs of iOS built for, both by default (iphoneos, iphonesimulator)
61
+ */
62
+ sdks?: IosSdk[];
63
+ /**
64
+ * Called with what is done, the builds taking a while
65
+ */
66
+ progress?: (message: string) => void;
67
+ };
68
+ /**
69
+ * Build the native addons of a mobile application of Android: a native tree per architecture (<directory>-<arch>, the
70
+ * one of process.arch loaded by the bundle), each package of addons built for it from its sources (node-gyp, the NDK,
71
+ * the headers and the library of libnode), or keeping its prebuilt addons of the architecture
72
+ * (prebuilds/android-<arch>, node-gyp-build). The tree of the build is removed once they are made
73
+ * @param project
74
+ * @param directory the native tree
75
+ * @param files the files of the tree
76
+ * @param node the export of the libnode of Android
77
+ * @param options
78
+ * @internal
79
+ */
80
+ export declare function prepareAndroidAddons(project: string, directory: string, files: NativeFile[], node: string, options?: MobileAddonOptions): Promise<MobileAddons>;
81
+ /**
82
+ * The name of the framework of an addon: its package and its file, in the characters of the names and of the
83
+ * identifiers of the bundles (letters, digits and hyphens)
84
+ * @param name the name of its package
85
+ * @param file its file
86
+ * @internal
87
+ */
88
+ export declare function frameworkName(name: string, file: string): string;
89
+ /**
90
+ * The Info.plist of the framework of an addon: the keys the frameworks embedded in an application of the App Store
91
+ * have
92
+ * @param name
93
+ * @param version the version of its package
94
+ * @param sdk
95
+ * @internal
96
+ */
97
+ export declare function frameworkInfo(name: string, version: string, sdk: IosSdk): string;
98
+ /**
99
+ * The headers of a libnode as node-gyp builds the addons against them, linked but for these:
100
+ * - node_object_wrap.h without the calls of the cleanup hooks of node::ObjectWrap (OBJECT_WRAP_HOOKS), as in the headers
101
+ * of Node.js 24.18: an addon built on node::ObjectWrap (better-sqlite3, the addons of NAN) would abort the application
102
+ * whenever the garbage collector frees one of its objects. A header without them is copied as it is;
103
+ * - for iOS, config.gypi with OS "mac": the libnode of iOS is configured with OS "ios", for which the common.gypi of
104
+ * Node.js turns the exceptions and the RTTI of C++ off in the projects of Xcode as it does for macOS, while the addons
105
+ * (and node-addon-api) give their settings of Xcode (the exceptions, the RTTI, the standard of C++) to OS "mac" only.
106
+ * Built as for macOS, an addon keeps them; the SDK, the architectures and the deployment target of iOS are given to
107
+ * xcodebuild
108
+ * @param node the export of the libnode
109
+ * @param work a directory of the build
110
+ * @param os "mac" for iOS: the OS given to config.gypi
111
+ * @returns the directory of the headers (the nodedir of node-gyp)
112
+ */
113
+ export declare function addonNodeHeaders(node: string, work: string, os?: 'mac'): Promise<string>;
114
+ /**
115
+ * Build the native addons of a mobile application of iOS: each package of addons built for the SDKs from its sources
116
+ * (node-gyp, xcodebuild, linking the framework of the Node.js of the application), each addon made a framework, which
117
+ * the project of iOS embeds in the application; its files in the native tree replaced by placeholders (no library of
118
+ * the App Store outside of its frameworks), which the entry of the project loads from the frameworks of the application
119
+ * (MOBILE_ADDONS_FILE: the project is in the application, next to its frameworks). The frameworks of the SDKs made
120
+ * before are removed
121
+ * @param project
122
+ * @param stage the Node.js project
123
+ * @param directory its native tree
124
+ * @param files the files of the tree
125
+ * @param frameworks the directory of the frameworks, a directory per SDK (the NodeAddons of the project of iOS)
126
+ * @param node the export of the libnode of iOS
127
+ * @param options
128
+ * @internal
129
+ */
130
+ export declare function prepareIosAddons(project: string, stage: string, directory: string, files: NativeFile[], frameworks: string, node: string, options?: MobileAddonOptions): Promise<MobileAddons>;
131
+ /**
132
+ * The name of the library of an addon in the HAP: libaddon-<package>-<file>.so, in letters, digits, hyphens and
133
+ * underscores (the libraries made before are the libaddon-*.so of the directory)
134
+ * @param name the name of its package
135
+ * @param file its file
136
+ * @internal
137
+ */
138
+ export declare function harmonyLibraryName(name: string, file: string): string;
139
+ /**
140
+ * Build the native addons of a mobile application of HarmonyOS: each package of addons built from its sources (node-gyp,
141
+ * the LLVM of the native SDK, linking libnode.so), each addon made a library of the HAP (libaddon-<package>-<file>.so in
142
+ * its libs/arm64-v8a: the addons cannot be loaded from the resources of the HAP); its files in the native tree replaced
143
+ * by placeholders, which the entry of the project loads from the libraries of the HAP (MOBILE_ADDONS_FILE)
144
+ * @param project
145
+ * @param stage the Node.js project
146
+ * @param directory its native tree
147
+ * @param files the files of the tree
148
+ * @param libraries the directory of the libraries of the HAP (the libs/arm64-v8a of its module)
149
+ * @param node the export of the libnode of HarmonyOS
150
+ * @param options
151
+ * @internal
152
+ */
153
+ export declare function prepareHarmonyAddons(project: string, stage: string, directory: string, files: NativeFile[], libraries: string, node: string, options?: MobileAddonOptions): Promise<MobileAddons>;
154
+ export {};
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The version of Node.js of the mobile applications when their libnode does not tell it: the one of the release of
3
+ * lakutata/libnode they download (MOBILE_NODE_RELEASE)
4
+ */
5
+ export declare const MOBILE_NODE_VERSION: string;
6
+ /**
7
+ * The systems of the mobile applications of React Native
8
+ */
9
+ export type MobilePlatform = 'android' | 'ios' | 'harmony';
10
+ /**
11
+ * The architectures of Android of a libnode built for them (the arch of Node.js names the native tree of the
12
+ * architecture, the target names the compilers of the NDK)
13
+ */
14
+ export declare const ANDROID_ABIS: {
15
+ readonly 'arm64-v8a': {
16
+ readonly arch: "arm64";
17
+ readonly target: "aarch64-linux-android";
18
+ };
19
+ readonly 'armeabi-v7a': {
20
+ readonly arch: "arm";
21
+ readonly target: "armv7a-linux-androideabi";
22
+ };
23
+ readonly x86_64: {
24
+ readonly arch: "x64";
25
+ readonly target: "x86_64-linux-android";
26
+ };
27
+ };
28
+ /**
29
+ * An architecture of Android (an ABI): arm64-v8a, armeabi-v7a or x86_64
30
+ */
31
+ export type AndroidAbi = keyof typeof ANDROID_ABIS;
32
+ /**
33
+ * The version of Node.js of a libnode: the one of its headers (include/node/node_version.h)
34
+ * @param directory the export of the libnode
35
+ * @internal
36
+ */
37
+ export declare function mobileNodeVersion(directory: string): string;
38
+ /**
39
+ * The architectures of Android a libnode is built for (libs/<abi>/libnode.so)
40
+ * @param directory the export of the libnode of Android
41
+ * @internal
42
+ */
43
+ export declare function mobileNodeAbis(directory: string): AndroidAbi[];
44
+ /**
45
+ * Check the export of a libnode of a system: its headers, and its libraries (Android: libs/<abi>/libnode.so, HarmonyOS:
46
+ * libs/arm64-v8a/libnode.so) or its framework (iOS: NodeMobile.xcframework)
47
+ * @param platform
48
+ * @param directory
49
+ * @internal
50
+ */
51
+ export declare function checkMobileNode(platform: MobilePlatform, directory: string): void;
52
+ /**
53
+ * The release of lakutata/libnode the mobile applications download their libnode from: its tag is v<release> (the
54
+ * version of Node.js, then -<revision> for a release of the same version built again)
55
+ */
56
+ export declare const MOBILE_NODE_RELEASE: string;
57
+ /**
58
+ * The options of {@link downloadMobileNode}
59
+ */
60
+ export type MobileNodeDownloadOptions = {
61
+ /**
62
+ * The system downloaded for
63
+ */
64
+ platform: MobilePlatform;
65
+ /**
66
+ * The architectures of Android downloaded for, arm64-v8a and x86_64 by default (the devices, the emulators of the
67
+ * computers of Intel)
68
+ */
69
+ abis?: AndroidAbi[];
70
+ /**
71
+ * Called with what is being downloaded
72
+ */
73
+ progress?: (line: string) => void;
74
+ };
75
+ /**
76
+ * Download the libnode of a mobile system from the releases of lakutata/libnode (LAKUTATA_LIBNODE_MIRROR: a mirror of
77
+ * them), once: its archives are checked with the SHA256SUMS of the release and kept in the cache
78
+ * (~/.cache/lakutata/mobile, LAKUTATA_CACHE_DIR). LAKUTATA_MOBILE_NODE_DIR gives exports of a libnode of your own instead
79
+ * (a directory per system: android, ios, harmony; built with the repository of lakutata/libnode)
80
+ * @param options
81
+ * @returns the directory of the export: its headers (include/node) and its libraries (libs/<abi>/libnode.so) or its
82
+ * framework (NodeMobile.xcframework)
83
+ * @example
84
+ * import {downloadMobileNode} from '@lakutata/builder'
85
+ *
86
+ * const directory = await downloadMobileNode({platform: 'android', abis: ['arm64-v8a'], progress: console.log})
87
+ * console.log(directory)
88
+ */
89
+ export declare function downloadMobileNode(options: MobileNodeDownloadOptions): Promise<string>;
@@ -0,0 +1,111 @@
1
+ import { type BundleResult } from '../Bundle.js';
2
+ import { type IosSdk, type MobileAddons } from './Addons.js';
3
+ import { type AndroidAbi, type MobilePlatform } from './Node.js';
4
+ /**
5
+ * The options of {@link stageMobileApp}
6
+ */
7
+ export type MobileStageOptions = {
8
+ /**
9
+ * The system the project is made for: Android (copied from the assets of the application into its files at its
10
+ * first launch), iOS (in the bundle of the application) or HarmonyOS (in the resources of the HAP)
11
+ */
12
+ platform: MobilePlatform;
13
+ /**
14
+ * The directory of the application (its package.json), the current one by default
15
+ */
16
+ project?: string;
17
+ /**
18
+ * The directory of the Node.js project made, which the native project of the system packs into the application
19
+ * (android/app/src/main/assets/nodejs, ios/nodejs, harmony/entry/src/main/resources/resfile/nodejs in the projects
20
+ * of the mobile-react template); made again at each stage
21
+ */
22
+ outdir: string;
23
+ /**
24
+ * The compiled entry of the application (the "main" of the package.json by default)
25
+ */
26
+ entry?: string;
27
+ /**
28
+ * Minify the bundle (true by default)
29
+ */
30
+ minify?: boolean;
31
+ /**
32
+ * The modules left out of the bundle, besides `@lakutata/netif` (the listening on network interfaces, which the
33
+ * mobile systems do not have)
34
+ */
35
+ external?: string[];
36
+ /**
37
+ * The libnode of the system: the directory it is put into (packages/ipc/native/node/out/<platform> in the projects
38
+ * of the mobile-react template), its headers (include/node) and its libraries. The bundle targets its version of
39
+ * Node.js (24.20.0 without it); the native addons are built against it, and need it
40
+ */
41
+ node?: string;
42
+ /**
43
+ * The architectures of Android the native addons are built for, the ones of the libnode by default
44
+ */
45
+ abis?: AndroidAbi[];
46
+ /**
47
+ * The SDKs of iOS the native addons are built for: iphoneos and iphonesimulator by default
48
+ */
49
+ sdks?: IosSdk[];
50
+ /**
51
+ * The directory of the frameworks of the native addons of iOS, a directory per SDK, which the project of iOS embeds
52
+ * in the application (`ios/NodeAddons` in the projects of the template); required by the native addons of iOS, the
53
+ * frameworks of the SDKs built made again at each stage
54
+ */
55
+ frameworks?: string;
56
+ /**
57
+ * The directory of the libraries of the HAP the native addons of HarmonyOS are put in
58
+ * (`harmony/entry/libs/arm64-v8a` in the projects of the template); required by the native addons of HarmonyOS, the
59
+ * libraries of the addons made before (libaddon-*.so) removed at each stage
60
+ */
61
+ libraries?: string;
62
+ /**
63
+ * Called with what is done (the native addons built, which takes a while)
64
+ */
65
+ progress?: (message: string) => void;
66
+ };
67
+ /**
68
+ * The Node.js project made by {@link stageMobileApp}
69
+ */
70
+ export type MobileStage = {
71
+ /**
72
+ * Its directory: its manifest (package.json), its entry (main.js), the bundle of the application (app.cjs) and its
73
+ * resources (resources)
74
+ */
75
+ directory: string;
76
+ /**
77
+ * The system it is made for
78
+ */
79
+ platform: MobilePlatform;
80
+ /**
81
+ * The version of Node.js it is made for
82
+ */
83
+ node: string;
84
+ bundle: BundleResult;
85
+ /**
86
+ * What was done to the native addons of the application, undefined without addon
87
+ */
88
+ addons?: MobileAddons;
89
+ };
90
+ /**
91
+ * Make the Node.js project of a mobile application of React Native (Android, iOS, HarmonyOS), which the native module
92
+ * of the application runs in its libnode: the bundle of the application (CommonJS, for the version of Node.js of the
93
+ * libnode) and its resources (lakutata.resources), its manifest and its entry. The bundle holds the dependencies: the
94
+ * project is packed into the application as it is. The native addons are built for the system from the sources of their
95
+ * packages, against the headers and the libraries of the libnode: on Android, a native tree per architecture (node-gyp
96
+ * and the NDK of Android); on iOS, a framework per addon for each SDK (node-gyp and Xcode), in the directory of the
97
+ * frameworks the project of iOS embeds; on HarmonyOS, a library per addon (node-gyp and the native SDK of HarmonyOS),
98
+ * in the libraries of the HAP
99
+ * @param options
100
+ * @example
101
+ * import {stageMobileApp} from '@lakutata/builder'
102
+ *
103
+ * //In packages/app of a project of the mobile-react template, before the application of Android is built
104
+ * const stage = await stageMobileApp({
105
+ * platform: 'android',
106
+ * outdir: '../../android/app/src/main/assets/nodejs',
107
+ * node: '../ipc/native/node/out/android'
108
+ * })
109
+ * console.log(stage.directory, stage.node)
110
+ */
111
+ export declare function stageMobileApp(options: MobileStageOptions): Promise<MobileStage>;
@@ -0,0 +1,69 @@
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
+ * node-gyp: the one of the project, of the builder, else the one of npm
42
+ * @param project
43
+ * @internal
44
+ */
45
+ export declare function nodeGyp(project: string): string;
46
+ /**
47
+ * The directory of the package of a file (the one holding its package.json)
48
+ * @param file
49
+ * @internal
50
+ */
51
+ export declare function packageOf(file: string): string | undefined;
52
+ /**
53
+ * The .node files under a directory
54
+ * @param directory
55
+ * @internal
56
+ */
57
+ export declare function nodeFiles(directory: string): Promise<string[]>;
58
+ /**
59
+ * Make the addons of the native tree of an application of NW.js load in its runtime: the packages whose addons are not
60
+ * 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
61
+ * headers of NW.js), built again from their sources; on Windows, the node.exe they import named node.dll
62
+ * @param project
63
+ * @param directory the native tree
64
+ * @param files the files of the tree (their sources)
65
+ * @param release
66
+ * @param platform the build of NW.js (win-x64, osx-arm64…)
67
+ * @internal
68
+ */
69
+ export declare function prepareNwjsAddons(project: string, directory: string, files: NativeFile[], release: NwjsRelease, platform: string): Promise<NwjsAddons>;
@@ -0,0 +1,56 @@
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
+ * Called with what is being downloaded (the runtime of NW.js)
13
+ */
14
+ progress?: (line: string) => void;
15
+ };
16
+ /**
17
+ * The application of NW.js made by {@link buildNwjsApp}, distributed as it is or by its installers
18
+ */
19
+ export type NwjsApp = {
20
+ /**
21
+ * Its directory: the runtime of NW.js and the application (Windows, Linux), the bundle of macOS (<product>.app)
22
+ */
23
+ directory: string;
24
+ /**
25
+ * Its executable, named after the program (<program>.exe, <product>.app/Contents/MacOS/nwjs, <program>)
26
+ */
27
+ executable: string;
28
+ /**
29
+ * The name of its program and of its product
30
+ */
31
+ program: string;
32
+ productName: string;
33
+ runtime: NwjsRuntime;
34
+ /**
35
+ * The application staged (its release, its addons): its directory is removed once copied
36
+ */
37
+ stage: NwjsStage;
38
+ };
39
+ /**
40
+ * Make the application of NW.js of a project for this system: the runtime of NW.js (normal) with the application
41
+ * (stageNwjsApp: its bundle, its native addons made to load in NW.js, its resources, its manifest), named after it.
42
+ * On Windows and Linux, the files of the application are next to its executable (nw.exe, nw renamed after its program:
43
+ * the name of its installers, lakutata.installer.name, else the program of its package; on Windows, its icon and its
44
+ * version information are the ones of the application); on macOS, they are in the bundle
45
+ * (<product>.app/Contents/Resources/app.nw), whose Info.plist gives its name, its identifier (the appId of the
46
+ * installer), its version and its icon, signed again (ad hoc). The icon is lakutata.icon. Its files are readable by
47
+ * every user, its programs runnable (once installed by root, the application runs for the users)
48
+ * @param options
49
+ * @example
50
+ * import {buildNwjsApp} from '@lakutata/builder'
51
+ *
52
+ * //dist/nwjs/desk-osx-arm64/Desk.app on a Mac with Apple silicon
53
+ * const app = await buildNwjsApp({})
54
+ * console.log(app.directory, app.runtime.version)
55
+ */
56
+ export declare function buildNwjsApp(options: NwjsAppOptions): Promise<NwjsApp>;
@@ -0,0 +1,120 @@
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
+ * Called with what is being downloaded
54
+ */
55
+ progress?: (line: string) => void;
56
+ };
57
+ /**
58
+ * A runtime of NW.js, downloaded into the cache
59
+ */
60
+ export type NwjsRuntime = NwjsRelease & {
61
+ flavor: NwjsFlavor;
62
+ /**
63
+ * Its system and its architecture as NW.js names them (osx-arm64)
64
+ */
65
+ platform: string;
66
+ /**
67
+ * The directory of the runtime: nw.exe and its libraries, nwjs.app, nw and its libraries
68
+ */
69
+ directory: string;
70
+ /**
71
+ * Its executable: nw.exe, nwjs.app/Contents/MacOS/nwjs, nw
72
+ */
73
+ executable: string;
74
+ };
75
+ /**
76
+ * Compare two versions (1.2.3)
77
+ * @param left
78
+ * @param right
79
+ */
80
+ export declare function compareVersions(left: string, right: string): number;
81
+ /**
82
+ * The releases of NW.js, newest first: the list of nwjs.io (LAKUTATA_NWJS_VERSIONS), kept a day in the cache; the
83
+ * cached one when it cannot be read
84
+ * @example
85
+ * import {nwjsReleases} from '@lakutata/builder'
86
+ *
87
+ * for (const release of (await nwjsReleases()).slice(0, 3)) console.log(release.version, release.node, release.chromium)
88
+ */
89
+ export declare function nwjsReleases(): Promise<NwjsRelease[]>;
90
+ /**
91
+ * A release of NW.js: a version, latest (the latest release) or win7 (0.72.0, the last one running on Windows 7, 8
92
+ * and 8.1). Refused when it embeds a Node.js older than the one lakutata runs on (18.10)
93
+ * @param version
94
+ * @example
95
+ * import {nwjsRelease} from '@lakutata/builder'
96
+ *
97
+ * const release = await nwjsRelease('win7')
98
+ * console.log(release.version, release.node, release.chromium) //0.72.0 19.3.0 109.0.5414.87
99
+ */
100
+ export declare function nwjsRelease(version: string): Promise<NwjsRelease>;
101
+ /**
102
+ * The system and the architecture of a release as NW.js names them (osx-arm64), the x64 build on a Mac with Apple
103
+ * silicon when the release has no arm64 one
104
+ * @param release
105
+ * @param platform
106
+ * @param arch
107
+ */
108
+ export declare function nwjsPlatform(release: NwjsRelease, platform?: NodeJS.Platform, arch?: string): string;
109
+ /**
110
+ * A runtime of NW.js for a system, downloaded once into the cache (~/.cache/lakutata/nwjs, LAKUTATA_CACHE_DIR) from
111
+ * dl.nwjs.io (LAKUTATA_NWJS_MIRROR: a mirror of it) and checked with the SHASUMS256.txt of its release
112
+ * @param options
113
+ * @example
114
+ * import {downloadNwjs} from '@lakutata/builder'
115
+ *
116
+ * //The NW.js of the development (its developer tools), for the machine
117
+ * const runtime = await downloadNwjs({version: 'latest', flavor: 'sdk'})
118
+ * console.log(runtime.executable, runtime.node)
119
+ */
120
+ export declare function downloadNwjs(options: NwjsRuntimeOptions): Promise<NwjsRuntime>;