@lakutata/builder 3.1.5 → 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.
@@ -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>;
@@ -37,6 +37,24 @@ export type NwjsAddons = {
37
37
  */
38
38
  rebuilt: string[];
39
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[]>;
40
58
  /**
41
59
  * Make the addons of the native tree of an application of NW.js load in its runtime: the packages whose addons are not
42
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
@@ -8,6 +8,10 @@ export type NwjsAppOptions = Omit<NwjsStageOptions, 'outdir'> & {
8
8
  * The directory of the application made (dist/nwjs by default): <program>-<build of NW.js> in it
9
9
  */
10
10
  outdir?: string;
11
+ /**
12
+ * Called with what is being downloaded (the runtime of NW.js)
13
+ */
14
+ progress?: (line: string) => void;
11
15
  };
12
16
  /**
13
17
  * The application of NW.js made by {@link buildNwjsApp}, distributed as it is or by its installers
@@ -49,6 +49,10 @@ export type NwjsRuntimeOptions = {
49
49
  * a release without osx-arm64 (before 0.77) is the x64 one, run by Rosetta
50
50
  */
51
51
  arch?: string;
52
+ /**
53
+ * Called with what is being downloaded
54
+ */
55
+ progress?: (line: string) => void;
52
56
  };
53
57
  /**
54
58
  * A runtime of NW.js, downloaded into the cache
@@ -40,8 +40,9 @@ export declare function wixSource(plan: InstallerPlan, stage: string, serviceDir
40
40
  * @param targets
41
41
  * @param work
42
42
  * @param outdir
43
+ * @param progress Called with what is being downloaded (WinSW, NSIS, WiX)
43
44
  */
44
- export declare function buildWindowsPackages(plan: InstallerPlan, targets: WindowsTarget[], work: string, outdir: string): Promise<{
45
+ export declare function buildWindowsPackages(plan: InstallerPlan, targets: WindowsTarget[], work: string, outdir: string, progress?: (line: string) => void): Promise<{
45
46
  target: string;
46
47
  file: string;
47
48
  size: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lakutata/builder",
3
- "version": "3.1.5",
3
+ "version": "3.1.6",
4
4
  "description": "The builder of the applications of the lakutata framework: their bundles, their executables (Node.js, Bun) with their native addons and their resources.",
5
5
  "keywords": [
6
6
  "lakutata",