@blotch/angular-lynx-native 22.2.24 → 22.2.25
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 +2 -2
- package/dist/android/project.d.ts +26 -3
- package/dist/android/project.d.ts.map +1 -1
- package/dist/android/project.js +80 -2
- package/dist/ios/project.d.ts +19 -3
- package/dist/ios/project.d.ts.map +1 -1
- package/dist/ios/project.js +89 -2
- package/dist/options.d.ts +62 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +92 -0
- package/package.json +1 -1
- package/templates/android/README.md +11 -0
- package/templates/android/app/src/main/AndroidManifest.xml +24 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +24 -3
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShortcutActivity.kt +33 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShortcutsModule.kt +72 -0
- package/templates/android/app/src/main/res/xml/shortcuts.xml +7 -0
- package/templates/ios/App/LynxViewController.swift +5 -0
- package/templates/ios/App/ShortcutsModule.swift +82 -0
- package/templates/ios/App/WebViewLoader.swift +95 -0
- package/templates/ios/App/XElementRegistry.swift +5 -1
package/README.md
CHANGED
|
@@ -21,13 +21,13 @@ 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). `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.
|
|
24
|
+
Both register the native modules the runtime's services call, which Lynx Explorer doesn't have: `AngularLynxWebAuth` (`WebAuthModule.swift`, `WebAuthModule.kt`) opens `LynxWebAuthSession`'s sign-in page, in `ASWebAuthenticationSession` on iOS and a Custom Tab on Android, and returns the URL it redirects to. `AngularLynxLocalStorage` (`LocalStorageModule.swift`, `LocalStorageModule.kt`) keeps `LynxLocalStorage`'s values in a `UserDefaults` suite and a `SharedPreferences` file of their own. `AngularLynxSecureStorage` (`SecureStorageModule.swift`, `SecureStorageModule.kt`) keeps `LynxSecureStorage`'s in the Keychain on iOS and, on Android, in `SharedPreferences`, each value encrypted with AES-GCM by an Android Keystore key, a file Auto Backup leaves out (`res/xml/backup_rules.xml`, `data_extraction_rules.xml`). `AngularLynxLinking` (`LinkingModule.swift`, `LinkingModule.kt`) opens `LynxLinking`'s links: `openURL` with `UIApplication.open` and an `ACTION_VIEW` intent, `openInApp` in `SFSafariViewController` and a Custom Tab, and `canOpenURL` with `UIApplication.canOpenURL` and `resolveActivity`, which answer only for the schemes the generator writes from angular.json's `canOpenURLSchemes` (with `http`, `https`, `mailto`, `tel` and `sms`) into Info.plist's `LSApplicationQueriesSchemes` and the manifest's `<queries>`. `AngularLynxImagePicker` (`ImagePickerModule.swift`, `ImagePickerModule.kt`) lets the person pick a photo for `LynxImagePicker`, with `PHPickerViewController` on iOS and the Photo Picker on Android, neither of which needs a permission, and calls back with it as base64, re-encoded as an upright JPEG when the app asks for a smaller one or the photo is a format such as HEIC. `AngularLynxShare` (`ShareModule.swift`, `ShareModule.kt`) opens `LynxShare`'s share sheet, `UIActivityViewController` on iOS and an `ACTION_SEND` chooser on Android, with the files written to temporary files on iOS and shared through a `FileProvider` on Android. Save Image on iOS needs `NSPhotoLibraryAddUsageDescription`, which the generator always writes (angular.json's `permissions.savePhotos`, with a default). `AngularLynxShell` (`ShellModule.swift`, `ShellModule.kt`) has `collectGarbage`, which the runtime calls once the app has released about a screen's worth of elements and settled: it reports moderate memory pressure with `LynxEnv.trimMemory`, which makes Lynx run a full collection of the main thread's JavaScript heap, freeing what PrimJS's routine collections leave behind of the screens that went. On Android it also connects the back button. Both shells report the system's memory warnings to `trimMemory` too, and leaving the screen. `AngularLynxShortcuts` (`ShortcutsModule.swift`, `ShortcutsModule.kt`) keeps the shortcuts the person ran until the runtime's `LynxShortcuts` takes them, with `take`, at startup and each time the shell sends the `angularLynxShortcut` global event, so the shortcut that started the app isn't lost and none is handled twice. The generator writes angular.json's `shortcuts` as App Intents on iOS (`App/AppShortcuts.swift`, with an `AppShortcutsProvider`: Xcode's App Intents step reads the titles and phrases out of the compiled code, so they have to be source), which Siri, Spotlight and the Shortcuts app run, and as static shortcuts on Android (`res/xml/shortcuts.xml`, with the titles in `res/values/shortcuts.xml`), in the menu a long press on the app's icon opens. Android starts a static shortcut's activity in a cleared task, which would end the running app, so they point at `ShortcutActivity`, which has a task of its own and passes the shortcut on to `MainActivity`.
|
|
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
|
|
|
28
28
|
`AngularLynxClipboard` (`ClipboardModule.swift`, `ClipboardModule.kt`) copies `LynxClipboard`'s text to `UIPasteboard.general` on iOS and `ClipboardManager` on Android, and reads it back.
|
|
29
29
|
|
|
30
|
-
Both link Lynx's XElement library, which holds `<input>`, `<textarea>`, `<overlay>`, `<svg>`, `<blur-view>`, `<viewpager>`, `<refresh>`, the `<scroll-coordinator>` family, `<webview>` and `<video>`. Lynx's core doesn't include these, and a host that doesn't register them renders nothing for those tags (on Android, nothing after them either). XElement's AnimaX and Markdown elements are left out: the runtime doesn't support them. On iOS, `<blur-view>` is XElement's with more of UIKit in it (`App/BlurView.swift`): a `blur-material` attribute for UIKit's adaptive blur materials, which the glass components draw their design before iOS 26 on (Lynx's blur-view has only the styles from before iOS 13); Liquid Glass that materializes, dissolves and eases between effects inside a `glass-container`, where Lynx's sets its effect at once; and a `glass-effect-id` attribute that pairs two glass shapes across a change so one morphs into the other (`App/GlassTransitions.swift`).
|
|
30
|
+
Both link Lynx's XElement library, which holds `<input>`, `<textarea>`, `<overlay>`, `<svg>`, `<blur-view>`, `<viewpager>`, `<refresh>`, the `<scroll-coordinator>` family, `<webview>` and `<video>`. Lynx's core doesn't include these, and a host that doesn't register them renders nothing for those tags (on Android, nothing after them either). XElement's AnimaX and Markdown elements are left out: the runtime doesn't support them. On iOS, `<blur-view>` is XElement's with more of UIKit in it (`App/BlurView.swift`): a `blur-material` attribute for UIKit's adaptive blur materials, which the glass components draw their design before iOS 26 on (Lynx's blur-view has only the styles from before iOS 13); Liquid Glass that materializes, dissolves and eases between effects inside a `glass-container`, where Lynx's sets its effect at once; and a `glass-effect-id` attribute that pairs two glass shapes across a change so one morphs into the other (`App/GlassTransitions.swift`). `<webview>` loads through XElement's loader, wrapped (`App/WebViewLoader.swift`) to take the loader off its web view's script message handlers when the element goes: XElement's loader never does, so the loader and the web view kept each other, and the web view's WebContent process, for as long as the app ran (issue #397).
|
|
31
31
|
|
|
32
32
|
Both have `<canvas>` with WebGL2 (issue #211), which Lynx doesn't: a `canvas` element (`App/AngularLynxWebGL.m`'s `AngularLynxCanvas`, a `CAMetalLayer` view; `CanvasUI.kt`, a `TextureView`) and the `AngularLynxWebGL` module the runtime's WebGL2 context sends its calls to, which runs them on OpenGL ES 3.0 (`App/AngularLynxWebGLContext.m`, `WebGLContext.kt`). On iOS that's [ANGLE](https://chromium.googlesource.com/angle/angle)'s OpenGL ES, on Metal, which Safari draws WebGL with too: iOS's own OpenGL ES is deprecated, and the Simulator runs it on the CPU, at seconds a frame for a lit three.js scene (issue #238), where Metal draws on the Mac's GPU. ANGLE's `libEGL` and `libGLESv2` frameworks, and its headers, come in the Lynx frameworks zip (below). Android's OpenGL ES is the phone's, which the emulator already runs on the Mac's GPU. The runtime runs on Lynx's main thread and WebGL needs answers synchronously, so both turn on main-thread modules (`enableMTSModule`): the config's modules are then callable from main-thread JavaScript as `lynx.module(name)`. The WebGL module's `encodeImage`, behind `canvas.toBlob()` and `toDataURL()`, reads the drawing buffer and encodes it as a PNG or JPEG with ImageIO or `Bitmap.compress`; on iOS it reads through a pixel pack buffer, since ANGLE on Metal reads straight into memory many times slower. `AngularLynxAssets` (`App/AssetsModule.swift`, `AssetsModule.kt`) reads a file the app bundles for the main thread's `fetch`, which has no page URL to resolve `/static/...` against. The command numbers the WebGL module reads (`App/AngularLynxWebGLOps.h`, `WebGLOps.kt`) are generated from the runtime's `canvas/webgl-ops.ts` with `npm run generate:webgl-ops -w packages/native`; `scripts/webgl-ops.test.ts` fails when they're stale. UIKit's module imports Apple's OpenGL ES headers into every file, so `AngularLynxWebGLContext.m` turns off their deprecation warnings, which land on ANGLE's functions of the same names; the explicit link to `libGLESv2` comes before UIKit's automatic one to OpenGLES, so those calls bind to ANGLE.
|
|
33
33
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { PlatformGenerator } from '../generate.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type ResolvedApp } from '../options.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Writes the app options into the Android template: identity goes in
|
|
5
5
|
* angular-lynx.properties (which app/build.gradle.kts reads), and permissions,
|
|
6
6
|
* deep links and the apps canOpenURL can see go between the manifest's
|
|
7
|
-
* `angular-lynx:*` markers,
|
|
8
|
-
* resources.
|
|
7
|
+
* `angular-lynx:*` markers, the icon options become the launcher icon's
|
|
8
|
+
* resources, and the shortcuts become the static shortcuts' resources.
|
|
9
9
|
*/
|
|
10
10
|
export declare const androidGenerator: PlatformGenerator;
|
|
11
11
|
/**
|
|
@@ -23,6 +23,29 @@ export declare const deepLinkEntries: (app: ResolvedApp) => string;
|
|
|
23
23
|
* though startActivity() still opens one.
|
|
24
24
|
*/
|
|
25
25
|
export declare const queriesEntries: (app: ResolvedApp) => string;
|
|
26
|
+
/**
|
|
27
|
+
* res/xml/shortcuts.xml: angular.json's `shortcuts` as the app's static
|
|
28
|
+
* shortcuts, the ones in the menu a long press on the app's icon opens.
|
|
29
|
+
* They're there from the moment the app is installed, which the ones an app
|
|
30
|
+
* adds while it runs aren't.
|
|
31
|
+
*
|
|
32
|
+
* Each starts ShortcutActivity with its ID and route, which hands them to
|
|
33
|
+
* MainActivity (see ShortcutActivity.kt for why not directly). A shortcut's
|
|
34
|
+
* intent names its activity in full, with the applicationId as the package,
|
|
35
|
+
* since the manifest's placeholders don't reach other resources.
|
|
36
|
+
*/
|
|
37
|
+
export declare const shortcutsXml: (app: ResolvedApp) => string;
|
|
38
|
+
/**
|
|
39
|
+
* Text as an Android string resource. Besides XML's own characters, a
|
|
40
|
+
* resource reads `'` and `"` as quoting, a backslash as an escape, and a
|
|
41
|
+
* leading `@` or `?` as a reference to another resource.
|
|
42
|
+
*/
|
|
43
|
+
export declare const stringResource: (text: string) => string;
|
|
44
|
+
/**
|
|
45
|
+
* res/values/shortcuts.xml: each shortcut's title, which a shortcut can only
|
|
46
|
+
* take from a string resource.
|
|
47
|
+
*/
|
|
48
|
+
export declare const shortcutStringsXml: (app: ResolvedApp) => string;
|
|
26
49
|
/** The Android SDK, from the environment or the Android Studio default. */
|
|
27
50
|
export declare const findAndroidSdk: (env?: NodeJS.ProcessEnv) => string | undefined;
|
|
28
51
|
//# sourceMappingURL=project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/android/project.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAEL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAcvB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,iBA8B9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,WAOtC,CAAC;AAEN,eAAO,MAAM,UAAU,GAAI,KAAK,WAAW,KAAG,MAYhC,CAAC;AAEf,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAiBpD,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,KAAK,WAAW,KAAG,MAYjC,CAAC;AAEnB;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,KAAK,WAAW,KAAG,MAUpC,CAAC;AAOf;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GAAI,KAAK,WAAW,KAAG,MAgClC,CAAC;AAEf;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAMpB,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,KAAK,WAAW,KAAG,MAWxC,CAAC;AAEf,2EAA2E;AAC3E,eAAO,MAAM,cAAc,GACzB,MAAK,MAAM,CAAC,UAAwB,KACnC,MAAM,GAAG,SAaX,CAAC"}
|
package/dist/android/project.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { chmodSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { shortcutIdentifier, } from "../options.js";
|
|
4
5
|
import { PERMISSION_MAP } from "../permissions.js";
|
|
5
6
|
import { writeAndroidIcon } from "./icon.js";
|
|
6
7
|
import { escapeXml, replaceMarker } from "../xml.js";
|
|
7
8
|
const MANIFEST = 'app/src/main/AndroidManifest.xml';
|
|
9
|
+
const RESOURCES = 'app/src/main/res';
|
|
8
10
|
const SCREEN_ORIENTATIONS = {
|
|
9
11
|
portrait: 'portrait',
|
|
10
12
|
landscape: 'sensorLandscape',
|
|
@@ -14,8 +16,8 @@ const SCREEN_ORIENTATIONS = {
|
|
|
14
16
|
* Writes the app options into the Android template: identity goes in
|
|
15
17
|
* angular-lynx.properties (which app/build.gradle.kts reads), and permissions,
|
|
16
18
|
* deep links and the apps canOpenURL can see go between the manifest's
|
|
17
|
-
* `angular-lynx:*` markers,
|
|
18
|
-
* resources.
|
|
19
|
+
* `angular-lynx:*` markers, the icon options become the launcher icon's
|
|
20
|
+
* resources, and the shortcuts become the static shortcuts' resources.
|
|
19
21
|
*/
|
|
20
22
|
export const androidGenerator = {
|
|
21
23
|
configure: (dir, app, projectRoot) => {
|
|
@@ -29,6 +31,12 @@ export const androidGenerator = {
|
|
|
29
31
|
manifest = replaceMarker(manifest, 'deep-links', deepLinkEntries(app));
|
|
30
32
|
manifest = replaceMarker(manifest, 'queries', queriesEntries(app));
|
|
31
33
|
writeFileSync(manifestPath, manifest);
|
|
34
|
+
// The template's shortcuts.xml is an empty list, which an app without
|
|
35
|
+
// shortcuts keeps.
|
|
36
|
+
if (app.shortcuts.length > 0) {
|
|
37
|
+
writeFileSync(path.join(dir, RESOURCES, 'xml/shortcuts.xml'), shortcutsXml(app));
|
|
38
|
+
writeFileSync(path.join(dir, RESOURCES, 'values/shortcuts.xml'), shortcutStringsXml(app));
|
|
39
|
+
}
|
|
32
40
|
writeAndroidIcon(dir, app, projectRoot);
|
|
33
41
|
},
|
|
34
42
|
bundleDir: (dir) => path.join(dir, 'app/src/main/assets'),
|
|
@@ -90,6 +98,76 @@ export const queriesEntries = (app) => [
|
|
|
90
98
|
]),
|
|
91
99
|
'</queries>',
|
|
92
100
|
].join('\n');
|
|
101
|
+
/**
|
|
102
|
+
* The string resource holding a shortcut's label.
|
|
103
|
+
*/
|
|
104
|
+
const shortcutLabel = (id) => `shortcut_${shortcutIdentifier(id)}`;
|
|
105
|
+
/**
|
|
106
|
+
* res/xml/shortcuts.xml: angular.json's `shortcuts` as the app's static
|
|
107
|
+
* shortcuts, the ones in the menu a long press on the app's icon opens.
|
|
108
|
+
* They're there from the moment the app is installed, which the ones an app
|
|
109
|
+
* adds while it runs aren't.
|
|
110
|
+
*
|
|
111
|
+
* Each starts ShortcutActivity with its ID and route, which hands them to
|
|
112
|
+
* MainActivity (see ShortcutActivity.kt for why not directly). A shortcut's
|
|
113
|
+
* intent names its activity in full, with the applicationId as the package,
|
|
114
|
+
* since the manifest's placeholders don't reach other resources.
|
|
115
|
+
*/
|
|
116
|
+
export const shortcutsXml = (app) => [
|
|
117
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
118
|
+
'<!--',
|
|
119
|
+
' Written by @blotch/angular-lynx-native from the shortcuts in',
|
|
120
|
+
" angular.json's builder options on every build. Edits here are",
|
|
121
|
+
' overwritten; change angular.json instead (or eject).',
|
|
122
|
+
'-->',
|
|
123
|
+
'<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">',
|
|
124
|
+
...app.shortcuts.flatMap((shortcut) => [
|
|
125
|
+
' <shortcut',
|
|
126
|
+
` android:shortcutId="${escapeXml(shortcut.id)}"`,
|
|
127
|
+
' android:enabled="true"',
|
|
128
|
+
// A shortcut without an icon gets an empty circle in the launcher's
|
|
129
|
+
// menu, so each takes the app's.
|
|
130
|
+
' android:icon="@mipmap/ic_launcher"',
|
|
131
|
+
` android:shortcutShortLabel="@string/${shortcutLabel(shortcut.id)}">`,
|
|
132
|
+
' <intent',
|
|
133
|
+
' android:action="android.intent.action.VIEW"',
|
|
134
|
+
` android:targetPackage="${escapeXml(app.id)}"`,
|
|
135
|
+
' android:targetClass="dev.angularlynx.shell.ShortcutActivity">',
|
|
136
|
+
` <extra android:name="angularLynxShortcutId" android:value="${escapeXml(shortcut.id)}" />`,
|
|
137
|
+
...(shortcut.route === undefined
|
|
138
|
+
? []
|
|
139
|
+
: [
|
|
140
|
+
` <extra android:name="angularLynxShortcutRoute" android:value="${escapeXml(shortcut.route)}" />`,
|
|
141
|
+
]),
|
|
142
|
+
' </intent>',
|
|
143
|
+
' </shortcut>',
|
|
144
|
+
]),
|
|
145
|
+
'</shortcuts>',
|
|
146
|
+
'',
|
|
147
|
+
].join('\n');
|
|
148
|
+
/**
|
|
149
|
+
* Text as an Android string resource. Besides XML's own characters, a
|
|
150
|
+
* resource reads `'` and `"` as quoting, a backslash as an escape, and a
|
|
151
|
+
* leading `@` or `?` as a reference to another resource.
|
|
152
|
+
*/
|
|
153
|
+
export const stringResource = (text) => text
|
|
154
|
+
.replace(/[\\'"]/g, '\\$&')
|
|
155
|
+
.replace(/^[@?]/, '\\$&')
|
|
156
|
+
.replace(/&/g, '&')
|
|
157
|
+
.replace(/</g, '<')
|
|
158
|
+
.replace(/>/g, '>');
|
|
159
|
+
/**
|
|
160
|
+
* res/values/shortcuts.xml: each shortcut's title, which a shortcut can only
|
|
161
|
+
* take from a string resource.
|
|
162
|
+
*/
|
|
163
|
+
export const shortcutStringsXml = (app) => [
|
|
164
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
165
|
+
"<!-- Written from angular.json's shortcuts (see xml/shortcuts.xml). -->",
|
|
166
|
+
'<resources>',
|
|
167
|
+
...app.shortcuts.map((shortcut) => ` <string name="${shortcutLabel(shortcut.id)}">${stringResource(shortcut.title)}</string>`),
|
|
168
|
+
'</resources>',
|
|
169
|
+
'',
|
|
170
|
+
].join('\n');
|
|
93
171
|
/** The Android SDK, from the environment or the Android Studio default. */
|
|
94
172
|
export const findAndroidSdk = (env = process.env) => {
|
|
95
173
|
const candidates = [
|
package/dist/ios/project.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { PlatformGenerator } from '../generate.ts';
|
|
2
|
-
import type
|
|
2
|
+
import { type ResolvedApp } from '../options.ts';
|
|
3
3
|
/**
|
|
4
4
|
* Writes the app options into the iOS template: build settings go in
|
|
5
|
-
* Config/App.xcconfig (which App.xcodeproj reads),
|
|
6
|
-
* between the template's `angular-lynx:info` markers
|
|
5
|
+
* Config/App.xcconfig (which App.xcodeproj reads), Info.plist entries go
|
|
6
|
+
* between the template's `angular-lynx:info` markers, and the shortcuts
|
|
7
|
+
* become App/AppShortcuts.swift.
|
|
7
8
|
*/
|
|
8
9
|
export declare const iosGenerator: PlatformGenerator;
|
|
9
10
|
export declare const xcconfig: (app: ResolvedApp) => string;
|
|
@@ -17,4 +18,19 @@ export declare const LOCAL_NETWORK_REASON = "Loads the app from ng serve on your
|
|
|
17
18
|
export declare const infoPlistEntries: (app: ResolvedApp, { development }?: {
|
|
18
19
|
readonly development?: boolean;
|
|
19
20
|
}) => string;
|
|
21
|
+
/**
|
|
22
|
+
* App/AppShortcuts.swift: angular.json's `shortcuts` as App Intents, which is
|
|
23
|
+
* how iOS offers an app's actions to Siri, Spotlight and the Shortcuts app.
|
|
24
|
+
*
|
|
25
|
+
* It's written as source, not read from a file when the app starts, because
|
|
26
|
+
* Xcode's App Intents step reads the titles and phrases out of the compiled
|
|
27
|
+
* code at build time, and takes only literals. Each intent opens the app
|
|
28
|
+
* and leaves its shortcut with ShortcutCenter (ShortcutsModule.swift), where
|
|
29
|
+
* the runtime's LynxShortcuts takes it.
|
|
30
|
+
*
|
|
31
|
+
* The intents are iOS 16's, which is when App Shortcuts arrived, and the
|
|
32
|
+
* shell runs on iOS 15, which gets none. An intent's type name is what iOS
|
|
33
|
+
* stores a saved shortcut under, so it comes from the ID alone.
|
|
34
|
+
*/
|
|
35
|
+
export declare const appShortcutsSwift: (app: ResolvedApp) => string;
|
|
20
36
|
//# sourceMappingURL=project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/ios/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/ios/project.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD,OAAO,EAGL,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAiBvB;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,iBAsC1B,CAAC;AAQF,eAAO,MAAM,QAAQ,GAAI,KAAK,WAAW,KAAG,MAY9B,CAAC;AAEf,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,uDACe,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,uEACqC,CAAC;AAEvE,eAAO,MAAM,gBAAgB,GAC3B,KAAK,WAAW,EAChB,kBAAyB;IAAE,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,KAC/D,MAmEF,CAAC;AAoBF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,WAAW,KAAG,MAwDpD,CAAC"}
|
package/dist/ios/project.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { copyFileSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { readPngSize } from "../png.js";
|
|
4
|
+
import { APP_NAME_PLACEHOLDER, shortcutIdentifier, } from "../options.js";
|
|
4
5
|
import { PERMISSION_MAP } from "../permissions.js";
|
|
5
6
|
import { escapeXml, replaceMarker } from "../xml.js";
|
|
6
7
|
const ORIENTATIONS = {
|
|
@@ -17,14 +18,20 @@ const ORIENTATIONS = {
|
|
|
17
18
|
};
|
|
18
19
|
/**
|
|
19
20
|
* Writes the app options into the iOS template: build settings go in
|
|
20
|
-
* Config/App.xcconfig (which App.xcodeproj reads),
|
|
21
|
-
* between the template's `angular-lynx:info` markers
|
|
21
|
+
* Config/App.xcconfig (which App.xcodeproj reads), Info.plist entries go
|
|
22
|
+
* between the template's `angular-lynx:info` markers, and the shortcuts
|
|
23
|
+
* become App/AppShortcuts.swift.
|
|
22
24
|
*/
|
|
23
25
|
export const iosGenerator = {
|
|
24
26
|
configure: (dir, app, projectRoot, development = false) => {
|
|
25
27
|
writeFileSync(path.join(dir, 'Config/App.xcconfig'), xcconfig(app));
|
|
26
28
|
const plistPath = path.join(dir, 'App/Info.plist');
|
|
27
29
|
writeFileSync(plistPath, replaceMarker(readFileSync(plistPath, 'utf8'), 'info', infoPlistEntries(app, { development })));
|
|
30
|
+
// The project compiles every Swift file in App/, so the file only has to
|
|
31
|
+
// be there. An app without shortcuts gets none, and declares no intents.
|
|
32
|
+
if (app.shortcuts.length > 0) {
|
|
33
|
+
writeFileSync(path.join(dir, 'App/AppShortcuts.swift'), appShortcutsSwift(app));
|
|
34
|
+
}
|
|
28
35
|
if (app.icon) {
|
|
29
36
|
const icon = path.resolve(projectRoot, app.icon);
|
|
30
37
|
const size = readPngSize(icon);
|
|
@@ -100,3 +107,83 @@ export const infoPlistEntries = (app, { development = false } = {}) => {
|
|
|
100
107
|
}
|
|
101
108
|
return lines.join('\n');
|
|
102
109
|
};
|
|
110
|
+
/**
|
|
111
|
+
* Text as the inside of a Swift string literal.
|
|
112
|
+
*/
|
|
113
|
+
const swiftString = (text) => text.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
|
|
114
|
+
/**
|
|
115
|
+
* A shortcut's phrase as a Swift string literal, with the app's name as the
|
|
116
|
+
* interpolation App Intents reads it from: Siri then hears the name the
|
|
117
|
+
* person knows the app by, and the names in Info.plist's
|
|
118
|
+
* INAlternativeAppNames.
|
|
119
|
+
*/
|
|
120
|
+
const swiftPhrase = (phrase) => `"${phrase
|
|
121
|
+
.split(APP_NAME_PLACEHOLDER)
|
|
122
|
+
.map(swiftString)
|
|
123
|
+
.join('\\(.applicationName)')}"`;
|
|
124
|
+
/**
|
|
125
|
+
* App/AppShortcuts.swift: angular.json's `shortcuts` as App Intents, which is
|
|
126
|
+
* how iOS offers an app's actions to Siri, Spotlight and the Shortcuts app.
|
|
127
|
+
*
|
|
128
|
+
* It's written as source, not read from a file when the app starts, because
|
|
129
|
+
* Xcode's App Intents step reads the titles and phrases out of the compiled
|
|
130
|
+
* code at build time, and takes only literals. Each intent opens the app
|
|
131
|
+
* and leaves its shortcut with ShortcutCenter (ShortcutsModule.swift), where
|
|
132
|
+
* the runtime's LynxShortcuts takes it.
|
|
133
|
+
*
|
|
134
|
+
* The intents are iOS 16's, which is when App Shortcuts arrived, and the
|
|
135
|
+
* shell runs on iOS 15, which gets none. An intent's type name is what iOS
|
|
136
|
+
* stores a saved shortcut under, so it comes from the ID alone.
|
|
137
|
+
*/
|
|
138
|
+
export const appShortcutsSwift = (app) => {
|
|
139
|
+
const intents = app.shortcuts.map((shortcut) => {
|
|
140
|
+
const route = shortcut.route === undefined
|
|
141
|
+
? ''
|
|
142
|
+
: `, route: "${swiftString(shortcut.route)}"`;
|
|
143
|
+
return [
|
|
144
|
+
'@available(iOS 16.0, *)',
|
|
145
|
+
`struct Shortcut_${shortcutIdentifier(shortcut.id)}: AppIntent {`,
|
|
146
|
+
` static let title: LocalizedStringResource = "${swiftString(shortcut.title)}"`,
|
|
147
|
+
' // The app handles it, so it comes to the front: iOS 26 and later read',
|
|
148
|
+
' // supportedModes, and earlier ones openAppWhenRun.',
|
|
149
|
+
' static let openAppWhenRun = true',
|
|
150
|
+
' @available(iOS 26.0, *)',
|
|
151
|
+
' static var supportedModes: IntentModes { .foreground }',
|
|
152
|
+
'',
|
|
153
|
+
' func perform() async throws -> some IntentResult {',
|
|
154
|
+
` ShortcutCenter.shared.run(id: "${swiftString(shortcut.id)}"${route})`,
|
|
155
|
+
' return .result()',
|
|
156
|
+
' }',
|
|
157
|
+
'}',
|
|
158
|
+
].join('\n');
|
|
159
|
+
});
|
|
160
|
+
const shortcuts = app.shortcuts.map((shortcut) => [
|
|
161
|
+
' AppShortcut(',
|
|
162
|
+
` intent: Shortcut_${shortcutIdentifier(shortcut.id)}(),`,
|
|
163
|
+
' phrases: [',
|
|
164
|
+
...shortcut.phrases.map((phrase) => ` ${swiftPhrase(phrase)},`),
|
|
165
|
+
' ],',
|
|
166
|
+
` shortTitle: "${swiftString(shortcut.title)}"${shortcut.symbol === undefined ? '' : ','}`,
|
|
167
|
+
...(shortcut.symbol === undefined
|
|
168
|
+
? []
|
|
169
|
+
: [` systemImageName: "${shortcut.symbol}"`]),
|
|
170
|
+
' )',
|
|
171
|
+
].join('\n'));
|
|
172
|
+
return [
|
|
173
|
+
'// Written by @blotch/angular-lynx-native from the shortcuts in',
|
|
174
|
+
"// angular.json's builder options on every build. Edits here are",
|
|
175
|
+
'// overwritten; change angular.json instead (or eject).',
|
|
176
|
+
'import AppIntents',
|
|
177
|
+
'',
|
|
178
|
+
intents.join('\n\n'),
|
|
179
|
+
'',
|
|
180
|
+
"/// What iOS reads the app's shortcuts from: there is one provider per app.",
|
|
181
|
+
'@available(iOS 16.0, *)',
|
|
182
|
+
'struct AngularLynxAppShortcuts: AppShortcutsProvider {',
|
|
183
|
+
' static var appShortcuts: [AppShortcut] {',
|
|
184
|
+
shortcuts.join('\n'),
|
|
185
|
+
' }',
|
|
186
|
+
'}',
|
|
187
|
+
'',
|
|
188
|
+
].join('\n');
|
|
189
|
+
};
|
package/dist/options.d.ts
CHANGED
|
@@ -38,6 +38,13 @@ export type NativeAppOptions = {
|
|
|
38
38
|
* `mailto`, `tel` and `sms` are always there.
|
|
39
39
|
*/
|
|
40
40
|
readonly canOpenURLSchemes?: readonly string[];
|
|
41
|
+
/**
|
|
42
|
+
* Things the app does that the phone offers outside it (see
|
|
43
|
+
* {@link AppShortcut}): on iOS through Siri, Spotlight and the Shortcuts
|
|
44
|
+
* app, and on Android in the menu a long press on the app's icon opens.
|
|
45
|
+
* The app hears each one through the runtime's `LynxShortcuts`.
|
|
46
|
+
*/
|
|
47
|
+
readonly shortcuts?: readonly AppShortcut[];
|
|
41
48
|
/**
|
|
42
49
|
* A 1024×1024 PNG without transparency, relative to the project root. iOS
|
|
43
50
|
* uses it as it is. Android gets it resized for each screen density, round
|
|
@@ -49,6 +56,55 @@ export type NativeAppOptions = {
|
|
|
49
56
|
readonly android?: AndroidOptions;
|
|
50
57
|
};
|
|
51
58
|
export type Orientation = 'portrait' | 'landscape' | 'all';
|
|
59
|
+
/**
|
|
60
|
+
* One thing the app does, which the person can ask for without opening the
|
|
61
|
+
* app first.
|
|
62
|
+
*
|
|
63
|
+
* iOS makes it an App Shortcut (an App Intent the shell declares): Siri runs
|
|
64
|
+
* it when it hears one of its `phrases`, and it's listed in Spotlight and in
|
|
65
|
+
* the Shortcuts app, where it can go on the Action button or in an
|
|
66
|
+
* automation. Android lists it in the menu a long press on the app's icon
|
|
67
|
+
* opens. Either way the app comes to the front, the router goes to `route`
|
|
68
|
+
* when there is one, and `LynxShortcuts` calls the handlers the app
|
|
69
|
+
* registered for `id`.
|
|
70
|
+
*/
|
|
71
|
+
export type AppShortcut = {
|
|
72
|
+
/**
|
|
73
|
+
* What the app's code knows the shortcut by: `LynxShortcuts.on(id, …)`.
|
|
74
|
+
* Letters, digits, hyphens and underscores, starting with a letter. Keep
|
|
75
|
+
* it once the app is released: the shortcuts people saved are stored
|
|
76
|
+
* under it.
|
|
77
|
+
*/
|
|
78
|
+
readonly id: string;
|
|
79
|
+
/** The name the phone lists it under, such as "Refresh". */
|
|
80
|
+
readonly title: string;
|
|
81
|
+
/**
|
|
82
|
+
* What the person says to Siri. Each one names the app with `{appName}`,
|
|
83
|
+
* which Siri requires: `"Refresh {appName}"`. Defaults to the title and the
|
|
84
|
+
* app's name, `"<title> in {appName}"`. iOS only.
|
|
85
|
+
*/
|
|
86
|
+
readonly phrases?: readonly string[];
|
|
87
|
+
/**
|
|
88
|
+
* The path the router navigates to when the shortcut runs, such as
|
|
89
|
+
* `/photos`. Without one, the app stays where it is.
|
|
90
|
+
*/
|
|
91
|
+
readonly route?: string;
|
|
92
|
+
/**
|
|
93
|
+
* The SF Symbol iOS draws beside it, such as `arrow.clockwise`. iOS only.
|
|
94
|
+
*/
|
|
95
|
+
readonly symbol?: string;
|
|
96
|
+
};
|
|
97
|
+
/** An {@link AppShortcut} with its default phrase. */
|
|
98
|
+
export type ResolvedShortcut = {
|
|
99
|
+
readonly id: string;
|
|
100
|
+
readonly title: string;
|
|
101
|
+
/** Each holds {@link APP_NAME_PLACEHOLDER} once or more. */
|
|
102
|
+
readonly phrases: readonly string[];
|
|
103
|
+
readonly route?: string;
|
|
104
|
+
readonly symbol?: string;
|
|
105
|
+
};
|
|
106
|
+
/** Where a shortcut's phrase names the app. */
|
|
107
|
+
export declare const APP_NAME_PLACEHOLDER = "{appName}";
|
|
52
108
|
export type Permission = 'camera' | 'microphone' | 'location' | 'photos' | 'savePhotos' | 'contacts' | 'notifications';
|
|
53
109
|
/**
|
|
54
110
|
* How the `.ipa` is signed, as Xcode's export methods name it:
|
|
@@ -126,6 +182,7 @@ export type ResolvedApp = {
|
|
|
126
182
|
* {@link ALWAYS_QUERIED_SCHEMES}, in lowercase, each once.
|
|
127
183
|
*/
|
|
128
184
|
readonly canOpenURLSchemes: readonly string[];
|
|
185
|
+
readonly shortcuts: readonly ResolvedShortcut[];
|
|
129
186
|
readonly icon?: string;
|
|
130
187
|
/** `MyApp`: the iOS product (and so .app/.ipa) name. */
|
|
131
188
|
readonly productName: string;
|
|
@@ -156,6 +213,11 @@ export declare const resolveAppOptions: (rawOptions: NativeAppOptions, defaults:
|
|
|
156
213
|
readonly projectName: string;
|
|
157
214
|
readonly packageVersion?: string;
|
|
158
215
|
}) => ResolvedApp;
|
|
216
|
+
/**
|
|
217
|
+
* A shortcut's ID as part of a Swift type name or an Android resource name,
|
|
218
|
+
* neither of which takes a hyphen: `show-photos` → `show_photos`.
|
|
219
|
+
*/
|
|
220
|
+
export declare const shortcutIdentifier: (id: string) => string;
|
|
159
221
|
/**
|
|
160
222
|
* Drops `undefined` values and the objects left empty by that. Angular CLI
|
|
161
223
|
* fills in every property its schema declares for a nested option object,
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,QAAQ,C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'app-store-connect',
|
|
3
5
|
'release-testing',
|
|
@@ -34,6 +36,24 @@ export const ALWAYS_QUERIED_SCHEMES = [
|
|
|
34
36
|
];
|
|
35
37
|
/** The most schemes iOS reads from LSApplicationQueriesSchemes. */
|
|
36
38
|
const MAX_QUERIED_SCHEMES = 50;
|
|
39
|
+
const SHORTCUT_ID = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
40
|
+
/** SF Symbols are named in dot-separated words: `arrow.clockwise`. */
|
|
41
|
+
const SF_SYMBOL = /^[A-Za-z0-9]+(\.[A-Za-z0-9]+)*$/;
|
|
42
|
+
/**
|
|
43
|
+
* The most App Shortcuts iOS takes from one app. Android's launchers show
|
|
44
|
+
* about four, the first ones listed.
|
|
45
|
+
*/
|
|
46
|
+
const MAX_SHORTCUTS = 10;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the text has a line break or another control character, which
|
|
49
|
+
* neither a Swift string literal nor an Android string resource takes as it
|
|
50
|
+
* is. Checked by code point: a regular expression for them would hold the
|
|
51
|
+
* control characters themselves.
|
|
52
|
+
*/
|
|
53
|
+
const hasControlCharacter = (text) => [...text].some((character) => {
|
|
54
|
+
const code = character.codePointAt(0);
|
|
55
|
+
return code < 0x20 || code === 0x7f || code === 0x2028 || code === 0x2029;
|
|
56
|
+
});
|
|
37
57
|
const PERMISSIONS = [
|
|
38
58
|
'camera',
|
|
39
59
|
'microphone',
|
|
@@ -101,6 +121,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
|
|
|
101
121
|
if (canOpenURLSchemes.length > MAX_QUERIED_SCHEMES) {
|
|
102
122
|
throw new NativeConfigError(`canOpenURLSchemes lists ${canOpenURLSchemes.length} schemes with the ${ALWAYS_QUERIED_SCHEMES.length} always there (${ALWAYS_QUERIED_SCHEMES.join(', ')}). iOS reads no more than ${MAX_QUERIED_SCHEMES}.`);
|
|
103
123
|
}
|
|
124
|
+
const shortcuts = resolveShortcuts(options.shortcuts ?? []);
|
|
104
125
|
const android = options.android ?? {};
|
|
105
126
|
if (android.adaptiveIcon) {
|
|
106
127
|
const { foreground, background } = android.adaptiveIcon;
|
|
@@ -137,6 +158,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
|
|
|
137
158
|
permissions,
|
|
138
159
|
deepLinkSchemes,
|
|
139
160
|
canOpenURLSchemes,
|
|
161
|
+
shortcuts,
|
|
140
162
|
icon: options.icon,
|
|
141
163
|
productName,
|
|
142
164
|
artifactName,
|
|
@@ -144,6 +166,76 @@ export const resolveAppOptions = (rawOptions, defaults) => {
|
|
|
144
166
|
android,
|
|
145
167
|
};
|
|
146
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* A shortcut's ID as part of a Swift type name or an Android resource name,
|
|
171
|
+
* neither of which takes a hyphen: `show-photos` → `show_photos`.
|
|
172
|
+
*/
|
|
173
|
+
export const shortcutIdentifier = (id) => id.replace(/-/g, '_');
|
|
174
|
+
/**
|
|
175
|
+
* Checks each shortcut and gives it its default phrase. What's wrong is
|
|
176
|
+
* caught here, where the message can name the option: the Swift and XML the
|
|
177
|
+
* generators write from these would otherwise fail in Xcode's App Intents
|
|
178
|
+
* step or in Gradle, far from angular.json.
|
|
179
|
+
*/
|
|
180
|
+
const resolveShortcuts = (shortcuts) => {
|
|
181
|
+
if (shortcuts.length > MAX_SHORTCUTS) {
|
|
182
|
+
throw new NativeConfigError(`shortcuts lists ${shortcuts.length}. iOS takes no more than ${MAX_SHORTCUTS} from an app.`);
|
|
183
|
+
}
|
|
184
|
+
const identifiers = new Set();
|
|
185
|
+
const heard = new Set();
|
|
186
|
+
return shortcuts.map((entry, index) => {
|
|
187
|
+
// compact() leaves undefined where angular.json has an empty object.
|
|
188
|
+
const shortcut = (entry ?? {});
|
|
189
|
+
const { id, route, symbol } = shortcut;
|
|
190
|
+
if (typeof id !== 'string' || !SHORTCUT_ID.test(id)) {
|
|
191
|
+
throw new NativeConfigError(`shortcuts[${index}].id "${id}" is not valid. Use letters, digits, hyphens and underscores, starting with a letter, e.g. "show-photos".`);
|
|
192
|
+
}
|
|
193
|
+
// The Swift type and the Android resources are named after the ID with
|
|
194
|
+
// its hyphens as underscores, so two IDs a hyphen apart would share them.
|
|
195
|
+
const identifier = shortcutIdentifier(id).toLowerCase();
|
|
196
|
+
if (identifiers.has(identifier)) {
|
|
197
|
+
throw new NativeConfigError(`shortcuts has two entries with the id "${id}". Each needs its own (a hyphen and an underscore count as the same, and so do capitals).`);
|
|
198
|
+
}
|
|
199
|
+
identifiers.add(identifier);
|
|
200
|
+
const title = typeof shortcut.title === 'string' ? shortcut.title.trim() : '';
|
|
201
|
+
if (!title || hasControlCharacter(title)) {
|
|
202
|
+
throw new NativeConfigError(`shortcuts "${id}" needs a title on one line, the name the phone lists it under, e.g. "Show photos".`);
|
|
203
|
+
}
|
|
204
|
+
const phrases = (shortcut.phrases ?? [`${title} in ${APP_NAME_PLACEHOLDER}`]).map((phrase) => (typeof phrase === 'string' ? phrase.trim() : ''));
|
|
205
|
+
if (phrases.length === 0) {
|
|
206
|
+
throw new NativeConfigError(`shortcuts "${id}" has no phrases. Give Siri at least one, e.g. "${title} in ${APP_NAME_PLACEHOLDER}", or leave phrases out for that one.`);
|
|
207
|
+
}
|
|
208
|
+
for (const phrase of phrases) {
|
|
209
|
+
if (!phrase.includes(APP_NAME_PLACEHOLDER) ||
|
|
210
|
+
hasControlCharacter(phrase)) {
|
|
211
|
+
throw new NativeConfigError(`shortcuts "${id}" has the phrase "${phrase}", which doesn't name the app. Siri only listens for phrases that do: put ${APP_NAME_PLACEHOLDER} where the app's name is said, e.g. "${title} in ${APP_NAME_PLACEHOLDER}".`);
|
|
212
|
+
}
|
|
213
|
+
// Siri couldn't tell which of two shortcuts a phrase they share means.
|
|
214
|
+
const spoken = phrase.toLowerCase();
|
|
215
|
+
if (heard.has(spoken)) {
|
|
216
|
+
throw new NativeConfigError(`shortcuts has the phrase "${phrase}" twice. Siri needs each phrase to mean one shortcut.`);
|
|
217
|
+
}
|
|
218
|
+
heard.add(spoken);
|
|
219
|
+
}
|
|
220
|
+
if (route !== undefined &&
|
|
221
|
+
(typeof route !== 'string' ||
|
|
222
|
+
!route.startsWith('/') ||
|
|
223
|
+
hasControlCharacter(route))) {
|
|
224
|
+
throw new NativeConfigError(`shortcuts "${id}" has the route "${route}". Give the path the router navigates to, starting with "/", e.g. "/photos".`);
|
|
225
|
+
}
|
|
226
|
+
if (symbol !== undefined &&
|
|
227
|
+
(typeof symbol !== 'string' || !SF_SYMBOL.test(symbol))) {
|
|
228
|
+
throw new NativeConfigError(`shortcuts "${id}" has the symbol "${symbol}", which is not an SF Symbol's name, e.g. "arrow.clockwise".`);
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
id,
|
|
232
|
+
title,
|
|
233
|
+
phrases,
|
|
234
|
+
...(route !== undefined && { route }),
|
|
235
|
+
...(symbol !== undefined && { symbol }),
|
|
236
|
+
};
|
|
237
|
+
});
|
|
238
|
+
};
|
|
147
239
|
/**
|
|
148
240
|
* `my-app` → `myapp`: a project name as one app ID segment.
|
|
149
241
|
*/
|
package/package.json
CHANGED
|
@@ -12,6 +12,7 @@ The app is one activity holding one full-screen `LynxView` that runs `main.lynx.
|
|
|
12
12
|
| App identity | `angular-lynx.properties` | Keys: `applicationId`, `versionName`, `versionCode`, `appName`, `screenOrientation` (`portrait`, `sensorLandscape` or `unspecified`). Read by `app/build.gradle.kts`. The committed file holds defaults. |
|
|
13
13
|
| Permissions | `AndroidManifest.xml`, at `<!-- angular-lynx:permissions -->` | `<uses-permission>` lines. `INTERNET` is always declared. |
|
|
14
14
|
| Deep links | `AndroidManifest.xml`, at `<!-- angular-lynx:deep-links -->` | `<intent-filter>`s inside the main activity. |
|
|
15
|
+
| Shortcuts | `res/xml/shortcuts.xml`, `res/values/shortcuts.xml` | One `<shortcut>` per entry of angular.json's `shortcuts`, and a string for its title. The committed `shortcuts.xml` is an empty list. |
|
|
15
16
|
| SDK location | `local.properties` | `sdk.dir=…`, unless `ANDROID_HOME` is set. |
|
|
16
17
|
| Release signing | Gradle properties, from the environment | `ORG_GRADLE_PROJECT_angularLynxStoreFile`, `…StorePassword`, `…KeyAlias`, `…KeyPassword` (no dots: dash, `/bin/sh` on Debian and Ubuntu, drops variables whose names aren't shell identifiers before `gradlew` starts Gradle). Never written to disk. Without all four, release builds are signed with the debug key (installable, not uploadable). |
|
|
17
18
|
|
|
@@ -52,6 +53,16 @@ PrimJS, which runs the app's JavaScript on Lynx's main thread, collects garbage
|
|
|
52
53
|
|
|
53
54
|
iOS's `LinkingModule.swift` does the same with `UIApplication.open`, `SFSafariViewController` and `UIApplication.canOpenURL`, which answers only for the schemes in Info.plist's `LSApplicationQueriesSchemes`.
|
|
54
55
|
|
|
56
|
+
## Shortcuts
|
|
57
|
+
|
|
58
|
+
angular.json's `shortcuts` are the app's static shortcuts, in the menu a long press on its icon opens: the manifest's `android.app.shortcuts` meta-data on `MainActivity` points at `res/xml/shortcuts.xml`, which the generator writes. Static ones are there from the moment the app is installed. Each takes the app's icon, since the launcher draws an empty circle for a shortcut without one.
|
|
59
|
+
|
|
60
|
+
- **A shortcut points at `ShortcutActivity`, not `MainActivity`.** Android starts a static shortcut's activity with `FLAG_ACTIVITY_NEW_TASK` and `FLAG_ACTIVITY_CLEAR_TASK`, which an app can't change, so pointing at `MainActivity` would end the open one, and the running Angular app with it. `ShortcutActivity` has a task of its own to clear (`taskAffinity=""`, out of Recents, `Theme.NoDisplay`), starts `MainActivity` the ordinary way with the shortcut's extras, and finishes. The open `MainActivity` gets them in `onNewIntent`. It isn't exported: the launcher starts a shortcut as the app itself.
|
|
61
|
+
- **`NativeModules.AngularLynxShortcuts.take(callback)`** (`ShortcutsModule.kt`, behind the runtime's `LynxShortcuts`) calls back with `{ shortcuts }`: each one that ran since the last call, as `{ id, route? }`. `MainActivity` leaves a shortcut with the module and, when the app is open, sends the `angularLynxShortcut` global event, which the runtime answers by taking them. It also takes them once as it starts, which is how the shortcut that started the app arrives.
|
|
62
|
+
- **A recreated activity doesn't run its shortcut again.** Android hands an activity the intent it started with when it recreates it, and when the app is reopened from Recents, so `onCreate` only takes the shortcut from a first start that didn't come from history.
|
|
63
|
+
|
|
64
|
+
iOS's shell does the same with App Intents: the generator writes `App/AppShortcuts.swift`, whose intents open the app and leave their shortcut with `ShortcutsModule.swift`'s `ShortcutCenter`.
|
|
65
|
+
|
|
55
66
|
## Storage
|
|
56
67
|
|
|
57
68
|
`NativeModules.AngularLynxLocalStorage` and `NativeModules.AngularLynxSecureStorage` (`LocalStorageModule.kt` and `SecureStorageModule.kt`, behind the runtime's `LynxLocalStorage` and `LynxSecureStorage`) keep string values, which the runtime stores as JSON, each in a `SharedPreferences` file of its own. Each method calls back once with `{ value }`, `{}` or `{ error }`.
|
|
@@ -46,8 +46,32 @@
|
|
|
46
46
|
<category android:name="android.intent.category.LAUNCHER" />
|
|
47
47
|
</intent-filter>
|
|
48
48
|
<!-- angular-lynx:deep-links -->
|
|
49
|
+
<!--
|
|
50
|
+
angular.json's shortcuts, in the menu a long press on the
|
|
51
|
+
app's icon opens. Android reads them from the launcher
|
|
52
|
+
activity.
|
|
53
|
+
-->
|
|
54
|
+
<meta-data
|
|
55
|
+
android:name="android.app.shortcuts"
|
|
56
|
+
android:resource="@xml/shortcuts" />
|
|
49
57
|
</activity>
|
|
50
58
|
|
|
59
|
+
<!--
|
|
60
|
+
Where the shortcuts point: it hands the shortcut to MainActivity
|
|
61
|
+
and finishes without drawing (ShortcutActivity.kt). Android starts
|
|
62
|
+
a shortcut's activity in a cleared task, so it gets one of its own
|
|
63
|
+
to clear (no taskAffinity, and not in Recents), which leaves the
|
|
64
|
+
open app as it is. Not exported: the launcher starts a shortcut as
|
|
65
|
+
the app itself.
|
|
66
|
+
-->
|
|
67
|
+
<activity
|
|
68
|
+
android:name=".ShortcutActivity"
|
|
69
|
+
android:excludeFromRecents="true"
|
|
70
|
+
android:exported="false"
|
|
71
|
+
android:noHistory="true"
|
|
72
|
+
android:taskAffinity=""
|
|
73
|
+
android:theme="@android:style/Theme.NoDisplay" />
|
|
74
|
+
|
|
51
75
|
<!--
|
|
52
76
|
The files LynxShare shares (ShareModule), which the app picked in
|
|
53
77
|
the share sheet reads through content:// URIs of this provider.
|
|
@@ -100,6 +100,16 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
100
100
|
enableEdgeToEdge()
|
|
101
101
|
super.onCreate(savedInstanceState)
|
|
102
102
|
|
|
103
|
+
// A shortcut that started the app waits for the runtime to take it.
|
|
104
|
+
// Android hands a recreated activity the intent it started with
|
|
105
|
+
// again, and so does reopening the app from Recents, neither of
|
|
106
|
+
// which is the person running the shortcut again.
|
|
107
|
+
if (savedInstanceState == null &&
|
|
108
|
+
intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY == 0
|
|
109
|
+
) {
|
|
110
|
+
ShortcutsModule.run(intent)
|
|
111
|
+
}
|
|
112
|
+
|
|
103
113
|
// The bundle in the app's assets, or in the debug build `ng serve
|
|
104
114
|
// --platform android` runs, the dev server's (DevServer.kt).
|
|
105
115
|
val bundleUrl = DevServer.bundleUrl(this) ?: BundleAssets.MAIN_BUNDLE
|
|
@@ -124,6 +134,9 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
124
134
|
// The share sheet behind LynxShare (ShareModule.kt), which it opens
|
|
125
135
|
// from this activity.
|
|
126
136
|
registerModule(ShareModule.NAME, ShareModule::class.java, this@MainActivity)
|
|
137
|
+
// The shortcuts the person runs from the app icon's menu, which
|
|
138
|
+
// LynxShortcuts takes (ShortcutsModule.kt).
|
|
139
|
+
registerModule(ShortcutsModule.NAME, ShortcutsModule::class.java, null)
|
|
127
140
|
// <canvas>'s WebGL (WebGLModule.kt), which the runtime calls from
|
|
128
141
|
// the main thread, where Angular runs: main-thread modules let
|
|
129
142
|
// it get its answers synchronously, with lynx.module(name).
|
|
@@ -247,11 +260,19 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
247
260
|
}
|
|
248
261
|
}
|
|
249
262
|
|
|
250
|
-
// The
|
|
251
|
-
//
|
|
252
|
-
// above it. It arrives before onResume, which then finds no session open.
|
|
263
|
+
// The activity is singleTask, so an intent for it while it's open comes
|
|
264
|
+
// here rather than starting another.
|
|
253
265
|
override fun onNewIntent(intent: Intent) {
|
|
254
266
|
super.onNewIntent(intent)
|
|
267
|
+
// A shortcut run while the app is open (ShortcutActivity): the
|
|
268
|
+
// runtime takes it when it hears the event.
|
|
269
|
+
if (ShortcutsModule.run(intent)) {
|
|
270
|
+
lynxView.sendGlobalEvent(ShortcutsModule.EVENT, JavaOnlyArray())
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
// The sign-in page's redirect to the callback scheme: the deep link
|
|
274
|
+
// comes back to this activity, which closes the Custom Tab above it.
|
|
275
|
+
// It arrives before onResume, which then finds no session open.
|
|
255
276
|
val url = intent.data ?: return
|
|
256
277
|
val session = webAuthSession ?: return
|
|
257
278
|
if (url.scheme?.lowercase() != session.scheme) return
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package dev.angularlynx.shell
|
|
2
|
+
|
|
3
|
+
import android.app.Activity
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import android.os.Bundle
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Where the app's shortcuts point (`res/xml/shortcuts.xml`): it passes the
|
|
9
|
+
* shortcut on to MainActivity and is gone before it draws anything.
|
|
10
|
+
*
|
|
11
|
+
* A shortcut can't point at MainActivity itself. Android starts a static
|
|
12
|
+
* shortcut's activity with FLAG_ACTIVITY_CLEAR_TASK, which can't be changed,
|
|
13
|
+
* so it would end the open MainActivity, and the running Angular app with
|
|
14
|
+
* it, before starting a new one: every shortcut would restart the app. This
|
|
15
|
+
* activity has a task of its own for Android to clear (`taskAffinity=""` in
|
|
16
|
+
* the manifest), and starts MainActivity the ordinary way, which brings the
|
|
17
|
+
* open one to the front and hands it the shortcut in onNewIntent. It's the
|
|
18
|
+
* trampoline Android's shortcut guide describes.
|
|
19
|
+
*/
|
|
20
|
+
class ShortcutActivity : Activity() {
|
|
21
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
|
22
|
+
super.onCreate(savedInstanceState)
|
|
23
|
+
startActivity(
|
|
24
|
+
Intent(this, MainActivity::class.java).apply {
|
|
25
|
+
intent.extras?.let { putExtras(it) }
|
|
26
|
+
// MainActivity lives in another task than this one.
|
|
27
|
+
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
28
|
+
},
|
|
29
|
+
)
|
|
30
|
+
// Theme.NoDisplay needs the activity finished before it would resume.
|
|
31
|
+
finish()
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
package dev.angularlynx.shell
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.content.Intent
|
|
5
|
+
import com.lynx.jsbridge.LynxMethod
|
|
6
|
+
import com.lynx.jsbridge.LynxModule
|
|
7
|
+
import com.lynx.react.bridge.Callback
|
|
8
|
+
import com.lynx.react.bridge.JavaOnlyArray
|
|
9
|
+
import com.lynx.react.bridge.JavaOnlyMap
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The native module behind the runtime's `LynxShortcuts`, which calls it as
|
|
13
|
+
* `NativeModules.AngularLynxShortcuts` (from the background thread, where
|
|
14
|
+
* NativeModules lives). iOS's shell has one of the same name.
|
|
15
|
+
*
|
|
16
|
+
* angular.json's `shortcuts` become the app's static shortcuts
|
|
17
|
+
* (`res/xml/shortcuts.xml`, which the generator writes), the ones in the menu
|
|
18
|
+
* a long press on the app's icon opens. One may start the app, so the
|
|
19
|
+
* activity can't hand it straight to the Angular app: it leaves the shortcut
|
|
20
|
+
* here, and the runtime takes it when it's ready, at startup and again each
|
|
21
|
+
* time it hears the `angularLynxShortcut` global event. A shortcut waits for
|
|
22
|
+
* as long as that takes, so the one that started the app is never lost, and
|
|
23
|
+
* none is handled twice.
|
|
24
|
+
*
|
|
25
|
+
* `take` calls back with `{ shortcuts }`: each shortcut the person ran since
|
|
26
|
+
* the last call, as `{ id, route? }`.
|
|
27
|
+
*/
|
|
28
|
+
class ShortcutsModule(context: Context, param: Any?) : LynxModule(context, param) {
|
|
29
|
+
@LynxMethod
|
|
30
|
+
fun take(callback: Callback) {
|
|
31
|
+
val shortcuts = JavaOnlyArray()
|
|
32
|
+
for (shortcut in takeWaiting()) {
|
|
33
|
+
shortcuts.pushMap(JavaOnlyMap.from(shortcut))
|
|
34
|
+
}
|
|
35
|
+
callback.invoke(JavaOnlyMap.from(mapOf("shortcuts" to shortcuts)))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
companion object {
|
|
39
|
+
const val NAME = "AngularLynxShortcuts"
|
|
40
|
+
|
|
41
|
+
// The global event that says a shortcut is waiting. It carries
|
|
42
|
+
// nothing: the listener answers by taking them.
|
|
43
|
+
const val EVENT = "angularLynxShortcut"
|
|
44
|
+
|
|
45
|
+
// What a shortcut's intent carries (res/xml/shortcuts.xml).
|
|
46
|
+
const val EXTRA_ID = "angularLynxShortcutId"
|
|
47
|
+
const val EXTRA_ROUTE = "angularLynxShortcutRoute"
|
|
48
|
+
|
|
49
|
+
// The activity leaves them on the main thread, and Lynx calls
|
|
50
|
+
// modules off it.
|
|
51
|
+
private val waiting = mutableListOf<Map<String, String>>()
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Leaves the shortcut `intent` carries for the runtime to take.
|
|
55
|
+
* Returns whether it carried one.
|
|
56
|
+
*/
|
|
57
|
+
fun run(intent: Intent): Boolean {
|
|
58
|
+
val id = intent.getStringExtra(EXTRA_ID) ?: return false
|
|
59
|
+
val route = intent.getStringExtra(EXTRA_ROUTE)
|
|
60
|
+
val shortcut = if (route == null) mapOf("id" to id) else mapOf("id" to id, "route" to route)
|
|
61
|
+
synchronized(waiting) { waiting.add(shortcut) }
|
|
62
|
+
return true
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun takeWaiting(): List<Map<String, String>> =
|
|
66
|
+
synchronized(waiting) {
|
|
67
|
+
val taken = waiting.toList()
|
|
68
|
+
waiting.clear()
|
|
69
|
+
taken
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
The app's static shortcuts, in the menu a long press on its icon opens.
|
|
4
|
+
The generator writes this file from angular.json's shortcuts; an app
|
|
5
|
+
without any keeps this empty list.
|
|
6
|
+
-->
|
|
7
|
+
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android" />
|
|
@@ -43,6 +43,9 @@ final class LynxViewController: UIViewController {
|
|
|
43
43
|
// The full collections the runtime asks for after screens go
|
|
44
44
|
// (ShellModule).
|
|
45
45
|
config.register(ShellModule.self)
|
|
46
|
+
// The shortcuts the person runs from Siri, Spotlight or the Shortcuts
|
|
47
|
+
// app, which LynxShortcuts takes (ShortcutsModule).
|
|
48
|
+
config.register(ShortcutsModule.self)
|
|
46
49
|
// `ng serve --platform ios`'s live reload, in the development build.
|
|
47
50
|
DevServer.shared.register(in: config)
|
|
48
51
|
let lynxView = LynxView { builder in
|
|
@@ -61,6 +64,8 @@ final class LynxViewController: UIViewController {
|
|
|
61
64
|
lynxView.layoutHeightMode = .exact
|
|
62
65
|
view.addSubview(lynxView)
|
|
63
66
|
self.lynxView = lynxView
|
|
67
|
+
// Who hears that a shortcut ran while the app is open.
|
|
68
|
+
ShortcutCenter.shared.lynxView = lynxView
|
|
64
69
|
|
|
65
70
|
layoutLynxView()
|
|
66
71
|
lynxView.updateGlobalProps(with: globalProps())
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import Lynx
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
/// The shortcuts the person has run and the app hasn't taken yet.
|
|
5
|
+
///
|
|
6
|
+
/// angular.json's `shortcuts` become App Intents (AppShortcuts.swift, which
|
|
7
|
+
/// the generator writes), and iOS runs one from Siri, Spotlight or the
|
|
8
|
+
/// Shortcuts app. It may run before the app has started, which iOS then
|
|
9
|
+
/// launches for it, so an intent can't call into the app: it leaves the
|
|
10
|
+
/// shortcut here, and the runtime's `LynxShortcuts` takes it when it's ready,
|
|
11
|
+
/// at startup and again each time it hears the `angularLynxShortcut` global
|
|
12
|
+
/// event. A shortcut waits here for as long as that takes, so the one that
|
|
13
|
+
/// launched the app is never lost, and none is handled twice.
|
|
14
|
+
final class ShortcutCenter {
|
|
15
|
+
static let shared = ShortcutCenter()
|
|
16
|
+
|
|
17
|
+
/// The global event that says a shortcut is waiting. It carries nothing:
|
|
18
|
+
/// the listener answers by taking them.
|
|
19
|
+
static let event = "angularLynxShortcut"
|
|
20
|
+
|
|
21
|
+
/// App Intents run off the main thread, and Lynx calls modules off it too.
|
|
22
|
+
private let lock = NSLock()
|
|
23
|
+
private var waiting: [[String: String]] = []
|
|
24
|
+
|
|
25
|
+
/// The app's LynxView, which LynxViewController sets once it has one.
|
|
26
|
+
weak var lynxView: LynxView?
|
|
27
|
+
|
|
28
|
+
/// Called by each shortcut's App Intent, with angular.json's `id` and
|
|
29
|
+
/// `route`.
|
|
30
|
+
func run(id: String, route: String? = nil) {
|
|
31
|
+
var shortcut = ["id": id]
|
|
32
|
+
if let route {
|
|
33
|
+
shortcut["route"] = route
|
|
34
|
+
}
|
|
35
|
+
lock.lock()
|
|
36
|
+
waiting.append(shortcut)
|
|
37
|
+
lock.unlock()
|
|
38
|
+
DispatchQueue.main.async {
|
|
39
|
+
// Before the LynxView exists there's nobody to tell, and the runtime
|
|
40
|
+
// asks when it starts anyway.
|
|
41
|
+
self.lynxView?.sendGlobalEvent(Self.event, withParams: [])
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// The waiting shortcuts, oldest first, which stop waiting.
|
|
46
|
+
func take() -> [[String: String]] {
|
|
47
|
+
lock.lock()
|
|
48
|
+
defer { lock.unlock() }
|
|
49
|
+
let taken = waiting
|
|
50
|
+
waiting = []
|
|
51
|
+
return taken
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/// The native module behind the runtime's `LynxShortcuts`, which calls it as
|
|
56
|
+
/// `NativeModules.AngularLynxShortcuts` (from the background thread, where
|
|
57
|
+
/// NativeModules lives). Android's shell has one of the same name.
|
|
58
|
+
///
|
|
59
|
+
/// `take` calls back with `{ shortcuts }`: each shortcut the person ran since
|
|
60
|
+
/// the last call, as `{ id, route? }`.
|
|
61
|
+
final class ShortcutsModule: NSObject, LynxModule {
|
|
62
|
+
static var name: String { "AngularLynxShortcuts" }
|
|
63
|
+
|
|
64
|
+
static var methodLookup: [String: String] {
|
|
65
|
+
["take": NSStringFromSelector(#selector(take(_:)))]
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override init() {
|
|
69
|
+
super.init()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Swift can't import an optional initializer as optional, so Lynx's
|
|
73
|
+
// initWithParam: is required here. Registered without a param, the module
|
|
74
|
+
// ignores it.
|
|
75
|
+
init(param: Any) {
|
|
76
|
+
super.init()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@objc func take(_ callback: @escaping LynxCallbackBlock) {
|
|
80
|
+
callback(["shortcuts": ShortcutCenter.shared.take()])
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import Lynx
|
|
2
|
+
import WebKit
|
|
3
|
+
import XElement
|
|
4
|
+
|
|
5
|
+
/// The loader behind every `<webview>`: XElement's own, which lets its web
|
|
6
|
+
/// view go when the element goes.
|
|
7
|
+
///
|
|
8
|
+
/// XElement's `LynxWebViewDefaultLoader` never does (issue #397). It makes
|
|
9
|
+
/// itself its web view's script message handler, and `WKUserContentController`
|
|
10
|
+
/// keeps its handlers until they're taken off, which nothing does. So the
|
|
11
|
+
/// loader keeps the web view, the web view's content controller keeps the
|
|
12
|
+
/// loader, and when the element lets the loader go, the two keep each other.
|
|
13
|
+
/// With them stays the WebContent process WebKit started for the web view:
|
|
14
|
+
/// every `<webview>` an app had shown stayed for as long as it ran, 21 of them
|
|
15
|
+
/// holding 0.9 to 2.4 GB after three visits to a screen with seven. Android's
|
|
16
|
+
/// WebViews have no such cycle and go with their elements.
|
|
17
|
+
///
|
|
18
|
+
/// This wraps XElement's loader and takes the handler off when the element
|
|
19
|
+
/// lets it go, which ends the cycle; the two then go with the element.
|
|
20
|
+
/// Everything else is XElement's: the web view's settings, the navigation
|
|
21
|
+
/// callbacks, and the messages a page posts (`bindmessage`). The element
|
|
22
|
+
/// keeps its loader on the main thread, where this goes too.
|
|
23
|
+
final class ShellWebViewLoader: NSObject, LynxWebViewLoader {
|
|
24
|
+
private let loader: LynxWebViewLoader
|
|
25
|
+
/// The name the handler is under. Taken now: by the time this goes, the
|
|
26
|
+
/// element that names it (the delegate, held weakly) has gone.
|
|
27
|
+
private let handlerName: String
|
|
28
|
+
private var webView: WKWebView?
|
|
29
|
+
|
|
30
|
+
init(delegate: LynxWebViewLoaderDelegate) {
|
|
31
|
+
loader = LynxWebViewDefaultLoader(delegate: delegate)
|
|
32
|
+
handlerName = delegate.nameOfScriptMessageHandler()
|
|
33
|
+
super.init()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
deinit {
|
|
37
|
+
webView?.configuration.userContentController
|
|
38
|
+
.removeScriptMessageHandler(forName: handlerName)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// XElement's container is its web view. Going through getWebView() here
|
|
42
|
+
// means the web view is known to deinit however the element first asks.
|
|
43
|
+
func getContainerView() -> UIView {
|
|
44
|
+
getWebView()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func getWebView() -> WKWebView {
|
|
48
|
+
let webView = loader.getWebView()
|
|
49
|
+
self.webView = webView
|
|
50
|
+
return webView
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func setParams(_ params: [AnyHashable: Any]) {
|
|
54
|
+
loader.setParams(params)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
func load(_ urlStr: String) {
|
|
58
|
+
loader.load(urlStr)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
func loadHtmlString(_ htmlString: String) {
|
|
62
|
+
loader.loadHtmlString(htmlString)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func reload() {
|
|
66
|
+
loader.reload()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
func evaluateJavaScript(
|
|
70
|
+
_ javaScriptString: String,
|
|
71
|
+
completionHandler: ((Any?, Error?) -> Void)?
|
|
72
|
+
) {
|
|
73
|
+
loader.evaluateJavaScript(javaScriptString, completionHandler: completionHandler)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// Makes `ShellWebViewLoader` the `"default"` loader, the one a `<webview>`
|
|
78
|
+
/// uses unless its `webview-type` names another.
|
|
79
|
+
final class ShellWebViewLoaderProvider: NSObject, LynxWebViewLoaderProvider {
|
|
80
|
+
static func register() {
|
|
81
|
+
// XElement registers its own provider as "default" in a task Lynx runs
|
|
82
|
+
// the first time it starts (LYNX_LOAD_LAZY), which would replace one
|
|
83
|
+
// registered before that. The tasks run once, so starting them here puts
|
|
84
|
+
// this one after XElement's.
|
|
85
|
+
LynxLazyRegister.loadLynxInitTask()
|
|
86
|
+
LynxWebViewService.sharedInstance().providers?["default"] =
|
|
87
|
+
ShellWebViewLoaderProvider()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func createLynxWebViewLoader(with delegate: LynxWebViewLoaderDelegate)
|
|
91
|
+
-> LynxWebViewLoader?
|
|
92
|
+
{
|
|
93
|
+
ShellWebViewLoader(delegate: delegate)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -13,7 +13,8 @@ import XElement
|
|
|
13
13
|
/// classes under the same names here, before the first LynxConfig or LynxView
|
|
14
14
|
/// exists. `<blur-view>` is XElement's with UIKit's blur materials and glass
|
|
15
15
|
/// transitions added (BlurView). `<canvas>` is the shell's own, for WebGL
|
|
16
|
-
/// (AngularLynxWebGL.h).
|
|
16
|
+
/// (AngularLynxWebGL.h). `<webview>`'s loader is XElement's, wrapped so its web
|
|
17
|
+
/// view doesn't outlive the element (ShellWebViewLoader).
|
|
17
18
|
enum XElementRegistry {
|
|
18
19
|
static func register() {
|
|
19
20
|
let elements: [(String, AnyClass)] = [
|
|
@@ -53,5 +54,8 @@ enum XElementRegistry {
|
|
|
53
54
|
for (name, node) in shadowNodes {
|
|
54
55
|
LynxComponentRegistry.registerShadowNode(node, withName: name)
|
|
55
56
|
}
|
|
57
|
+
// <webview> loads through XElement's loader, wrapped so the web view and
|
|
58
|
+
// its WebContent process go with the element (WebViewLoader.swift).
|
|
59
|
+
ShellWebViewLoaderProvider.register()
|
|
56
60
|
}
|
|
57
61
|
}
|