@blotch/angular-lynx-native 22.3.1 → 22.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +41 -15
  2. package/dist/android/project.d.ts +90 -1
  3. package/dist/android/project.d.ts.map +1 -1
  4. package/dist/android/project.js +369 -5
  5. package/dist/eject.d.ts +15 -1
  6. package/dist/eject.d.ts.map +1 -1
  7. package/dist/eject.js +13 -2
  8. package/dist/features.d.ts +70 -0
  9. package/dist/features.d.ts.map +1 -0
  10. package/dist/features.js +115 -0
  11. package/dist/generate.d.ts +17 -1
  12. package/dist/generate.d.ts.map +1 -1
  13. package/dist/generate.js +12 -4
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +8 -1
  17. package/dist/ios/build.d.ts.map +1 -1
  18. package/dist/ios/build.js +8 -2
  19. package/dist/ios/frameworks.d.ts +6 -5
  20. package/dist/ios/frameworks.d.ts.map +1 -1
  21. package/dist/ios/frameworks.js +46 -15
  22. package/dist/ios/project.d.ts +173 -11
  23. package/dist/ios/project.d.ts.map +1 -1
  24. package/dist/ios/project.js +767 -33
  25. package/dist/options.d.ts +140 -1
  26. package/dist/options.d.ts.map +1 -1
  27. package/dist/options.js +127 -0
  28. package/dist/permissions.d.ts +18 -1
  29. package/dist/permissions.d.ts.map +1 -1
  30. package/dist/permissions.js +63 -3
  31. package/package.json +1 -1
  32. package/templates/android/README.md +35 -2
  33. package/templates/android/angular-lynx.properties +2 -0
  34. package/templates/android/app/build.gradle.kts +51 -2
  35. package/templates/android/app/src/main/AndroidManifest.xml +14 -3
  36. package/templates/android/app/src/main/java/dev/angularlynx/shell/BarcodeScannerModule.kt +144 -0
  37. package/templates/android/app/src/main/java/dev/angularlynx/shell/BiometricsModule.kt +433 -0
  38. package/templates/android/app/src/main/java/dev/angularlynx/shell/BitmapPresenter.kt +98 -0
  39. package/templates/android/app/src/main/java/dev/angularlynx/shell/BitmapRendererContext.kt +175 -0
  40. package/templates/android/app/src/main/java/dev/angularlynx/shell/BluetoothModule.kt +1288 -0
  41. package/templates/android/app/src/main/java/dev/angularlynx/shell/CalendarModule.kt +127 -0
  42. package/templates/android/app/src/main/java/dev/angularlynx/shell/Canvas2DContext.kt +1557 -0
  43. package/templates/android/app/src/main/java/dev/angularlynx/shell/Canvas2DOps.kt +63 -0
  44. package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasFilter.kt +357 -0
  45. package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasUI.kt +4 -3
  46. package/templates/android/app/src/main/java/dev/angularlynx/shell/FilePickerModule.kt +263 -0
  47. package/templates/android/app/src/main/java/dev/angularlynx/shell/HapticsModule.kt +82 -0
  48. package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +376 -6
  49. package/templates/android/app/src/main/java/dev/angularlynx/shell/ModuleBytes.kt +58 -0
  50. package/templates/android/app/src/main/java/dev/angularlynx/shell/MotionModule.kt +332 -0
  51. package/templates/android/app/src/main/java/dev/angularlynx/shell/NfcModule.kt +274 -0
  52. package/templates/android/app/src/main/java/dev/angularlynx/shell/PermissionRequests.kt +25 -0
  53. package/templates/android/app/src/main/java/dev/angularlynx/shell/PhotoLibraryModule.kt +168 -0
  54. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShareTargetModule.kt +234 -0
  55. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellApplication.kt +6 -0
  56. package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellModule.kt +47 -3
  57. package/templates/android/app/src/main/java/dev/angularlynx/shell/StoreReviewModule.kt +66 -0
  58. package/templates/android/app/src/main/java/dev/angularlynx/shell/SystemFontFamilies.kt +68 -0
  59. package/templates/android/app/src/main/java/dev/angularlynx/shell/TrackingModule.kt +74 -0
  60. package/templates/android/app/src/main/java/dev/angularlynx/shell/VideoFrameTarget.kt +429 -0
  61. package/templates/android/app/src/main/java/dev/angularlynx/shell/VideoUI.kt +676 -0
  62. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLContext.kt +128 -13
  63. package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLModule.kt +493 -65
  64. package/templates/android/app/src/main/java/dev/angularlynx/shell/WifiModule.kt +429 -0
  65. package/templates/android/app/src/main/res/values/biometrics.xml +9 -0
  66. package/templates/android/app/src/main/res/values/share_target.xml +11 -0
  67. package/templates/android/app/src/main/res/xml/backup_rules.xml +5 -3
  68. package/templates/android/app/src/main/res/xml/data_extraction_rules.xml +6 -3
  69. package/templates/android/build.gradle.kts +1 -1
  70. package/templates/android/gradle/wrapper/gradle-wrapper.properties +2 -2
  71. package/templates/ios/App/AngularLynxBitmapRendererContext.m +188 -0
  72. package/templates/ios/App/AngularLynxCanvas2DContext.m +2467 -0
  73. package/templates/ios/App/AngularLynxCanvas2DOps.h +61 -0
  74. package/templates/ios/App/AngularLynxVideo.h +37 -0
  75. package/templates/ios/App/AngularLynxVideo.m +435 -0
  76. package/templates/ios/App/AngularLynxWebGL.h +69 -7
  77. package/templates/ios/App/AngularLynxWebGL.m +538 -29
  78. package/templates/ios/App/AngularLynxWebGLContext.m +148 -46
  79. package/templates/ios/App/AppDelegate.swift +34 -2
  80. package/templates/ios/App/AppleSignInButton.swift +106 -0
  81. package/templates/ios/App/AppleSignInModule.swift +222 -0
  82. package/templates/ios/App/BarcodeScannerModule.swift +284 -0
  83. package/templates/ios/App/BiometricsModule.swift +256 -0
  84. package/templates/ios/App/BluetoothModule.swift +1086 -0
  85. package/templates/ios/App/CalendarModule.swift +158 -0
  86. package/templates/ios/App/FilePickerModule.swift +240 -0
  87. package/templates/ios/App/HapticsModule.swift +90 -0
  88. package/templates/ios/App/Info.plist +2 -0
  89. package/templates/ios/App/LynxViewController.swift +210 -6
  90. package/templates/ios/App/MotionModule.swift +430 -0
  91. package/templates/ios/App/NfcModule.swift +346 -0
  92. package/templates/ios/App/PhotoLibraryModule.swift +169 -0
  93. package/templates/ios/App/ShareTargetModule.swift +150 -0
  94. package/templates/ios/App/ShellModule.swift +17 -0
  95. package/templates/ios/App/StoreReviewModule.swift +61 -0
  96. package/templates/ios/App/TrackingModule.swift +121 -0
  97. package/templates/ios/App/WifiModule.swift +237 -0
  98. package/templates/ios/App/XElementRegistry.swift +13 -3
  99. package/templates/ios/ShareExtension/Info.plist +42 -0
  100. package/templates/ios/ShareExtension/ShareViewController.swift +387 -0
@@ -60,6 +60,11 @@ android {
60
60
  // its insets listener). A properties file written before the option
61
61
  // existed has no line for it, and gets the default.
62
62
  resValue("bool", "edge_to_edge", appConfig.getProperty("edgeToEdge") ?: "true")
63
+ // Whether MainActivity sets the LynxView's font scale from the
64
+ // system's font size, and the largest it takes (0 for no cap). Read
65
+ // with the same default for a properties file written before them.
66
+ resValue("bool", "text_scaling", appConfig.getProperty("textScaling") ?: "true")
67
+ resValue("string", "max_text_scale", appConfig.getProperty("maxTextScale") ?: "0")
63
68
  }
64
69
 
65
70
  signingConfigs {
@@ -157,6 +162,33 @@ dependencies {
157
162
  // from every format the Photo Picker hands back, the same way on every
158
163
  // Android version.
159
164
  implementation("androidx.exifinterface:exifinterface:1.4.2")
165
+ // BiometricPrompt, which BiometricsModule shows: the same prompt from
166
+ // Android 7 up, with the fingerprint dialog on versions before Android 9's
167
+ // own. Only an app with permissions.biometrics keeps it, with the module.
168
+ // angular-lynx:biometrics
169
+ implementation("androidx.biometric:biometric:1.1.0")
170
+ // /angular-lynx:biometrics
171
+ // Google's code scanner, which BarcodeScannerModule opens: it runs in
172
+ // Google Play services, which shows the camera, so the app needs no
173
+ // CAMERA permission and ships no ML Kit model. Only an app whose
174
+ // angular.json sets permissions.camera keeps these lines and the module
175
+ // (@blotch/angular-lynx-native's android/project.ts).
176
+ // angular-lynx:barcode-scanner
177
+ implementation("com.google.android.gms:play-services-code-scanner:16.1.0")
178
+ // /angular-lynx:barcode-scanner
179
+ // Google Play's In-App Review API, which StoreReviewModule asks for the
180
+ // rating prompt. Only an app whose angular.json sets storeReview keeps
181
+ // these lines (@blotch/angular-lynx-native's android/project.ts).
182
+ // angular-lynx:store-review
183
+ implementation("com.google.android.play:review:2.0.2")
184
+ // /angular-lynx:store-review
185
+ // Google Play's advertising ID library, which TrackingModule asks whether
186
+ // the person has opted out of personalized ads or deleted their ID. It
187
+ // also declares AD_ID, which the manifest does too. Only an app whose
188
+ // angular.json sets permissions.tracking keeps these lines.
189
+ // angular-lynx:tracking
190
+ implementation("com.google.android.gms:play-services-ads-identifier:18.3.0")
191
+ // /angular-lynx:tracking
160
192
 
161
193
  // The Lynx engine, its JavaScript runtime (PrimJS) and its JS SDK.
162
194
  implementation("org.lynxsdk.lynx:lynx:$lynxVersion")
@@ -180,7 +212,7 @@ dependencies {
180
212
  // an app that ships it. 0.10.5 fixes that and keeps the API Fresco 2.x
181
213
  // calls (React Native ships the two together), so Gradle's conflict
182
214
  // resolution moves Fresco onto it.
183
- implementation("com.facebook.soloader:soloader:0.10.5")
215
+ implementation("com.facebook.soloader:soloader:0.13.0")
184
216
  implementation("com.squareup.okhttp3:okhttp:4.12.1")
185
217
 
186
218
  // XElement: <input>, <textarea>, <overlay>, <svg>, <blur-view>,
@@ -195,8 +227,25 @@ dependencies {
195
227
  exclude(group = "org.lynxsdk.lynx", module = "xelement-markdown")
196
228
  }
197
229
  // The umbrella declares its modules for runtime only. EdgeToEdgeOverlay
198
- // extends <overlay>'s classes, so that module is compiled against too.
230
+ // extends <overlay>'s classes, so that module is compiled against too,
231
+ // as is <video>'s.
199
232
  implementation("org.lynxsdk.lynx:xelement-overlay:$lynxVersion")
233
+ // VideoUI extends <video>'s classes and reads its media3 PlayerView, at
234
+ // the media3 version xelement-video depends on.
235
+ implementation("org.lynxsdk.lynx:xelement-video:$lynxVersion")
236
+ implementation("androidx.media3:media3-ui:1.0.2")
237
+ implementation("androidx.media3:media3-common:1.0.2")
238
+ // cspell:words servalsvg libserval
239
+ // ServalSVG, the engine <svg> draws with. xelement-svg asks for 0.0.2,
240
+ // whose AAR has libserval_svg.so for arm64-v8a, armeabi-v7a and x86 but
241
+ // not x86_64, so on an x86_64 emulator every <svg> is blank and Lynx's
242
+ // SVG thread throws UnsatisfiedLinkError. 0.2.4 ships all four ABIs,
243
+ // 16 KB-aligned on 64-bit, and keeps the Java API xelement-svg calls;
244
+ // Gradle's conflict resolution moves xelement-svg onto it. It's also the
245
+ // version the iOS frameworks link (build-lynx-ios-frameworks.sh), so
246
+ // both platforms draw with the same engine. Drop this once xelement-svg
247
+ // depends on a release with x86_64.
248
+ implementation("org.lynxsdk.lynx:servalsvg:0.2.4")
200
249
  // XElement's modules depend on appcompat and material 1.0.0, which bring
201
250
  // vectordrawable 1.0.0 and vectordrawable-animated 1.0.0. Those two share
202
251
  // the namespace androidx.vectordrawable, and AGP 9's manifest merger
@@ -25,11 +25,17 @@
25
25
  <!--
26
26
  Auto Backup leaves out LynxSecureStorage's file (SecureStorageModule):
27
27
  dataExtractionRules from Android 12, fullBackupContent before.
28
+
29
+ enableOnBackInvokedCallback opts in to predictive back on Android 13
30
+ to 15, which Android 16 turns on for an app that targets API 36:
31
+ without it, Android 14 sends MainActivity's back handler only the
32
+ finished gesture, so a stack can't move its page with the finger.
28
33
  -->
29
34
  <application
30
35
  android:name=".ShellApplication"
31
36
  android:allowBackup="true"
32
37
  android:dataExtractionRules="@xml/data_extraction_rules"
38
+ android:enableOnBackInvokedCallback="true"
33
39
  android:fullBackupContent="@xml/backup_rules"
34
40
  android:icon="@mipmap/ic_launcher"
35
41
  android:roundIcon="@mipmap/ic_launcher_round"
@@ -41,13 +47,13 @@
41
47
  <!--
42
48
  One activity holding one LynxView; Angular Router does all navigation
43
49
  inside it. configChanges keeps the activity (and the running Angular
44
- app) alive on rotation, resizing and dark-mode switches instead of
45
- restarting it; the LynxView re-lays itself out. It starts with the
50
+ app) alive on rotation, resizing, dark-mode switches and a new font
51
+ size instead of restarting it; the LynxView re-lays itself out. It starts with the
46
52
  splash screen's theme, which installSplashScreen() replaces.
47
53
  -->
48
54
  <activity
49
55
  android:name=".MainActivity"
50
- android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|uiMode"
56
+ android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|uiMode|fontScale"
51
57
  android:exported="true"
52
58
  android:launchMode="singleTask"
53
59
  android:screenOrientation="${screenOrientation}"
@@ -58,6 +64,11 @@
58
64
  <category android:name="android.intent.category.LAUNCHER" />
59
65
  </intent-filter>
60
66
  <!-- angular-lynx:deep-links -->
67
+ <!--
68
+ angular.json's shareTarget: the app in other apps' share
69
+ sheets, for its MIME types (ShareTargetModule.kt).
70
+ -->
71
+ <!-- angular-lynx:share-target -->
61
72
  <!--
62
73
  angular.json's shortcuts, in the menu a long press on the
63
74
  app's icon opens. Android reads them from the launcher
@@ -0,0 +1,144 @@
1
+ package dev.angularlynx.shell
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import android.os.Handler
6
+ import android.os.Looper
7
+ import com.google.android.gms.common.ConnectionResult
8
+ import com.google.android.gms.common.GoogleApiAvailability
9
+ import com.google.mlkit.common.MlKitException
10
+ import com.google.mlkit.vision.barcode.common.Barcode
11
+ import com.google.mlkit.vision.codescanner.GmsBarcodeScannerOptions
12
+ import com.google.mlkit.vision.codescanner.GmsBarcodeScanning
13
+ import com.lynx.jsbridge.LynxMethod
14
+ import com.lynx.jsbridge.LynxModule
15
+ import com.lynx.react.bridge.Callback
16
+ import com.lynx.react.bridge.JavaOnlyMap
17
+ import com.lynx.react.bridge.ReadableMap
18
+
19
+ /**
20
+ * The native module behind the runtime's `LynxBarcodeScanner`, which calls it
21
+ * as `NativeModules.AngularLynxBarcodeScanner` (from the background thread,
22
+ * where NativeModules lives). MainActivity registers it with itself as the
23
+ * param: the scanner opens over it.
24
+ *
25
+ * It opens Google's code scanner, which runs in Google Play services rather
26
+ * than the app: Play services shows the camera and hands back only the code
27
+ * read, so the app needs no CAMERA permission and draws no camera screen.
28
+ * A phone without Play services has no scanner, and a scan reports
29
+ * `unavailable`; Play services downloads the scanner the first time an app
30
+ * asks for it, and a scan before that's done reports `unavailable` too.
31
+ *
32
+ * Only an app whose angular.json sets `permissions.camera` has this file and
33
+ * the Play services library behind it (app/build.gradle.kts's
34
+ * `angular-lynx:barcode-scanner` lines), as only it has the iOS module. So
35
+ * MainActivity looks it up by name, and nothing else may name the class.
36
+ */
37
+ class BarcodeScannerModule(context: Context, param: Any?) : LynxModule(context, param) {
38
+ private val activity = param as Activity
39
+ private val main = Handler(Looper.getMainLooper())
40
+
41
+ /** Whether a scan is open: Play services runs one at a time. */
42
+ private var scanning = false
43
+
44
+ /**
45
+ * Opens the scanner and calls back once with `{ format, value }`, or
46
+ * `{ error, message }`, where `error` is `canceled`, `unavailable`,
47
+ * `denied` or `failed`, as the iOS module does.
48
+ */
49
+ @LynxMethod
50
+ fun scan(request: ReadableMap, callback: Callback) {
51
+ val names = request.getArray("formats")?.let { formats ->
52
+ (0 until formats.size()).map { formats.getString(it) }
53
+ } ?: emptyList()
54
+ // Lynx calls modules off the main thread, and the scanner starts an
55
+ // activity.
56
+ main.post { start(names, callback) }
57
+ }
58
+
59
+ private fun start(names: List<String>, callback: Callback) {
60
+ if (scanning) {
61
+ callback.invoke(error("failed", "A scan is already open."))
62
+ return
63
+ }
64
+ if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(activity) !=
65
+ ConnectionResult.SUCCESS
66
+ ) {
67
+ callback.invoke(error("unavailable", "The barcode scanner needs Google Play services."))
68
+ return
69
+ }
70
+ val formats = names.mapNotNull { FORMATS[it] }.distinct()
71
+ val options = GmsBarcodeScannerOptions.Builder()
72
+ .apply {
73
+ if (formats.isNotEmpty()) {
74
+ setBarcodeFormats(formats.first(), *formats.drop(1).toIntArray())
75
+ }
76
+ }
77
+ // Zooms in on a code that's far away, as the system camera does.
78
+ .enableAutoZoom()
79
+ .build()
80
+ scanning = true
81
+ val done = { result: JavaOnlyMap ->
82
+ scanning = false
83
+ callback.invoke(result)
84
+ }
85
+ GmsBarcodeScanning.getClient(activity, options)
86
+ .startScan()
87
+ .addOnSuccessListener { barcode ->
88
+ val format = NAMES[barcode.format]
89
+ val value = barcode.rawValue ?: barcode.displayValue
90
+ if (format == null || value == null) {
91
+ done(error("failed", "The scanner read a code it couldn't hand over."))
92
+ } else {
93
+ done(JavaOnlyMap.from(mapOf("format" to format, "value" to value)))
94
+ }
95
+ }
96
+ .addOnCanceledListener { done(error("canceled", "The scan was canceled.")) }
97
+ .addOnFailureListener { failure ->
98
+ val code = (failure as? MlKitException)?.errorCode
99
+ done(
100
+ when (code) {
101
+ MlKitException.CODE_SCANNER_CANCELLED ->
102
+ error("canceled", "The scan was canceled.")
103
+ // Play services shows the camera, so it's Play
104
+ // services, not the app, that the person refused it
105
+ // to.
106
+ MlKitException.CODE_SCANNER_CAMERA_PERMISSION_NOT_GRANTED ->
107
+ error("denied", "Google Play services isn't allowed to use the camera.")
108
+ MlKitException.UNAVAILABLE, MlKitException.CODE_SCANNER_UNAVAILABLE ->
109
+ error(
110
+ "unavailable",
111
+ "Google Play services has no barcode scanner yet. It downloads one the first time an app asks: try again shortly.",
112
+ )
113
+ else -> error("failed", failure.message ?: "The scanner could not read a code.")
114
+ },
115
+ )
116
+ }
117
+ }
118
+
119
+ private fun error(code: String, message: String) =
120
+ JavaOnlyMap.from(mapOf("error" to code, "message" to message))
121
+
122
+ companion object {
123
+ const val NAME = "AngularLynxBarcodeScanner"
124
+
125
+ /** The runtime's BarcodeFormat names as ML Kit's formats. */
126
+ private val FORMATS = mapOf(
127
+ "qr" to Barcode.FORMAT_QR_CODE,
128
+ "aztec" to Barcode.FORMAT_AZTEC,
129
+ "dataMatrix" to Barcode.FORMAT_DATA_MATRIX,
130
+ "pdf417" to Barcode.FORMAT_PDF417,
131
+ "ean13" to Barcode.FORMAT_EAN_13,
132
+ "ean8" to Barcode.FORMAT_EAN_8,
133
+ "upcA" to Barcode.FORMAT_UPC_A,
134
+ "upcE" to Barcode.FORMAT_UPC_E,
135
+ "code39" to Barcode.FORMAT_CODE_39,
136
+ "code93" to Barcode.FORMAT_CODE_93,
137
+ "code128" to Barcode.FORMAT_CODE_128,
138
+ "itf" to Barcode.FORMAT_ITF,
139
+ "codabar" to Barcode.FORMAT_CODABAR,
140
+ )
141
+
142
+ private val NAMES = FORMATS.entries.associate { (name, format) -> format to name }
143
+ }
144
+ }