@xrnjs/app-template 0.0.7 → 0.1.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.
Files changed (126) hide show
  1. package/$package.json +30 -36
  2. package/android/app/build.gradle +56 -73
  3. package/android/app/src/debug/java/com/xrn/template/ReactNativeFlipper.java +23 -44
  4. package/android/app/src/main/assets/xrn-manifest.json +1 -1
  5. package/android/app/src/main/java/com/xrn/template/MainApplication.kt +54 -65
  6. package/android/app/src/main/java/com/xrn/template/multibundle/CodePushBundleActivity.kt +65 -0
  7. package/android/app/src/main/java/com/xrn/template/multibundle/CodePushJSBundleLoader.kt +18 -0
  8. package/android/app/src/main/java/com/xrn/template/multibundle/CodePushUtils.kt +263 -0
  9. package/android/app/src/main/java/com/xrn/template/multibundle/XBundleTool.kt +9 -0
  10. package/android/app/src/main/java/com/xrn/template/multibundle/XRNReactHostDelegate.kt +56 -0
  11. package/android/app/src/main/java/com/xrn/template/navigation/XBundleActivity.kt +10 -7
  12. package/android/app/src/main/res/raw/bundle_config.json +2 -6
  13. package/android/build.gradle +40 -39
  14. package/android/buildSrc/build.gradle.kts +15 -0
  15. package/android/gradle/wrapper/gradle-wrapper.properties +3 -1
  16. package/android/gradle.properties +17 -10
  17. package/android/settings.gradle +40 -12
  18. package/harmony/.clang-tidy +1 -1
  19. package/harmony/.clangd +3 -1
  20. package/harmony/AppScope/app.json5 +1 -1
  21. package/harmony/build-profile.json5 +8 -8
  22. package/harmony/entry/oh-package-lock.json5 +283 -262
  23. package/harmony/entry/oh-package.json5 +35 -36
  24. package/harmony/entry/src/main/cpp/CMakeLists.txt +37 -17
  25. package/harmony/entry/src/main/cpp/PackageProvider.cpp +20 -2
  26. package/harmony/entry/src/main/cpp/generated/BundleNavigation.cpp +3 -0
  27. package/harmony/entry/src/main/cpp/generated/RNOHGeneratedPackage.h +31 -87
  28. package/harmony/entry/src/main/cpp/generated/RTNCodePush.cpp +7 -1
  29. package/harmony/entry/src/main/cpp/generated/XRNBundleModule.cpp +9 -0
  30. package/harmony/entry/src/main/cpp/generated/XRNDebugToolsModule.cpp +10 -0
  31. package/harmony/entry/src/main/cpp/generated/{ImageResizer.cpp → XRNImageView.cpp} +6 -3
  32. package/harmony/entry/src/main/cpp/generated/{ImageResizer.h → XRNImageView.h} +2 -2
  33. package/harmony/entry/src/main/cpp/generated/{RNCWebViewComponentDescriptor.h → XRNImageViewComponentDescriptor.h} +11 -10
  34. package/harmony/entry/src/main/cpp/generated/XRNImageViewJSIBinder.h +58 -0
  35. package/harmony/entry/src/main/cpp/generated/XRNKeyboard.cpp +23 -0
  36. package/harmony/entry/src/main/cpp/generated/{RNLocalize.h → XRNKeyboard.h} +2 -2
  37. package/harmony/entry/src/main/cpp/generated/XRNNavigation.cpp +5 -0
  38. package/harmony/entry/src/main/cpp/generated/{RNCWebViewModule.cpp → XRNNetworkModule.cpp} +2 -4
  39. package/harmony/entry/src/main/cpp/generated/{RNCWebViewModule.h → XRNNetworkModule.h} +2 -2
  40. package/harmony/entry/src/main/ets/BundleHelper.ets +41 -45
  41. package/harmony/entry/src/main/ets/MainAbilityStage.ets +9 -4
  42. package/harmony/entry/src/main/ets/entryability/EntryAbility.ets +1 -1
  43. package/harmony/entry/src/main/ets/navDestination/BizModuleContainer.ets +2 -2
  44. package/harmony/entry/src/main/ets/navDestination/MainModuleContainer.ets +2 -2
  45. package/harmony/entry/src/main/ets/navDestination/Splash.ets +1 -2
  46. package/harmony/entry/src/main/ets/pages/Index.ets +4 -4
  47. package/harmony/entry/src/main/resources/rawfile/bundle_config.json5 +2 -6
  48. package/harmony/entry/src/main/resources/rawfile/xrn-manifest.json +1 -0
  49. package/harmony/oh-package-lock.json5 +2 -1
  50. package/harmony/oh-package.json5 +12 -4
  51. package/index.ts +0 -0
  52. package/ios/BundleEventCenter/Hooks/XRNCustomKeyborad+XTHooks.h +16 -0
  53. package/ios/BundleEventCenter/Hooks/XRNCustomKeyborad+XTHooks.mm +40 -0
  54. package/ios/BundleEventCenter/Hooks/XTIQKeyboardManagerBridge.h +15 -0
  55. package/ios/BundleEventCenter/Hooks/XTIQKeyboardManagerBridge.m +22 -0
  56. package/ios/BundleEventCenter/XTBundleProvider.m +98 -72
  57. package/ios/BundleEventCenter/XTBundleViewControllerFactory.m +4 -15
  58. package/ios/BundleEventCenter/bundleController/XTBundleViewController.mm +43 -0
  59. package/ios/BundleEventCenter/bundleController/XTMainBundleViewController.mm +48 -0
  60. package/ios/BundleEventCenter/bundleController/xtBundles.plist +1 -1
  61. package/ios/Podfile +234 -151
  62. package/ios/Podfile.lock +2810 -594
  63. package/ios/RNDebug/DebugPlugin/XTPluginManage.m +5 -5
  64. package/ios/RNDebug/MotroTools/XTMetroAutoConnector.h +21 -0
  65. package/ios/RNDebug/MotroTools/XTMetroAutoConnector.m +124 -0
  66. package/ios/RNDebug/MotroTools/XTReloadCommandHelper.h +30 -0
  67. package/ios/RNDebug/MotroTools/XTReloadCommandHelper.mm +128 -0
  68. package/ios/RNDebug/Views/XTScanQRPlugin.swift +9 -4
  69. package/ios/XRNTemplate/AppDelegate.h +3 -3
  70. package/ios/XRNTemplate/AppDelegate.mm +40 -102
  71. package/ios/XRNTemplate/Info.plist +4 -4
  72. package/ios/XRNTemplate/PrivacyInfo.xcprivacy +48 -0
  73. package/ios/XRNTemplate-Bridging-Header.h +2 -1
  74. package/ios/XRNTemplate.xcodeproj/project.pbxproj +68 -77
  75. package/ios/ios_patches/fixed_glog_config.h +195 -0
  76. package/ios/ios_patches/xt_IQKeyboardManager+Position.swift +1341 -0
  77. package/ios/ios_patches/xt_IQKeyboardManager.swift +454 -0
  78. package/ios/subBundles/.gitkeep +0 -0
  79. package/main-bundle/babel.config.js +2 -2
  80. package/main-bundle/package.json +11 -20
  81. package/main-bundle/yarn.lock +14655 -9651
  82. package/metro.config.js +21 -0
  83. package/package.json +2 -2
  84. package/react-native.config.js +3 -45
  85. package/src/.gitkeep +0 -0
  86. package/sub-bundle/babel.config.js +2 -2
  87. package/sub-bundle/package.json +11 -20
  88. package/sub-bundle/react-native.config.js +4 -0
  89. package/sub-bundle/yarn.lock +14655 -9651
  90. package/xrn.config.json +12 -12
  91. package/android/app/src/main/java/com/xrn/template/multibundle/XDevSupportParams.kt +0 -6
  92. package/android/app/src/main/java/com/xrn/template/multibundle/XRNHostParams.kt +0 -82
  93. package/harmony/entry/src/main/cpp/generated/ConfigNativeModule.cpp +0 -21
  94. package/harmony/entry/src/main/cpp/generated/ConfigNativeModule.h +0 -21
  95. package/harmony/entry/src/main/cpp/generated/GetRandomValuesNativeModule.cpp +0 -21
  96. package/harmony/entry/src/main/cpp/generated/GetRandomValuesNativeModule.h +0 -21
  97. package/harmony/entry/src/main/cpp/generated/NativeHarmonyTouchId.cpp +0 -22
  98. package/harmony/entry/src/main/cpp/generated/NativeHarmonyTouchId.h +0 -21
  99. package/harmony/entry/src/main/cpp/generated/OreitationLockerNativeModule.cpp +0 -31
  100. package/harmony/entry/src/main/cpp/generated/OreitationLockerNativeModule.h +0 -21
  101. package/harmony/entry/src/main/cpp/generated/RNCCameraRoll.cpp +0 -28
  102. package/harmony/entry/src/main/cpp/generated/RNCCameraRoll.h +0 -21
  103. package/harmony/entry/src/main/cpp/generated/RNCCameraRollPermission.cpp +0 -26
  104. package/harmony/entry/src/main/cpp/generated/RNCCameraRollPermission.h +0 -21
  105. package/harmony/entry/src/main/cpp/generated/RNCWebViewJSIBinder.h +0 -120
  106. package/harmony/entry/src/main/cpp/generated/RNDeviceInfo.cpp +0 -164
  107. package/harmony/entry/src/main/cpp/generated/RNDeviceInfo.h +0 -21
  108. package/harmony/entry/src/main/cpp/generated/RNDocumentPicker.cpp +0 -24
  109. package/harmony/entry/src/main/cpp/generated/RNDocumentPicker.h +0 -21
  110. package/harmony/entry/src/main/cpp/generated/RNGestureHandlerButtonComponentDescriptor.h +0 -43
  111. package/harmony/entry/src/main/cpp/generated/RNGestureHandlerButtonJSIBinder.h +0 -38
  112. package/harmony/entry/src/main/cpp/generated/RNGestureHandlerModule.cpp +0 -28
  113. package/harmony/entry/src/main/cpp/generated/RNGestureHandlerModule.h +0 -21
  114. package/harmony/entry/src/main/cpp/generated/RNGestureHandlerRootViewComponentDescriptor.h +0 -43
  115. package/harmony/entry/src/main/cpp/generated/RNGestureHandlerRootViewJSIBinder.h +0 -31
  116. package/harmony/entry/src/main/cpp/generated/RNLocalize.cpp +0 -31
  117. package/harmony/entry/src/main/cpp/generated/ReactNativeBlobUtil.cpp +0 -51
  118. package/harmony/entry/src/main/cpp/generated/ReactNativeBlobUtil.h +0 -21
  119. package/harmony/entry/src/main/cpp/generated/XRNAssetLoaderModule.cpp +0 -21
  120. package/harmony/entry/src/main/cpp/generated/XRNAssetLoaderModule.h +0 -21
  121. package/harmony/entry/src/main/cpp/generated/XRNFileModule.cpp +0 -22
  122. package/harmony/entry/src/main/cpp/generated/XRNFileModule.h +0 -21
  123. package/ios/BundleEventCenter/bundleController/XTBundleViewController.m +0 -35
  124. package/ios/BundleEventCenter/bundleController/XTMainBundleViewController.m +0 -41
  125. package/main-bundle/.watchmanconfig +0 -1
  126. package/sub-bundle/.watchmanconfig +0 -1
@@ -0,0 +1,263 @@
1
+ package com.xrn.template.multibundle
2
+
3
+ import com.blankj.utilcode.util.ActivityUtils
4
+ import com.blankj.utilcode.util.LogUtils
5
+ import com.blankj.utilcode.util.Utils
6
+ import com.microsoft.codepush.react.CodePush
7
+ import com.microsoft.codepush.react.CodePushUtils
8
+ import com.microsoft.codepush.react.DownloadProgress
9
+ import com.xrn.template.BuildConfig
10
+ import kotlinx.coroutines.CoroutineScope
11
+ import kotlinx.coroutines.Dispatchers
12
+ import kotlinx.coroutines.launch
13
+ import kotlinx.coroutines.withContext
14
+ import xrn.modules.codepush.CodePushManager
15
+ import xrn.modules.codepush.DownloadProgressCallback
16
+ import xrn.modules.codepush.LocalPackage
17
+ import xrn.modules.codepush.RemotePackage
18
+ import xrn.modules.codepush.SyncOptions
19
+ import xrn.modules.codepush.SyncStatus
20
+ import xrn.modules.codepush.SyncStatusChangedCallback
21
+ import xrn.modules.loading.LoadingManager
22
+ import xrn.modules.loading.R
23
+ import xrn.modules.multibundle.bundle.BundleInfoManager
24
+ import xrn.modules.multibundle.view.RNContainerActivity
25
+
26
+
27
+ object CodePushUtils {
28
+
29
+ private const val DEFAULT_CHECK_UPDATE_TIMEOUT_MILLIS = 2000
30
+ val DEFAULT_ROLL_BACK_RETRY_OPTIONS = SyncOptions.RollbackRetryOptions(
31
+ delayInHours = 24, maxRetryAttempts = 5
32
+ )
33
+
34
+ private val instanceMap by lazy { mutableMapOf<String, CodePushManager>() }
35
+
36
+ fun getOrCreate(
37
+ bundleName: String,
38
+ codePush: CodePush? = null,
39
+ forceCreate: Boolean = false
40
+ ): CodePushManager {
41
+ val deploymentKey = getDeploymentKey(bundleName)
42
+
43
+ if (!instanceMap.contains(deploymentKey) || forceCreate) {
44
+ val newCodePush = codePush
45
+ ?: CodePush(
46
+ deploymentKey,
47
+ Utils.getApp(),
48
+ BuildConfig.DEBUG,
49
+ BuildConfig.CODEPUSH_URL,
50
+ com.xrn.template.R.string.codepush_public_key,
51
+ )
52
+
53
+ val mgr = CodePushManager(
54
+ codePush = newCodePush
55
+ ).apply { initialize(XBundleTool.getBizAssetsBundleFileName(bundleName)) }
56
+ instanceMap[deploymentKey] = mgr
57
+ }
58
+
59
+ return instanceMap.getValue(deploymentKey)
60
+ }
61
+
62
+ fun syncUpdate(
63
+ bundleName: String,
64
+ codePushManager: CodePushManager = getOrCreate(bundleName),
65
+ checkUpdateTimeoutMillis: Int = DEFAULT_CHECK_UPDATE_TIMEOUT_MILLIS,
66
+ syncOptions: SyncOptions = SyncOptions(rollbackRetryOptions = DEFAULT_ROLL_BACK_RETRY_OPTIONS),
67
+ completedCallback: (() -> Unit)? = null,
68
+ ) {
69
+ var isInvoked = false
70
+
71
+ fun oneTimeCompletedCallback() {
72
+ if (isInvoked) return
73
+ isInvoked = true
74
+
75
+ completedCallback?.invoke()
76
+ }
77
+
78
+ var retryCallback: (() -> Unit)? = null
79
+
80
+ var isMandatory = true
81
+
82
+ val syncStatusChangedCallback = object : SyncStatusChangedCallback {
83
+ override fun call(
84
+ status: SyncStatus,
85
+ remotePackage: RemotePackage?,
86
+ localPackage: LocalPackage?,
87
+ e: Throwable?
88
+ ) {
89
+ when (status) {
90
+ SyncStatus.UP_TO_DATE -> {
91
+ oneTimeCompletedCallback()
92
+ }
93
+
94
+ SyncStatus.DOWNLOADING_PACKAGE -> {
95
+ if (remotePackage != null) {
96
+ isMandatory = remotePackage.isMandatory
97
+
98
+ if (!isMandatory) {
99
+ oneTimeCompletedCallback()
100
+ }
101
+ }
102
+ }
103
+
104
+ SyncStatus.UPDATE_INSTALLED -> {
105
+ oneTimeCompletedCallback()
106
+ }
107
+
108
+ SyncStatus.PATCH_ERROR -> if (e != null) LogUtils.e(e)
109
+
110
+ SyncStatus.UNKNOWN_ERROR -> {
111
+ if (e != null) LogUtils.e(e)
112
+
113
+ if (retryCallback != null) {
114
+ retryCallback?.invoke()
115
+ } else {
116
+ oneTimeCompletedCallback()
117
+ }
118
+ }
119
+
120
+ else -> {}
121
+ }
122
+ }
123
+ }
124
+
125
+ val isMainBundle = BundleInfoManager.getBundleInfo(bundleName)?.isMainBundle() ?: false
126
+ val deploymentKey = getDeploymentKey(bundleName)
127
+
128
+ val downloadProgressCallback = object : DownloadProgressCallback {
129
+ override fun onProgress(downloadProgress: DownloadProgress) {
130
+ val percent =
131
+ (downloadProgress.receivedBytes / downloadProgress.totalBytes.toDouble()) * 100
132
+
133
+ CodePushUtils.log("Package download progress: ${percent.toInt()}%")
134
+
135
+ if (!isMandatory || percent > 100) return
136
+
137
+ /* 当前用户看到 Activity 为对应 bundle 才更新进度 */
138
+ val topActivity = ActivityUtils.getTopActivity()
139
+ if (topActivity is RNContainerActivity && topActivity.getBundleName() == bundleName) {
140
+ LoadingManager.updateProgress(
141
+ ActivityUtils.getTopActivity(),
142
+ percent.toInt(),
143
+ isMainBundle
144
+ )
145
+ return
146
+ }
147
+ }
148
+ }
149
+
150
+ retryCallback = if (codePushManager.getReactPackage().isBinaryJSBundleFileExists) {
151
+ null
152
+ } else {
153
+ {
154
+ LoadingManager.showErrorBoundary(
155
+ ActivityUtils.getTopActivity(),
156
+ Utils.getApp().getString(R.string.error_boundary_network_error),
157
+ Utils.getApp().getString(R.string.error_boundary_retry),
158
+ {
159
+ LoadingManager.hideErrorBoundary()
160
+
161
+ codePushManager.sync(
162
+ deploymentKey,
163
+ syncOptions,
164
+ checkUpdateTimeoutMillis,
165
+ false,
166
+ null,
167
+ syncStatusChangedCallback,
168
+ downloadProgressCallback,
169
+ )
170
+ },
171
+ {
172
+ val topActivity = ActivityUtils.getTopActivity()
173
+ if (topActivity is RNContainerActivity && topActivity.getBundleName() == bundleName) {
174
+ topActivity.reactHost.destroy("", null)
175
+ topActivity.finish()
176
+ }
177
+ }
178
+ )
179
+ }
180
+ }
181
+
182
+ codePushManager.sync(
183
+ deploymentKey,
184
+ syncOptions,
185
+ checkUpdateTimeoutMillis,
186
+ false,
187
+ null,
188
+ syncStatusChangedCallback,
189
+ downloadProgressCallback,
190
+ )
191
+ }
192
+
193
+ fun syncUpdateAsynchronously(
194
+ bundleName: String,
195
+ checkUpdateTimeoutMillis: Int = DEFAULT_CHECK_UPDATE_TIMEOUT_MILLIS,
196
+ rollbackRetryOptions: SyncOptions.RollbackRetryOptions = DEFAULT_ROLL_BACK_RETRY_OPTIONS,
197
+ completedCallback: (() -> Unit)? = null,
198
+ ) {
199
+ syncUpdateAsynchronously(
200
+ bundleName,
201
+ getOrCreate(bundleName),
202
+ checkUpdateTimeoutMillis,
203
+ rollbackRetryOptions,
204
+ completedCallback
205
+ )
206
+ }
207
+
208
+ fun syncUpdateAsynchronously(
209
+ bundleName: String,
210
+ codePushManager: CodePushManager,
211
+ checkUpdateTimeoutMillis: Int = DEFAULT_CHECK_UPDATE_TIMEOUT_MILLIS,
212
+ rollbackRetryOptions: SyncOptions.RollbackRetryOptions = DEFAULT_ROLL_BACK_RETRY_OPTIONS,
213
+ completedCallback: (() -> Unit)? = null,
214
+ ) {
215
+ CoroutineScope(Dispatchers.Main).launch {
216
+ withContext(Dispatchers.IO) {
217
+ syncUpdate(
218
+ bundleName,
219
+ codePushManager,
220
+ checkUpdateTimeoutMillis,
221
+ SyncOptions(rollbackRetryOptions = rollbackRetryOptions),
222
+ completedCallback
223
+ )
224
+ }
225
+ }
226
+ }
227
+
228
+ fun syncUpdateSilently(
229
+ bundleName: String,
230
+ checkUpdateTimeoutMillis: Int = DEFAULT_CHECK_UPDATE_TIMEOUT_MILLIS,
231
+ rollbackRetryOptions: SyncOptions.RollbackRetryOptions = DEFAULT_ROLL_BACK_RETRY_OPTIONS,
232
+ ) {
233
+ syncUpdateSilently(
234
+ bundleName,
235
+ getOrCreate(bundleName), checkUpdateTimeoutMillis, rollbackRetryOptions
236
+ )
237
+ }
238
+
239
+ fun syncUpdateSilently(
240
+ bundleName: String,
241
+ codePushManager: CodePushManager,
242
+ checkUpdateTimeoutMillis: Int = DEFAULT_CHECK_UPDATE_TIMEOUT_MILLIS,
243
+ rollbackRetryOptions: SyncOptions.RollbackRetryOptions = DEFAULT_ROLL_BACK_RETRY_OPTIONS,
244
+ ) {
245
+ syncUpdate(
246
+ bundleName,
247
+ codePushManager,
248
+ checkUpdateTimeoutMillis,
249
+ SyncOptions(rollbackRetryOptions = rollbackRetryOptions),
250
+ null
251
+ )
252
+ }
253
+
254
+ fun onJSBundleLoaded(bundleName: String, jsBundleFile: String) {
255
+ getOrCreate(bundleName).getReactPackage().onJSBundleLoaded(jsBundleFile)
256
+ }
257
+
258
+ private fun getDeploymentKey(bundleName: String): String {
259
+ val bundleInfo = BundleInfoManager.getBundleInfo(bundleName) ?: return ""
260
+ return bundleInfo.getCodePushKey()
261
+ }
262
+
263
+ }
@@ -0,0 +1,9 @@
1
+ package com.xrn.template.multibundle
2
+
3
+ object XBundleTool {
4
+
5
+ fun getBizAssetsBundleFileName(bundleName: String): String {
6
+ return "index.${bundleName}.bundle"
7
+ }
8
+
9
+ }
@@ -0,0 +1,56 @@
1
+ package com.xrn.template.multibundle
2
+
3
+ import android.app.Application
4
+ import com.facebook.react.PackageList
5
+ import com.facebook.react.ReactPackage
6
+ import com.facebook.react.bridge.JSBundleLoader
7
+ import xrn.modules.keyboard.XRNKeyboardPackage
8
+ import xrn.modules.multibundle.bundle.BundleInfoManager
9
+ import xrn.modules.multibundle.defaults.XRNDefaultReactHostDelegate
10
+ import xrn.modules.multibundle.runtime.JSBundleType
11
+
12
+ class XRNReactHostDelegate(
13
+ val application: Application,
14
+ override var bundleName: String,
15
+ val commonOnly: Boolean
16
+ ) : XRNDefaultReactHostDelegate(bundleName) {
17
+
18
+ private val mCodePush by lazy { CodePushUtils.getOrCreate(bundleName, null, true).codePush }
19
+
20
+ private val mJSBundleLoader = object : CodePushJSBundleLoader(
21
+ application, bundleName, commonOnly, this@XRNReactHostDelegate
22
+ ) {
23
+ override fun onLoadStart(bundleType: JSBundleType, bundleName: String) {
24
+ super.onLoadStart(bundleType, bundleName)
25
+ if (bundleType == JSBundleType.BIZ) {
26
+ val deploymentKey =
27
+ BundleInfoManager.getBundleInfo(bundleName)?.getCodePushKey() ?: return
28
+ this@XRNReactHostDelegate.mCodePush.resetDeploymentKey(deploymentKey)
29
+ CodePushUtils.getOrCreate(bundleName, mCodePush)
30
+ }
31
+ }
32
+ }
33
+ override val jsBundleLoader: JSBundleLoader = mJSBundleLoader
34
+
35
+ override val reactPackages: List<ReactPackage>
36
+ get() {
37
+ return PackageList(application).packages.apply {
38
+ //懒加载时,遍历需要放在前面
39
+ add(0, XRNKeyboardPackage())
40
+ add(0, mCodePush)
41
+ }
42
+ }
43
+
44
+ override fun isSplitMode(): Boolean {
45
+ return false
46
+ }
47
+
48
+ override fun getJSBundleFile(jsBundleType: JSBundleType): String {
49
+ return when (jsBundleType) {
50
+ JSBundleType.COMMON -> ""
51
+ JSBundleType.BIZ -> mCodePush.getJSBundleFile(
52
+ XBundleTool.getBizAssetsBundleFileName(bundleName)
53
+ )
54
+ }
55
+ }
56
+ }
@@ -10,15 +10,15 @@ import com.lzf.easyfloat.EasyFloat
10
10
  import com.lzf.easyfloat.enums.ShowPattern
11
11
  import com.lzf.easyfloat.enums.SidePattern
12
12
  import com.xrn.template.R
13
+ import com.xrn.template.multibundle.CodePushBundleActivity
13
14
  import com.xrn.template.utils.DevEntryUtil
14
15
  import com.xrn.template.utils.LifecycleAwareRunnable
15
- import xrn.modules.navigation.kotlin.BaseRNContainerActivity
16
16
 
17
- open class XBundleActivity:BaseRNContainerActivity() {
17
+ open class XBundleActivity: CodePushBundleActivity() {
18
18
 
19
19
  override fun onCreate(savedInstanceState: Bundle?) {
20
20
  super.onCreate(null)
21
- if (mBundleName.isBlank() || mModuleName.isBlank()) {
21
+ if (getBundleName().isBlank() || getModuleName().isBlank()) {
22
22
  ToastUtils.showShort("RN容器初始化失败、bundleName或moduleName不允许为空")
23
23
  finish()
24
24
  return
@@ -32,12 +32,15 @@ open class XBundleActivity:BaseRNContainerActivity() {
32
32
  .setTag(this@XBundleActivity.toString())
33
33
  .registerCallback {
34
34
  createResult { isCreated, msg, view ->
35
+ val envView = view?.findViewById<TextView>(R.id.tvEnv)
35
36
  view?.setOnClickListener {
36
- getRNHost()?.reactInstanceManager?.currentReactContext?.getJSModule(
37
- DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)?.emit("NATIVE_FLOAT_BAR_CLICK", null)
37
+ reactHost.currentReactContext?.getJSModule(
38
+ DeviceEventManagerModule.RCTDeviceEventEmitter::class.java
39
+ )?.emit("NATIVE_FLOAT_BAR_CLICK", null)
38
40
  }
39
41
  view?.background = drawable
40
- val runnable = LifecycleAwareRunnable(lifecycle) { DevEntryUtil.devEntryAttachSide(view) }
42
+ val runnable =
43
+ LifecycleAwareRunnable(lifecycle) { DevEntryUtil.devEntryAttachSide(view) }
41
44
  LifecycleAwareRunnable.getHandler().postDelayed(runnable, 500)
42
45
  }
43
46
 
@@ -53,4 +56,4 @@ open class XBundleActivity:BaseRNContainerActivity() {
53
56
  }
54
57
  builder.show()
55
58
  }
56
- }
59
+ }
@@ -1,21 +1,17 @@
1
1
  {
2
- "project": {
3
- "name": "XRNTemplate"
4
- },
5
- "defaultOptions": {
6
- "bundleType": "sub"
7
- },
8
2
  "bundles": [
9
3
  {
10
4
  "bundleName": "main-bundle",
11
5
  "bundlePackageRelativePath": "./main-bundle",
12
6
  "bundleType": "main",
7
+ "checkNativeDep": false,
13
8
  "codePushKey": "0NzkdHaOp6RhCDWjD1G3KogLieV54ksvOXqog",
14
9
  "port": 8081
15
10
  },
16
11
  {
17
12
  "bundleName": "sub-bundle",
18
13
  "bundlePackageRelativePath": "./sub-bundle",
14
+ "checkNativeDep": false,
19
15
  "codePushKey": "KpWDtkf7lssWGGhFVlubzRq9gAg74ksvOXqog",
20
16
  "port": 6061
21
17
  }
@@ -2,45 +2,41 @@
2
2
 
3
3
  buildscript {
4
4
  ext {
5
- buildToolsVersion = "34.0.0"
6
- minSdkVersion = 21
7
- compileSdkVersion = 34
8
- targetSdkVersion = 34
5
+ buildToolsVersion = "35.0.0"
6
+ minSdkVersion = 24
7
+ compileSdkVersion = 35
8
+ targetSdkVersion = 35
9
9
  supportLibVersion = "29.0.0"
10
10
 
11
- kotlin_version = '1.8.20'
12
-
13
- // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
14
- ndkVersion = "23.1.7779620"
15
11
  androidXCore = "1.0.2"
16
- glideVersion = "4.16.0"
12
+ glideVersion = "5.0.5"
17
13
  excludeAppGlideModule = true
14
+
18
15
  // gradle,AGP,kotlin 版本必须按照以下文档配置
19
16
  // https://kotlinlang.org/docs/gradle-configure-project.html#apply-the-plugin
20
- AGPVersion = '7.4.2'
21
- kotlin_version = '1.8.20'
17
+ AGPVersion = '8.7.2'
18
+ kotlin_version = '2.0.21'
22
19
  // 有些第三方库读取的这个配置,比如:async-storage
23
- kotlinVersion = '1.8.20'
20
+ kotlinVersion = "2.0.21"
24
21
  // 协程和 kotlin 版本必须按照以下文档配置
25
22
  // https://github.com/Kotlin/kotlinx.coroutines/tree/1.7.3
26
- kotlin_coroutines_version = '1.7.3'
23
+ kotlin_coroutines_version = '1.9.0'
27
24
 
28
- // REACT_NATIVE_NODE_MODULES_DIR = "../node_modules/react-native"
25
+ ndkVersion = "27.1.12297006"
29
26
  }
30
27
  repositories {
31
28
  // google
32
29
  maven { url 'https://maven.aliyun.com/repository/google' }
33
30
  // central & jcenter
34
31
  maven { url 'https://maven.aliyun.com/repository/public' }
32
+ google()
35
33
  mavenCentral()
36
- mavenLocal()
34
+ maven { url 'https://developer.huawei.com/repo/' }
37
35
  }
38
36
  dependencies {
39
37
  classpath("com.android.tools.build:gradle:$AGPVersion")
40
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
41
38
  classpath("com.facebook.react:react-native-gradle-plugin")
42
- classpath("de.undercouch:gradle-download-task:5.0.1")
43
- classpath "org.jetbrains.kotlin:kotlin-serialization:1.8.0"
39
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
44
40
  }
45
41
  }
46
42
 
@@ -55,29 +51,34 @@ allprojects {
55
51
  maven { url 'https://maven.aliyun.com/repository/public' }
56
52
  mavenCentral()
57
53
  mavenLocal()
58
- maven {
59
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
60
- url("$rootDir/../node_modules/react-native/android")
61
- }
62
- maven {
63
- // Android JSC is installed from npm
64
- url("$rootDir/../node_modules/jsc-android/dist")
65
- }
54
+ maven { url 'https://developer.huawei.com/repo/' }
55
+ }
56
+ }
66
57
 
67
- // central & jcenter
68
- maven {
69
- url 'https://maven.aliyun.com/repository/public'
70
- content {
71
- excludeGroup "com.facebook.react"
72
- }
73
- }
58
+ apply plugin: "com.facebook.react.rootproject"
59
+
60
+ // 去除 ReactModalHostView / ReactModalHostManager 的 final 修饰符
61
+ // RN 0.77.x 中这些类从 Java 改为 Kotlin 实现,Kotlin class 默认 final,
62
+ // 导致 @xrnjs/keyboard 的 XTModalHostView / XTModalHostViewManager 无法继承。
63
+ // RemoveFinalPlugin(buildSrc)在编译期修改 classpath 字节码去 final,
64
+ // 并在 app 打包期通过 AGP InstrumentationScope.ALL 确保 APK 中类也是 non-final。
65
+ project(':xrnjs_keyboard') {
66
+ apply plugin: com.xtapp.RemoveFinalPlugin
67
+ }
74
68
 
75
- mavenCentral {
76
- // We don't want to fetch react-native from Maven Central as there are
77
- // older versions over there.
78
- content {
79
- excludeGroup "com.facebook.react"
69
+ // App 声明了 flavorDimensions "env"、"channel",但多数第三方 / 二方库的 android
70
+ // 模块没有声明这两个维度,变体匹配会因 "No matching variant" 失败。
71
+ // 给所有非 app 子项目补上 missingDimensionStrategy,让它们回退到 dev/china 默认变体。
72
+ // 用 withId 监听 com.android.library 插件应用时机,确保在 android 扩展就绪后再配置。
73
+ subprojects { subproject ->
74
+ if (subproject.name != 'app') {
75
+ subproject.plugins.withId('com.android.library') {
76
+ subproject.android {
77
+ defaultConfig {
78
+ missingDimensionStrategy 'env', 'dev'
79
+ missingDimensionStrategy 'channel', 'china'
80
+ }
80
81
  }
81
82
  }
82
83
  }
83
- }
84
+ }
@@ -0,0 +1,15 @@
1
+ plugins {
2
+ `kotlin-dsl`
3
+ }
4
+
5
+ repositories {
6
+ maven { url = uri("https://maven.aliyun.com/repository/google") }
7
+ maven { url = uri("https://maven.aliyun.com/repository/public") }
8
+ google()
9
+ mavenCentral()
10
+ }
11
+
12
+ dependencies {
13
+ implementation("com.android.tools.build:gradle:8.7.2")
14
+ implementation("org.ow2.asm:asm:9.7.1")
15
+ }
@@ -1,5 +1,7 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
4
+ networkTimeout=10000
5
+ validateDistributionUrl=true
4
6
  zipStoreBase=GRADLE_USER_HOME
5
7
  zipStorePath=wrapper/dists
@@ -10,7 +10,7 @@
10
10
  # Specifies the JVM arguments used for the daemon process.
11
11
  # The setting is particularly useful for tweaking memory settings.
12
12
  # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13
- org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
13
+ org.gradle.jvmargs=-Xmx8g -XX:MaxMetaspaceSize=512m -Djava.net.useSystemProxies=false
14
14
 
15
15
  # When configured, Gradle will run in incubating parallel mode.
16
16
  # This option should only be used with decoupled projects. More details, visit
@@ -25,39 +25,46 @@ android.useAndroidX=true
25
25
  android.enableJetifier=true
26
26
 
27
27
  # Version of flipper SDK to use with React Native
28
- FLIPPER_VERSION=0.235.0
28
+ FLIPPER_VERSION=0.273.0
29
29
 
30
30
  # Use this property to specify which architecture you want to build.
31
31
  # You can also override it from the CLI using
32
32
  # ./gradlew <task> -PreactNativeArchitectures=x86_64
33
- reactNativeArchitectures=armeabi-v7a,arm64-v8a
33
+ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
34
34
 
35
35
  # Use this property to enable support to the new architecture.
36
36
  # This will allow you to use TurboModules and the Fabric render in
37
37
  # your application. You should enable this flag either if you want
38
38
  # to write custom TurboModules/Fabric components OR use libraries that
39
39
  # are providing them.
40
- newArchEnabled=false
40
+ newArchEnabled=true
41
41
 
42
42
  # Use this property to enable or disable the Hermes JS engine.
43
43
  # If set to false, you will be using JSC instead.
44
- hermesEnabled=false
45
- enableHermes=false
44
+ hermesEnabled=true
45
+ enableHermes=true
46
46
  org.gradle.daemon=true
47
47
  org.gradle.configureondemand=true
48
48
  #### Jenkins auto edit
49
- VERSIONNAME=1.0.0
50
- VERSIONCODE=20250702
49
+ VERSIONNAME=0.0.1
50
+ VERSIONCODE=260915143
51
51
 
52
52
 
53
53
  # 解决找不到so文件 split_config.arm64_v8a.apk
54
- android.bundle.enableUncompressedNativeLibs=false
55
54
 
56
55
  # ASM Version
57
56
  sensorsAnalytics.asmVersion=ASM9
58
57
 
59
58
  # AsyncStorage
60
- AsyncStorage_useNextStorage=true
59
+ # useNextStorage stays false (default). The 2.x "next storage" backend pulls in
60
+ # KSP + androidx.room, but async-storage's bundled kspVersion table tops out at
61
+ # 1.9.24-1.0.20 and has no entry for Kotlin 2.0.21, so the KSP task crashes with a
62
+ # getChangedFiles signature mismatch on Gradle 8.10.2. xrngo leaves this off too.
61
63
 
62
64
  #VisionCamera
63
65
  VisionCamera_enableCodeScanner=true
66
+
67
+ # Disable JDK use of macOS system proxy. The local proxy at 127.0.0.1:8899
68
+ # performs SSL MITM with an untrusted CA, which breaks Gradle dependency
69
+ # downloads (PKIX path building failed).
70
+ systemProp.java.net.useSystemProxies=false
@@ -1,18 +1,46 @@
1
- rootProject.name = 'XRNTemplate'
1
+ pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
2
+ plugins { id("com.facebook.react.settings") }
3
+
4
+ // Force-clear JVM proxy system properties. The macOS system proxy at
5
+ // 127.0.0.1:8899 performs SSL MITM with an untrusted CA, which breaks Gradle
6
+ // dependency downloads (PKIX path building failed). Cleared here (after the
7
+ // plugins {} block, before autolinking/dependency resolution) so downloads go direct.
8
+ System.clearProperty("http.proxyHost")
9
+ System.clearProperty("http.proxyPort")
10
+ System.clearProperty("https.proxyHost")
11
+ System.clearProperty("https.proxyPort")
12
+ System.clearProperty("http.nonProxyHosts")
13
+ System.clearProperty("https.nonProxyHosts")
14
+ try {
15
+ java.net.ProxySelector.setDefault(new java.net.ProxySelector() {
16
+ java.util.List<java.net.Proxy> select(java.net.URI uri) { [java.net.Proxy.NO_PROXY] }
17
+ void connectFailed(java.net.URI uri, java.net.SocketAddress sa, java.io.IOException ioe) {}
18
+ })
19
+ } catch (Throwable t) {}
20
+
21
+ extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
22
+ rootProject.name = 'xrngo'
2
23
 
3
- apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
4
24
  include ':app'
5
25
  includeBuild('../node_modules/@react-native/gradle-plugin')
6
26
 
7
- include ':xrnjs_react-native-code-push'
8
- project(':xrnjs_react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/@xrnjs/react-native-code-push/android/app')
27
+ // @xrnjs/multi-bundle is excluded from React Native autolinking (its android
28
+ // platform returns null), so it must be included here manually. Other @xrnjs/*
29
+ // native packages are autolinked as :xrnjs_<name> and need no manual include.
30
+ include(':xrnjs-multi-bundle')
31
+ project(':xrnjs-multi-bundle').projectDir = new File(rootProject.projectDir, '../node_modules/@xrnjs/multi-bundle/android')
9
32
 
10
- include(':xrnjs_multi-bundle')
11
- project(':xrnjs_multi-bundle').projectDir = new File(rootProject.projectDir, '../node_modules/@xrnjs/multi-bundle/android')
33
+ // CodePush is intentionally excluded from React Native autolinking by @xrnjs/core,
34
+ // while @xrnjs/bundle depends on it as a Gradle project.
35
+ // The package name is scoped (@xrnjs/react-native-code-push) but the Gradle project
36
+ // keeps the autolinking-style name :xrnjs_react-native-code-push (underscore) that
37
+ // app/build.gradle and :xrnjs_bundle reference.
38
+ include(':xrnjs_react-native-code-push')
39
+ project(':xrnjs_react-native-code-push').projectDir = new File(rootProject.projectDir, '../node_modules/@xrnjs/react-native-code-push/android')
12
40
 
13
- if (settings.hasProperty("newArchEnabled") && settings.newArchEnabled == "true") {
14
- include(":ReactAndroid")
15
- project(":ReactAndroid").projectDir = file('../node_modules/react-native/ReactAndroid')
16
- include(":ReactAndroid:hermes-engine")
17
- project(":ReactAndroid:hermes-engine").projectDir = file('../node_modules/react-native/ReactAndroid/hermes-engine')
18
- }
41
+ def appNodeModulesPath = new File(rootProject.projectDir, '../node_modules').toPath().normalize()
42
+ rootProject.children.each { project ->
43
+ if (project.projectDir.toPath().normalize().startsWith(appNodeModulesPath)) {
44
+ project.projectDir = project.projectDir.canonicalFile
45
+ }
46
+ }
@@ -1 +1 @@
1
- Checks: 'misc-missing-switch-cases,misc-napi-module-name,misc-replace-if-else-with-ternary-operator,misc-unused-local-variable,misc-unused-parameters,modernize-use-auto,readability-system-capabilities'
1
+ Checks: 'misc-missing-switch-cases,misc-napi-module-name,misc-replace-if-else-with-ternary-operator,misc-unused-local-variable,misc-unused-parameters,modernize-use-auto,readability-system-capabilities,misc-napi-macro-module-name,capi-version-validation'