@blotch/angular-lynx-native 22.2.21 → 22.2.23
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 +4 -0
- package/dist/android/build.d.ts +6 -1
- package/dist/android/build.d.ts.map +1 -1
- package/dist/android/build.js +14 -3
- package/dist/android/run.d.ts +10 -1
- package/dist/android/run.d.ts.map +1 -1
- package/dist/android/run.js +46 -1
- package/dist/dev-build.d.ts +16 -0
- package/dist/dev-build.d.ts.map +1 -0
- package/dist/dev-build.js +44 -0
- package/dist/generate.d.ts +24 -5
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +14 -6
- package/dist/index.d.ts +12 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -9
- package/dist/ios/build.d.ts +14 -1
- package/dist/ios/build.d.ts.map +1 -1
- package/dist/ios/build.js +15 -6
- package/dist/ios/iphone.d.ts +1 -1
- package/dist/ios/iphone.d.ts.map +1 -1
- package/dist/ios/iphone.js +21 -4
- package/dist/ios/project.d.ts +8 -1
- package/dist/ios/project.d.ts.map +1 -1
- package/dist/ios/project.js +17 -3
- package/dist/ios/run.d.ts +1 -1
- package/dist/ios/run.d.ts.map +1 -1
- package/dist/ios/run.js +4 -1
- package/dist/run.d.ts +42 -2
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +16 -1
- package/package.json +1 -1
- package/templates/android/app/src/debug/java/dev/angularlynx/shell/DevServer.kt +159 -0
- package/templates/android/app/src/debug/java/dev/angularlynx/shell/DevServerModules.kt +163 -0
- package/templates/android/app/src/debug/res/xml/network_security_config.xml +13 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/AssetsModule.kt +22 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +8 -1
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ResourceFetchers.kt +12 -6
- package/templates/android/app/src/release/java/dev/angularlynx/shell/DevServer.kt +24 -0
- package/templates/ios/App/AssetsModule.swift +21 -3
- package/templates/ios/App/BundleResourceFetcher.swift +46 -2
- package/templates/ios/App/DevServer.swift +190 -0
- package/templates/ios/App/DevServerModules.swift +223 -0
- package/templates/ios/App/LynxViewController.swift +9 -1
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@ User documentation: [Publishing your App](../website/docs/guide/building-for-pro
|
|
|
11
11
|
3. **Builds** it with `xcodebuild` or Gradle and copies the binaries to `dist/<platform>/`.
|
|
12
12
|
4. **Runs** it, with `--run` (`src/ios/run.ts`, `src/android/run.ts`): picks a simulator, emulator or phone (`--device`, else a running one, else the newest iPhone simulator or the first AVD) and starts it before step 3, so it boots while the app compiles; then installs the app and opens it. iOS uses `simctl` and shows the simulator in DeviceHub (`devices://device/open?id=<UDID>`) or, before Xcode 27.1, the Simulator app. When `--device` names a paired iPhone (`src/ios/iphone.ts`, found with `devicectl list devices`), step 3 builds a development-signed `-sdk iphoneos` app for it instead (`ios.teamId`, `-allowProvisioningUpdates`), and `devicectl` installs and opens it. Android uses the SDK's `adb` and `emulator` and opens the launcher activity by component.
|
|
13
13
|
|
|
14
|
+
5. **Develops** in it, for `ng serve --platform ios|android` (`devServer` in `buildNativeApp`): generates the project into `lynx-native/<platform>-dev` without a bundle, builds Xcode's Debug configuration (for the picked simulator alone, into its own derived data) or Android's debug build type (`:app:assembleDebug`, the debug key), and opens it with the dev server's URL: a `-AngularLynxDevServer <url>` launch argument on iOS (`simctl launch`, `devicectl ... process launch`), `--es AngularLynxDevServer http://localhost:<port>/main.lynx.bundle` and `--es AngularLynxDevServerOrigin <the address the bundle was built with>` on Android, after `adb reverse tcp:<port> tcp:<port>`. A stamp next to the app (`src/dev-build.ts`) records the project's input hash and the device; when both match, the next `ng serve --platform` reinstalls the app without running Xcode or Gradle. An ejected project is always built, and one ejected before this existed (no `DevServer.swift` / `DevServer.kt`) fails with a message to eject again.
|
|
15
|
+
|
|
14
16
|
An ejected project (`ios/` or `android/` with a `.angular-lynx-ejected` marker, written by `ng generate @blotch/angular-lynx:eject`) is built as it is and never regenerated.
|
|
15
17
|
|
|
16
18
|
## The shells
|
|
@@ -21,6 +23,8 @@ Both send the same global props, which the runtime's services read: `platform`,
|
|
|
21
23
|
|
|
22
24
|
Both register the native modules the runtime's services call, which Lynx Explorer doesn't have: `AngularLynxWebAuth` (`WebAuthModule.swift`, `WebAuthModule.kt`) opens `LynxWebAuthSession`'s sign-in page, in `ASWebAuthenticationSession` on iOS and a Custom Tab on Android, and returns the URL it redirects to. `AngularLynxLocalStorage` (`LocalStorageModule.swift`, `LocalStorageModule.kt`) keeps `LynxLocalStorage`'s values in a `UserDefaults` suite and a `SharedPreferences` file of their own. `AngularLynxSecureStorage` (`SecureStorageModule.swift`, `SecureStorageModule.kt`) keeps `LynxSecureStorage`'s in the Keychain on iOS and, on Android, in `SharedPreferences`, each value encrypted with AES-GCM by an Android Keystore key, a file Auto Backup leaves out (`res/xml/backup_rules.xml`, `data_extraction_rules.xml`). `AngularLynxLinking` (`LinkingModule.swift`, `LinkingModule.kt`) opens `LynxLinking`'s links: `openURL` with `UIApplication.open` and an `ACTION_VIEW` intent, `openInApp` in `SFSafariViewController` and a Custom Tab, and `canOpenURL` with `UIApplication.canOpenURL` and `resolveActivity`, which answer only for the schemes the generator writes from angular.json's `canOpenURLSchemes` (with `http`, `https`, `mailto`, `tel` and `sms`) into Info.plist's `LSApplicationQueriesSchemes` and the manifest's `<queries>`. `AngularLynxImagePicker` (`ImagePickerModule.swift`, `ImagePickerModule.kt`) lets the person pick a photo for `LynxImagePicker`, with `PHPickerViewController` on iOS and the Photo Picker on Android, neither of which needs a permission, and calls back with it as base64, re-encoded as an upright JPEG when the app asks for a smaller one or the photo is a format such as HEIC. `AngularLynxShare` (`ShareModule.swift`, `ShareModule.kt`) opens `LynxShare`'s share sheet, `UIActivityViewController` on iOS and an `ACTION_SEND` chooser on Android, with the files written to temporary files on iOS and shared through a `FileProvider` on Android. Save Image on iOS needs `NSPhotoLibraryAddUsageDescription`, which the generator always writes (angular.json's `permissions.savePhotos`, with a default). Android also has `AngularLynxShell`, for the back button.
|
|
23
25
|
|
|
26
|
+
Only the development build (`ng serve --platform`) loads from a dev server: the code is in `App/DevServer.swift` and `App/DevServerModules.swift` under `#if DEBUG`, and in the debug source set on Android (`app/src/debug`, with a no-op `DevServer` in `app/src/release`), so a release build can't be pointed anywhere else. `DevServer` reads the URL from the launch argument or intent extra and keeps it (`UserDefaults`, `SharedPreferences`), so the app opened from the home screen loads from the same server. The loaders (`BundleResourceFetcher.swift`, `ResourceFetchers.kt`) and `AngularLynxAssets` then fetch every relative URL, and on Android every URL on the address the bundle was built with, from the dev server instead of the app, uncached. When the bundle itself doesn't load, `DevServer` covers the page with a message and loads it again every two seconds. rspeedy's live reload client talks to Lynx DevTool, which the shells don't have: `NativeModules.LynxWebSocketModule` (through `@lynx-js/websocket`) for the dev server's socket and `NativeModules.LynxDevToolSetModule.invokeCdp` for a full reload (a DevTool protocol `Page.reload`). The development build registers modules under those names (`DevWebSocketModule`, `DevReloadModule`): a WebSocket with `URLSessionWebSocketTask` and OkHttp that sends the same `websocketOpen`, `websocketMessage`, `websocketClosed` and `websocketFailed` global events as Lynx DevTool's, and a `Page.reload` that loads the bundle again, as DevTool's `LynxPageReloadHelper` does. URLSession sends an empty `Sec-WebSocket-Protocol` header for an empty protocol list, which the dev server refuses, so the iOS socket passes none then. On Android, the debug build's `network_security_config.xml` allows plain HTTP to any host, since the app's own `fetch()` of an imported file goes to the address the bundle was built with; the release build's allows it to `localhost` alone.
|
|
27
|
+
|
|
24
28
|
`AngularLynxClipboard` (`ClipboardModule.swift`, `ClipboardModule.kt`) copies `LynxClipboard`'s text to `UIPasteboard.general` on iOS and `ClipboardManager` on Android, and reads it back.
|
|
25
29
|
|
|
26
30
|
Both link Lynx's XElement library, which holds `<input>`, `<textarea>`, `<overlay>`, `<svg>`, `<blur-view>`, `<viewpager>`, `<refresh>`, the `<scroll-coordinator>` family, `<webview>` and `<video>`. Lynx's core doesn't include these, and a host that doesn't register them renders nothing for those tags (on Android, nothing after them either). XElement's AnimaX and Markdown elements are left out: the runtime doesn't support them. On iOS, `<blur-view>` is XElement's with more of UIKit in it (`App/BlurView.swift`): a `blur-material` attribute for UIKit's adaptive blur materials, which the glass components draw their design before iOS 26 on (Lynx's blur-view has only the styles from before iOS 13); Liquid Glass that materializes, dissolves and eases between effects inside a `glass-container`, where Lynx's sets its effect at once; and a `glass-effect-id` attribute that pairs two glass shapes across a change so one morphs into the other (`App/GlassTransitions.swift`).
|
package/dist/android/build.d.ts
CHANGED
|
@@ -16,13 +16,18 @@ export declare const resolveAndroidSigning: (app: ResolvedApp, env?: NodeJS.Proc
|
|
|
16
16
|
/**
|
|
17
17
|
* Builds the Android shell into a release `.apk` (for emulators and
|
|
18
18
|
* sideloading) and `.aab` (for Google Play). Returns the artifacts' paths.
|
|
19
|
+
*
|
|
20
|
+
* With `development`, `ng serve --platform android`'s app instead: the debug
|
|
21
|
+
* build type's `.apk` alone, which compiles the shell's dev server support in
|
|
22
|
+
* (src/debug) and is signed with the debug key.
|
|
19
23
|
*/
|
|
20
|
-
export declare const buildAndroid: ({ project, app, outputDir, logFile, log, signing, }: {
|
|
24
|
+
export declare const buildAndroid: ({ project, app, outputDir, logFile, log, signing, development, }: {
|
|
21
25
|
readonly project: PreparedProject;
|
|
22
26
|
readonly app: ResolvedApp;
|
|
23
27
|
readonly outputDir: string;
|
|
24
28
|
readonly logFile: string;
|
|
25
29
|
readonly log: (message: string) => void;
|
|
26
30
|
readonly signing: AndroidSigning | undefined;
|
|
31
|
+
readonly development?: boolean;
|
|
27
32
|
}) => Promise<string[]>;
|
|
28
33
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/android/build.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAA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EAAE,cAAc,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC,KAAG,OAAO,CAAC,MAAM,EAAE,CA8DnB,CAAC"}
|
package/dist/android/build.js
CHANGED
|
@@ -40,8 +40,12 @@ export const resolveAndroidSigning = (app, env = process.env) => {
|
|
|
40
40
|
/**
|
|
41
41
|
* Builds the Android shell into a release `.apk` (for emulators and
|
|
42
42
|
* sideloading) and `.aab` (for Google Play). Returns the artifacts' paths.
|
|
43
|
+
*
|
|
44
|
+
* With `development`, `ng serve --platform android`'s app instead: the debug
|
|
45
|
+
* build type's `.apk` alone, which compiles the shell's dev server support in
|
|
46
|
+
* (src/debug) and is signed with the debug key.
|
|
43
47
|
*/
|
|
44
|
-
export const buildAndroid = async ({ project, app, outputDir, logFile, log, signing, }) => {
|
|
48
|
+
export const buildAndroid = async ({ project, app, outputDir, logFile, log, signing, development = false, }) => {
|
|
45
49
|
// Signing values reach Gradle as project properties through
|
|
46
50
|
// ORG_GRADLE_PROJECT_* environment variables: never on the command line,
|
|
47
51
|
// which the process list and our build log would show, and never in a file
|
|
@@ -68,7 +72,7 @@ export const buildAndroid = async ({ project, app, outputDir, logFile, log, sign
|
|
|
68
72
|
ORG_GRADLE_PROJECT_angularLynxKeyPassword: signing.keyPassword,
|
|
69
73
|
}),
|
|
70
74
|
};
|
|
71
|
-
if (!signing) {
|
|
75
|
+
if (!signing && !development) {
|
|
72
76
|
log('Signing the release build with the debug key: set android.signing in angular.json for a Google Play upload.');
|
|
73
77
|
}
|
|
74
78
|
log('Building the Android app');
|
|
@@ -78,9 +82,16 @@ export const buildAndroid = async ({ project, app, outputDir, logFile, log, sign
|
|
|
78
82
|
// gradlew arrives without its executable bit.
|
|
79
83
|
chmodSync(path.join(project.dir, 'gradlew'), 0o755);
|
|
80
84
|
}
|
|
81
|
-
await run(gradlew,
|
|
85
|
+
await run(gradlew, development
|
|
86
|
+
? [':app:assembleDebug', '--console=plain']
|
|
87
|
+
: [':app:assembleRelease', ':app:bundleRelease', '--console=plain'], { cwd: project.dir, logFile, env });
|
|
82
88
|
mkdirSync(outputDir, { recursive: true });
|
|
83
89
|
const outputs = path.join(project.dir, 'app/build/outputs');
|
|
90
|
+
if (development) {
|
|
91
|
+
const apk = path.join(outputDir, `${app.artifactName}-dev.apk`);
|
|
92
|
+
cpSync(path.join(outputs, 'apk/debug/app-debug.apk'), apk);
|
|
93
|
+
return [apk];
|
|
94
|
+
}
|
|
84
95
|
const apk = path.join(outputDir, `${app.artifactName}.apk`);
|
|
85
96
|
const aab = path.join(outputDir, `${app.artifactName}.aab`);
|
|
86
97
|
cpSync(path.join(outputs, 'apk/release/app-release.apk'), apk);
|
package/dist/android/run.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type DevServerOptions, type RunTarget } from '../run.ts';
|
|
2
2
|
/**
|
|
3
3
|
* The activity the shell template declares: its manifest names `.MainActivity`
|
|
4
4
|
* in the `dev.angularlynx.shell` namespace, whatever the app's ID is.
|
|
@@ -57,5 +57,14 @@ export declare const startAndroidDevice: ({ device, logFile, log, env, timing, }
|
|
|
57
57
|
readonly env?: NodeJS.ProcessEnv;
|
|
58
58
|
readonly timing?: typeof TIMING;
|
|
59
59
|
}) => Promise<RunTarget>;
|
|
60
|
+
/**
|
|
61
|
+
* The intent extras that point the development app at the dev server
|
|
62
|
+
* (DevServer.kt reads them): the bundle at localhost, which `adb reverse`
|
|
63
|
+
* forwards to this machine, and the address the bundle was built with, so the
|
|
64
|
+
* app sends what the bundle asks of that address (lazy bundles, images, the
|
|
65
|
+
* live reload socket) to localhost too. Quoted, because adb runs `am` in the
|
|
66
|
+
* device's shell.
|
|
67
|
+
*/
|
|
68
|
+
export declare const androidDevServerExtras: (devServer: DevServerOptions | undefined) => string[];
|
|
60
69
|
export {};
|
|
61
70
|
//# sourceMappingURL=run.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/android/run.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/android/run.ts"],"names":[],"mappings":"AAKA,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACf,MAAM,WAAW,CAAC;AAGnB;;;GAGG;AACH,eAAO,MAAM,cAAc,uCAAuC,CAAC;AAEnE,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,gFAAgF;IAChF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,MAAM,KAAG,SAAS,EAQtD,CAAC;AAIL,mFAAmF;AACnF,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACnD;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,SAAS,SAAS,EAAE,EAC7B,QAAQ,MAAM,GAAG,SAAS,EAC1B,kCAGG;IACD,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClE,QAAQ,CAAC,kBAAkB,EAAE,MAAM,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;CAC/D,KACA,OAAO,CAAC,aAAa,CAsEvB,CAAC;AAEF,+EAA+E;AAC/E,QAAA,MAAM,MAAM;;;CAA0C,CAAC;AAEvD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAU,wCAMtC;IACD,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,MAAM,CAAC;CACjC,KAAG,OAAO,CAAC,SAAS,CAmKpB,CAAC;AAUF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GACjC,WAAW,gBAAgB,GAAG,SAAS,KACtC,MAAM,EAaR,CAAC"}
|
package/dist/android/run.js
CHANGED
|
@@ -2,6 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { closeSync, existsSync, openSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { NativeBuildError, capture, run } from "../process.js";
|
|
5
|
+
import { DEV_SERVER_ARGUMENT, DEV_SERVER_ORIGIN_ARGUMENT, } from "../run.js";
|
|
5
6
|
import { findAndroidSdk } from "./project.js";
|
|
6
7
|
/**
|
|
7
8
|
* The activity the shell template declares: its manifest names `.MainActivity`
|
|
@@ -139,7 +140,7 @@ export const startAndroidDevice = async ({ device, logFile, log, env = process.e
|
|
|
139
140
|
}
|
|
140
141
|
const emulatorLog = emulatorLogFile(logFile);
|
|
141
142
|
return {
|
|
142
|
-
launch: async (binary, app) => {
|
|
143
|
+
launch: async (binary, app, devServer) => {
|
|
143
144
|
const serials = new Set(before.map((candidate) => candidate.serial));
|
|
144
145
|
let serial = 'serial' in choice ? choice.serial : undefined;
|
|
145
146
|
// An emulator shows up in `adb devices` a few seconds after it starts,
|
|
@@ -193,6 +194,18 @@ export const startAndroidDevice = async ({ device, logFile, log, env = process.e
|
|
|
193
194
|
app.id,
|
|
194
195
|
]);
|
|
195
196
|
const component = resolved?.trim().split('\n').at(-1)?.trim();
|
|
197
|
+
if (devServer) {
|
|
198
|
+
// Lets the app reach the dev server at localhost, whatever network
|
|
199
|
+
// the device is on: adb forwards the device's port to this
|
|
200
|
+
// machine's, over USB or wireless debugging, and an emulator's too.
|
|
201
|
+
await adb([
|
|
202
|
+
'-s',
|
|
203
|
+
serial,
|
|
204
|
+
'reverse',
|
|
205
|
+
`tcp:${devServerPort(devServer)}`,
|
|
206
|
+
`tcp:${devServerPort(devServer)}`,
|
|
207
|
+
]);
|
|
208
|
+
}
|
|
196
209
|
// -S stops the copy a previous `--run` left open first, as iOS's
|
|
197
210
|
// --terminate-running-process does.
|
|
198
211
|
const output = await adb([
|
|
@@ -205,6 +218,7 @@ export const startAndroidDevice = async ({ device, logFile, log, env = process.e
|
|
|
205
218
|
'-W',
|
|
206
219
|
'-n',
|
|
207
220
|
component?.includes('/') ? component : `${app.id}/${SHELL_ACTIVITY}`,
|
|
221
|
+
...androidDevServerExtras(devServer),
|
|
208
222
|
]);
|
|
209
223
|
// `am start` exits with 0 even when it fails, and says why on stdout,
|
|
210
224
|
// last: `Error type 3`, then `Error: Activity class ... does not exist.`
|
|
@@ -219,6 +233,37 @@ export const startAndroidDevice = async ({ device, logFile, log, env = process.e
|
|
|
219
233
|
},
|
|
220
234
|
};
|
|
221
235
|
};
|
|
236
|
+
/**
|
|
237
|
+
* The dev server's port, which `adb reverse` forwards.
|
|
238
|
+
*/
|
|
239
|
+
const devServerPort = (devServer) => {
|
|
240
|
+
const url = new URL(devServer.bundleUrl);
|
|
241
|
+
return url.port || (url.protocol === 'https:' ? '443' : '80');
|
|
242
|
+
};
|
|
243
|
+
/**
|
|
244
|
+
* The intent extras that point the development app at the dev server
|
|
245
|
+
* (DevServer.kt reads them): the bundle at localhost, which `adb reverse`
|
|
246
|
+
* forwards to this machine, and the address the bundle was built with, so the
|
|
247
|
+
* app sends what the bundle asks of that address (lazy bundles, images, the
|
|
248
|
+
* live reload socket) to localhost too. Quoted, because adb runs `am` in the
|
|
249
|
+
* device's shell.
|
|
250
|
+
*/
|
|
251
|
+
export const androidDevServerExtras = (devServer) => {
|
|
252
|
+
if (!devServer)
|
|
253
|
+
return [];
|
|
254
|
+
const built = new URL(devServer.bundleUrl);
|
|
255
|
+
const local = new URL(devServer.bundleUrl);
|
|
256
|
+
local.hostname = 'localhost';
|
|
257
|
+
return [
|
|
258
|
+
'--es',
|
|
259
|
+
DEV_SERVER_ARGUMENT,
|
|
260
|
+
shellQuote(local.href),
|
|
261
|
+
'--es',
|
|
262
|
+
DEV_SERVER_ORIGIN_ARGUMENT,
|
|
263
|
+
shellQuote(built.origin),
|
|
264
|
+
];
|
|
265
|
+
};
|
|
266
|
+
const shellQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
222
267
|
const capitalize = (text) => text[0].toUpperCase() + text.slice(1);
|
|
223
268
|
const emulatorLogFile = (logFile) => path.join(path.dirname(logFile), 'emulator.log');
|
|
224
269
|
/**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the development app depends on: the generated project's input hash,
|
|
3
|
+
* and the device it was built for (an iPhone build is signed for that
|
|
4
|
+
* phone; a simulator build is compiled for that simulator's architecture).
|
|
5
|
+
*/
|
|
6
|
+
export declare const devBuildKey: (projectHash: string, destination: string) => string;
|
|
7
|
+
/**
|
|
8
|
+
* The artifacts the last development build in `outputDir` left, when it was
|
|
9
|
+
* built for `key` and they're all still there; undefined to build again.
|
|
10
|
+
*/
|
|
11
|
+
export declare const reusableDevBuild: (outputDir: string, key: string) => string[] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Records a development build, for {@link reusableDevBuild}.
|
|
14
|
+
*/
|
|
15
|
+
export declare const recordDevBuild: (outputDir: string, key: string, artifacts: readonly string[]) => void;
|
|
16
|
+
//# sourceMappingURL=dev-build.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-build.d.ts","sourceRoot":"","sources":["../src/dev-build.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,aAAa,MAAM,EAAE,aAAa,MAAM,WAChC,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,WAAW,MAAM,EACjB,KAAK,MAAM,KACV,MAAM,EAAE,GAAG,SAab,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GACzB,WAAW,MAAM,EACjB,KAAK,MAAM,EACX,WAAW,SAAS,MAAM,EAAE,KAC3B,IAOA,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Written next to `ng serve --platform`'s development app once it's built:
|
|
5
|
+
* the hash of the generated project it was built from and where it was built
|
|
6
|
+
* for, then the artifacts. A second `ng serve --platform` with the same
|
|
7
|
+
* native inputs then reinstalls the app without running Xcode or Gradle,
|
|
8
|
+
* which take a minute or more even with nothing to compile. The app loads
|
|
9
|
+
* its bundle from the dev server, so nothing else goes into it.
|
|
10
|
+
*/
|
|
11
|
+
const STAMP = '.angular-lynx-build';
|
|
12
|
+
/**
|
|
13
|
+
* What the development app depends on: the generated project's input hash,
|
|
14
|
+
* and the device it was built for (an iPhone build is signed for that
|
|
15
|
+
* phone; a simulator build is compiled for that simulator's architecture).
|
|
16
|
+
*/
|
|
17
|
+
export const devBuildKey = (projectHash, destination) => `${projectHash}\n${destination}\n`;
|
|
18
|
+
/**
|
|
19
|
+
* The artifacts the last development build in `outputDir` left, when it was
|
|
20
|
+
* built for `key` and they're all still there; undefined to build again.
|
|
21
|
+
*/
|
|
22
|
+
export const reusableDevBuild = (outputDir, key) => {
|
|
23
|
+
const stamp = path.join(outputDir, STAMP);
|
|
24
|
+
if (!existsSync(stamp))
|
|
25
|
+
return undefined;
|
|
26
|
+
const contents = readFileSync(stamp, 'utf8');
|
|
27
|
+
if (!contents.startsWith(key))
|
|
28
|
+
return undefined;
|
|
29
|
+
const artifacts = contents
|
|
30
|
+
.slice(key.length)
|
|
31
|
+
.split('\n')
|
|
32
|
+
.filter(Boolean)
|
|
33
|
+
.map((artifact) => path.join(outputDir, artifact));
|
|
34
|
+
return artifacts.length > 0 && artifacts.every((file) => existsSync(file))
|
|
35
|
+
? artifacts
|
|
36
|
+
: undefined;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Records a development build, for {@link reusableDevBuild}.
|
|
40
|
+
*/
|
|
41
|
+
export const recordDevBuild = (outputDir, key, artifacts) => writeFileSync(path.join(outputDir, STAMP), key +
|
|
42
|
+
artifacts
|
|
43
|
+
.map((artifact) => path.relative(outputDir, artifact))
|
|
44
|
+
.join('\n'));
|
package/dist/generate.d.ts
CHANGED
|
@@ -10,8 +10,11 @@ export declare const TEMPLATES_DIR: string;
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const EJECT_MARKER = ".angular-lynx-ejected";
|
|
12
12
|
export type PlatformGenerator = {
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Writes the config into a fresh copy of the template. `development` is
|
|
15
|
+
* true for `ng serve --platform`'s development app.
|
|
16
|
+
*/
|
|
17
|
+
readonly configure: (dir: string, app: ResolvedApp, projectRoot: string, development?: boolean) => void;
|
|
15
18
|
/** Where the Lynx bundle and its assets go inside the native project. */
|
|
16
19
|
readonly bundleDir: (dir: string) => string;
|
|
17
20
|
};
|
|
@@ -22,6 +25,11 @@ export type PreparedProject = {
|
|
|
22
25
|
readonly ejected: boolean;
|
|
23
26
|
/** False when the cached project matched the inputs and was reused. */
|
|
24
27
|
readonly regenerated: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The hash of the generated project's inputs, or undefined for an ejected
|
|
30
|
+
* project, whose inputs are the user's own files.
|
|
31
|
+
*/
|
|
32
|
+
readonly hash?: string;
|
|
25
33
|
};
|
|
26
34
|
/**
|
|
27
35
|
* Makes the native project for a platform ready to build: the generated one in
|
|
@@ -31,17 +39,28 @@ export type PreparedProject = {
|
|
|
31
39
|
* the template files, the app options and the icon images) matches the last run, so
|
|
32
40
|
* Xcode and Gradle keep their incremental state between builds. The bundle is
|
|
33
41
|
* copied in on every build, because it changes on every build.
|
|
42
|
+
*
|
|
43
|
+
* `ng serve --platform`'s development app is generated in a folder of its
|
|
44
|
+
* own, `<workDir>/<platform>-dev`, so it and `ng build --platform`'s app each
|
|
45
|
+
* keep their incremental build state, and one never regenerates or overwrites
|
|
46
|
+
* the other. It gets no bundle (`bundleDir` undefined): it loads the bundle
|
|
47
|
+
* from the dev server.
|
|
34
48
|
*/
|
|
35
|
-
export declare const prepareProject: ({ platform, generator, projectRoot, workDir, app, bundleDir, packageVersion, }: {
|
|
49
|
+
export declare const prepareProject: ({ platform, generator, projectRoot, workDir, app, bundleDir, packageVersion, development, }: {
|
|
36
50
|
readonly platform: Platform;
|
|
37
51
|
readonly generator: PlatformGenerator;
|
|
38
52
|
readonly projectRoot: string;
|
|
39
53
|
/** Where generated projects go (see `BuildNativeAppOptions.workDir`). */
|
|
40
54
|
readonly workDir: string;
|
|
41
55
|
readonly app: ResolvedApp;
|
|
42
|
-
/**
|
|
43
|
-
|
|
56
|
+
/**
|
|
57
|
+
* The rspeedy output folder (dist/), or undefined for the development app,
|
|
58
|
+
* which takes no bundle.
|
|
59
|
+
*/
|
|
60
|
+
readonly bundleDir: string | undefined;
|
|
44
61
|
readonly packageVersion: string;
|
|
62
|
+
/** The development app `ng serve --platform` runs. */
|
|
63
|
+
readonly development?: boolean;
|
|
45
64
|
}) => PreparedProject;
|
|
46
65
|
/**
|
|
47
66
|
* Up to 22.2.2, native builds worked in `.angular-lynx/` at the project root.
|
package/dist/generate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAaA,OAAO,EAAyB,KAAK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,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,sDAAsD;IACtD,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;CAChC,KAAG,eA2BH,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,MAAM,EACnB,KAAK,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,KAC7B,IAUF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,KAAG,IAqBrD,CAAC"}
|
package/dist/generate.js
CHANGED
|
@@ -21,14 +21,21 @@ const HASH_FILE = '.angular-lynx-hash';
|
|
|
21
21
|
* the template files, the app options and the icon images) matches the last run, so
|
|
22
22
|
* Xcode and Gradle keep their incremental state between builds. The bundle is
|
|
23
23
|
* copied in on every build, because it changes on every build.
|
|
24
|
+
*
|
|
25
|
+
* `ng serve --platform`'s development app is generated in a folder of its
|
|
26
|
+
* own, `<workDir>/<platform>-dev`, so it and `ng build --platform`'s app each
|
|
27
|
+
* keep their incremental build state, and one never regenerates or overwrites
|
|
28
|
+
* the other. It gets no bundle (`bundleDir` undefined): it loads the bundle
|
|
29
|
+
* from the dev server.
|
|
24
30
|
*/
|
|
25
|
-
export const prepareProject = ({ platform, generator, projectRoot, workDir, app, bundleDir, packageVersion, }) => {
|
|
31
|
+
export const prepareProject = ({ platform, generator, projectRoot, workDir, app, bundleDir, packageVersion, development = false, }) => {
|
|
26
32
|
const ejectedDir = path.join(projectRoot, platform);
|
|
27
33
|
if (existsSync(path.join(ejectedDir, EJECT_MARKER))) {
|
|
28
|
-
|
|
34
|
+
if (bundleDir)
|
|
35
|
+
copyBundle(bundleDir, generator.bundleDir(ejectedDir));
|
|
29
36
|
return { dir: ejectedDir, ejected: true, regenerated: false };
|
|
30
37
|
}
|
|
31
|
-
const dir = path.join(workDir, platform);
|
|
38
|
+
const dir = path.join(workDir, development ? `${platform}-dev` : platform);
|
|
32
39
|
const hash = inputHash({ platform, app, projectRoot, packageVersion });
|
|
33
40
|
const hashFile = path.join(dir, HASH_FILE);
|
|
34
41
|
const upToDate = existsSync(hashFile) && readFileSync(hashFile, 'utf8') === hash;
|
|
@@ -36,15 +43,16 @@ export const prepareProject = ({ platform, generator, projectRoot, workDir, app,
|
|
|
36
43
|
rmSync(dir, { recursive: true, force: true });
|
|
37
44
|
mkdirSync(dir, { recursive: true });
|
|
38
45
|
cpSync(path.join(TEMPLATES_DIR, platform), dir, { recursive: true });
|
|
39
|
-
generator.configure(dir, app, projectRoot);
|
|
46
|
+
generator.configure(dir, app, projectRoot, development);
|
|
40
47
|
writeFileSync(hashFile, hash);
|
|
41
48
|
}
|
|
42
49
|
// Generated projects are build output. `ng new` already ignores Angular's
|
|
43
50
|
// cache, but a moved cache (`cli.cache.path`) or an edited .gitignore may
|
|
44
51
|
// not be: keep them out of the user's git without asking them to edit it.
|
|
45
52
|
writeFileSync(path.join(workDir, '.gitignore'), '*\n');
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
if (bundleDir)
|
|
54
|
+
copyBundle(bundleDir, generator.bundleDir(dir));
|
|
55
|
+
return { dir, ejected: false, regenerated: !upToDate, hash };
|
|
48
56
|
};
|
|
49
57
|
/**
|
|
50
58
|
* Up to 22.2.2, native builds worked in `.angular-lynx/` at the project root.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Platform } from './generate.ts';
|
|
2
2
|
import { type NativeAppOptions } from './options.ts';
|
|
3
|
-
import type { RunOptions } from './run.ts';
|
|
3
|
+
import type { DevServerOptions, RunOptions } from './run.ts';
|
|
4
4
|
export type { Platform } from './generate.ts';
|
|
5
5
|
export { EJECT_MARKER, copyBundle, prepareProject } from './generate.ts';
|
|
6
6
|
export { renderEjectedProject } from './eject.ts';
|
|
@@ -8,7 +8,7 @@ export { LYNX_IOS, FRAMEWORKS_ENV } from './ios/frameworks.ts';
|
|
|
8
8
|
export type { AndroidOptions, IosExportMethod, IosOptions, NativeAppOptions, Orientation, Permission, ResolvedApp, } from './options.ts';
|
|
9
9
|
export { NativeConfigError, resolveAppOptions } from './options.ts';
|
|
10
10
|
export { NativeBuildError } from './process.ts';
|
|
11
|
-
export type { RunOptions } from './run.ts';
|
|
11
|
+
export type { DevServerOptions, RunOptions } from './run.ts';
|
|
12
12
|
export declare const PACKAGE_VERSION: string;
|
|
13
13
|
export type BuildNativeAppOptions = {
|
|
14
14
|
readonly platform: Platform;
|
|
@@ -24,7 +24,10 @@ export type BuildNativeAppOptions = {
|
|
|
24
24
|
readonly projectName: string;
|
|
25
25
|
/** The project's package.json version, the default app version. */
|
|
26
26
|
readonly packageVersion?: string;
|
|
27
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* The rspeedy output folder holding main.lynx.bundle. Unused with
|
|
29
|
+
* `devServer`: the development app loads the bundle from the server.
|
|
30
|
+
*/
|
|
28
31
|
readonly bundleDir: string;
|
|
29
32
|
/** Where the binaries go, e.g. dist/ios. Emptied before they're written. */
|
|
30
33
|
readonly outputDir: string;
|
|
@@ -34,6 +37,12 @@ export type BuildNativeAppOptions = {
|
|
|
34
37
|
* built: `ng build --platform <platform> --run`.
|
|
35
38
|
*/
|
|
36
39
|
readonly run?: RunOptions;
|
|
40
|
+
/**
|
|
41
|
+
* `ng serve --platform <platform>`: build the development app, which loads
|
|
42
|
+
* its bundle from this dev server and reloads on every edit, and open it
|
|
43
|
+
* where `run` says. Needs `run`.
|
|
44
|
+
*/
|
|
45
|
+
readonly devServer?: DevServerOptions;
|
|
37
46
|
readonly log: (message: string) => void;
|
|
38
47
|
};
|
|
39
48
|
/**
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,KAAK,QAAQ,EAGd,MAAM,eAAe,CAAC;AASvB,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,cAAc,CAAC;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE7D,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/D,YAAY,EACV,cAAc,EACd,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,WAAW,GACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAW7D,eAAO,MAAM,eAAe,EAAE,MAErB,CAAC;AAEV,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,mEAAmE;IACnE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,8CAA8C;IAC9C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,CAAC;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;IACtC,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,SAAS,qBAAqB,KAC7B,OAAO,CAAC;IACT,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,CAyIA,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { androidGenerator } from "./android/project.js";
|
|
4
4
|
import { buildAndroid, resolveAndroidSigning } from "./android/build.js";
|
|
5
5
|
import { startAndroidDevice } from "./android/run.js";
|
|
6
|
+
import { devBuildKey, recordDevBuild, reusableDevBuild } from "./dev-build.js";
|
|
6
7
|
import { prepareProject, removeLegacyWorkDir, } from "./generate.js";
|
|
7
8
|
import { buildIos, missingTeamMessage, resolveIosSigning, } from "./ios/build.js";
|
|
8
9
|
import { resolveLynxFrameworks } from "./ios/frameworks.js";
|
|
@@ -15,6 +16,14 @@ export { renderEjectedProject } from "./eject.js";
|
|
|
15
16
|
export { LYNX_IOS, FRAMEWORKS_ENV } from "./ios/frameworks.js";
|
|
16
17
|
export { NativeConfigError, resolveAppOptions } from "./options.js";
|
|
17
18
|
export { NativeBuildError } from "./process.js";
|
|
19
|
+
/**
|
|
20
|
+
* The shell file that loads the app from the dev server in the development
|
|
21
|
+
* build, which a project ejected before `ng serve --platform` lacks.
|
|
22
|
+
*/
|
|
23
|
+
const DEV_SERVER_SOURCE = {
|
|
24
|
+
ios: 'App/DevServer.swift',
|
|
25
|
+
android: 'app/src/debug/java/dev/angularlynx/shell/DevServer.kt',
|
|
26
|
+
};
|
|
18
27
|
export const PACKAGE_VERSION = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')).version;
|
|
19
28
|
/**
|
|
20
29
|
* Turns a built Lynx bundle into native binaries: generates (or reuses) the
|
|
@@ -23,7 +32,10 @@ export const PACKAGE_VERSION = JSON.parse(readFileSync(new URL('../package.json'
|
|
|
23
32
|
* Returns the paths of the binaries it wrote to `outputDir`.
|
|
24
33
|
*/
|
|
25
34
|
export const buildNativeApp = async (options) => {
|
|
26
|
-
const { platform, projectRoot, workDir, log } = options;
|
|
35
|
+
const { platform, projectRoot, workDir, log, devServer } = options;
|
|
36
|
+
if (devServer && !options.run) {
|
|
37
|
+
throw new Error('The development app is built to run on a device: pass `run` with `devServer`.');
|
|
38
|
+
}
|
|
27
39
|
if (platform === 'ios' && process.platform !== 'darwin') {
|
|
28
40
|
throw new Error('Building for iOS needs macOS with Xcode installed: Apple only ships its build tools for macOS.');
|
|
29
41
|
}
|
|
@@ -32,11 +44,18 @@ export const buildNativeApp = async (options) => {
|
|
|
32
44
|
packageVersion: options.packageVersion,
|
|
33
45
|
});
|
|
34
46
|
// Resolved before generating anything, so a missing secret fails in
|
|
35
|
-
// milliseconds rather than after a native build.
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
// milliseconds rather than after a native build. The development app is
|
|
48
|
+
// signed only as far as a device needs: an iPhone takes the team's
|
|
49
|
+
// development signing, never an .ipa's export, and Android's debug build
|
|
50
|
+
// type always uses the debug key, so its upload key isn't read.
|
|
51
|
+
const iosSigning = platform === 'ios'
|
|
52
|
+
? withoutExport(resolveIosSigning(app), devServer)
|
|
53
|
+
: undefined;
|
|
54
|
+
const androidSigning = platform === 'android' && !devServer
|
|
55
|
+
? resolveAndroidSigning(app)
|
|
56
|
+
: undefined;
|
|
38
57
|
removeLegacyWorkDir(projectRoot, log);
|
|
39
|
-
const logFile = path.join(workDir, 'logs', `${platform}.log`);
|
|
58
|
+
const logFile = path.join(workDir, 'logs', `${platform}${devServer ? '-dev' : ''}.log`);
|
|
40
59
|
mkdirSync(path.dirname(logFile), { recursive: true });
|
|
41
60
|
writeFileSync(logFile, '');
|
|
42
61
|
const target = !options.run
|
|
@@ -55,14 +74,34 @@ export const buildNativeApp = async (options) => {
|
|
|
55
74
|
projectRoot,
|
|
56
75
|
workDir,
|
|
57
76
|
app,
|
|
58
|
-
bundleDir: options.bundleDir,
|
|
77
|
+
bundleDir: devServer ? undefined : options.bundleDir,
|
|
59
78
|
packageVersion: PACKAGE_VERSION,
|
|
79
|
+
development: !!devServer,
|
|
60
80
|
});
|
|
81
|
+
if (devServer &&
|
|
82
|
+
project.ejected &&
|
|
83
|
+
!existsSync(path.join(project.dir, DEV_SERVER_SOURCE[platform]))) {
|
|
84
|
+
throw new NativeBuildError(`The ejected ${platform}/ project has no ${DEV_SERVER_SOURCE[platform]}: it was ejected before \`ng serve --platform\` existed, so it can't load the app from the dev server. Eject again into a new folder (move ${platform}/ aside and run \`ng generate @blotch/angular-lynx:eject --platform ${platform}\`), then carry your changes over to it.`);
|
|
85
|
+
}
|
|
61
86
|
log(project.ejected
|
|
62
87
|
? `Using the ejected ${platform}/ project`
|
|
63
88
|
: project.regenerated
|
|
64
89
|
? `Generated the ${platform} project`
|
|
65
90
|
: `Reusing the generated ${platform} project (no config changes)`);
|
|
91
|
+
// Where the app was built for, which a development build for a simulator
|
|
92
|
+
// or a phone depends on as much as on the project.
|
|
93
|
+
const destination = target?.iPhone?.udid ?? target?.simulator?.udid ?? '';
|
|
94
|
+
// An ejected project is the user's own, whose native code may have changed
|
|
95
|
+
// without anything here knowing, so it's always built.
|
|
96
|
+
const devKey = devServer && project.hash
|
|
97
|
+
? devBuildKey(project.hash, destination)
|
|
98
|
+
: undefined;
|
|
99
|
+
const builtArtifacts = devKey && reusableDevBuild(options.outputDir, devKey);
|
|
100
|
+
if (builtArtifacts) {
|
|
101
|
+
log(`Reusing the development ${platform} app (no native changes)`);
|
|
102
|
+
await target.launch(builtArtifacts[0], app, devServer);
|
|
103
|
+
return { artifacts: builtArtifacts, projectDir: project.dir };
|
|
104
|
+
}
|
|
66
105
|
// rspeedy's clean leaves dist/ios and dist/android alone, so building one
|
|
67
106
|
// platform doesn't delete the other's app. Emptying this platform's folder
|
|
68
107
|
// here keeps what an earlier build wrote from outliving it: an .ipa from a
|
|
@@ -73,12 +112,17 @@ export const buildNativeApp = async (options) => {
|
|
|
73
112
|
project,
|
|
74
113
|
app,
|
|
75
114
|
frameworksDir: await resolveLynxFrameworks(logFile, log),
|
|
76
|
-
|
|
115
|
+
// Apart from the release build's, so switching between `ng serve`
|
|
116
|
+
// and `ng build` leaves both incremental.
|
|
117
|
+
buildDir: path.join(workDir, 'build', devServer ? 'ios-dev' : 'ios'),
|
|
77
118
|
outputDir: options.outputDir,
|
|
78
119
|
logFile,
|
|
79
120
|
log,
|
|
80
121
|
signing: iosSigning,
|
|
81
122
|
device: target?.iPhone,
|
|
123
|
+
development: !!devServer,
|
|
124
|
+
// A release build is for any simulator: it's an artifact in dist/.
|
|
125
|
+
simulator: devServer ? target?.simulator : undefined,
|
|
82
126
|
})
|
|
83
127
|
: await buildAndroid({
|
|
84
128
|
project,
|
|
@@ -87,10 +131,22 @@ export const buildNativeApp = async (options) => {
|
|
|
87
131
|
logFile,
|
|
88
132
|
log,
|
|
89
133
|
signing: androidSigning,
|
|
134
|
+
development: !!devServer,
|
|
90
135
|
});
|
|
136
|
+
if (devKey)
|
|
137
|
+
recordDevBuild(options.outputDir, devKey, artifacts);
|
|
91
138
|
await target?.launch(
|
|
92
139
|
// The simulator's or the iPhone's .app or the .apk, not the .ipa or .aab
|
|
93
140
|
// for the stores.
|
|
94
|
-
artifacts.find((artifact) => artifact.endsWith(platform === 'ios' ? '.app' : '.apk')), app);
|
|
141
|
+
artifacts.find((artifact) => artifact.endsWith(platform === 'ios' ? '.app' : '.apk')), app, devServer);
|
|
95
142
|
return { artifacts, projectDir: project.dir };
|
|
96
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* The development app never exports an .ipa, so its signing has no export.
|
|
146
|
+
*/
|
|
147
|
+
const withoutExport = (signing, devServer) => {
|
|
148
|
+
if (!signing || !devServer || !signing.export)
|
|
149
|
+
return signing;
|
|
150
|
+
const { export: _, ...rest } = signing;
|
|
151
|
+
return rest;
|
|
152
|
+
};
|
package/dist/ios/build.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export declare const resolveIosSigning: (app: ResolvedApp, env?: NodeJS.ProcessE
|
|
|
34
34
|
* would be thrown away, and archiving the `.ipa` takes minutes a Personal
|
|
35
35
|
* Team's run would spend failing. Returns the artifacts' paths.
|
|
36
36
|
*/
|
|
37
|
-
export declare const buildIos: ({ project, app, frameworksDir, buildDir, outputDir, logFile, log, signing, device, }: {
|
|
37
|
+
export declare const buildIos: ({ project, app, frameworksDir, buildDir, outputDir, logFile, log, signing, device, development, simulator, }: {
|
|
38
38
|
readonly project: PreparedProject;
|
|
39
39
|
readonly app: ResolvedApp;
|
|
40
40
|
readonly frameworksDir: string;
|
|
@@ -49,6 +49,19 @@ export declare const buildIos: ({ project, app, frameworksDir, buildDir, outputD
|
|
|
49
49
|
readonly udid: string;
|
|
50
50
|
readonly name: string;
|
|
51
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* `ng serve --platform ios`'s development app: the Debug configuration,
|
|
54
|
+
* which compiles the shell's dev server support in (DevServer.swift) and
|
|
55
|
+
* builds for one architecture, and no `.ipa`.
|
|
56
|
+
*/
|
|
57
|
+
readonly development?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* The simulator the development app runs on. The Debug configuration builds
|
|
60
|
+
* only its architecture, so it builds for that simulator rather than any.
|
|
61
|
+
*/
|
|
62
|
+
readonly simulator?: {
|
|
63
|
+
readonly udid: string;
|
|
64
|
+
};
|
|
52
65
|
}) => Promise<string[]>;
|
|
53
66
|
/**
|
|
54
67
|
* What to do when `--run` targets an iPhone but nothing says who signs the
|
package/dist/ios/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/ios/build.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIlE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,WAAW,EAChB,MAAK,MAAM,CAAC,UAAwB,KACnC,UAAU,GAAG,SAwCf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAU,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/ios/build.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAA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