@blotch/angular-lynx-native 22.3.2 → 22.3.3
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 +8 -2
- package/dist/android/project.d.ts +27 -3
- package/dist/android/project.d.ts.map +1 -1
- package/dist/android/project.js +80 -9
- package/dist/eject.d.ts.map +1 -1
- package/dist/eject.js +1 -0
- package/dist/files.d.ts +24 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +41 -0
- package/dist/generate.d.ts +17 -2
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +68 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/ios/project.d.ts +21 -2
- package/dist/ios/project.d.ts.map +1 -1
- package/dist/ios/project.js +58 -2
- package/dist/options.d.ts +68 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +27 -0
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +18 -3
- package/dist/plugins.d.ts +245 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +1244 -0
- package/package.json +1 -1
- package/templates/android/README.md +12 -4
- package/templates/android/app/build.gradle.kts +27 -9
- package/templates/android/app/src/main/AndroidManifest.xml +5 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/AngularLynxPlugins.kt +13 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/AudioRecorderModule.kt +520 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/EdgeToEdgeOverlay.kt +24 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/EngineThreadHint.kt +156 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/GeolocationModule.kt +557 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/HostElementUI.kt +331 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ImagePickerModule.kt +143 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ImagePipeline.kt +83 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +153 -9
- package/templates/android/app/src/main/java/dev/angularlynx/shell/NetworkStatus.kt +121 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/PermissionRequests.kt +10 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/PhotoLibraryModule.kt +203 -16
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellApplication.kt +1 -8
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellModule.kt +11 -1
- package/templates/android/app/src/main/res/xml/share_paths.xml +7 -2
- package/templates/ios/App/AngularLynxPlugins.swift +22 -0
- package/templates/ios/App/AnimationFrameRate.swift +66 -0
- package/templates/ios/App/AppDelegate.swift +3 -1
- package/templates/ios/App/AudioRecorderModule.swift +433 -0
- package/templates/ios/App/GeolocationModule.swift +455 -0
- package/templates/ios/App/HostElementUI.swift +270 -0
- package/templates/ios/App/ImagePickerModule.swift +160 -1
- package/templates/ios/App/LynxViewController.swift +66 -5
- package/templates/ios/App/NetworkStatus.swift +41 -0
package/README.md
CHANGED
|
@@ -21,11 +21,13 @@ Both are one full-screen `LynxView` running `main.lynx.bundle`; Angular Router d
|
|
|
21
21
|
|
|
22
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
23
|
|
|
24
|
+
On Android 12 and later the shell also tells Android when that thread has work coming (`EngineThreadHint.kt`). The engine thread works in bursts (a tap's handler, a navigation, a page to build), and Android's scheduler picks a thread's core and the core's frequency from how busy the thread has been, so each burst starts on a slow core. The shell keeps a performance hint session (`PerformanceHintManager`) for the thread, as Android keeps one for the UI thread and RenderThread itself, and reports to it at every touch: a finger going down or lifting, and a move no more often than the system reads reports. On a Pixel 9 Pro Fold a pushed page's first render came 22 ms after the tap's handler, where it took 44 ms, for about 60 mJ more energy a push. The reports stop with the touches, and Android lets the thread back down by itself.
|
|
25
|
+
|
|
24
26
|
Release builds log only Lynx's warnings and errors. Lynx's iOS frameworks and Android AARs are built for release, where Lynx logs at INFO: a line for every touch move, hit test, flush, layout, event listener and main-thread module call, written as it's logged (`NSLog` on iOS, a call from native code into `android.util.Log` on Android), mostly on the engine thread and, during a touch, on the UI thread. So `AppDelegate` calls `SetMinimumLoggingLevel(.warning)` before anything else, under `#if !DEBUG`, and `ShellApplication` calls `LLog.setMinimumLoggingLevel(LLog.WARN)` when the app isn't debuggable, after `LynxEnv`'s init, which loads the native library the call needs. The development build (`ng serve --platform`) keeps every line. The app's JavaScript errors still reach the system log, since Lynx logs them as errors, and its `console` output is unchanged: Lynx writes that whatever the level.
|
|
25
27
|
|
|
26
|
-
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`), the accessibility settings `reduceMotion`, `reduceTransparency` (iOS only) and `increaseContrast`, again whenever the user changes one, `textScale` (the user's text size, `1` at the default: Dynamic Type's body size over its default on iOS, the font scale on Android, capped by angular.json's `textScaling.max`, `1` with `"textScaling": false`), again whenever it changes, `appState` (`active`, `inactive` or `background`, which `LynxAppState` reads, again as the scene's activation changes on iOS and as the activity starts, resumes, pauses and stops, or another window takes the focus, on Android), and `initialURL`, the link that started the app, if one did, with one of angular.json's `deepLinkSchemes` or an https link to its `appLinkDomains` (the scene's `connectionOptions.urlContexts`, or for a Universal Link its web browsing `userActivities`, on iOS, the launch intent's data on Android, unless the app was reopened from Recents), which `LynxLinking.getInitialURL()` returns and the router starts at. 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`, accessibility settings, `textScale` or `
|
|
28
|
+
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`), the accessibility settings `reduceMotion`, `reduceTransparency` (iOS only) and `increaseContrast`, again whenever the user changes one, `textScale` (the user's text size, `1` at the default: Dynamic Type's body size over its default on iOS, the font scale on Android, capped by angular.json's `textScaling.max`, `1` with `"textScaling": false`), again whenever it changes, `appState` (`active`, `inactive` or `background`, which `LynxAppState` reads, again as the scene's activation changes on iOS and as the activity starts, resumes, pauses and stops, or another window takes the focus, on Android), `online` (whether the phone has a route to the internet, which `LynxNetwork` reads: `NWPathMonitor`'s path is `satisfied` on iOS, which means a connection can be tried rather than that it succeeds, and is sent as online until the monitor's first path; on Android the default network has the internet capability and Android has validated it, so a captive portal counts as offline; again whenever it changes, `NetworkStatus.swift` and `NetworkStatus.kt`), and `initialURL`, the link that started the app, if one did, with one of angular.json's `deepLinkSchemes` or an https link to its `appLinkDomains` (the scene's `connectionOptions.urlContexts`, or for a Universal Link its web browsing `userActivities`, on iOS, the launch intent's data on Android, unless the app was reopened from Recents), which `LynxLinking.getInitialURL()` returns and the router starts at. 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`, accessibility settings, `textScale`, `appState` or `online`. Both shells also set the `LynxView`'s font scale to `textScale`, at launch and with `updateFontScale` when it changes (Android keeps the activity through a font size change: the manifest's `configChanges` lists `fontScale`). The build tells Lynx to scale only `sp` lengths by it and writes the page's root font size in `sp`, so every `rem` follows the phone's text size and a `px` size stays as written. See [`templates/android/README.md`](templates/android/README.md) for the Android shell's details.
|
|
27
29
|
|
|
28
|
-
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>`. It also has `takeURLs`, which hands `LynxLinking.onURL()` and the router the links that open the app while it's running: `SceneDelegate.scene(_:openURLContexts:)` and `scene(_:continue:)` (a Universal Link), and `MainActivity.onNewIntent` (after a waiting web sign-in has had its redirect) keep each one (`LinkCenter` in `LinkingModule.swift`, the module's companion on Android) and send the `angularLynxURL` global event, which the runtime answers by taking them, as `LynxShortcuts` does. `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). `AngularLynxPhotoLibrary` (`PhotoLibraryModule.swift`, `PhotoLibraryModule.kt`) saves `LynxPhotoLibrary`'s image or video straight to the library: `PHAssetCreationRequest` with add-only access on iOS, and a MediaStore insert into `Pictures/<app name>` or `Movies/<app name>` on Android 10 and later, which needs no permission (it answers `unavailable` before Android 10). Only an app whose angular.json sets `permissions.savePhotos` has it: the generator's `leaveOut` deletes it from the others, with its registration between `MainActivity`'s `// angular-lynx:photo-library` markers, and iOS registers it by name. `permissions.photos` is iOS only (`NSPhotoLibraryUsageDescription`): Android declares nothing for it, since nothing in the shells reads the library and Google Play rejects `READ_MEDIA_IMAGES` without a core need. `AngularLynxBarcodeScanner` (`BarcodeScannerModule.swift`, `BarcodeScannerModule.kt`) reads a QR code or a barcode for `LynxBarcodeScanner` with the platform's own scanner, VisionKit's `DataScannerViewController` on iOS (16 and later) and Google's code scanner from Play services on Android (`play-services-code-scanner`, which needs no camera permission), and calls back with `{ format, value }`. Only an app whose angular.json sets `permissions.camera` has it: App Store Connect flags an app whose code uses the camera without `NSCameraUsageDescription` (ITMS-90683), so the generator's `configure` deletes the module from every other app, on Android with the library between `app/build.gradle.kts`'s `// angular-lynx:barcode-scanner` markers, and the shells register it by name (`NSClassFromString("AngularLynxBarcodeScannerModule")`, `Class.forName`), which builds either way. `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. It has `markEvent(name)`, which marks a moment the app names in a system trace: an `os_signpost` event named `Mark` with the name as its message, in the Points of Interest category Instruments shows (os_signpost's names are fixed when the shell is compiled), and on Android an instant `Trace` section of that name, which Perfetto shows, and a `Mark <name> at <ns> ns` line in logcat, with `SystemClock.elapsedRealtimeNanos()` at the call (logcat shows no trace sections), as its `reportFullyDrawn` logs `Fully Drawn at <ns> ns` beside the system's own `Fully drawn` line, which gives no clock time. The runtime doesn't call it; the benchmark apps mark their mount screen's start with it (`benchmarks/SPEC.md`), for the harness to time the screen apart from the launch. 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`.
|
|
30
|
+
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>`. It also has `takeURLs`, which hands `LynxLinking.onURL()` and the router the links that open the app while it's running: `SceneDelegate.scene(_:openURLContexts:)` and `scene(_:continue:)` (a Universal Link), and `MainActivity.onNewIntent` (after a waiting web sign-in has had its redirect) keep each one (`LinkCenter` in `LinkingModule.swift`, the module's companion on Android) and send the `angularLynxURL` global event, which the runtime answers by taking them, as `LynxShortcuts` does. `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. Its `takePhoto` opens the camera for `pick({ source: 'camera' })`, `UIImagePickerController` on iOS and the phone's camera app on Android (`ActivityResultContracts.TakePicture`, into the share `FileProvider`'s `angular-lynx-camera` cache folder, after asking for `CAMERA` through `PermissionHost`), and always re-encodes the photo as an upright JPEG. Only an app whose angular.json sets `permissions.camera` has it (ITMS-90683, as for the scanner below): the generator's `leaveOut` takes out the lines between `// angular-lynx:image-picker-camera` markers in `ImagePickerModule.swift`, `ImagePickerModule.kt` and `MainActivity.kt`, and the camera folder from `res/xml/share_paths.xml`, so the runtime finds no `takePhoto` and rejects with `unavailable`. `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). `AngularLynxPhotoLibrary` (`PhotoLibraryModule.swift`, `PhotoLibraryModule.kt`) saves `LynxPhotoLibrary`'s image or video straight to the library: `PHAssetCreationRequest` with add-only access on iOS, and a MediaStore insert into `Pictures/<app name>` or `Movies/<app name>` on Android 10 and later, which needs no permission (it answers `unavailable` before Android 10). Only an app whose angular.json sets `permissions.savePhotos` has it: the generator's `leaveOut` deletes it from the others, with its registration between `MainActivity`'s `// angular-lynx:photo-library` markers, and iOS registers it by name. `permissions.photos` is iOS only (`NSPhotoLibraryUsageDescription`): Android declares nothing for it, since nothing in the shells reads the library and Google Play rejects `READ_MEDIA_IMAGES` without a core need. `AngularLynxBarcodeScanner` (`BarcodeScannerModule.swift`, `BarcodeScannerModule.kt`) reads a QR code or a barcode for `LynxBarcodeScanner` with the platform's own scanner, VisionKit's `DataScannerViewController` on iOS (16 and later) and Google's code scanner from Play services on Android (`play-services-code-scanner`, which needs no camera permission), and calls back with `{ format, value }`. Only an app whose angular.json sets `permissions.camera` has it: App Store Connect flags an app whose code uses the camera without `NSCameraUsageDescription` (ITMS-90683), so the generator's `configure` deletes the module from every other app, on Android with the library between `app/build.gradle.kts`'s `// angular-lynx:barcode-scanner` markers, and the shells register it by name (`NSClassFromString("AngularLynxBarcodeScannerModule")`, `Class.forName`), which builds either way. `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. It has `markEvent(name)`, which marks a moment the app names in a system trace: an `os_signpost` event named `Mark` with the name as its message, in the Points of Interest category Instruments shows (os_signpost's names are fixed when the shell is compiled), and on Android an instant `Trace` section of that name, which Perfetto shows, and a `Mark <name> at <ns> ns` line in logcat, with `SystemClock.elapsedRealtimeNanos()` at the call (logcat shows no trace sections), as its `reportFullyDrawn` logs `Fully Drawn at <ns> ns` beside the system's own `Fully drawn` line, which gives no clock time. The runtime doesn't call it; the benchmark apps mark their mount screen's start with it (`benchmarks/SPEC.md`), for the harness to time the screen apart from the launch. 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`.
|
|
29
31
|
|
|
30
32
|
`AngularLynxBiometrics` (`BiometricsModule.swift`, `BiometricsModule.kt`) is `LynxBiometrics`' prompt and the store for `LynxSecureStorage`'s `requireBiometrics` values (issue #918). `availability` reports the sensor (`LAContext.biometryType`; on Android `BiometricManager.canAuthenticate(BIOMETRIC_STRONG)` and the package manager's fingerprint, face and iris features), whether a face or finger is enrolled, and whether the phone has a passcode. `authenticate` shows `LAContext.evaluatePolicy` (biometrics only, with the "Enter Password" fallback hidden, or `.deviceOwnerAuthentication` with `allowDeviceCredential`) or AndroidX's `BiometricPrompt`, strong biometrics only, which is why `MainActivity` is a `FragmentActivity`. The store keeps each value on iOS as a Keychain item of its own service with `SecAccessControl(.biometryCurrentSet)` and `kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly`, read with an `LAContext` whose `localizedReason` is the app's (a missing key is found from its attributes first, which don't ask), and on Android sealed with AES-GCM under a key of its own, which RSA-OAEP wraps under a Keystore key pair that needs a strong biometric for each use (`setUserAuthenticationRequired`, `setInvalidatedByBiometricEnrollment`): storing uses the public key and doesn't prompt, and reading unwraps through `BiometricPrompt`'s `CryptoObject`. Enrolling a new face or finger invalidates the item or the pair, and the values then read as none. Only an app with angular.json's `permissions.biometrics` has the module: the generator (`leaveOut`) deletes `BiometricsModule.swift` (`IOS_BIOMETRICS_SOURCES`), or `BiometricsModule.kt` (`ANDROID_BIOMETRICS_SOURCES`), `res/values/biometrics.xml` (the prompt's default reason, which it writes from the permission) and the lines between the `// angular-lynx:biometrics` markers of `MainActivity.kt` and `app/build.gradle.kts` (its registration and AndroidX Biometric) from the others, and LynxViewController registers it by its Objective-C name (`AngularLynxBiometricsModule`). That keeps `LocalAuthentication` out of an iOS app with no `NSFaceIDUsageDescription`, without which Face ID fails.
|
|
31
33
|
|
|
@@ -45,8 +47,12 @@ Only the development build (`ng serve --platform`) loads from a dev server: the
|
|
|
45
47
|
|
|
46
48
|
`AngularLynxCalendar` (`CalendarModule.swift`, `CalendarModule.kt`) opens the system's event editor for `LynxCalendar.addEvent()`, filled in with the app's event (title, start and end in milliseconds since 1970, all-day, location, notes): EventKitUI's `EKEventEditViewController` on iOS 17 and later, which runs outside the app and saves the event itself, so the app needs no calendar permission or usage description, and an `ACTION_INSERT` on `CalendarContract.Events` on Android, which the calendar app's own editor takes. iOS calls back `{ result: "saved" }` or `"canceled"`, from the editor's delegate or a swipe down; before iOS 17 the editor needs full calendar access, so it answers `{ error: "unavailable" }`. Android calls back `"saved"` only when the calendar app answers `RESULT_OK`, and `"unknown"` otherwise, since Google Calendar answers `RESULT_CANCELED` either way, or `{ error: "unavailable" }` without a calendar app. `MainActivity` registers the `StartActivityForResult` launcher as it's created, as the image picker's, and passes the module a `CalendarModule.Host`. An app opts in to it with angular.json's `calendar`: without it, the generator deletes both files and the lines between `MainActivity.kt`'s `// angular-lynx:calendar` markers, and `LynxViewController` finds no `AngularLynxCalendarModule` class to register.
|
|
47
49
|
|
|
50
|
+
`AngularLynxAudioRecorder` (`AudioRecorderModule.swift`, `AudioRecorderModule.kt`) records from the microphone for `LynxAudioRecorder` (issue #922): `AVAudioRecorder` through an `AVAudioSession` (`playAndRecord`, put back as it was once the recording ends) on iOS, and `MediaRecorder` on Android, both AAC in an MPEG-4 file (`.m4a`, mono, 44.1 kHz, 64,000 bits a second) in the app's temporary folder. `permission` and `requestPermission` answer `{ permission }` (Android asks for `RECORD_AUDIO` through `PermissionHost`), `start` (`{ recording, maxDuration? }`) asks first if it needs to, `pause`, `resume`, `stop` (`{ clip }`), `cancel` (deletes the file) and `read` (`{ base64 }`, only for the module's own recordings) do the rest. The `angularLynxAudioRecorder` global event carries the `recording` id: `level` (0..1, -60 to 0 dBFS) and `durationMs` ten times a second, `paused` when the system paused it (an interruption on iOS, the app going to the background on both), and `ended` at `maxDuration` (`{ clip }`, which a later `stop` answers with too) or on an error. Only an app with angular.json's `permissions.microphone` has the module: the permission writes `NSMicrophoneUsageDescription` (App Store Connect flags microphone code without it, ITMS-90683), and Android's manifest gets `RECORD_AUDIO` and a not-required `android.hardware.microphone`; the generator (`leaveOut`) deletes the module and the lines between `MainActivity.kt`'s `// angular-lynx:audio-recorder` markers from the others.
|
|
51
|
+
|
|
48
52
|
`AngularLynxNfc` (`NfcModule.swift`, `NfcModule.kt`) reads and writes NFC tags for `LynxNfc` (issue #921): Core NFC's `NFCNDEFReaderSession`, whose system sheet shows the runtime's `alertMessage`, on iOS, and `NfcAdapter.enableReaderMode` (NFC-A, B, F and V), in `MainActivity` while it's in the foreground, on Android. The runtime opens a session with `start` (`{ alertMessage?, multiple, write? }`), takes each tag with `next`, and ends it with `stop`, whose `message` or `errorMessage` iOS's sheet shows as it closes; `state` says `ready`, `disabled` (Android's NFC turned off) or `unsupported`. Records cross as `{ tnf, type, id, payload }` with the bytes in base64, and the runtime (`nfc/ndef.ts`) builds and reads them, Text and URI records included, so the shells only take NDEF messages apart and put them together. A tag is connected, its NDEF status queried, then read or written (an Android tag that `NdefFormatable` reports is formatted with the message); with `multiple`, a tag that fails is skipped and polling restarts. Only an app with angular.json's `permissions.nfc` has the module: the permission writes `NFCReaderUsageDescription`, `IOS_ENTITLEMENTS` adds `com.apple.developer.nfc.readersession.formats` (`TAG`, the only format iOS 13 and later take, which covers NDEF sessions) to `Config/App.entitlements`, Android's manifest gets `android.permission.NFC` and a not-required `android.hardware.nfc`, and the generator (`leaveOut`) deletes the module and the lines between `MainActivity.kt`'s `// angular-lynx:nfc` markers from the others. A free Personal Team can't sign the entitlement, which `explainSigningFailure` says.
|
|
49
53
|
|
|
54
|
+
`AngularLynxGeolocation` (`GeolocationModule.swift`, `GeolocationModule.kt`) finds where the phone is for `LynxGeolocation` (issue #916), while the app is in use. `getState` answers `{ state }` without asking: `unknown`, `denied`, `approximate`, `precise` or `off` (Location turned off for the whole phone). `requestPermission` shows the prompt if the person hasn't been asked, and answers the state. `getCurrentPosition({ accuracy, timeout, maximumAge })` answers `{ position }`, and `startWatch({ watch, accuracy, distanceFilter })` answers `{}` once it's started and sends each position as an `angularLynxGeolocation` global event (`{ type: 'position', watch, position }`), until `stopWatch(watch)`, or a `watchStopped` with the reason; a `state` event follows each change. Both ask first when the person hasn't been asked, and answer `{ error, message }` with `denied`, `off`, `timeout`, `busy` or `failed`. iOS uses Core Location: a `CLLocationManager` per request and watch, all on the main thread, whose `accuracyAuthorization` tells precise from approximate. Android uses `LocationManager` through AndroidX's `LocationManagerCompat`, with no Play services: the fused provider from Android 12, GPS or the network before it, and asks for both location permissions through `MainActivity`'s `PermissionHost`, so Android 12 and later let the person choose approximate, reported as `approximate` rather than a refusal. An app opts in with angular.json's `permissions.location`, which also writes `NSLocationWhenInUseUsageDescription` and declares `ACCESS_COARSE_LOCATION` and `ACCESS_FINE_LOCATION`: without it, the generator deletes both files and the lines between `MainActivity.kt`'s `// angular-lynx:geolocation` markers, and `LynxViewController` finds no `AngularLynxGeolocationModule` class to register, since App Store Connect flags Core Location code without the usage description (ITMS-90683).
|
|
55
|
+
|
|
50
56
|
`AngularLynxAppleSignIn` (`AppleSignInModule.swift`, iOS only) opens `LynxAppleSignIn`'s Sign in with Apple sheet: an `ASAuthorizationAppleIDProvider` request with the scopes, nonce and state asked for, presented by an `ASAuthorizationController` over the key window. It calls back the user identifier, the identity token and authorization code as UTF-8 text, the email and the shared parts of the name when Apple gives them, and `realUserStatus`, or `{ error: 'canceled' | 'failed', message }`. `credentialState` answers `getCredentialState(forUserID:)`, `available` answers `{ available: true }`, and `button`, which the runtime calls synchronously from the main thread, answers `{ available: true }` to say `<apple-sign-in-button>` is registered. That element is `AppleSignInButton.swift`, iOS's `ASAuthorizationAppleIDButton` behind the tag, which `XElementRegistry` registers by its Objective-C name, `AngularLynxAppleSignInButton`; UIKit sets a button's type and style only when it makes it, so a change to `type` or `button-style` makes a new one. The sheet needs the `com.apple.developer.applesignin` entitlement, which a free Personal Team can't sign, so without angular.json's `signInWithApple` the generator deletes both files and writes no entitlement, and `LynxViewController` and `XElementRegistry` find no class to register. Android has no module: the runtime rejects with `unsupported` there, and draws `<apple-sign-in-button>` itself.
|
|
51
57
|
|
|
52
58
|
`AngularLynxMotion` (`MotionModule.swift`, `MotionModule.kt`) is `LynxMotion`'s sensors (issue #920): `CMMotionManager`'s accelerometer and device motion (rotation rate, and the attitude against `.xArbitraryZVertical`) and `CLLocationManager`'s heading on iOS, and `SensorManager`'s accelerometer, gyroscope, game rotation vector and rotation vector on Android, each a `LynxContextModule` that runs a sensor from `start(sensor, interval)` until `stop(sensor)` and sends what it sampled in the `angularLynxMotion` global event, as flat arrays of numbers, at most every 16 ms. Both hear shakes from the accelerometer themselves (the runtime's `ShakeDetector`, after Square's Seismic), convert iOS's acceleration from g to the web's m/s², send the orientation as Android's device-to-earth rotation matrix (iOS's `CMRotationMatrix`, transposed or not by which way gravity says is up), and stop the sensors while the app is in the background. None needs a permission. An app opts in with angular.json's `motion`: without it, the generator deletes both files and the lines between `MainActivity.kt`'s `// angular-lynx:motion` markers, and `LynxViewController` finds no `AngularLynxMotionModule` class to register.
|
|
@@ -15,9 +15,10 @@ export declare const ANDROID_BARCODE_SCANNER_SOURCE = "app/src/main/java/dev/ang
|
|
|
15
15
|
* permission. The store review module stays only in an app with
|
|
16
16
|
* `storeReview`, the calendar module only in one with `calendar`, the
|
|
17
17
|
* tracking module only in one with `permissions.tracking`, the NFC module
|
|
18
|
-
* only in one with `permissions.nfc`, the
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
18
|
+
* only in one with `permissions.nfc`, the audio recorder's module only in one
|
|
19
|
+
* with `permissions.microphone`, the geolocation module only in one with
|
|
20
|
+
* `permissions.location`, the motion module only in one with `motion`, and
|
|
21
|
+
* the Wi-Fi module only in one with `wifi`, with only the parts it turns on.
|
|
21
22
|
*/
|
|
22
23
|
export declare const androidGenerator: PlatformGenerator;
|
|
23
24
|
/** The module behind `LynxStoreReview`, which only `storeReview` keeps. */
|
|
@@ -26,8 +27,24 @@ export declare const ANDROID_STORE_REVIEW_SOURCE = "app/src/main/java/dev/angula
|
|
|
26
27
|
export declare const ANDROID_WIFI_SOURCE = "app/src/main/java/dev/angularlynx/shell/WifiModule.kt";
|
|
27
28
|
/** The module behind `LynxCalendar`, which only `calendar` keeps. */
|
|
28
29
|
export declare const ANDROID_CALENDAR_SOURCE = "app/src/main/java/dev/angularlynx/shell/CalendarModule.kt";
|
|
30
|
+
/**
|
|
31
|
+
* The module behind `LynxAudioRecorder`, which only `permissions.microphone`
|
|
32
|
+
* keeps.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ANDROID_AUDIO_RECORDER_SOURCE = "app/src/main/java/dev/angularlynx/shell/AudioRecorderModule.kt";
|
|
29
35
|
/** The module behind `LynxNfc`, which only `permissions.nfc` keeps. */
|
|
30
36
|
export declare const ANDROID_NFC_SOURCE = "app/src/main/java/dev/angularlynx/shell/NfcModule.kt";
|
|
37
|
+
/**
|
|
38
|
+
* The files with LynxImagePicker's camera in them, between
|
|
39
|
+
* `// angular-lynx:image-picker-camera` markers, which only an app with
|
|
40
|
+
* `permissions.camera` keeps.
|
|
41
|
+
*/
|
|
42
|
+
export declare const ANDROID_IMAGE_PICKER_CAMERA_MARKED: readonly ["app/src/main/java/dev/angularlynx/shell/ImagePickerModule.kt", "app/src/main/java/dev/angularlynx/shell/MainActivity.kt"];
|
|
43
|
+
/**
|
|
44
|
+
* The module behind `LynxGeolocation`, which only `permissions.location`
|
|
45
|
+
* keeps.
|
|
46
|
+
*/
|
|
47
|
+
export declare const ANDROID_GEOLOCATION_SOURCE = "app/src/main/java/dev/angularlynx/shell/GeolocationModule.kt";
|
|
31
48
|
/**
|
|
32
49
|
* The module behind `LynxTracking`, which only an app with
|
|
33
50
|
* `permissions.tracking` keeps.
|
|
@@ -56,6 +73,13 @@ export declare const ANDROID_PHOTO_LIBRARY_SOURCES: readonly ["PhotoLibraryModul
|
|
|
56
73
|
* app gives none, angular.json's `permissions.biometrics`.
|
|
57
74
|
*/
|
|
58
75
|
export declare const biometricsStringsXml: (reason: string) => string;
|
|
76
|
+
/** Where the plugins' Kotlin and Java go, a folder per plugin. */
|
|
77
|
+
export declare const ANDROID_PLUGIN_SOURCES = "app/src/main/java/plugins";
|
|
78
|
+
/**
|
|
79
|
+
* Where the plugins' Android resources go, a resource folder per plugin,
|
|
80
|
+
* which the template's build.gradle.kts adds to the app module's.
|
|
81
|
+
*/
|
|
82
|
+
export declare const ANDROID_PLUGIN_RESOURCES = "app/src/main/plugin-res";
|
|
59
83
|
/**
|
|
60
84
|
* The shell's `<canvas>`, its `AngularLynxWebGL` module and its contexts, and
|
|
61
85
|
* `<video>`'s readable frames, which only MainActivity's marked lines reach.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,iBAAiB,EAAkB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,iBA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,GAAI,KAAK,WAAW,KAAG,MAgBhC,CAAC;AAuBf,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAsBpD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,GAC1B,aAAa,SAAS,iBAAiB,EAAE,KACxC,MAAM,EA8BR,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW,KAAG,MAuBrC,CAAC;AAEf,2EAA2E;AAC3E,eAAO,MAAM,2BAA2B,iEAA0C,CAAC;AAKnF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,MAoBrD,CAAC;AAEF,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,GAAI,WAAW,SAAS,MAAM,EAAE,KAAG,MAUvD,CAAC;AASf;;;;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"}
|
package/dist/android/project.js
CHANGED
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { leaveOutWifi, removeMarkedLines, removeTemplateFiles, } from "../features.js";
|
|
5
5
|
import { shortcutIdentifier, } from "../options.js";
|
|
6
6
|
import { PERMISSION_MAP } from "../permissions.js";
|
|
7
|
+
import { androidPluginsKotlin, checkAndroidResources, checkJvmPackages, copyPluginResources, copyPluginSources, readNativePlugins, } from "../plugins.js";
|
|
7
8
|
import { writeAndroidSplash } from "../splash.js";
|
|
8
9
|
import { writeAndroidIcon } from "./icon.js";
|
|
9
10
|
import { escapeXml, replaceMarker } from "../xml.js";
|
|
@@ -31,9 +32,10 @@ const SCREEN_ORIENTATIONS = {
|
|
|
31
32
|
* permission. The store review module stays only in an app with
|
|
32
33
|
* `storeReview`, the calendar module only in one with `calendar`, the
|
|
33
34
|
* tracking module only in one with `permissions.tracking`, the NFC module
|
|
34
|
-
* only in one with `permissions.nfc`, the
|
|
35
|
-
* `
|
|
36
|
-
*
|
|
35
|
+
* only in one with `permissions.nfc`, the audio recorder's module only in one
|
|
36
|
+
* with `permissions.microphone`, the geolocation module only in one with
|
|
37
|
+
* `permissions.location`, the motion module only in one with `motion`, and
|
|
38
|
+
* the Wi-Fi module only in one with `wifi`, with only the parts it turns on.
|
|
37
39
|
*/
|
|
38
40
|
export const androidGenerator = {
|
|
39
41
|
configure: (dir, app, projectRoot) => {
|
|
@@ -85,6 +87,18 @@ export const androidGenerator = {
|
|
|
85
87
|
writeFileSync(path.join(dir, BIOMETRICS_STRINGS), biometricsStringsXml(reason));
|
|
86
88
|
}
|
|
87
89
|
},
|
|
90
|
+
// The plugins' Kotlin and Java: Gradle compiles everything under
|
|
91
|
+
// src/main/java, whatever its package. Their resources, a resource folder
|
|
92
|
+
// each, which build.gradle.kts adds to the app module's. The registration
|
|
93
|
+
// replaces the template's, which registers nothing.
|
|
94
|
+
writePlugins: (dir, app, projectRoot) => {
|
|
95
|
+
const plugins = readNativePlugins(app.nativePlugins, projectRoot);
|
|
96
|
+
checkJvmPackages(plugins);
|
|
97
|
+
checkAndroidResources(plugins, path.join(dir, 'app'));
|
|
98
|
+
copyPluginSources(plugins, 'android', path.join(dir, ANDROID_PLUGIN_SOURCES));
|
|
99
|
+
copyPluginResources(plugins, path.join(dir, ANDROID_PLUGIN_RESOURCES));
|
|
100
|
+
writeFileSync(path.join(dir, SHELL_SOURCES, 'AngularLynxPlugins.kt'), androidPluginsKotlin(plugins));
|
|
101
|
+
},
|
|
88
102
|
leaveOut: (dir, features, app) => {
|
|
89
103
|
// The biometrics module, AndroidX Biometric and the lines that register
|
|
90
104
|
// it are only for an app that asks for biometrics.
|
|
@@ -150,6 +164,22 @@ export const androidGenerator = {
|
|
|
150
164
|
removeTemplateFiles(dir, [ANDROID_NFC_SOURCE]);
|
|
151
165
|
removeMarkedLines(path.join(dir, SHELL_SOURCES, 'MainActivity.kt'), 'nfc');
|
|
152
166
|
}
|
|
167
|
+
// As on iOS, the recorder is only for an app that says why it uses the
|
|
168
|
+
// microphone (`permissions.microphone`, which also declares
|
|
169
|
+
// RECORD_AUDIO): the module and MainActivity's lines that register it
|
|
170
|
+
// (`// angular-lynx:audio-recorder`).
|
|
171
|
+
if (!app.permissions.microphone) {
|
|
172
|
+
removeTemplateFiles(dir, [ANDROID_AUDIO_RECORDER_SOURCE]);
|
|
173
|
+
removeMarkedLines(path.join(dir, SHELL_SOURCES, 'MainActivity.kt'), 'audio-recorder');
|
|
174
|
+
}
|
|
175
|
+
// As on iOS, the geolocation module is only for an app that says why it
|
|
176
|
+
// finds the phone (`permissions.location`, which also declares the
|
|
177
|
+
// location permissions): the module and MainActivity's lines that
|
|
178
|
+
// register it (`// angular-lynx:geolocation`).
|
|
179
|
+
if (!app.permissions.location) {
|
|
180
|
+
removeTemplateFiles(dir, [ANDROID_GEOLOCATION_SOURCE]);
|
|
181
|
+
removeMarkedLines(path.join(dir, SHELL_SOURCES, 'MainActivity.kt'), 'geolocation');
|
|
182
|
+
}
|
|
153
183
|
// The photo library module, and the lines that register it, are only
|
|
154
184
|
// for an app that asks for savePhotos.
|
|
155
185
|
if (!app.permissions.savePhotos) {
|
|
@@ -170,6 +200,18 @@ export const androidGenerator = {
|
|
|
170
200
|
removeTemplateFiles(dir, [ANDROID_MOTION_SOURCE]);
|
|
171
201
|
removeMarkedLines(path.join(dir, SHELL_SOURCES, 'MainActivity.kt'), 'motion');
|
|
172
202
|
}
|
|
203
|
+
// As on iOS, LynxImagePicker's camera is only for an app that says why
|
|
204
|
+
// it uses the camera (`permissions.camera`, which also declares CAMERA):
|
|
205
|
+
// the module's takePhoto, MainActivity's camera launcher
|
|
206
|
+
// (`// angular-lynx:image-picker-camera`), and the folder FileProvider
|
|
207
|
+
// shares the photo from.
|
|
208
|
+
if (!app.permissions.camera) {
|
|
209
|
+
for (const file of ANDROID_IMAGE_PICKER_CAMERA_MARKED) {
|
|
210
|
+
removeMarkedLines(path.join(dir, file), 'image-picker-camera');
|
|
211
|
+
}
|
|
212
|
+
const paths = path.join(dir, FILE_PROVIDER_PATHS);
|
|
213
|
+
writeFileSync(paths, replaceMarker(readFileSync(paths, 'utf8'), 'image-picker-camera', ''));
|
|
214
|
+
}
|
|
173
215
|
leaveOutCanvas(dir, features);
|
|
174
216
|
},
|
|
175
217
|
bundleDir: (dir) => path.join(dir, 'app/src/main/assets'),
|
|
@@ -198,8 +240,33 @@ export const ANDROID_STORE_REVIEW_SOURCE = `${SHELL_SOURCES}/StoreReviewModule.k
|
|
|
198
240
|
export const ANDROID_WIFI_SOURCE = `${SHELL_SOURCES}/WifiModule.kt`;
|
|
199
241
|
/** The module behind `LynxCalendar`, which only `calendar` keeps. */
|
|
200
242
|
export const ANDROID_CALENDAR_SOURCE = `${SHELL_SOURCES}/CalendarModule.kt`;
|
|
243
|
+
/**
|
|
244
|
+
* The module behind `LynxAudioRecorder`, which only `permissions.microphone`
|
|
245
|
+
* keeps.
|
|
246
|
+
*/
|
|
247
|
+
export const ANDROID_AUDIO_RECORDER_SOURCE = `${SHELL_SOURCES}/AudioRecorderModule.kt`;
|
|
201
248
|
/** The module behind `LynxNfc`, which only `permissions.nfc` keeps. */
|
|
202
249
|
export const ANDROID_NFC_SOURCE = `${SHELL_SOURCES}/NfcModule.kt`;
|
|
250
|
+
/**
|
|
251
|
+
* The files with LynxImagePicker's camera in them, between
|
|
252
|
+
* `// angular-lynx:image-picker-camera` markers, which only an app with
|
|
253
|
+
* `permissions.camera` keeps.
|
|
254
|
+
*/
|
|
255
|
+
export const ANDROID_IMAGE_PICKER_CAMERA_MARKED = [
|
|
256
|
+
`${SHELL_SOURCES}/ImagePickerModule.kt`,
|
|
257
|
+
`${SHELL_SOURCES}/MainActivity.kt`,
|
|
258
|
+
];
|
|
259
|
+
/**
|
|
260
|
+
* The folders FileProvider shares from: the camera's, between
|
|
261
|
+
* `<!-- angular-lynx:image-picker-camera -->` markers, is only in an app
|
|
262
|
+
* with `permissions.camera`.
|
|
263
|
+
*/
|
|
264
|
+
const FILE_PROVIDER_PATHS = 'app/src/main/res/xml/share_paths.xml';
|
|
265
|
+
/**
|
|
266
|
+
* The module behind `LynxGeolocation`, which only `permissions.location`
|
|
267
|
+
* keeps.
|
|
268
|
+
*/
|
|
269
|
+
export const ANDROID_GEOLOCATION_SOURCE = `${SHELL_SOURCES}/GeolocationModule.kt`;
|
|
203
270
|
/**
|
|
204
271
|
* The module behind `LynxTracking`, which only an app with
|
|
205
272
|
* `permissions.tracking` keeps.
|
|
@@ -262,6 +329,13 @@ export const biometricsStringsXml = (reason) => [
|
|
|
262
329
|
'</resources>',
|
|
263
330
|
'',
|
|
264
331
|
].join('\n');
|
|
332
|
+
/** Where the plugins' Kotlin and Java go, a folder per plugin. */
|
|
333
|
+
export const ANDROID_PLUGIN_SOURCES = 'app/src/main/java/plugins';
|
|
334
|
+
/**
|
|
335
|
+
* Where the plugins' Android resources go, a resource folder per plugin,
|
|
336
|
+
* which the template's build.gradle.kts adds to the app module's.
|
|
337
|
+
*/
|
|
338
|
+
export const ANDROID_PLUGIN_RESOURCES = 'app/src/main/plugin-res';
|
|
265
339
|
/**
|
|
266
340
|
* The shell's `<canvas>`, its `AngularLynxWebGL` module and its contexts, and
|
|
267
341
|
* `<video>`'s readable frames, which only MainActivity's marked lines reach.
|
|
@@ -321,20 +395,17 @@ export const properties = (app) => [
|
|
|
321
395
|
* reading the network (`WifiManager.getConnectionInfo`, with the location
|
|
322
396
|
* permission `permissions.location` adds) and joining one
|
|
323
397
|
* (`WifiNetworkSuggestion`, and `ConnectivityManager.requestNetwork` for a
|
|
324
|
-
* `WifiNetworkSpecifier`).
|
|
398
|
+
* `WifiNetworkSpecifier`). Both need `ACCESS_NETWORK_STATE` too, which the
|
|
399
|
+
* manifest template declares for every app, since `LynxNetwork` needs it.
|
|
325
400
|
*/
|
|
326
401
|
const wifiPermissions = (app) => [
|
|
327
402
|
...(app.wifi.readCurrentNetwork
|
|
328
|
-
? [
|
|
329
|
-
'android.permission.ACCESS_WIFI_STATE',
|
|
330
|
-
'android.permission.ACCESS_NETWORK_STATE',
|
|
331
|
-
]
|
|
403
|
+
? ['android.permission.ACCESS_WIFI_STATE']
|
|
332
404
|
: []),
|
|
333
405
|
...(app.wifi.join
|
|
334
406
|
? [
|
|
335
407
|
'android.permission.ACCESS_WIFI_STATE',
|
|
336
408
|
'android.permission.CHANGE_WIFI_STATE',
|
|
337
|
-
'android.permission.ACCESS_NETWORK_STATE',
|
|
338
409
|
'android.permission.CHANGE_NETWORK_STATE',
|
|
339
410
|
]
|
|
340
411
|
: []),
|
package/dist/eject.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../src/eject.ts"],"names":[],"mappings":"AAYA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAgB,KAAK,QAAQ,EAAiB,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,cAAc,CAAC;AA+BxE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,0FAQlC;IACD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACpC,KAAG,GAAG,CAAC,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"eject.d.ts","sourceRoot":"","sources":["../src/eject.ts"],"names":[],"mappings":"AAYA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAgB,KAAK,QAAQ,EAAiB,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,cAAc,CAAC;AA+BxE;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,GAAI,0FAQlC;IACD,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,cAAc,CAAC;CACpC,KAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CA6BrB,CAAC"}
|
package/dist/eject.js
CHANGED
|
@@ -56,6 +56,7 @@ export const renderEjectedProject = ({ platform, projectRoot, projectName, packa
|
|
|
56
56
|
const generator = platform === 'ios' ? iosGenerator : androidGenerator;
|
|
57
57
|
generator.configure(dir, resolved, projectRoot);
|
|
58
58
|
generator.leaveOut(dir, features, resolved);
|
|
59
|
+
generator.writePlugins(dir, resolved, projectRoot);
|
|
59
60
|
writeFileSync(path.join(dir, '.gitignore'), GITIGNORE[platform]);
|
|
60
61
|
writeFileSync(path.join(dir, EJECT_MARKER), [
|
|
61
62
|
`Ejected from @blotch/angular-lynx-native ${generatorVersion}.`,
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A file found by {@link listFiles}. */
|
|
2
|
+
export type ListedFile = {
|
|
3
|
+
/** Its path under the listed folder, with `/` between the parts. */
|
|
4
|
+
readonly relative: string;
|
|
5
|
+
readonly absolute: string;
|
|
6
|
+
/** Whether it's a folder, which only `folders` lists. */
|
|
7
|
+
readonly folder?: true;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Every file under `dir`, sorted by name, so a hash of them doesn't depend
|
|
11
|
+
* on the file system's order. A symbolic link is followed, so a linked folder
|
|
12
|
+
* is listed as the folder it points at rather than read as a file, and two
|
|
13
|
+
* links to one folder list it twice.
|
|
14
|
+
*
|
|
15
|
+
* @param dir - The folder to list.
|
|
16
|
+
* @param options - Whether to list each folder too, before its files, so
|
|
17
|
+
* an empty one counts.
|
|
18
|
+
* @throws NativeConfigError for a link to a folder it is in, whose files
|
|
19
|
+
* would never end.
|
|
20
|
+
*/
|
|
21
|
+
export declare const listFiles: (dir: string, { folders }?: {
|
|
22
|
+
readonly folders?: boolean;
|
|
23
|
+
}) => ListedFile[];
|
|
24
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAKA,yCAAyC;AACzC,MAAM,MAAM,UAAU,GAAG;IACvB,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,yDAAyD;IACzD,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,GACpB,KAAK,MAAM,EACX,cAAqB;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,KACvD,UAAU,EAiCZ,CAAC"}
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readdirSync, realpathSync, statSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { NativeConfigError } from "./options.js";
|
|
4
|
+
/**
|
|
5
|
+
* Every file under `dir`, sorted by name, so a hash of them doesn't depend
|
|
6
|
+
* on the file system's order. A symbolic link is followed, so a linked folder
|
|
7
|
+
* is listed as the folder it points at rather than read as a file, and two
|
|
8
|
+
* links to one folder list it twice.
|
|
9
|
+
*
|
|
10
|
+
* @param dir - The folder to list.
|
|
11
|
+
* @param options - Whether to list each folder too, before its files, so
|
|
12
|
+
* an empty one counts.
|
|
13
|
+
* @throws NativeConfigError for a link to a folder it is in, whose files
|
|
14
|
+
* would never end.
|
|
15
|
+
*/
|
|
16
|
+
export const listFiles = (dir, { folders = false } = {}) => {
|
|
17
|
+
const list = (folder, prefix,
|
|
18
|
+
// The real path of each folder from `dir` down to this one, to the path
|
|
19
|
+
// it was listed by.
|
|
20
|
+
around) => readdirSync(folder, { withFileTypes: true })
|
|
21
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
22
|
+
.flatMap((entry) => {
|
|
23
|
+
const relative = path.posix.join(prefix, entry.name);
|
|
24
|
+
const absolute = path.join(folder, entry.name);
|
|
25
|
+
if (entry.isSymbolicLink()
|
|
26
|
+
? !statSync(absolute).isDirectory()
|
|
27
|
+
: !entry.isDirectory()) {
|
|
28
|
+
return [{ relative, absolute }];
|
|
29
|
+
}
|
|
30
|
+
const real = realpathSync(absolute);
|
|
31
|
+
const loop = around.get(real);
|
|
32
|
+
if (loop !== undefined) {
|
|
33
|
+
throw new NativeConfigError(`${relative} in ${dir} links to a folder it is in, ${loop}, so its files would never end. Link to a folder outside it.`);
|
|
34
|
+
}
|
|
35
|
+
return [
|
|
36
|
+
...(folders ? [{ relative, absolute, folder: true }] : []),
|
|
37
|
+
...list(absolute, relative, new Map([...around, [real, absolute]])),
|
|
38
|
+
];
|
|
39
|
+
});
|
|
40
|
+
return list(dir, '', new Map([[realpathSync(dir), dir]]));
|
|
41
|
+
};
|
package/dist/generate.d.ts
CHANGED
|
@@ -25,6 +25,14 @@ export type PlatformGenerator = {
|
|
|
25
25
|
* the user's to grow.
|
|
26
26
|
*/
|
|
27
27
|
readonly leaveOut: (dir: string, features: NativeFeatures, app: ResolvedApp) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Copies the app's native plugins (`nativePlugins`) into the project and
|
|
30
|
+
* writes their registration, replacing what an earlier call wrote. It
|
|
31
|
+
* comes after `leaveOut`, so a plugin is checked against the shell's
|
|
32
|
+
* sources the app keeps, and prepareProject calls it alone when only a
|
|
33
|
+
* plugin's files changed.
|
|
34
|
+
*/
|
|
35
|
+
readonly writePlugins: (dir: string, app: ResolvedApp, projectRoot: string) => void;
|
|
28
36
|
/** Where the Lynx bundle and its assets go inside the native project. */
|
|
29
37
|
readonly bundleDir: (dir: string) => string;
|
|
30
38
|
};
|
|
@@ -35,6 +43,11 @@ export type PreparedProject = {
|
|
|
35
43
|
readonly ejected: boolean;
|
|
36
44
|
/** False when the cached project matched the inputs and was reused. */
|
|
37
45
|
readonly regenerated: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* True when the cached project was reused with its plugins written again,
|
|
48
|
+
* because only a plugin's files changed.
|
|
49
|
+
*/
|
|
50
|
+
readonly pluginsUpdated?: boolean;
|
|
38
51
|
/**
|
|
39
52
|
* The hash of the generated project's inputs, or undefined for an ejected
|
|
40
53
|
* project, whose inputs are the user's own files.
|
|
@@ -47,8 +60,10 @@ export type PreparedProject = {
|
|
|
47
60
|
*
|
|
48
61
|
* Generation is skipped when a hash of every input (this package's version,
|
|
49
62
|
* the template files, the app options and the icon and splash images) matches the last run, so
|
|
50
|
-
* Xcode and Gradle keep their incremental state between builds.
|
|
51
|
-
*
|
|
63
|
+
* Xcode and Gradle keep their incremental state between builds. When only a
|
|
64
|
+
* native plugin's files changed, the project is kept and its plugins written
|
|
65
|
+
* again. The bundle is copied in on every build, because it changes on every
|
|
66
|
+
* build.
|
|
52
67
|
*
|
|
53
68
|
* `ng serve --platform`'s development app is generated in a folder of its
|
|
54
69
|
* own, `<workDir>/<platform>-dev`, so it and `ng build --platform`'s app each
|
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,EAAuB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAaA,OAAO,EAAuB,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAIvE,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEzC,mDAAmD;AACnD,eAAO,MAAM,aAAa,QAEzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,0BAA0B,CAAC;AAKpD,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,CAClB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,WAAW,EAChB,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,OAAO,KAClB,IAAI,CAAC;IACV;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,EAAE,CACjB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,cAAc,EACxB,GAAG,EAAE,WAAW,KACb,IAAI,CAAC;IACV;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,EAAE,CACrB,GAAG,EAAE,MAAM,EACX,GAAG,E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,UAAU,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,KAAG,IAqBrD,CAAC"}
|
package/dist/generate.js
CHANGED
|
@@ -4,6 +4,8 @@ import path from 'node:path';
|
|
|
4
4
|
import { fileURLToPath } from 'node:url';
|
|
5
5
|
import { ALL_NATIVE_FEATURES } from "./features.js";
|
|
6
6
|
import { ICON_BACKGROUND_COLOR } from "./options.js";
|
|
7
|
+
import { listFiles } from "./files.js";
|
|
8
|
+
import { pluginInputFiles, readNativePlugins } from "./plugins.js";
|
|
7
9
|
/** The shell templates shipped in this package. */
|
|
8
10
|
export const TEMPLATES_DIR = fileURLToPath(new URL('../templates/', import.meta.url));
|
|
9
11
|
/**
|
|
@@ -14,14 +16,17 @@ export const TEMPLATES_DIR = fileURLToPath(new URL('../templates/', import.meta.
|
|
|
14
16
|
*/
|
|
15
17
|
export const EJECT_MARKER = '.angular-lynx-ejected';
|
|
16
18
|
const HASH_FILE = '.angular-lynx-hash';
|
|
19
|
+
const PLUGINS_HASH_FILE = '.angular-lynx-plugins-hash';
|
|
17
20
|
/**
|
|
18
21
|
* Makes the native project for a platform ready to build: the generated one in
|
|
19
22
|
* `<workDir>/<platform>`, or the user's ejected folder.
|
|
20
23
|
*
|
|
21
24
|
* Generation is skipped when a hash of every input (this package's version,
|
|
22
25
|
* the template files, the app options and the icon and splash images) matches the last run, so
|
|
23
|
-
* Xcode and Gradle keep their incremental state between builds.
|
|
24
|
-
*
|
|
26
|
+
* Xcode and Gradle keep their incremental state between builds. When only a
|
|
27
|
+
* native plugin's files changed, the project is kept and its plugins written
|
|
28
|
+
* again. The bundle is copied in on every build, because it changes on every
|
|
29
|
+
* build.
|
|
25
30
|
*
|
|
26
31
|
* `ng serve --platform`'s development app is generated in a folder of its
|
|
27
32
|
* own, `<workDir>/<platform>-dev`, so it and `ng build --platform`'s app each
|
|
@@ -37,30 +42,54 @@ export const prepareProject = ({ platform, generator, projectRoot, workDir, app,
|
|
|
37
42
|
return { dir: ejectedDir, ejected: true, regenerated: false };
|
|
38
43
|
}
|
|
39
44
|
const dir = path.join(workDir, development ? `${platform}-dev` : platform);
|
|
40
|
-
|
|
45
|
+
// Before anything is generated, so a broken nativePlugins entry leaves the
|
|
46
|
+
// last project as it was.
|
|
47
|
+
readNativePlugins(app.nativePlugins, projectRoot);
|
|
48
|
+
const projectHash = inputHash({
|
|
41
49
|
platform,
|
|
42
50
|
app,
|
|
43
51
|
projectRoot,
|
|
44
52
|
packageVersion,
|
|
45
53
|
features,
|
|
46
54
|
});
|
|
55
|
+
const plugins = pluginsHash(app, projectRoot);
|
|
47
56
|
const hashFile = path.join(dir, HASH_FILE);
|
|
48
|
-
const
|
|
57
|
+
const pluginsHashFile = path.join(dir, PLUGINS_HASH_FILE);
|
|
58
|
+
const upToDate = existsSync(hashFile) && readFileSync(hashFile, 'utf8') === projectHash;
|
|
59
|
+
const pluginsUpToDate = upToDate &&
|
|
60
|
+
existsSync(pluginsHashFile) &&
|
|
61
|
+
readFileSync(pluginsHashFile, 'utf8') === plugins;
|
|
49
62
|
if (!upToDate) {
|
|
50
63
|
rmSync(dir, { recursive: true, force: true });
|
|
51
64
|
mkdirSync(dir, { recursive: true });
|
|
52
65
|
cpSync(path.join(TEMPLATES_DIR, platform), dir, { recursive: true });
|
|
53
66
|
generator.configure(dir, app, projectRoot, development);
|
|
54
67
|
generator.leaveOut(dir, features, app);
|
|
55
|
-
writeFileSync(hashFile,
|
|
68
|
+
writeFileSync(hashFile, projectHash);
|
|
56
69
|
}
|
|
70
|
+
if (!pluginsUpToDate) {
|
|
71
|
+
// First, so a write that fails partway, after deleting the last copy,
|
|
72
|
+
// leaves no hash that inputs restored to the last copy's would match.
|
|
73
|
+
rmSync(pluginsHashFile, { force: true });
|
|
74
|
+
generator.writePlugins(dir, app, projectRoot);
|
|
75
|
+
writeFileSync(pluginsHashFile, plugins);
|
|
76
|
+
}
|
|
77
|
+
const hash = createHash('sha256')
|
|
78
|
+
.update(`${projectHash}\n${plugins}`)
|
|
79
|
+
.digest('hex');
|
|
57
80
|
// Generated projects are build output. `ng new` already ignores Angular's
|
|
58
81
|
// cache, but a moved cache (`cli.cache.path`) or an edited .gitignore may
|
|
59
82
|
// not be: keep them out of the user's git without asking them to edit it.
|
|
60
83
|
writeFileSync(path.join(workDir, '.gitignore'), '*\n');
|
|
61
84
|
if (bundleDir)
|
|
62
85
|
copyBundle(bundleDir, generator.bundleDir(dir));
|
|
63
|
-
return {
|
|
86
|
+
return {
|
|
87
|
+
dir,
|
|
88
|
+
ejected: false,
|
|
89
|
+
regenerated: !upToDate,
|
|
90
|
+
...(upToDate && !pluginsUpToDate && { pluginsUpdated: true }),
|
|
91
|
+
hash,
|
|
92
|
+
};
|
|
64
93
|
};
|
|
65
94
|
/**
|
|
66
95
|
* Up to 22.2.2, native builds worked in `.angular-lynx/` at the project root.
|
|
@@ -103,7 +132,14 @@ export const copyBundle = (from, to) => {
|
|
|
103
132
|
};
|
|
104
133
|
const inputHash = ({ platform, app, projectRoot, packageVersion, features, }) => {
|
|
105
134
|
const hash = createHash('sha256');
|
|
106
|
-
|
|
135
|
+
// The plugins by their folders alone: what each registers is in
|
|
136
|
+
// pluginsHash, so an edit to it updates only the plugins, as an edit to
|
|
137
|
+
// their sources does.
|
|
138
|
+
const options = {
|
|
139
|
+
...app,
|
|
140
|
+
nativePlugins: app.nativePlugins.map((plugin) => plugin.path),
|
|
141
|
+
};
|
|
142
|
+
hash.update(`${packageVersion}\n${platform}\n${JSON.stringify(options)}\n${JSON.stringify(features)}\n`);
|
|
107
143
|
for (const file of listFiles(path.join(TEMPLATES_DIR, platform))) {
|
|
108
144
|
hash.update(file.relative);
|
|
109
145
|
hash.update(readFileSync(file.absolute));
|
|
@@ -127,14 +163,29 @@ const inputHash = ({ platform, app, projectRoot, packageVersion, features, }) =>
|
|
|
127
163
|
return hash.digest('hex');
|
|
128
164
|
};
|
|
129
165
|
/**
|
|
130
|
-
*
|
|
166
|
+
* A hash of the plugins' entries in angular.json, then their sources and
|
|
167
|
+
* folders, by path relative to the project root and contents. Apart from
|
|
168
|
+
* inputHash, so an edit to a plugin's entry or files updates only the
|
|
169
|
+
* plugins in the project (`writePlugins`), and Xcode and
|
|
170
|
+
* Gradle keep the rest of their incremental state. Each path ends in a NUL,
|
|
171
|
+
* which no path has, and each file's contents start with their length, so
|
|
172
|
+
* the end of one file can't be read as the next one's path; a folder has
|
|
173
|
+
* `folder` in place of the length.
|
|
131
174
|
*/
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
});
|
|
175
|
+
const pluginsHash = (app, projectRoot) => {
|
|
176
|
+
const hash = createHash('sha256');
|
|
177
|
+
// JSON has no NUL outside a string's escapes, so it ends where the paths
|
|
178
|
+
// start.
|
|
179
|
+
hash.update(`${JSON.stringify(app.nativePlugins)}\0`);
|
|
180
|
+
for (const { absolute, folder } of pluginInputFiles(app.nativePlugins, projectRoot)) {
|
|
181
|
+
const relative = path.relative(projectRoot, absolute);
|
|
182
|
+
if (folder) {
|
|
183
|
+
hash.update(`${relative}\0folder\0`);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const contents = readFileSync(absolute);
|
|
187
|
+
hash.update(`${relative}\0${contents.length}\0`);
|
|
188
|
+
hash.update(contents);
|
|
189
|
+
}
|
|
190
|
+
return hash.digest('hex');
|
|
191
|
+
};
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,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;AAG7D,YAAY,EAAE,QAAQ,EAAE,MAAM,eAA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