@blotch/angular-lynx-native 22.2.22 → 22.2.24

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 CHANGED
@@ -21,7 +21,7 @@ Both are one full-screen `LynxView` running `main.lynx.bundle`; Angular Router d
21
21
 
22
22
  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
23
 
24
- Both register the native modules the runtime's services call, which Lynx Explorer doesn't have: `AngularLynxWebAuth` (`WebAuthModule.swift`, `WebAuthModule.kt`) opens `LynxWebAuthSession`'s sign-in page, in `ASWebAuthenticationSession` on iOS and a Custom Tab on Android, and returns the URL it redirects to. `AngularLynxLocalStorage` (`LocalStorageModule.swift`, `LocalStorageModule.kt`) keeps `LynxLocalStorage`'s values in a `UserDefaults` suite and a `SharedPreferences` file of their own. `AngularLynxSecureStorage` (`SecureStorageModule.swift`, `SecureStorageModule.kt`) keeps `LynxSecureStorage`'s in the Keychain on iOS and, on Android, in `SharedPreferences`, each value encrypted with AES-GCM by an Android Keystore key, a file Auto Backup leaves out (`res/xml/backup_rules.xml`, `data_extraction_rules.xml`). `AngularLynxLinking` (`LinkingModule.swift`, `LinkingModule.kt`) opens `LynxLinking`'s links: `openURL` with `UIApplication.open` and an `ACTION_VIEW` intent, `openInApp` in `SFSafariViewController` and a Custom Tab, and `canOpenURL` with `UIApplication.canOpenURL` and `resolveActivity`, which answer only for the schemes the generator writes from angular.json's `canOpenURLSchemes` (with `http`, `https`, `mailto`, `tel` and `sms`) into Info.plist's `LSApplicationQueriesSchemes` and the manifest's `<queries>`. `AngularLynxImagePicker` (`ImagePickerModule.swift`, `ImagePickerModule.kt`) lets the person pick a photo for `LynxImagePicker`, with `PHPickerViewController` on iOS and the Photo Picker on Android, neither of which needs a permission, and calls back with it as base64, re-encoded as an upright JPEG when the app asks for a smaller one or the photo is a format such as HEIC. `AngularLynxShare` (`ShareModule.swift`, `ShareModule.kt`) opens `LynxShare`'s share sheet, `UIActivityViewController` on iOS and an `ACTION_SEND` chooser on Android, with the files written to temporary files on iOS and shared through a `FileProvider` on Android. Save Image on iOS needs `NSPhotoLibraryAddUsageDescription`, which the generator always writes (angular.json's `permissions.savePhotos`, with a default). Android also has `AngularLynxShell`, for the back button.
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.
25
25
 
26
26
  Only the development build (`ng serve --platform`) loads from a dev server: the code is in `App/DevServer.swift` and `App/DevServerModules.swift` under `#if DEBUG`, and in the debug source set on Android (`app/src/debug`, with a no-op `DevServer` in `app/src/release`), so a release build can't be pointed anywhere else. `DevServer` reads the URL from the launch argument or intent extra and keeps it (`UserDefaults`, `SharedPreferences`), so the app opened from the home screen loads from the same server. The loaders (`BundleResourceFetcher.swift`, `ResourceFetchers.kt`) and `AngularLynxAssets` then fetch every relative URL, and on Android every URL on the address the bundle was built with, from the dev server instead of the app, uncached. When the bundle itself doesn't load, `DevServer` covers the page with a message and loads it again every two seconds. rspeedy's live reload client talks to Lynx DevTool, which the shells don't have: `NativeModules.LynxWebSocketModule` (through `@lynx-js/websocket`) for the dev server's socket and `NativeModules.LynxDevToolSetModule.invokeCdp` for a full reload (a DevTool protocol `Page.reload`). The development build registers modules under those names (`DevWebSocketModule`, `DevReloadModule`): a WebSocket with `URLSessionWebSocketTask` and OkHttp that sends the same `websocketOpen`, `websocketMessage`, `websocketClosed` and `websocketFailed` global events as Lynx DevTool's, and a `Page.reload` that loads the bundle again, as DevTool's `LynxPageReloadHelper` does. URLSession sends an empty `Sec-WebSocket-Protocol` header for an empty protocol list, which the dev server refuses, so the iOS socket passes none then. On Android, the debug build's `network_security_config.xml` allows plain HTTP to any host, since the app's own `fetch()` of an imported file goes to the address the bundle was built with; the release build's allows it to `localhost` alone.
27
27
 
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/ios/build.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAIlE,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE;QAChB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;KAC3B,CAAC;IACF,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,GAC5B,KAAK,WAAW,EAChB,MAAK,MAAM,CAAC,UAAwB,KACnC,UAAU,GAAG,SAwCf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAU,8GAY5B;IACD,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;I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;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAChD,KAAG,OAAO,CAAC,MAAM,EAAE,CAsJnB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,MAAM,KACjB,OAAO,CAAC,MAAM,CAShB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzE;;;;;GAKG;AACH,eAAO,MAAM,YAAY,GAAU,mBAKhC;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,KAAG,OAAO,CAAC,SAAS,WAAW,EAAE,CA2DzE,CAAC;AAiEF,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,MAAM,EACd,QAAQ,eAAe,KACtB,MAuBF,CAAC"}
package/dist/ios/build.js CHANGED
@@ -271,6 +271,11 @@ const explainSigningFailure = (error, teamId) => {
271
271
  if (/No Accounts?\b|No account for team/i.test(error.message)) {
272
272
  return new NativeBuildError(`Xcode has no signed-in account for team ${teamId}. Sign in to Xcode with the Apple ID of that team (Xcode → Settings → Accounts), or set ios.signing to an App Store Connect API key, then build again.\n\n${error.message}`);
273
273
  }
274
+ // Apple refuses to register one more device, and xcodebuild then also
275
+ // reports "No profiles for", which alone would point at the wrong fix.
276
+ if (/maximum number of registered \w+ devices/i.test(error.message)) {
277
+ return new NativeBuildError(`Team ${teamId} can't register this device: it has as many as Apple allows. A paid team can remove the devices it no longer uses at the start of its membership year (developer.apple.com → Certificates, IDs & Profiles → Devices). A free Personal Team can't remove them, so set ios.teamId to another team, such as the Personal Team of another Apple ID signed in to Xcode.\n\n${error.message}`);
278
+ }
274
279
  if (/requires a development team|No profiles for/i.test(error.message)) {
275
280
  return new NativeBuildError(`Xcode couldn't make a provisioning profile for team ${teamId}. Check that ios.teamId is a team your Apple ID in Xcode → Settings → Accounts belongs to, and for an .ipa that the team is in the paid Apple Developer Program.\n\n${error.message}`);
276
281
  }
@@ -1 +1 @@
1
- {"version":3,"file":"iphone.d.ts","sourceRoot":"","sources":["../../src/ios/iphone.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAyB,MAAM,WAAW,CAAC;AAElE;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,wDAAwD;IACxD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE;QACpB,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAClB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;YAC3B,iEAAiE;YACjE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;YAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;SACjC,CAAC;QACF,QAAQ,CAAC,UAAU,CAAC,EAAE;YAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;SAAE,CAAC;QACzD,QAAQ,CAAC,KAAK,CAAC,EAAE;YACf,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YACvB,2CAA2C;YAC3C,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;SACxC,CAAC;KACH,CAAC;IACF,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QAC5B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAC1B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,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AAI,0BAIzB;IACD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC,KAAG,SAkCH,CAAC;AAkEF,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8EAA8E;IAC9E,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,eAAe,EAsB7D,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,SAAS,SAAS,eAAe,EAAE,EACnC,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,SAAS,MAAM,KACd,MA2BF,CAAC"}
@@ -122,9 +122,12 @@ export const startIPhone = ({ phone, logFile, log, }) => {
122
122
  phone.udid,
123
123
  '--terminate-existing',
124
124
  app.id,
125
- // devicectl hands what follows the app to it as its arguments.
126
- ...iosDevServerArguments(devServer),
127
- ], { phone, action: 'open the app', logFile });
125
+ ], {
126
+ phone,
127
+ action: 'open the app',
128
+ logFile,
129
+ appArguments: iosDevServerArguments(devServer),
130
+ });
128
131
  log(`Opened ${app.name} on ${phone.name}`);
129
132
  },
130
133
  };
@@ -133,12 +136,23 @@ export const startIPhone = ({ phone, logFile, log, }) => {
133
136
  * Runs a devicectl command with its result written as JSON, so a failure is
134
137
  * read from the structured error rather than its indented text, and
135
138
  * explained when it's something the developer fixes on the phone.
139
+ *
140
+ * `appArguments` go to the app `process launch` opens, after a `--`.
141
+ * devicectl reads its own options anywhere before that, so without it,
142
+ * `-AngularLynxDevServer` failed as "Unknown option '-A'", and a
143
+ * `--json-output` after the arguments would have been the app's.
136
144
  */
137
- const devicectl = async (args, { phone, action, logFile, }) => {
145
+ const devicectl = async (args, { phone, action, logFile, appArguments = [], }) => {
138
146
  const json = path.join(path.dirname(logFile), 'devicectl.json');
139
147
  rmSync(json, { force: true });
140
148
  try {
141
- await run('xcrun', ['devicectl', ...args, '--json-output', json], {
149
+ await run('xcrun', [
150
+ 'devicectl',
151
+ ...args,
152
+ '--json-output',
153
+ json,
154
+ ...(appArguments.length > 0 ? ['--', ...appArguments] : []),
155
+ ], {
142
156
  cwd: process.cwd(),
143
157
  logFile,
144
158
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotch/angular-lynx-native",
3
- "version": "22.2.22",
3
+ "version": "22.2.24",
4
4
  "description": "Builds AngularLynx apps into iOS and Android binaries",
5
5
  "homepage": "https://github.com/Blotch-Smart-Frames/AngularLynx#readme",
6
6
  "bugs": {
@@ -34,6 +34,10 @@ Build commands and outputs (no flavors, so the names are fixed):
34
34
 
35
35
  Back is off by default, so it leaves the app like any root screen. The runtime turns it on while the Router has history by calling `NativeModules.AngularLynxShell.setBackHandlerEnabled(true)`, and off again on the first screen (`LynxBackButton` in `packages/runtime/src/lib/router/lynx-back-button.ts`, which `provideRouter()` starts; the call goes through the background thread, where `NativeModules` lives). While it's on, a back press sends the global event `angularLynxBack` instead, which the runtime turns into `Location.back()`. The app has to say beforehand because Android decides synchronously, at the start of the gesture, whether an app handles back (predictive back animates differently). Layer 6's `native/back-button.yaml` checks both ends.
36
36
 
37
+ ## Memory
38
+
39
+ PrimJS, which runs the app's JavaScript on Lynx's main thread, collects garbage as the app runs, but those collections leave behind much of what a screen leaves when it goes, so native memory grows with every screen the app shows. Lynx runs a full collection, which frees it, when the host reports memory pressure with `LynxEnv.trimMemory`. The runtime asks for one through `NativeModules.AngularLynxShell.collectGarbage()` (`ShellModule.kt`, which reports moderate pressure) once the app has released about a screen's worth of elements and settled (`collect-garbage.ts` in `packages/runtime`), and `ShellApplication.kt` reports the system's `onTrimMemory` and `onLowMemory`, including the app leaving the screen.
40
+
37
41
  ## Web sign-in
38
42
 
39
43
  `NativeModules.AngularLynxWebAuth.start(request, callback)` (`WebAuthModule.kt`, behind the runtime's `LynxWebAuthSession`) opens `request.url` in a Custom Tab (`androidx.browser`). The page's redirect to `request.callbackScheme` comes back as a deep link: the activity is `singleTask`, so the intent reaches the open one in `onNewIntent`, which hands the URL to the callback, and starting it closes the Custom Tab above it. That's why the scheme has to be in the app's `deepLinkSchemes`. Android says nothing when a Custom Tab is closed, so the activity resuming with a session still open, after having gone behind the tab, means the person canceled. iOS's `WebAuthModule.swift` reports the same results through `ASWebAuthenticationSession`.
@@ -1,6 +1,7 @@
1
1
  package dev.angularlynx.shell
2
2
 
3
3
  import android.app.Application
4
+ import android.content.ComponentCallbacks2
4
5
  import com.facebook.drawee.backends.pipeline.Fresco
5
6
  import com.facebook.imagepipeline.core.ImagePipelineConfig
6
7
  import com.facebook.imagepipeline.memory.PoolConfig
@@ -36,4 +37,27 @@ class ShellApplication : Application() {
36
37
  // its loaders to the LynxView it builds.
37
38
  LynxEnv.inst().init(this, null, null, null)
38
39
  }
40
+
41
+ // Lynx leaves it to the host app to report memory pressure. Either level
42
+ // runs a full collection of each LynxView's main-thread JavaScript heap;
43
+ // critical also empties Lynx's text layout cache. Leaving the screen is
44
+ // reported too: out of sight, a collection's pause can't show, and the
45
+ // memory it frees makes the app less likely to be ended in the background.
46
+ override fun onTrimMemory(level: Int) {
47
+ super.onTrimMemory(level)
48
+ val pressure =
49
+ if (level == ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL ||
50
+ level >= ComponentCallbacks2.TRIM_MEMORY_COMPLETE
51
+ ) {
52
+ ShellModule.MEMORY_PRESSURE_CRITICAL
53
+ } else {
54
+ ShellModule.MEMORY_PRESSURE_MODERATE
55
+ }
56
+ LynxEnv.inst().trimMemory(pressure)
57
+ }
58
+
59
+ override fun onLowMemory() {
60
+ super.onLowMemory()
61
+ LynxEnv.inst().trimMemory(ShellModule.MEMORY_PRESSURE_CRITICAL)
62
+ }
39
63
  }
@@ -5,6 +5,7 @@ import android.os.Handler
5
5
  import android.os.Looper
6
6
  import com.lynx.jsbridge.LynxMethod
7
7
  import com.lynx.jsbridge.LynxModule
8
+ import com.lynx.tasm.LynxEnv
8
9
 
9
10
  /**
10
11
  * Native module the AngularLynx runtime calls as
@@ -19,6 +20,15 @@ import com.lynx.jsbridge.LynxModule
19
20
  * `angularLynxBack` global event; while disabled (the default, and whenever the
20
21
  * runtime doesn't know about this module) Android's default back behavior
21
22
  * applies, which leaves the app.
23
+ *
24
+ * `collectGarbage` runs a full collection of the main thread's JavaScript
25
+ * heap. PrimJS, which runs it, collects as the app runs, but those collections
26
+ * leave behind much of what a screen leaves when it goes, and the app's native
27
+ * memory grows with every screen it has shown. Lynx runs a full one, which also
28
+ * hands the freed pages back to the system, when the host app reports memory
29
+ * pressure, so this reports a moderate one. The runtime asks once it has
30
+ * released about a screen's worth of elements and the app has settled
31
+ * (`collect-garbage.ts` in `packages/runtime`).
22
32
  */
23
33
  class ShellModule(context: Context, param: Any?) : LynxModule(context, param) {
24
34
  private val host = param as Host
@@ -33,8 +43,18 @@ class ShellModule(context: Context, param: Any?) : LynxModule(context, param) {
33
43
  main.post { host.setBackHandlerEnabled(enabled) }
34
44
  }
35
45
 
46
+ @LynxMethod
47
+ fun collectGarbage() {
48
+ main.post { LynxEnv.inst().trimMemory(MEMORY_PRESSURE_MODERATE) }
49
+ }
50
+
36
51
  companion object {
37
52
  const val NAME = "AngularLynxShell"
38
53
  const val BACK_EVENT = "angularLynxBack"
54
+
55
+ // Lynx's MemoryPressureLevel values, from a package the app doesn't
56
+ // compile against.
57
+ const val MEMORY_PRESSURE_MODERATE = 1
58
+ const val MEMORY_PRESSURE_CRITICAL = 2
39
59
  }
40
60
  }
@@ -23,6 +23,13 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
23
23
  return true
24
24
  }
25
25
 
26
+ // Lynx leaves it to the host app to report memory pressure. Critical
27
+ // pressure runs a full collection of each LynxView's main-thread
28
+ // JavaScript heap and empties Lynx's text layout cache.
29
+ func applicationDidReceiveMemoryWarning(_ application: UIApplication) {
30
+ LynxEnv.sharedInstance().trimMemory(.critical)
31
+ }
32
+
26
33
  // Apps built with the iOS 27 SDK must use the scene lifecycle.
27
34
  func application(
28
35
  _ application: UIApplication,
@@ -49,4 +56,10 @@ final class SceneDelegate: UIResponder, UIWindowSceneDelegate {
49
56
  window.makeKeyAndVisible()
50
57
  self.window = window
51
58
  }
59
+
60
+ // Out of sight, a collection's pause can't show, and the memory it frees
61
+ // makes the app less likely to be ended while it's in the background.
62
+ func sceneDidEnterBackground(_ scene: UIScene) {
63
+ LynxEnv.sharedInstance().trimMemory(.moderate)
64
+ }
52
65
  }
@@ -40,6 +40,9 @@ final class LynxViewController: UIViewController {
40
40
  }
41
41
  // Bundled files for the main thread's fetch and Image (AssetsModule).
42
42
  config.register(AssetsModule.self)
43
+ // The full collections the runtime asks for after screens go
44
+ // (ShellModule).
45
+ config.register(ShellModule.self)
43
46
  // `ng serve --platform ios`'s live reload, in the development build.
44
47
  DevServer.shared.register(in: config)
45
48
  let lynxView = LynxView { builder in
@@ -0,0 +1,42 @@
1
+ import Lynx
2
+ import UIKit
3
+
4
+ /// The native module the AngularLynx runtime calls as
5
+ /// `NativeModules.AngularLynxShell` (from the background thread, where
6
+ /// NativeModules lives). Android's shell has one of the same name, which also
7
+ /// connects the back button.
8
+ ///
9
+ /// `collectGarbage` runs a full collection of the main thread's JavaScript
10
+ /// heap. PrimJS, which runs it, collects as the app runs, but those collections
11
+ /// leave behind much of what a screen leaves when it goes, and the app's
12
+ /// footprint grows with every screen it has shown. Lynx runs a full one, which
13
+ /// also hands the freed pages back to the system, when the host app reports
14
+ /// memory pressure, so this reports a moderate one. The runtime asks once it
15
+ /// has released about a screen's worth of elements and the app has settled
16
+ /// (`collect-garbage.ts` in `packages/runtime`).
17
+ final class ShellModule: NSObject, LynxModule {
18
+ static var name: String { "AngularLynxShell" }
19
+
20
+ static var methodLookup: [String: String] {
21
+ ["collectGarbage": NSStringFromSelector(#selector(collectGarbage))]
22
+ }
23
+
24
+ override init() {
25
+ super.init()
26
+ }
27
+
28
+ // Swift can't import an optional initializer as optional, so Lynx's
29
+ // initWithParam: is required here. Registered without a param, the module
30
+ // ignores it.
31
+ init(param: Any) {
32
+ super.init()
33
+ }
34
+
35
+ // Lynx calls modules off the main thread. trimMemory hands the collection
36
+ // to each LynxView's engine, which runs it on its own thread.
37
+ @objc func collectGarbage() {
38
+ DispatchQueue.main.async {
39
+ LynxEnv.sharedInstance().trimMemory(.moderate)
40
+ }
41
+ }
42
+ }