@blotch/angular-lynx-native 22.2.25 → 22.2.26

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 (47) hide show
  1. package/README.md +5 -3
  2. package/dist/android/project.d.ts +2 -1
  3. package/dist/android/project.d.ts.map +1 -1
  4. package/dist/android/project.js +4 -1
  5. package/dist/generate.d.ts +1 -1
  6. package/dist/generate.js +8 -2
  7. package/dist/index.d.ts +3 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +9 -0
  10. package/dist/ios/project.d.ts +3 -2
  11. package/dist/ios/project.d.ts.map +1 -1
  12. package/dist/ios/project.js +12 -2
  13. package/dist/options.d.ts +57 -0
  14. package/dist/options.d.ts.map +1 -1
  15. package/dist/options.js +51 -0
  16. package/dist/png.d.ts +5 -0
  17. package/dist/png.d.ts.map +1 -1
  18. package/dist/png.js +19 -5
  19. package/dist/splash.d.ts +70 -0
  20. package/dist/splash.d.ts.map +1 -0
  21. package/dist/splash.js +239 -0
  22. package/package.json +1 -1
  23. package/templates/android/README.md +8 -1
  24. package/templates/android/app/build.gradle.kts +4 -0
  25. package/templates/android/app/src/debug/java/dev/angularlynx/shell/DevServer.kt +6 -0
  26. package/templates/android/app/src/main/AndroidManifest.xml +3 -1
  27. package/templates/android/app/src/main/java/dev/angularlynx/shell/AssetsModule.kt +2 -1
  28. package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasUI.kt +16 -3
  29. package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +57 -1
  30. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellModule.kt +10 -0
  31. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLContext.kt +15 -4
  32. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLModule.kt +10 -1
  33. package/templates/android/app/src/main/res/values/colors.xml +3 -2
  34. package/templates/android/app/src/main/res/values/splash.xml +9 -0
  35. package/templates/android/app/src/main/res/values/themes.xml +14 -0
  36. package/templates/android/app/src/release/java/dev/angularlynx/shell/DevServer.kt +2 -0
  37. package/templates/ios/App/AngularLynxWebGL.h +34 -6
  38. package/templates/ios/App/AngularLynxWebGL.m +58 -23
  39. package/templates/ios/App/AngularLynxWebGLContext.m +25 -21
  40. package/templates/ios/App/AnimationFrameRate.swift +214 -0
  41. package/templates/ios/App/AppDelegate.swift +2 -0
  42. package/templates/ios/App/AssetsModule.swift +3 -1
  43. package/templates/ios/App/DevServer.swift +3 -0
  44. package/templates/ios/App/Info.plist +12 -5
  45. package/templates/ios/App/LynxViewController.swift +19 -1
  46. package/templates/ios/App/ShellModule.swift +14 -1
  47. package/templates/ios/App/SplashScreen.swift +71 -0
package/README.md CHANGED
@@ -6,7 +6,7 @@ User documentation: [Publishing your App](../website/docs/guide/building-for-pro
6
6
 
7
7
  ## What it does
8
8
 
9
- 1. **Generates** the native project from `templates/ios` or `templates/android` into the project's folder in Angular's build cache (`.angular/cache/<Angular version>/<project>/lynx-native/<platform>`, which `ng new` already gitignores and `ng cache clean` clears), writing the app options from `angular.json` into the few files the templates mark for it. It regenerates only when a hash of its inputs changes (this package's version, the template, the options, the icon images), so Xcode and Gradle keep their incremental state.
9
+ 1. **Generates** the native project from `templates/ios` or `templates/android` into the project's folder in Angular's build cache (`.angular/cache/<Angular version>/<project>/lynx-native/<platform>`, which `ng new` already gitignores and `ng cache clean` clears), writing the app options from `angular.json` into the few files the templates mark for it. It regenerates only when a hash of its inputs changes (this package's version, the template, the options, the icon and splash images), so Xcode and Gradle keep their incremental state.
10
10
  2. **Copies** `dist/` (without the web bundle) into the project.
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.
@@ -19,9 +19,11 @@ An ejected project (`ios/` or `android/` with a `.angular-lynx-ejected` marker,
19
19
 
20
20
  Both are one full-screen `LynxView` running `main.lynx.bundle`; Angular Router does all navigation inside it. Bundles and assets load from inside the app, so RSpeedy's default asset prefix (`/static/...`) works with no configuration. The `LynxView` fills the screen, under the status bar and the home indicator (`"edgeToEdge": false` in angular.json puts it inside the safe area instead). Lynx's own CSS `env(safe-area-inset-*)` is 0 there: Android never sets it, and the iOS shell creates its `LynxView` before the window is key, where Lynx reads it. The runtime gives every `env(safe-area-inset-*)` the insets the shell sends instead (see `safe-area-insets.ts` in the runtime), so they follow rotation. On Android the activity still pads the page for the keyboard, and the bottom inset is 0 while it's open. An `<overlay>` fills the screen too, so a bottom sheet covers the page down to the screen's edge and pads its content by the insets: on Android XElement's overlay window stops above the navigation bar, so the shell registers its own `overlay` behavior, `EdgeToEdgeOverlay.kt`, whose window draws under every bar, as the activity's does.
21
21
 
22
+ Both run Lynx's engine thread, where the main thread's JavaScript, and so the whole Angular app, runs with layout and Lynx's animator, off the platform's UI thread: Lynx's `MostOnTASM` thread strategy (`setThreadStrategyForRender(.mostOnTASM)`, `setThreadStrategyForRendering(ThreadStrategyForRendering.MOST_ON_TASM)`), where Lynx's default, and Lynx Explorer's, is `AllOnUI`. So change detection, a screen being built or a busy event handler doesn't freeze what UIKit and Android run themselves: a scroll view's momentum, typing in a text field, a web view. The cost is that the element tree reaches the screen a step later, after the flush crosses to the UI thread, and UI methods with it: the build plugin turns on Lynx's pending invokes (`enableElementInvokeUIMethodPendingTask`), which send a method after the flush that makes the element's UI. A `<list>` needs `enable-async-list` under this strategy, which the runtime sets on every list. The main-thread modules run on the engine thread too (below).
23
+
22
24
  Both send the same global props, which the runtime's services read: `platform`, `theme` (again whenever the phone switches between light and dark), `appLocale` (the phone's language as a BCP 47 tag), `appTimeZone` (its time zone's IANA name, which the `intl` build option's `Intl.DateTimeFormat` uses), `isNotchScreen`, `edgeToEdge`, the safe-area insets `safeAreaTop`, `safeAreaBottom`, `safeAreaLeft` and `safeAreaRight` (again whenever they change), `osVersion` (which Lynx leaves out of the main thread's `SystemInfo`), and the accessibility settings `reduceMotion`, `reduceTransparency` (iOS only) and `increaseContrast`, again whenever the user changes one. Android 12 and later also send `dynamicColors`, the wallpaper's Material 3 color roles in light and dark (`DynamicColors.kt`), again when the user changes their wallpaper or colors. Lynx Explorer sends `theme` and `isNotchScreen` too, but no `appLocale`, `appTimeZone`, `osVersion` or accessibility settings. See [`templates/android/README.md`](templates/android/README.md) for the Android shell's details.
23
25
 
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). `AngularLynxShell` (`ShellModule.swift`, `ShellModule.kt`) has `collectGarbage`, which the runtime calls once the app has released about a screen's worth of elements and settled: it reports moderate memory pressure with `LynxEnv.trimMemory`, which makes Lynx run a full collection of the main thread's JavaScript heap, freeing what PrimJS's routine collections leave behind of the screens that went. On Android it also connects the back button. Both shells report the system's memory warnings to `trimMemory` too, and leaving the screen. `AngularLynxShortcuts` (`ShortcutsModule.swift`, `ShortcutsModule.kt`) keeps the shortcuts the person ran until the runtime's `LynxShortcuts` takes them, with `take`, at startup and each time the shell sends the `angularLynxShortcut` global event, so the shortcut that started the app isn't lost and none is handled twice. The generator writes angular.json's `shortcuts` as App Intents on iOS (`App/AppShortcuts.swift`, with an `AppShortcutsProvider`: Xcode's App Intents step reads the titles and phrases out of the compiled code, so they have to be source), which Siri, Spotlight and the Shortcuts app run, and as static shortcuts on Android (`res/xml/shortcuts.xml`, with the titles in `res/values/shortcuts.xml`), in the menu a long press on the app's icon opens. Android starts a static shortcut's activity in a cleared task, which would end the running app, so they point at `ShortcutActivity`, which has a task of its own and passes the shortcut on to `MainActivity`.
26
+ 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). `AngularLynxShell` (`ShellModule.swift`, `ShellModule.kt`) has `hideSplashScreen`, which the runtime's `LynxSplashScreen` calls once the app's first screen is drawn (at Angular's first frame, or when `provideSplashScreen()` says): the phone takes a launch screen down at the app's first frame, which is the empty LynxView, so the iOS shell keeps a copy of it over the LynxView (`SplashScreen.swift`, the `LaunchBackground` color and `LaunchImage` image the generator writes from angular.json's `splash`) and Android's `MainActivity` keeps AndroidX's splash screen up (`installSplashScreen()`, `setKeepOnScreenCondition`), each fading it out when it's called, or five seconds after the app starts. It has `collectGarbage`, which the runtime calls once the app has released about a screen's worth of elements and settled: it reports moderate memory pressure with `LynxEnv.trimMemory`, which makes Lynx run a full collection of the main thread's JavaScript heap, freeing what PrimJS's routine collections leave behind of the screens that went. On Android it also connects the back button. Both shells report the system's memory warnings to `trimMemory` too, and leaving the screen. `AngularLynxShortcuts` (`ShortcutsModule.swift`, `ShortcutsModule.kt`) keeps the shortcuts the person ran until the runtime's `LynxShortcuts` takes them, with `take`, at startup and each time the shell sends the `angularLynxShortcut` global event, so the shortcut that started the app isn't lost and none is handled twice. The generator writes angular.json's `shortcuts` as App Intents on iOS (`App/AppShortcuts.swift`, with an `AppShortcutsProvider`: Xcode's App Intents step reads the titles and phrases out of the compiled code, so they have to be source), which Siri, Spotlight and the Shortcuts app run, and as static shortcuts on Android (`res/xml/shortcuts.xml`, with the titles in `res/values/shortcuts.xml`), in the menu a long press on the app's icon opens. Android starts a static shortcut's activity in a cleared task, which would end the running app, so they point at `ShortcutActivity`, which has a task of its own and passes the shortcut on to `MainActivity`.
25
27
 
26
28
  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
29
 
@@ -29,7 +31,7 @@ Only the development build (`ng serve --platform`) loads from a dev server: the
29
31
 
30
32
  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`). `<webview>` loads through XElement's loader, wrapped (`App/WebViewLoader.swift`) to take the loader off its web view's script message handlers when the element goes: XElement's loader never does, so the loader and the web view kept each other, and the web view's WebContent process, for as long as the app ran (issue #397).
31
33
 
32
- Both have `<canvas>` with WebGL2 (issue #211), which Lynx doesn't: a `canvas` element (`App/AngularLynxWebGL.m`'s `AngularLynxCanvas`, a `CAMetalLayer` view; `CanvasUI.kt`, a `TextureView`) and the `AngularLynxWebGL` module the runtime's WebGL2 context sends its calls to, which runs them on OpenGL ES 3.0 (`App/AngularLynxWebGLContext.m`, `WebGLContext.kt`). On iOS that's [ANGLE](https://chromium.googlesource.com/angle/angle)'s OpenGL ES, on Metal, which Safari draws WebGL with too: iOS's own OpenGL ES is deprecated, and the Simulator runs it on the CPU, at seconds a frame for a lit three.js scene (issue #238), where Metal draws on the Mac's GPU. ANGLE's `libEGL` and `libGLESv2` frameworks, and its headers, come in the Lynx frameworks zip (below). Android's OpenGL ES is the phone's, which the emulator already runs on the Mac's GPU. The runtime runs on Lynx's main thread and WebGL needs answers synchronously, so both turn on main-thread modules (`enableMTSModule`): the config's modules are then callable from main-thread JavaScript as `lynx.module(name)`. The WebGL module's `encodeImage`, behind `canvas.toBlob()` and `toDataURL()`, reads the drawing buffer and encodes it as a PNG or JPEG with ImageIO or `Bitmap.compress`; on iOS it reads through a pixel pack buffer, since ANGLE on Metal reads straight into memory many times slower. `AngularLynxAssets` (`App/AssetsModule.swift`, `AssetsModule.kt`) reads a file the app bundles for the main thread's `fetch`, which has no page URL to resolve `/static/...` against. The command numbers the WebGL module reads (`App/AngularLynxWebGLOps.h`, `WebGLOps.kt`) are generated from the runtime's `canvas/webgl-ops.ts` with `npm run generate:webgl-ops -w packages/native`; `scripts/webgl-ops.test.ts` fails when they're stale. UIKit's module imports Apple's OpenGL ES headers into every file, so `AngularLynxWebGLContext.m` turns off their deprecation warnings, which land on ANGLE's functions of the same names; the explicit link to `libGLESv2` comes before UIKit's automatic one to OpenGLES, so those calls bind to ANGLE.
34
+ Both have `<canvas>` with WebGL2 (issue #211), which Lynx doesn't: a `canvas` element (`App/AngularLynxWebGL.m`'s `AngularLynxCanvas`, a `CAMetalLayer` view; `CanvasUI.kt`, a `TextureView`) and the `AngularLynxWebGL` module the runtime's WebGL2 context sends its calls to, which runs them on OpenGL ES 3.0 (`App/AngularLynxWebGLContext.m`, `WebGLContext.kt`). On iOS that's [ANGLE](https://chromium.googlesource.com/angle/angle)'s OpenGL ES, on Metal, which Safari draws WebGL with too: iOS's own OpenGL ES is deprecated, and the Simulator runs it on the CPU, at seconds a frame for a lit three.js scene (issue #238), where Metal draws on the Mac's GPU. ANGLE's `libEGL` and `libGLESv2` frameworks, and its headers, come in the Lynx frameworks zip (below). Android's OpenGL ES is the phone's, which the emulator already runs on the Mac's GPU. The runtime runs on Lynx's main thread and WebGL needs answers synchronously, so both turn on main-thread modules (`enableMTSModule`): the config's modules are then callable from main-thread JavaScript as `lynx.module(name)`, and Lynx calls them on its engine thread, not the UI thread. An EGL context is current on one thread at a time, so GL runs there too, while the canvas's view lives on the UI thread. On iOS the view hands the context what it draws into, its `CAMetalLayer` and its size in pixels (`AngularLynxCanvasTarget`), through Lynx's `runOnTasmThread:`, so the contexts and the canvas registry are the engine thread's alone, and the context keeps its EGL context current there between batches; it sets the view's opacity back on the UI thread. On Android each call already makes the context current and puts back what was current before, so `WebGLContext` and `CanvasRegistry` are locked instead: the `TextureView`'s surface callbacks, on the UI thread, wait for a batch to end, which keeps the EGL surface from outliving the `SurfaceTexture` it draws to. The WebGL module's `encodeImage`, behind `canvas.toBlob()` and `toDataURL()`, reads the drawing buffer and encodes it as a PNG or JPEG with ImageIO or `Bitmap.compress`; on iOS it reads through a pixel pack buffer, since ANGLE on Metal reads straight into memory many times slower. `AngularLynxAssets` (`App/AssetsModule.swift`, `AssetsModule.kt`) reads a file the app bundles for the main thread's `fetch`, which has no page URL to resolve `/static/...` against. The command numbers the WebGL module reads (`App/AngularLynxWebGLOps.h`, `WebGLOps.kt`) are generated from the runtime's `canvas/webgl-ops.ts` with `npm run generate:webgl-ops -w packages/native`; `scripts/webgl-ops.test.ts` fails when they're stale. UIKit's module imports Apple's OpenGL ES headers into every file, so `AngularLynxWebGLContext.m` turns off their deprecation warnings, which land on ANGLE's functions of the same names; the explicit link to `libGLESv2` comes before UIKit's automatic one to OpenGLES, so those calls bind to ANGLE.
33
35
 
34
36
  | | iOS | Android |
35
37
  | ---------------- | ---------------------------------------------------- | -------------------------------------------------------- |
@@ -5,7 +5,8 @@ import { type ResolvedApp } from '../options.ts';
5
5
  * angular-lynx.properties (which app/build.gradle.kts reads), and permissions,
6
6
  * deep links and the apps canOpenURL can see go between the manifest's
7
7
  * `angular-lynx:*` markers, the icon options become the launcher icon's
8
- * resources, and the shortcuts become the static shortcuts' resources.
8
+ * resources, the shortcuts become the static shortcuts' resources, and the
9
+ * splash becomes the splash theme's color and image.
9
10
  */
10
11
  export declare const androidGenerator: PlatformGenerator;
11
12
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAcvB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBA8B9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,WAOtC,CAAC;AAEN,eAAO,MAAM,UAAU,GAAI,KAAK,WAAW,KAAG,MAYhC,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAiBpD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW,KAAG,MAYjC,CAAC;AAEnB;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,WAAW,KAAG,MAUpC,CAAC;AAOf;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,WAAW,KAAG,MAgClC,CAAC;AAEf;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAMpB,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,MAWxC,CAAC;AAEf,2EAA2E;AAC3E,eAAO,MAAM,cAAc,GACzB,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAM,GAAG,SAaX,CAAC"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAevB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBA+B9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,WAOtC,CAAC;AAEN,eAAO,MAAM,UAAU,GAAI,KAAK,WAAW,KAAG,MAYhC,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAiBpD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW,KAAG,MAYjC,CAAC;AAEnB;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,WAAW,KAAG,MAUpC,CAAC;AAOf;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,WAAW,KAAG,MAgClC,CAAC;AAEf;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAMpB,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,MAWxC,CAAC;AAEf,2EAA2E;AAC3E,eAAO,MAAM,cAAc,GACzB,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAM,GAAG,SAaX,CAAC"}
@@ -3,6 +3,7 @@ import os from 'node:os';
3
3
  import path from 'node:path';
4
4
  import { shortcutIdentifier, } from "../options.js";
5
5
  import { PERMISSION_MAP } from "../permissions.js";
6
+ import { writeAndroidSplash } from "../splash.js";
6
7
  import { writeAndroidIcon } from "./icon.js";
7
8
  import { escapeXml, replaceMarker } from "../xml.js";
8
9
  const MANIFEST = 'app/src/main/AndroidManifest.xml';
@@ -17,7 +18,8 @@ const SCREEN_ORIENTATIONS = {
17
18
  * angular-lynx.properties (which app/build.gradle.kts reads), and permissions,
18
19
  * deep links and the apps canOpenURL can see go between the manifest's
19
20
  * `angular-lynx:*` markers, the icon options become the launcher icon's
20
- * resources, and the shortcuts become the static shortcuts' resources.
21
+ * resources, the shortcuts become the static shortcuts' resources, and the
22
+ * splash becomes the splash theme's color and image.
21
23
  */
22
24
  export const androidGenerator = {
23
25
  configure: (dir, app, projectRoot) => {
@@ -38,6 +40,7 @@ export const androidGenerator = {
38
40
  writeFileSync(path.join(dir, RESOURCES, 'values/shortcuts.xml'), shortcutStringsXml(app));
39
41
  }
40
42
  writeAndroidIcon(dir, app, projectRoot);
43
+ writeAndroidSplash(dir, app, projectRoot);
41
44
  },
42
45
  bundleDir: (dir) => path.join(dir, 'app/src/main/assets'),
43
46
  };
@@ -36,7 +36,7 @@ export type PreparedProject = {
36
36
  * `<workDir>/<platform>`, or the user's ejected folder.
37
37
  *
38
38
  * Generation is skipped when a hash of every input (this package's version,
39
- * the template files, the app options and the icon images) matches the last run, so
39
+ * the template files, the app options and the icon and splash images) matches the last run, so
40
40
  * Xcode and Gradle keep their incremental state between builds. The bundle is
41
41
  * copied in on every build, because it changes on every build.
42
42
  *
package/dist/generate.js CHANGED
@@ -18,7 +18,7 @@ const HASH_FILE = '.angular-lynx-hash';
18
18
  * `<workDir>/<platform>`, or the user's ejected folder.
19
19
  *
20
20
  * Generation is skipped when a hash of every input (this package's version,
21
- * the template files, the app options and the icon images) matches the last run, so
21
+ * the template files, the app options and the icon and splash 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
24
  *
@@ -104,7 +104,13 @@ const inputHash = ({ platform, app, projectRoot, packageVersion, }) => {
104
104
  // replacing one with a new image of the same name regenerates the icons.
105
105
  // A missing file is hashed as such: generation then fails and says so.
106
106
  const { foreground, background } = (platform === 'android' && app.android.adaptiveIcon) || {};
107
- for (const file of [app.icon, foreground, background]) {
107
+ for (const file of [
108
+ app.icon,
109
+ foreground,
110
+ background,
111
+ app.splash.light.image,
112
+ app.splash.dark.image,
113
+ ]) {
108
114
  if (file && !ICON_BACKGROUND_COLOR.test(file)) {
109
115
  const absolute = path.resolve(projectRoot, file);
110
116
  hash.update(existsSync(absolute) ? readFileSync(absolute) : 'missing');
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export type { Platform } from './generate.ts';
5
5
  export { EJECT_MARKER, copyBundle, prepareProject } from './generate.ts';
6
6
  export { renderEjectedProject } from './eject.ts';
7
7
  export { LYNX_IOS, FRAMEWORKS_ENV } from './ios/frameworks.ts';
8
- export type { AndroidOptions, IosExportMethod, IosOptions, NativeAppOptions, Orientation, Permission, ResolvedApp, } from './options.ts';
8
+ export type { AndroidOptions, IosExportMethod, IosOptions, NativeAppOptions, Orientation, Permission, ResolvedApp, SplashOptions, } from './options.ts';
9
9
  export { NativeConfigError, resolveAppOptions } from './options.ts';
10
10
  export { NativeBuildError } from './process.ts';
11
11
  export type { DevServerOptions, RunOptions } from './run.ts';
@@ -44,6 +44,8 @@ export type BuildNativeAppOptions = {
44
44
  */
45
45
  readonly devServer?: DevServerOptions;
46
46
  readonly log: (message: string) => void;
47
+ /** Where warnings go, such as an image too wide for Android's splash. */
48
+ readonly warn?: (message: string) => void;
47
49
  };
48
50
  /**
49
51
  * Turns a built Lynx bundle into native binaries: generates (or reuses) the
@@ -1 +1 @@
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,MAA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AC;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;IACxC,yEAAyE;IACzE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,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,CAiJA,CAAC"}
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ import { iosGenerator } from "./ios/project.js";
11
11
  import { startIosTarget } from "./ios/run.js";
12
12
  import { resolveAppOptions } from "./options.js";
13
13
  import { NativeBuildError } from "./process.js";
14
+ import { splashWarnings } from "./splash.js";
14
15
  export { EJECT_MARKER, copyBundle, prepareProject } from "./generate.js";
15
16
  export { renderEjectedProject } from "./eject.js";
16
17
  export { LYNX_IOS, FRAMEWORKS_ENV } from "./ios/frameworks.js";
@@ -88,6 +89,14 @@ export const buildNativeApp = async (options) => {
88
89
  : project.regenerated
89
90
  ? `Generated the ${platform} project`
90
91
  : `Reusing the generated ${platform} project (no config changes)`);
92
+ // On every build, not only when the project is generated, so a warning
93
+ // isn't lost once the project is reused. An ejected project draws its
94
+ // splash from its own files.
95
+ if (!project.ejected) {
96
+ for (const warning of splashWarnings(app, projectRoot, platform)) {
97
+ (options.warn ?? log)(warning);
98
+ }
99
+ }
91
100
  // Where the app was built for, which a development build for a simulator
92
101
  // or a phone depends on as much as on the project.
93
102
  const destination = target?.iPhone?.udid ?? target?.simulator?.udid ?? '';
@@ -3,8 +3,9 @@ import { type ResolvedApp } from '../options.ts';
3
3
  /**
4
4
  * Writes the app options into the iOS template: build settings go in
5
5
  * Config/App.xcconfig (which App.xcodeproj reads), Info.plist entries go
6
- * between the template's `angular-lynx:info` markers, and the shortcuts
7
- * become App/AppShortcuts.swift.
6
+ * between the template's `angular-lynx:info` markers, the shortcuts
7
+ * become App/AppShortcuts.swift, and the icon and the splash go in the asset
8
+ * catalog.
8
9
  */
9
10
  export declare const iosGenerator: PlatformGenerator;
10
11
  export declare const xcconfig: (app: ResolvedApp) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/ios/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAiBvB;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,iBAsC1B,CAAC;AAQF,eAAO,MAAM,QAAQ,GAAI,KAAK,WAAW,KAAG,MAY9B,CAAC;AAEf,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,uDACe,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,uEACqC,CAAC;AAEvE,eAAO,MAAM,gBAAgB,GAC3B,KAAK,WAAW,EAChB,kBAAyB;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,KAC/D,MAmEF,CAAC;AAoBF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAwDpD,CAAC"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/ios/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAkBvB;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,iBAwC1B,CAAC;AAQF,eAAO,MAAM,QAAQ,GAAI,KAAK,WAAW,KAAG,MAY9B,CAAC;AAEf,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,uDACe,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,uEACqC,CAAC;AAEvE,eAAO,MAAM,gBAAgB,GAC3B,KAAK,WAAW,EAChB,kBAAyB;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,KAC/D,MAiFF,CAAC;AAoBF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAwDpD,CAAC"}
@@ -3,6 +3,7 @@ import path from 'node:path';
3
3
  import { readPngSize } from "../png.js";
4
4
  import { APP_NAME_PLACEHOLDER, shortcutIdentifier, } from "../options.js";
5
5
  import { PERMISSION_MAP } from "../permissions.js";
6
+ import { IOS_IMAGE_SET, writeIosSplash } from "../splash.js";
6
7
  import { escapeXml, replaceMarker } from "../xml.js";
7
8
  const ORIENTATIONS = {
8
9
  portrait: ['UIInterfaceOrientationPortrait'],
@@ -19,8 +20,9 @@ const ORIENTATIONS = {
19
20
  /**
20
21
  * Writes the app options into the iOS template: build settings go in
21
22
  * Config/App.xcconfig (which App.xcodeproj reads), Info.plist entries go
22
- * between the template's `angular-lynx:info` markers, and the shortcuts
23
- * become App/AppShortcuts.swift.
23
+ * between the template's `angular-lynx:info` markers, the shortcuts
24
+ * become App/AppShortcuts.swift, and the icon and the splash go in the asset
25
+ * catalog.
24
26
  */
25
27
  export const iosGenerator = {
26
28
  configure: (dir, app, projectRoot, development = false) => {
@@ -40,6 +42,7 @@ export const iosGenerator = {
40
42
  }
41
43
  copyFileSync(icon, path.join(dir, 'App/Assets.xcassets/AppIcon.appiconset/AppIcon.png'));
42
44
  }
45
+ writeIosSplash(dir, app, projectRoot);
43
46
  },
44
47
  bundleDir: (dir) => path.join(dir, 'LynxBundle'),
45
48
  };
@@ -73,6 +76,13 @@ export const infoPlistEntries = (app, { development = false } = {}) => {
73
76
  values.forEach((value) => lines.push(`\t<string>${escapeXml(value)}</string>`));
74
77
  lines.push('</array>');
75
78
  };
79
+ // The launch screen: angular.json's splash, its color (LaunchBackground,
80
+ // white by default) and its image, if it has one, centered on the whole
81
+ // screen. LynxViewController draws the same over the app until the app
82
+ // hides it (SplashScreen.swift).
83
+ lines.push('<key>UILaunchScreen</key>', '<dict>', '\t<key>UIColorName</key>', '\t<string>LaunchBackground</string>', ...(app.splash.light.image
84
+ ? ['\t<key>UIImageName</key>', `\t<string>${IOS_IMAGE_SET}</string>`]
85
+ : []), '</dict>');
76
86
  array('UISupportedInterfaceOrientations', ORIENTATIONS[app.orientation]);
77
87
  // Read by LynxViewController, which lays the LynxView out over the whole
78
88
  // screen or inside the safe area.
package/dist/options.d.ts CHANGED
@@ -52,9 +52,65 @@ export type NativeAppOptions = {
52
52
  * {@link AndroidOptions.adaptiveIcon}).
53
53
  */
54
54
  readonly icon?: string;
55
+ /**
56
+ * What the phone shows from the tap on the app's icon until the app's
57
+ * first screen is drawn (see {@link SplashOptions}).
58
+ */
59
+ readonly splash?: SplashOptions;
55
60
  readonly ios?: IosOptions;
56
61
  readonly android?: AndroidOptions;
57
62
  };
63
+ /**
64
+ * The launch screen: an image centered on a color, from the tap on the app's
65
+ * icon until the app hides it (the runtime's `provideSplashScreen()`), or
66
+ * until Angular first draws, without that.
67
+ *
68
+ * iOS shows it as the launch screen (`UILaunchScreen`), and the shell keeps a
69
+ * copy of it over the app until then. Android shows it as the splash screen,
70
+ * through AndroidX's `core-splashscreen`, which gives Android 7 to 11 the
71
+ * same splash as 12 and later.
72
+ */
73
+ export type SplashOptions = {
74
+ /**
75
+ * A PNG with transparency, relative to the project root, drawn centered.
76
+ * Without one, iOS shows the color alone, and Android the launcher icon,
77
+ * as Android 12 does by default.
78
+ */
79
+ readonly image?: string;
80
+ /**
81
+ * The image's width on screen, in points and dp; its height follows from
82
+ * its shape. Needed with `image`. Give the PNG at least three times this
83
+ * many pixels across, for the sharpest iPhones.
84
+ *
85
+ * Android shows a splash image inside a circle 192 dp across, so an image
86
+ * whose corners reach past it is drawn smaller there, with a build warning.
87
+ */
88
+ readonly imageWidth?: number;
89
+ /**
90
+ * The color behind the image, which the shells also paint behind the app
91
+ * (`#RRGGBB` or `#RGB`). Defaults to white, and on Android, to black in
92
+ * dark mode.
93
+ */
94
+ readonly backgroundColor?: string;
95
+ /** The image and the color in dark mode. Each defaults to the light one. */
96
+ readonly dark?: {
97
+ readonly image?: string;
98
+ readonly backgroundColor?: string;
99
+ };
100
+ };
101
+ /** The splash's image and color in one appearance, light or dark. */
102
+ export type SplashAppearance = {
103
+ readonly image?: string;
104
+ /** Undefined keeps the shell's own color. */
105
+ readonly backgroundColor?: string;
106
+ };
107
+ /** {@link SplashOptions} checked, with the dark values filled in. */
108
+ export type ResolvedSplash = {
109
+ /** Set when either appearance has an image. */
110
+ readonly imageWidth?: number;
111
+ readonly light: SplashAppearance;
112
+ readonly dark: SplashAppearance;
113
+ };
58
114
  export type Orientation = 'portrait' | 'landscape' | 'all';
59
115
  /**
60
116
  * One thing the app does, which the person can ask for without opening the
@@ -184,6 +240,7 @@ export type ResolvedApp = {
184
240
  readonly canOpenURLSchemes: readonly string[];
185
241
  readonly shortcuts: readonly ResolvedShortcut[];
186
242
  readonly icon?: string;
243
+ readonly splash: ResolvedSplash;
187
244
  /** `MyApp`: the iOS product (and so .app/.ipa) name. */
188
245
  readonly productName: string;
189
246
  /** `my-app`: the base name of Android artifacts. */
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG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MAAM,EAAE,CAAC;IAC5C;;;OAGG;IACH,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,wDAAwD;IACxD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAW/C;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAuC,CAAC;AAG1E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,SAAS,MAAM,EAMnD,CAAC;AAgCF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,gBAAgB,EAC5B,UAAU;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3E,WAoJF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,IAAI,MAAM,KAAG,MAA+B,CAAC;AA6KhF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,OAAO,KAAG,OAWxC,CAAC"}
package/dist/options.js CHANGED
@@ -122,6 +122,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
122
122
  throw new NativeConfigError(`canOpenURLSchemes lists ${canOpenURLSchemes.length} schemes with the ${ALWAYS_QUERIED_SCHEMES.length} always there (${ALWAYS_QUERIED_SCHEMES.join(', ')}). iOS reads no more than ${MAX_QUERIED_SCHEMES}.`);
123
123
  }
124
124
  const shortcuts = resolveShortcuts(options.shortcuts ?? []);
125
+ const splash = resolveSplash(options.splash ?? {});
125
126
  const android = options.android ?? {};
126
127
  if (android.adaptiveIcon) {
127
128
  const { foreground, background } = android.adaptiveIcon;
@@ -160,6 +161,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
160
161
  canOpenURLSchemes,
161
162
  shortcuts,
162
163
  icon: options.icon,
164
+ splash,
163
165
  productName,
164
166
  artifactName,
165
167
  ios: options.ios ?? {},
@@ -236,6 +238,55 @@ const resolveShortcuts = (shortcuts) => {
236
238
  };
237
239
  });
238
240
  };
241
+ /**
242
+ * Checks the splash options, and gives dark mode the light values it doesn't
243
+ * set. The images themselves are read when the project is generated.
244
+ */
245
+ const resolveSplash = (splash) => {
246
+ const { image, imageWidth, backgroundColor } = splash;
247
+ const dark = splash.dark ?? {};
248
+ for (const [option, file] of [
249
+ ['splash.image', image],
250
+ ['splash.dark.image', dark.image],
251
+ ]) {
252
+ if (file !== undefined &&
253
+ (typeof file !== 'string' || !file.toLowerCase().endsWith('.png'))) {
254
+ throw new NativeConfigError(`${option} "${file}" is not a PNG file. Give the path of a PNG with transparency, relative to the project root.`);
255
+ }
256
+ }
257
+ for (const [option, color] of [
258
+ ['splash.backgroundColor', backgroundColor],
259
+ ['splash.dark.backgroundColor', dark.backgroundColor],
260
+ ]) {
261
+ if (color !== undefined &&
262
+ (typeof color !== 'string' || !ICON_BACKGROUND_COLOR.test(color))) {
263
+ throw new NativeConfigError(`${option} "${color}" is not a color. Use #RRGGBB or #RGB, e.g. "#09090B".`);
264
+ }
265
+ }
266
+ // The dark image takes its size from imageWidth too, and a light mode
267
+ // without an image while dark mode has one would be a mistake.
268
+ if (dark.image !== undefined && image === undefined) {
269
+ throw new NativeConfigError('splash.dark.image needs splash.image too: dark mode has an image of its own only where light mode has one.');
270
+ }
271
+ if (image !== undefined) {
272
+ if (typeof imageWidth !== 'number' ||
273
+ !Number.isFinite(imageWidth) ||
274
+ imageWidth <= 0) {
275
+ throw new NativeConfigError(`splash.imageWidth ${imageWidth === undefined ? 'is missing' : `${imageWidth} is not valid`}. Give the image's width on screen in points and dp, e.g. 200: a phone's screen is about 400 across.`);
276
+ }
277
+ }
278
+ else if (imageWidth !== undefined) {
279
+ throw new NativeConfigError('splash.imageWidth needs splash.image: it sets how wide the image is drawn.');
280
+ }
281
+ return {
282
+ ...(image !== undefined && { imageWidth }),
283
+ light: { image, backgroundColor },
284
+ dark: {
285
+ image: dark.image ?? image,
286
+ backgroundColor: dark.backgroundColor ?? backgroundColor,
287
+ },
288
+ };
289
+ };
239
290
  /**
240
291
  * `my-app` → `myapp`: a project name as one app ID segment.
241
292
  */
package/dist/png.d.ts CHANGED
@@ -39,6 +39,11 @@ export declare const resize: (image: Image, width: number, height: number) => Im
39
39
  * continue the picture rather than show a frame of another color.
40
40
  */
41
41
  export declare const extendEdges: (image: Image, inset: number) => Image;
42
+ /**
43
+ * Puts the image in the middle of a transparent `width`×`height` canvas, at
44
+ * least as big as the image. An odd pixel of margin goes right and below.
45
+ */
46
+ export declare const centerOnCanvas: (image: Image, width: number, height: number) => Image;
42
47
  /**
43
48
  * Clears everything outside the largest circle that fits, with a one-pixel
44
49
  * soft edge so the circle isn't jagged: the round icon launchers on
package/dist/png.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"png.d.ts","sourceRoot":"","sources":["../src/png.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,KACX;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAiBnD,CAAC;AAYF,0EAA0E;AAC1E,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;A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AK,EACZ,OAAO,MAAM,EACb,QAAQ,MAAM,KACb,KAYF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,KAAG,KAezC,CAAC"}
package/dist/png.js CHANGED
@@ -24,11 +24,11 @@ export const readPngSize = (file) => {
24
24
  return { width: header.readUInt32BE(16), height: header.readUInt32BE(20) };
25
25
  };
26
26
  /**
27
- * pngjs, loaded the first time an icon is resized rather than with this
28
- * module. Only Android needs it, and CI builds the iOS app from this
29
- * package's tarball unpacked without its dependencies (packages/e2e's
30
- * README), which works as long as the iOS path loads nothing but Node's
31
- * built-ins.
27
+ * pngjs, loaded the first time an image is resized rather than with this
28
+ * module. Only Android's icons and a splash image need it, and CI builds the
29
+ * iOS app, which has no splash image, from this package's tarball unpacked
30
+ * without its dependencies (packages/e2e's README), which works as long as
31
+ * that path loads nothing but Node's built-ins.
32
32
  */
33
33
  const pngjs = () => createRequire(import.meta.url)('pngjs').PNG;
34
34
  /**
@@ -171,6 +171,20 @@ export const extendEdges = (image, inset) => {
171
171
  }
172
172
  return { width, height, data };
173
173
  };
174
+ /**
175
+ * Puts the image in the middle of a transparent `width`×`height` canvas, at
176
+ * least as big as the image. An odd pixel of margin goes right and below.
177
+ */
178
+ export const centerOnCanvas = (image, width, height) => {
179
+ const data = new Uint8Array(width * height * 4);
180
+ const left = Math.floor((width - image.width) / 2);
181
+ const top = Math.floor((height - image.height) / 2);
182
+ for (let y = 0; y < image.height; y++) {
183
+ const row = y * image.width * 4;
184
+ data.set(image.data.subarray(row, row + image.width * 4), ((top + y) * width + left) * 4);
185
+ }
186
+ return { width, height, data };
187
+ };
174
188
  /**
175
189
  * Clears everything outside the largest circle that fits, with a one-pixel
176
190
  * soft edge so the circle isn't jagged: the round icon launchers on
@@ -0,0 +1,70 @@
1
+ import type { Platform } from './generate.ts';
2
+ import type { ResolvedApp, ResolvedSplash } from './options.ts';
3
+ /**
4
+ * Android's splash icon, without an icon background, is a 288 dp square...
5
+ */
6
+ export declare const ANDROID_SLOT_DP = 288;
7
+ /**
8
+ * ...of which it shows the middle: a circle 192 dp across, two thirds of it.
9
+ * Anything outside the circle is cut off.
10
+ */
11
+ export declare const ANDROID_CIRCLE_DP = 192;
12
+ /** Where the shells find the launch image, by name. */
13
+ export declare const IOS_IMAGE_SET = "LaunchImage";
14
+ type Size = {
15
+ readonly width: number;
16
+ readonly height: number;
17
+ };
18
+ /**
19
+ * The image's size on screen in points (dp on Android): `imageWidth` across,
20
+ * and as tall as its shape makes that.
21
+ */
22
+ export declare const splashImageSize: (pixels: Size, imageWidth: number) => Size;
23
+ /**
24
+ * The size Android draws the image at: as on iOS, unless its corners reach
25
+ * past the circle Android shows, when it's scaled down until they touch it.
26
+ * A wide logo is then smaller than on iOS, but whole.
27
+ */
28
+ export declare const androidSplashSize: (size: Size) => Size;
29
+ /**
30
+ * What's worth knowing about how the splash images will look, checked on
31
+ * every build (unlike the project, which is generated only when its inputs
32
+ * change): an image too wide for Android's circle, or with too few pixels to
33
+ * be sharp. A missing image is left to generation, which fails on it.
34
+ */
35
+ export declare const splashWarnings: (app: ResolvedApp, projectRoot: string, platform: Platform) => readonly string[];
36
+ /**
37
+ * The `LaunchBackground` color set: the launch screen's color, which the
38
+ * shell also paints behind the LynxView. Only its dark entry varies with dark
39
+ * mode: an entry without an appearance is the color for any.
40
+ */
41
+ export declare const launchBackgroundColorSet: (splash: ResolvedSplash) => string;
42
+ /** The image set's Contents.json, for the files {@link writeIosSplash} writes. */
43
+ export declare const launchImageSet: (hasDark: boolean) => string;
44
+ /**
45
+ * Writes the splash into the iOS project's asset catalog: the
46
+ * `LaunchBackground` color set, and the `LaunchImage` image set at 1×, 2× and
47
+ * 3× (and again for dark mode). Info.plist's UILaunchScreen names them (see
48
+ * `infoPlistEntries`), and the shell's SplashScreen.swift draws the same two
49
+ * over the app until the app hides it.
50
+ *
51
+ * Each scale is made here: a launch screen draws its image at its natural
52
+ * size, which is its pixels over its scale, so each copy is `imageWidth`
53
+ * points across.
54
+ */
55
+ export declare const writeIosSplash: (dir: string, app: ResolvedApp, projectRoot: string) => void;
56
+ /**
57
+ * Writes the splash into the Android project's resources: its colors as
58
+ * `window_background` (light in `values/`, dark in `values-night/`), which
59
+ * the splash theme and the window behind the LynxView both use, and its
60
+ * image as the `splash_icon` drawable the theme shows.
61
+ *
62
+ * Android shows a splash image in a 288 dp square, cut to the circle 192 dp
63
+ * across in its middle, and scales whatever drawable it's given to the
64
+ * square. So the image is drawn on a transparent 288 dp canvas, at
65
+ * `imageWidth` dp, or smaller if its corners would be cut off, and the canvas
66
+ * made at each density, as the icons are.
67
+ */
68
+ export declare const writeAndroidSplash: (dir: string, app: ResolvedApp, projectRoot: string) => void;
69
+ export {};
70
+ //# sourceMappingURL=splash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"splash.d.ts","sourceRoot":"","sources":["../src/splash.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAUhE;;GAEG;AACH,eAAO,MAAM,eAAe,MAAM,CAAC;AACnC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAIrC,uDAAuD;AACvD,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAQ3C,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,QAAQ,IAAI,EAAE,YAAY,MAAM,KAAG,IAGjE,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,IAAI,KAAG,IAM9C,CAAC;AAgBF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GACzB,KAAK,WAAW,EAChB,aAAa,MAAM,EACnB,UA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