@blotch/angular-lynx-native 22.2.26 → 22.3.0
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 +12 -10
- package/dist/android/project.d.ts +11 -0
- package/dist/android/project.d.ts.map +1 -1
- package/dist/android/project.js +36 -10
- package/dist/app-links.d.ts +53 -0
- package/dist/app-links.d.ts.map +1 -0
- package/dist/app-links.js +115 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -0
- package/dist/ios/build.d.ts.map +1 -1
- package/dist/ios/build.js +5 -0
- package/dist/ios/project.d.ts +14 -1
- package/dist/ios/project.d.ts.map +1 -1
- package/dist/ios/project.js +46 -5
- package/dist/options.d.ts +11 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +19 -0
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +7 -0
- package/package.json +1 -1
- package/templates/android/README.md +6 -4
- package/templates/android/app/build.gradle.kts +22 -13
- package/templates/android/app/proguard-rules.pro +67 -55
- package/templates/android/app/src/main/java/dev/angularlynx/shell/LinkingModule.kt +42 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +39 -6
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellApplication.kt +15 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellModule.kt +14 -0
- package/templates/android/build.gradle.kts +1 -1
- package/templates/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/android/gradle/wrapper/gradle-wrapper.properties +2 -2
- package/templates/android/gradlew.bat +41 -11
- package/templates/ios/App/AngularLynxWebGLContext.m +79 -5
- package/templates/ios/App/AppDelegate.swift +46 -0
- package/templates/ios/App/LinkingModule.swift +62 -1
- package/templates/ios/App/LynxViewController.swift +11 -5
- package/templates/ios/App/ShellModule.swift +26 -0
package/dist/options.js
CHANGED
|
@@ -15,6 +15,13 @@ const APP_ID = /^[A-Za-z][A-Za-z0-9]*(\.[A-Za-z][A-Za-z0-9]*)+$/;
|
|
|
15
15
|
/** Up to three period-separated integers, as App Store Connect requires. */
|
|
16
16
|
const VERSION = /^\d+(\.\d+){0,2}$/;
|
|
17
17
|
const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/;
|
|
18
|
+
/**
|
|
19
|
+
* A host name of two labels or more, optionally after `*.` for its
|
|
20
|
+
* subdomains, as both the `applinks:` entitlement and an intent filter's
|
|
21
|
+
* `android:host` take it. No scheme, port or path: iOS takes a port only in
|
|
22
|
+
* its developer mode, and the site's file chooses the paths.
|
|
23
|
+
*/
|
|
24
|
+
const APP_LINK_DOMAIN = /^(\*\.)?([a-z0-9]([a-z0-9-]*[a-z0-9])?\.)+[a-z]([a-z0-9-]*[a-z0-9])?$/;
|
|
18
25
|
/**
|
|
19
26
|
* The colors both CSS and Android resources read the same way. Android also
|
|
20
27
|
* takes `#ARGB` and `#AARRGGBB`, but CSS reads 4 and 8 digits with the alpha
|
|
@@ -62,6 +69,7 @@ const PERMISSIONS = [
|
|
|
62
69
|
'savePhotos',
|
|
63
70
|
'contacts',
|
|
64
71
|
'notifications',
|
|
72
|
+
'localNetwork',
|
|
65
73
|
];
|
|
66
74
|
/**
|
|
67
75
|
* Applies defaults and validates the options, so the generators never see a
|
|
@@ -108,6 +116,16 @@ export const resolveAppOptions = (rawOptions, defaults) => {
|
|
|
108
116
|
throw new NativeConfigError(`deepLinkSchemes entry "${scheme}" is not a valid URL scheme.`);
|
|
109
117
|
}
|
|
110
118
|
}
|
|
119
|
+
// Host names are case-insensitive, so "Example.com" and "example.com" are
|
|
120
|
+
// one.
|
|
121
|
+
const appLinkDomains = [
|
|
122
|
+
...new Set((options.appLinkDomains ?? []).map((domain) => domain.toLowerCase())),
|
|
123
|
+
];
|
|
124
|
+
for (const domain of appLinkDomains) {
|
|
125
|
+
if (!APP_LINK_DOMAIN.test(domain)) {
|
|
126
|
+
throw new NativeConfigError(`appLinkDomains entry "${domain}" is not a domain. Give the host name alone, without https:// or a path, e.g. "example.com", or "*.example.com" for its subdomains.`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
111
129
|
const userQueriedSchemes = options.canOpenURLSchemes ?? [];
|
|
112
130
|
for (const scheme of userQueriedSchemes) {
|
|
113
131
|
if (!SCHEME.test(scheme)) {
|
|
@@ -158,6 +176,7 @@ export const resolveAppOptions = (rawOptions, defaults) => {
|
|
|
158
176
|
edgeToEdge: options.edgeToEdge ?? true,
|
|
159
177
|
permissions,
|
|
160
178
|
deepLinkSchemes,
|
|
179
|
+
appLinkDomains,
|
|
161
180
|
canOpenURLSchemes,
|
|
162
181
|
shortcuts,
|
|
163
182
|
icon: options.icon,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,UAAU,EACV;IACE,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C,
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,UAAU,EACV;IACE,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC;;;;OAIG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C,CA8CF,CAAC"}
|
package/dist/permissions.js
CHANGED
|
@@ -36,6 +36,13 @@ export const PERMISSION_MAP = {
|
|
|
36
36
|
ios: ['NSContactsUsageDescription'],
|
|
37
37
|
android: ['android.permission.READ_CONTACTS'],
|
|
38
38
|
},
|
|
39
|
+
// Connecting to a device or server on the local network, such as a printer,
|
|
40
|
+
// a TV or a server on the Mac during development: iOS (14 and later) asks
|
|
41
|
+
// first, with this reason. Android needs no permission for it.
|
|
42
|
+
localNetwork: {
|
|
43
|
+
ios: ['NSLocalNetworkUsageDescription'],
|
|
44
|
+
android: [],
|
|
45
|
+
},
|
|
39
46
|
// iOS asks for notification permission at runtime without a usage string.
|
|
40
47
|
notifications: {
|
|
41
48
|
ios: [],
|
package/package.json
CHANGED
|
@@ -25,6 +25,8 @@ Build commands and outputs (no flavors, so the names are fixed):
|
|
|
25
25
|
# app/build/outputs/bundle/release/app-release.aab
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
The release build runs R8 and the resource shrinker (`isMinifyEnabled`, `isShrinkResources`), and writes the mapping that turns the renamed classes back to `app/build/outputs/mapping/release/mapping.txt`, which also goes in the `.aab` for Google Play. Lynx's AAR ships keep rules for its own classes; `app/proguard-rules.pro` adds the ones they miss, each with what broke without it (the app aborting on launch, for one). Any class Lynx or the shell reaches only by name needs a rule there. How they were found, and the sizes, are in `investigations/native-app-builds.md` ("R8 in the Android release build").
|
|
29
|
+
|
|
28
30
|
## How the shell loads the app
|
|
29
31
|
|
|
30
32
|
- **Bundles** come from `assets/` (`ResourceFetchers.kt`, `BundleAssets.kt`). A URL without a scheme (`/static/…`, `static/…`), `asset:///…` and `file:///android_asset/…` all mean "the file at that path in `assets/`", so the bundle works with Rspeedy's default asset prefix (`/`) and doesn't need a platform-specific one. Absolute `http(s)` URLs are fetched with OkHttp.
|
|
@@ -52,7 +54,7 @@ PrimJS, which runs the app's JavaScript on Lynx's main thread, collects garbage
|
|
|
52
54
|
|
|
53
55
|
## Links
|
|
54
56
|
|
|
55
|
-
`NativeModules.AngularLynxLinking` (`LinkingModule.kt`, behind the runtime's `LynxLinking`) opens links outside the app. `MainActivity` registers it with itself as the param, since the module starts activities from it and watches its lifecycle.
|
|
57
|
+
`NativeModules.AngularLynxLinking` (`LinkingModule.kt`, behind the runtime's `LynxLinking`) opens links outside the app. `MainActivity` registers it with itself as the param, since the module starts activities from it and watches its lifecycle. Its `takeURLs(callback)` calls back with `{ urls }`, the links with one of angular.json's `deepLinkSchemes`, and the App Links to its `appLinkDomains`, that arrived while the app was open: `MainActivity.onNewIntent` keeps each one with the module and sends the `angularLynxURL` global event, which the runtime answers by taking them. The link that started the app goes in the `initialURL` global prop instead, read from the intent in `onCreate` unless the app was reopened from Recents.
|
|
56
58
|
|
|
57
59
|
- **`openURL(url, callback)`** starts an `ACTION_VIEW` intent, which the browser, the mail app or the app that claims the URL opens, and calls back with `{}`, or with `{ error, message }` when nothing does.
|
|
58
60
|
- **`openInApp(url, options, callback)`** opens an http(s) URL in a Custom Tab, with `options.toolbarColor` as its toolbar color. Android says nothing when a Custom Tab closes, so the module watches the activity's lifecycle and calls back when it resumes after pausing for the tab: the person closed the tab or came back to the app another way. It doesn't touch `WebAuthModule`'s session, which `MainActivity` tracks on its own.
|
|
@@ -112,8 +114,8 @@ Android's GLES has no 2D uploads from a `PIXEL_UNPACK_BUFFER` and no `glGetVerte
|
|
|
112
114
|
Pinned in `app/build.gradle.kts`, `build.gradle.kts` and `gradle/wrapper/gradle-wrapper.properties`:
|
|
113
115
|
|
|
114
116
|
- Lynx 4.1.0 and PrimJS 4.1.1 (Maven Central), Fresco 2.3.0 (the version Lynx's image service is built against), OkHttp 4.12.
|
|
115
|
-
- `androidx.browser` 1.
|
|
117
|
+
- `androidx.browser` 1.10.0, for the Custom Tabs `WebAuthModule` opens sign-in pages in and `LinkingModule` opens `openInApp()`'s pages in.
|
|
116
118
|
- `androidx.exifinterface` 1.4.2, for the orientation `ImagePickerModule` turns a re-encoded photo by.
|
|
117
|
-
- Lynx's XElement 4.1.0 (`<input>`, `<textarea>`, `<overlay>`, `<svg>`, `<blur-view>`, `<viewpager>`, `<refresh>`, the `<scroll-coordinator>` family, `<webview>`, `<video>`), without its AnimaX and Markdown modules, which the runtime doesn't support. `MainActivity` registers the elements with `XElementBehaviors`. XElement depends on appcompat and material 1.0.0, whose vectordrawable libraries share a namespace that AGP 9 rejects, so appcompat 1.
|
|
119
|
+
- Lynx's XElement 4.1.0 (`<input>`, `<textarea>`, `<overlay>`, `<svg>`, `<blur-view>`, `<viewpager>`, `<refresh>`, the `<scroll-coordinator>` family, `<webview>`, `<video>`), without its AnimaX and Markdown modules, which the runtime doesn't support. `MainActivity` registers the elements with `XElementBehaviors`. XElement depends on appcompat and material 1.0.0, whose vectordrawable libraries share a namespace that AGP 9 rejects, so appcompat 1.8.0 and material 1.14.0 are pinned.
|
|
118
120
|
- AGP 9.4.1 with its built-in Kotlin, Gradle 9.6.1 (AGP 9.4's minimum), JDK 17 or newer.
|
|
119
|
-
- `compileSdk`
|
|
121
|
+
- `compileSdk` 37 (androidx.core 1.19's minimum), `targetSdk` 36, `minSdk` 24. Google Play raises its target API requirement every August; bump `targetSdk` with it.
|
|
@@ -28,7 +28,7 @@ val hasReleaseSigning = releaseSigning.values.all { !it.isNullOrEmpty() }
|
|
|
28
28
|
|
|
29
29
|
// One place for the Lynx version, so a Lynx upgrade is a one-line change.
|
|
30
30
|
val lynxVersion = "4.1.0"
|
|
31
|
-
val primjsVersion = "4.
|
|
31
|
+
val primjsVersion = "4.2.1"
|
|
32
32
|
// Lynx's image service is written against Fresco 2.3, and Lynx Explorer ships
|
|
33
33
|
// the same version, so stay on it until Lynx moves.
|
|
34
34
|
val frescoVersion = "2.3.0"
|
|
@@ -37,7 +37,10 @@ android {
|
|
|
37
37
|
// The namespace is the package of the shell's own Kotlin code and R class.
|
|
38
38
|
// It's fixed; only the applicationId (the store identity) is configurable.
|
|
39
39
|
namespace = "dev.angularlynx.shell"
|
|
40
|
-
|
|
40
|
+
// The API level the app compiles against, which androidx.core 1.19
|
|
41
|
+
// requires to be 37 or later. It only makes newer APIs available to the
|
|
42
|
+
// code; targetSdk below is what opts the app in to new runtime behavior.
|
|
43
|
+
compileSdk = 37
|
|
41
44
|
|
|
42
45
|
defaultConfig {
|
|
43
46
|
applicationId = appConfig("applicationId")
|
|
@@ -72,11 +75,17 @@ android {
|
|
|
72
75
|
|
|
73
76
|
buildTypes {
|
|
74
77
|
release {
|
|
75
|
-
// R8
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
|
|
78
|
+
// R8 shrinks, optimizes and renames the app's Java and Kotlin,
|
|
79
|
+
// and the resource shrinker drops the resources nothing uses.
|
|
80
|
+
// Most of the code is libraries the app uses a little of (media3
|
|
81
|
+
// and Guava behind <video>, appcompat and material behind
|
|
82
|
+
// XElement): R8 takes the dex from 19.5 MB to 3.3 MB, and what an
|
|
83
|
+
// arm64 phone downloads from 13.6 MB to 7.5 MB. Lynx reaches much
|
|
84
|
+
// of its Java through JNI and reflection, which R8 can't see:
|
|
85
|
+
// Lynx's AAR ships keep rules for its own classes, and
|
|
86
|
+
// proguard-rules.pro adds the ones they miss.
|
|
87
|
+
isMinifyEnabled = true
|
|
88
|
+
isShrinkResources = true
|
|
80
89
|
proguardFiles(
|
|
81
90
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
82
91
|
"proguard-rules.pro",
|
|
@@ -120,15 +129,15 @@ android {
|
|
|
120
129
|
}
|
|
121
130
|
|
|
122
131
|
dependencies {
|
|
123
|
-
implementation("androidx.activity:activity-ktx:1.
|
|
124
|
-
implementation("androidx.core:core-ktx:1.
|
|
132
|
+
implementation("androidx.activity:activity-ktx:1.13.0")
|
|
133
|
+
implementation("androidx.core:core-ktx:1.19.1")
|
|
125
134
|
// The splash screen (MainActivity, themes.xml): Android 12's on every
|
|
126
135
|
// version the app runs on, and kept up until the app's first screen is
|
|
127
136
|
// ready.
|
|
128
137
|
implementation("androidx.core:core-splashscreen:1.2.0")
|
|
129
138
|
// Custom Tabs, which WebAuthModule opens sign-in pages in, and
|
|
130
139
|
// LinkingModule the pages of openInApp().
|
|
131
|
-
implementation("androidx.browser:browser:1.
|
|
140
|
+
implementation("androidx.browser:browser:1.10.0")
|
|
132
141
|
// EXIF orientation, which ImagePickerModule applies to a photo it
|
|
133
142
|
// re-encodes, since BitmapFactory ignores it. The AndroidX one reads it
|
|
134
143
|
// from every format the Photo Picker hands back, the same way on every
|
|
@@ -152,7 +161,7 @@ dependencies {
|
|
|
152
161
|
implementation("com.facebook.fresco:animated-webp:$frescoVersion")
|
|
153
162
|
implementation("com.facebook.fresco:webpsupport:$frescoVersion")
|
|
154
163
|
implementation("com.facebook.fresco:animated-base:$frescoVersion")
|
|
155
|
-
implementation("com.squareup.okhttp3:okhttp:4.12.
|
|
164
|
+
implementation("com.squareup.okhttp3:okhttp:4.12.1")
|
|
156
165
|
|
|
157
166
|
// XElement: <input>, <textarea>, <overlay>, <svg>, <blur-view>,
|
|
158
167
|
// <viewpager>, <refresh>, the <scroll-coordinator> family, <webview> and
|
|
@@ -172,6 +181,6 @@ dependencies {
|
|
|
172
181
|
// vectordrawable 1.0.0 and vectordrawable-animated 1.0.0. Those two share
|
|
173
182
|
// the namespace androidx.vectordrawable, and AGP 9's manifest merger
|
|
174
183
|
// fails the build on that; newer versions give them distinct namespaces.
|
|
175
|
-
implementation("androidx.appcompat:appcompat:1.
|
|
176
|
-
implementation("com.google.android.material:material:1.
|
|
184
|
+
implementation("androidx.appcompat:appcompat:1.8.0")
|
|
185
|
+
implementation("com.google.android.material:material:1.14.0")
|
|
177
186
|
}
|
|
@@ -1,65 +1,77 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# isMinifyEnabled
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
# native
|
|
19
|
-
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
# The release build's keep rules, on top of the ones its libraries ship.
|
|
2
|
+
#
|
|
3
|
+
# R8 (isMinifyEnabled in build.gradle.kts) removes and renames whatever it
|
|
4
|
+
# can't see used. Lynx reaches much of its Java through JNI and reflection,
|
|
5
|
+
# which R8 can't see, so Lynx's AAR carries keep rules of its own (its
|
|
6
|
+
# proguard.txt, which R8 applies by itself): @Keep classes, native and
|
|
7
|
+
# @CalledByNative methods, @LynxMethod modules, @LynxProp and @LynxUIMethod
|
|
8
|
+
# members, and every LynxBaseUI, ShadowNode and LynxModule subclass. They're
|
|
9
|
+
# the rules from Lynx's integration guide, plus a few. Fresco's core library,
|
|
10
|
+
# XElement's modules and the AndroidX libraries ship theirs too.
|
|
11
|
+
#
|
|
12
|
+
# The rules below cover what those miss. They were found by listing every
|
|
13
|
+
# reflective call and every method native code calls in the Lynx, XElement and
|
|
14
|
+
# Fresco classes, checking the release APK's dex for each, and running the E2E
|
|
15
|
+
# tests and a page that drives every XElement on an emulator.
|
|
16
|
+
# investigations/native-app-builds.md has the details.
|
|
17
|
+
#
|
|
18
|
+
# Methods Lynx's native code calls. Lynx's rules keep the ones marked with
|
|
19
|
+
# com.lynx.tasm.base.CalledByNative, but lynx-base and lynx-trace, which ship
|
|
20
|
+
# no rules, mark theirs with annotations of their own. Without these, R8
|
|
21
|
+
# removed LynxLog.log(), which lynx-base's native library looks up as Lynx
|
|
22
|
+
# starts, and the app aborted on launch ("JNI DETECTED ERROR IN APPLICATION:
|
|
23
|
+
# mid == null" from LynxBaseTrace.nativeInitBaseTrace).
|
|
22
24
|
-keepclasseswithmembers class * {
|
|
23
|
-
@com.lynx.
|
|
25
|
+
@com.lynx.base.CalledByNative <methods>;
|
|
24
26
|
}
|
|
25
|
-
|
|
26
|
-
# to customize a module, you need to keep the class name and the method annotated as LynxMethod.
|
|
27
27
|
-keepclasseswithmembers class * {
|
|
28
|
-
@com.lynx.
|
|
28
|
+
@com.lynx.trace.CalledByNative <methods>;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
# Most of the rest come from R8's full mode, AGP's default since AGP 8: a
|
|
32
|
+
# -keep rule that names a class without members keeps the class but not its
|
|
33
|
+
# constructor. The libraries' rules were written for ProGuard, which kept it,
|
|
34
|
+
# so a class they create with Class.newInstance() lost its constructor, and
|
|
35
|
+
# with it the methods only an instance could call.
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
# Lynx's generated setters and method invokers. Lynx finds the ones for each
|
|
38
|
+
# element class by name (<class>$$PropsSetter, <class>$$MethodInvoker) and
|
|
39
|
+
# creates them with newInstance(). Without these rules R8 emptied them (none
|
|
40
|
+
# had a constructor left), and Lynx then set every property and called every
|
|
41
|
+
# UI method through reflection instead.
|
|
42
|
+
-keep class * implements com.lynx.tasm.behavior.utils.Settable { <init>(); }
|
|
43
|
+
-keep class * implements com.lynx.tasm.behavior.utils.LynxUIMethodInvoker { <init>(); }
|
|
44
|
+
# The same for a JSI object's descriptor (<class>$$Descriptor).
|
|
45
|
+
-keep class * implements com.lynx.jsbridge.jsi.ILynxJSIObjectDescriptor { <init>(); }
|
|
40
46
|
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
-
|
|
44
|
-
private com.lynx.tasm.core.resource.LynxResourceLoader mLoader;
|
|
45
|
-
private com.lynx.tasm.core.resource.LynxResourceLoader mResourceLoader;
|
|
46
|
-
}
|
|
47
|
+
# Fresco creates its WebP transcoder by name, and R8 had removed its
|
|
48
|
+
# constructor and methods.
|
|
49
|
+
-keep class com.facebook.imagepipeline.nativecode.WebpTranscoderImpl { <init>(); }
|
|
47
50
|
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
52
|
-
-keep class * extends com.lynx.tasm.behavior.ui.LynxBaseUI
|
|
53
|
-
-keep class * extends com.lynx.tasm.behavior.shadow.ShadowNode
|
|
54
|
-
-keep class * extends com.lynx.jsbridge.LynxModule { *; }
|
|
55
|
-
-keep class * extends com.lynx.jsbridge.LynxContextModule
|
|
56
|
-
-keep class * implements com.lynx.tasm.behavior.utils.Settable
|
|
57
|
-
-keep class * implements com.lynx.tasm.behavior.utils.LynxUISetter
|
|
58
|
-
-keep class * implements com.lynx.tasm.behavior.utils.LynxUIMethodInvoker
|
|
59
|
-
-keep class com.lynx.tasm.rendernode.compat.**{
|
|
60
|
-
*;
|
|
51
|
+
# <viewpager> reads ViewPager's private mIsUnableToDrag by name, which
|
|
52
|
+
# XElement's own rules (they keep only populate()) leave R8 to rename.
|
|
53
|
+
-keepclassmembers class androidx.viewpager.widget.ViewPager {
|
|
54
|
+
private boolean mIsUnableToDrag;
|
|
61
55
|
}
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
|
|
57
|
+
# <text enable-emoji-compat> looks up AndroidX's EmojiCompat by name, which R8
|
|
58
|
+
# had renamed.
|
|
59
|
+
-keep class androidx.emoji2.text.EmojiCompat {
|
|
60
|
+
public static androidx.emoji2.text.EmojiCompat get();
|
|
61
|
+
public java.lang.CharSequence process(java.lang.CharSequence);
|
|
64
62
|
}
|
|
65
|
-
|
|
63
|
+
|
|
64
|
+
# Classes the app doesn't have, which R8 would otherwise fail the build on.
|
|
65
|
+
# XElement's umbrella registers <animax-view> and <markdown>, whose modules
|
|
66
|
+
# build.gradle.kts leaves out, so those two tags can't be created (the runtime
|
|
67
|
+
# doesn't support them). Lynx uses Gson only to describe its environment for
|
|
68
|
+
# debugging tools.
|
|
69
|
+
-dontwarn com.lynx.animax.**
|
|
70
|
+
-dontwarn com.lynx.xelement.markdown.**
|
|
71
|
+
-dontwarn com.google.gson.**
|
|
72
|
+
|
|
73
|
+
# Keep the file names and line numbers in stack traces. The mapping file
|
|
74
|
+
# (app/build/outputs/mapping/release/mapping.txt, which Gradle also puts in
|
|
75
|
+
# the .aab for Google Play) turns the renamed classes and methods back.
|
|
76
|
+
-keepattributes SourceFile,LineNumberTable
|
|
77
|
+
-renamesourcefileattribute SourceFile
|
|
@@ -14,6 +14,7 @@ import androidx.lifecycle.LifecycleOwner
|
|
|
14
14
|
import com.lynx.jsbridge.LynxMethod
|
|
15
15
|
import com.lynx.jsbridge.LynxModule
|
|
16
16
|
import com.lynx.react.bridge.Callback
|
|
17
|
+
import com.lynx.react.bridge.JavaOnlyArray
|
|
17
18
|
import com.lynx.react.bridge.JavaOnlyMap
|
|
18
19
|
import com.lynx.react.bridge.ReadableMap
|
|
19
20
|
|
|
@@ -29,6 +30,18 @@ import com.lynx.react.bridge.ReadableMap
|
|
|
29
30
|
* Custom Tab over the app. Each method calls back once: with `{}` when it's
|
|
30
31
|
* done, `{ value }` for `canOpenURL`, or `{ error: "failed", message }`, as
|
|
31
32
|
* the iOS module does.
|
|
33
|
+
*
|
|
34
|
+
* It also hands over the links that open the app: those with one of
|
|
35
|
+
* angular.json's `deepLinkSchemes`, and App Links, https links to its
|
|
36
|
+
* `appLinkDomains`. The one that starts it is MainActivity's `initialURL`
|
|
37
|
+
* global prop, which goes out before the bundle runs, so the router's first
|
|
38
|
+
* screen is already the link's. One that arrives while the app is open
|
|
39
|
+
* (MainActivity.onNewIntent) waits here, and the runtime's `LynxLinking`
|
|
40
|
+
* takes it with `takeURLs`, which calls back with `{ urls }`, when it hears
|
|
41
|
+
* the `angularLynxURL` global event, and once as it starts listening. A link
|
|
42
|
+
* waits for as long as that takes, so one that arrives while Angular is still
|
|
43
|
+
* starting isn't lost, and none is handled twice. ShortcutsModule works the
|
|
44
|
+
* same way.
|
|
32
45
|
*/
|
|
33
46
|
class LinkingModule(context: Context, param: Any?) : LynxModule(context, param) {
|
|
34
47
|
private val activity = param as ComponentActivity
|
|
@@ -125,6 +138,15 @@ class LinkingModule(context: Context, param: Any?) : LynxModule(context, param)
|
|
|
125
138
|
}
|
|
126
139
|
}
|
|
127
140
|
|
|
141
|
+
@LynxMethod
|
|
142
|
+
fun takeURLs(callback: Callback) {
|
|
143
|
+
val urls = JavaOnlyArray()
|
|
144
|
+
for (url in takeWaiting()) {
|
|
145
|
+
urls.pushString(url)
|
|
146
|
+
}
|
|
147
|
+
callback.invoke(JavaOnlyMap.from(mapOf("urls" to urls)))
|
|
148
|
+
}
|
|
149
|
+
|
|
128
150
|
private fun closed(watcher: DefaultLifecycleObserver) {
|
|
129
151
|
activity.lifecycle.removeObserver(watcher)
|
|
130
152
|
sheet = null
|
|
@@ -145,5 +167,25 @@ class LinkingModule(context: Context, param: Any?) : LynxModule(context, param)
|
|
|
145
167
|
|
|
146
168
|
companion object {
|
|
147
169
|
const val NAME = "AngularLynxLinking"
|
|
170
|
+
|
|
171
|
+
// The global event that says a link is waiting. It carries nothing:
|
|
172
|
+
// the listener answers by taking them.
|
|
173
|
+
const val EVENT = "angularLynxURL"
|
|
174
|
+
|
|
175
|
+
// The activity leaves them on the main thread, and Lynx calls
|
|
176
|
+
// modules off it.
|
|
177
|
+
private val waiting = mutableListOf<String>()
|
|
178
|
+
|
|
179
|
+
/** Leaves a link that arrived while the app is open for the runtime. */
|
|
180
|
+
fun open(url: String) {
|
|
181
|
+
synchronized(waiting) { waiting.add(url) }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private fun takeWaiting(): List<String> =
|
|
185
|
+
synchronized(waiting) {
|
|
186
|
+
val taken = waiting.toList()
|
|
187
|
+
waiting.clear()
|
|
188
|
+
taken
|
|
189
|
+
}
|
|
148
190
|
}
|
|
149
191
|
}
|
|
@@ -84,6 +84,11 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
84
84
|
}
|
|
85
85
|
private var webAuthSession: WebAuthSession? = null
|
|
86
86
|
|
|
87
|
+
// The link that started the app, with one of angular.json's
|
|
88
|
+
// deepLinkSchemes or an App Link to one of its appLinkDomains, sent as
|
|
89
|
+
// the initialURL global prop (see LinkingModule).
|
|
90
|
+
private var initialURL: String? = null
|
|
91
|
+
|
|
87
92
|
// The Photo Picker (see ImagePickerModule), and who to tell what was
|
|
88
93
|
// picked. An activity registers for results as it's created, before it
|
|
89
94
|
// starts, so a result that arrives after Android recreated it still
|
|
@@ -138,6 +143,17 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
138
143
|
) {
|
|
139
144
|
ShortcutsModule.run(intent)
|
|
140
145
|
}
|
|
146
|
+
// A link that started the app, which the router starts at. Unlike a
|
|
147
|
+
// shortcut it's read again when Android recreates the activity: the
|
|
148
|
+
// app starts again then, and a link tapped after Android ended the
|
|
149
|
+
// app in the background starts it that way too. Reopening the app
|
|
150
|
+
// from Recents hands over the link it last started with, which isn't
|
|
151
|
+
// the person following it again.
|
|
152
|
+
if (intent.action == Intent.ACTION_VIEW &&
|
|
153
|
+
intent.flags and Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY == 0
|
|
154
|
+
) {
|
|
155
|
+
initialURL = intent.dataString
|
|
156
|
+
}
|
|
141
157
|
|
|
142
158
|
// The bundle in the app's assets, or in the debug build `ng serve
|
|
143
159
|
// --platform android` runs, the dev server's (DevServer.kt).
|
|
@@ -295,6 +311,11 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
295
311
|
splashTimeout.removeCallbacksAndMessages(null)
|
|
296
312
|
}
|
|
297
313
|
|
|
314
|
+
// Activity.reportFullyDrawn() counts once per launch itself.
|
|
315
|
+
override fun markFullyDrawn() {
|
|
316
|
+
reportFullyDrawn()
|
|
317
|
+
}
|
|
318
|
+
|
|
298
319
|
override fun startWebAuthSession(url: Uri, callbackScheme: String, done: (WebAuthModule.Result) -> Unit) {
|
|
299
320
|
if (webAuthSession != null) {
|
|
300
321
|
done(WebAuthModule.Result.Failed("A sign-in is already open."))
|
|
@@ -320,14 +341,22 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
320
341
|
lynxView.sendGlobalEvent(ShortcutsModule.EVENT, JavaOnlyArray())
|
|
321
342
|
return
|
|
322
343
|
}
|
|
344
|
+
if (intent.action != Intent.ACTION_VIEW) return
|
|
345
|
+
val url = intent.data ?: return
|
|
323
346
|
// The sign-in page's redirect to the callback scheme: the deep link
|
|
324
347
|
// comes back to this activity, which closes the Custom Tab above it.
|
|
325
348
|
// It arrives before onResume, which then finds no session open.
|
|
326
|
-
val
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
349
|
+
val session = webAuthSession
|
|
350
|
+
if (session != null && url.scheme?.lowercase() == session.scheme) {
|
|
351
|
+
webAuthSession = null
|
|
352
|
+
session.done(WebAuthModule.Result.Returned(url.toString()))
|
|
353
|
+
return
|
|
354
|
+
}
|
|
355
|
+
// Any other link with one of the app's schemes, or an App Link: the
|
|
356
|
+
// runtime's LynxLinking takes it when it hears the event, and the
|
|
357
|
+
// router navigates to it.
|
|
358
|
+
LinkingModule.open(url.toString())
|
|
359
|
+
lynxView.sendGlobalEvent(LinkingModule.EVENT, JavaOnlyArray())
|
|
331
360
|
}
|
|
332
361
|
|
|
333
362
|
// The manifest's configChanges keeps the activity, and the running app,
|
|
@@ -358,7 +387,8 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
358
387
|
* The global props the runtime reads: `theme` (LynxTheme), `isNotchScreen`
|
|
359
388
|
* (LynxSafeArea), `appLocale` (LynxLocale), `appTimeZone` (the `intl`
|
|
360
389
|
* build option's Intl.DateTimeFormat), the accessibility settings
|
|
361
|
-
* (LynxAccessibilitySettings)
|
|
390
|
+
* (LynxAccessibilitySettings), `osVersion` (LynxSystemInfo) and
|
|
391
|
+
* `initialURL` (LynxLinking and the router), plus the
|
|
362
392
|
* safe-area insets in dp and `edgeToEdge`, which env(safe-area-inset-*)
|
|
363
393
|
* reads. The iOS shell sends the same keys, and Lynx Explorer sends theme
|
|
364
394
|
* and isNotchScreen too. Android 12 and later also send the wallpaper's
|
|
@@ -393,6 +423,9 @@ class MainActivity : ComponentActivity(), ShellModule.Host, WebAuthModule.Host {
|
|
|
393
423
|
// which it reads from the engine's local time, and names it with this.
|
|
394
424
|
props["appTimeZone"] = java.util.TimeZone.getDefault().id
|
|
395
425
|
DynamicColors.read(this)?.let { props["dynamicColors"] = it }
|
|
426
|
+
// The link that started the app, which the router starts at. In
|
|
427
|
+
// every update, since each sends the whole set.
|
|
428
|
+
initialURL?.let { props["initialURL"] = it }
|
|
396
429
|
return props
|
|
397
430
|
}
|
|
398
431
|
|
|
@@ -2,6 +2,7 @@ package dev.angularlynx.shell
|
|
|
2
2
|
|
|
3
3
|
import android.app.Application
|
|
4
4
|
import android.content.ComponentCallbacks2
|
|
5
|
+
import android.content.pm.ApplicationInfo
|
|
5
6
|
import com.facebook.drawee.backends.pipeline.Fresco
|
|
6
7
|
import com.facebook.imagepipeline.core.ImagePipelineConfig
|
|
7
8
|
import com.facebook.imagepipeline.memory.PoolConfig
|
|
@@ -10,6 +11,7 @@ import com.lynx.service.http.LynxHttpService
|
|
|
10
11
|
import com.lynx.service.image.LynxImageService
|
|
11
12
|
import com.lynx.service.log.LynxLogService
|
|
12
13
|
import com.lynx.tasm.LynxEnv
|
|
14
|
+
import com.lynx.tasm.base.LLog
|
|
13
15
|
import com.lynx.tasm.service.LynxServiceCenter
|
|
14
16
|
|
|
15
17
|
/**
|
|
@@ -36,6 +38,19 @@ class ShellApplication : Application() {
|
|
|
36
38
|
// No global template provider or custom elements: MainActivity passes
|
|
37
39
|
// its loaders to the LynxView it builds.
|
|
38
40
|
LynxEnv.inst().init(this, null, null, null)
|
|
41
|
+
|
|
42
|
+
// Lynx's libraries are built for release, where Lynx logs at INFO: a
|
|
43
|
+
// line for every touch, flush, layout, event listener and main-thread
|
|
44
|
+
// module call, each a call from native code back into Java and an
|
|
45
|
+
// android.util.Log write on the thread that logged it, mostly the
|
|
46
|
+
// engine thread Angular runs on. A release app keeps Lynx's warnings
|
|
47
|
+
// and errors, which carry the app's JavaScript errors; the debuggable
|
|
48
|
+
// build `ng serve --platform android` installs keeps every line for
|
|
49
|
+
// debugging. After init, which loads Lynx's native library: before
|
|
50
|
+
// it, the call does nothing.
|
|
51
|
+
if ((applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE) == 0) {
|
|
52
|
+
LLog.setMinimumLoggingLevel(LLog.WARN)
|
|
53
|
+
}
|
|
39
54
|
}
|
|
40
55
|
|
|
41
56
|
// Lynx leaves it to the host app to report memory pressure. Either level
|
|
@@ -33,6 +33,14 @@ import com.lynx.tasm.LynxEnv
|
|
|
33
33
|
* `hideSplashScreen` lets the splash screen go, which MainActivity keeps up
|
|
34
34
|
* until the app's first screen is ready. The runtime's LynxSplashScreen
|
|
35
35
|
* calls it.
|
|
36
|
+
*
|
|
37
|
+
* `reportFullyDrawn` calls `Activity.reportFullyDrawn()` when the app's first
|
|
38
|
+
* screen is complete (the runtime's `reportFullyDrawn()`), which logcat prints
|
|
39
|
+
* as `Fully drawn` and Android's startup tools (Macrobenchmark,
|
|
40
|
+
* `am start -W`'s callers) read as time to full display. It's called on the
|
|
41
|
+
* thread the runtime calls from, Lynx's engine thread: the system takes it
|
|
42
|
+
* from any thread, and a post to the UI thread would add a wait to the moment
|
|
43
|
+
* it marks.
|
|
36
44
|
*/
|
|
37
45
|
class ShellModule(context: Context, param: Any?) : LynxModule(context, param) {
|
|
38
46
|
private val host = param as Host
|
|
@@ -41,6 +49,7 @@ class ShellModule(context: Context, param: Any?) : LynxModule(context, param) {
|
|
|
41
49
|
interface Host {
|
|
42
50
|
fun setBackHandlerEnabled(enabled: Boolean)
|
|
43
51
|
fun hideSplashScreen()
|
|
52
|
+
fun markFullyDrawn()
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
@LynxMethod
|
|
@@ -53,6 +62,11 @@ class ShellModule(context: Context, param: Any?) : LynxModule(context, param) {
|
|
|
53
62
|
main.post { host.hideSplashScreen() }
|
|
54
63
|
}
|
|
55
64
|
|
|
65
|
+
@LynxMethod
|
|
66
|
+
fun reportFullyDrawn() {
|
|
67
|
+
host.markFullyDrawn()
|
|
68
|
+
}
|
|
69
|
+
|
|
56
70
|
@LynxMethod
|
|
57
71
|
fun collectGarbage() {
|
|
58
72
|
main.post { LynxEnv.inst().trimMemory(MEMORY_PRESSURE_MODERATE) }
|
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionSha256Sum=
|
|
4
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.
|
|
3
|
+
distributionSha256Sum=971fcd7150ca4ba04852c0b2ca0d2d0ab9468e14b03473eab19528809914c76b
|
|
4
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.2-bin.zip
|
|
5
5
|
networkTimeout=10000
|
|
6
6
|
retries=0
|
|
7
7
|
retryBackOffMs=500
|