@xrnjs/app-template 0.0.6 → 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 (124) 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
package/$package.json CHANGED
@@ -1,51 +1,45 @@
1
1
  {
2
2
  "name": "XRNTemplate",
3
- "version": "1.0.0",
3
+ "version": "0.0.1",
4
4
  "private": true,
5
5
  "main": "index.ts",
6
6
  "scripts": {
7
- "codegen": "react-native codegen-harmony --cpp-output-path ./harmony/entry/src/main/cpp/generated --rnoh-module-path ./harmony/entry/oh_modules/@rnoh/react-native-openharmony",
7
+ "bundle:common": "xrn build-common-bundle ios",
8
8
  "build:harmony": "xrn build XRNTemplate harmony --type debug --appFormat hap",
9
- "build:ios": "xrn build XRNTemplate ios --type debug --appFormat ipa",
10
- "build:ios-sim": "xrn build XRNTemplate ios --type debug --appFormat app",
11
9
  "build:android": "xrn build XRNTemplate android --type debug --appFormat apk",
12
- "publish:ios": "xrn app-publish XRNTemplate ios --type release --appFormat ipa --changeLog iOS发布",
13
- "postinstall": "xrn-native-postinstall"
10
+ "build:android:release": "xrn build XRNTemplate android --type release --appFormat apk",
11
+ "build:ios": "xrn build XRNTemplate ios --type debug --appFormat ipa",
12
+ "build:ios:sim": "xrn build XRNTemplate ios --type debug --appFormat app",
13
+ "postinstall": "npx xrn postinstall android ios harmony"
14
14
  },
15
15
  "dependencies": {
16
- "@react-native-async-storage/async-storage": "1.21.0",
17
- "@react-native-clipboard/clipboard": "1.13.2",
18
- "@react-native-community/netinfo": "11.3.2",
19
- "@xrnjs/core": "0.0.4",
20
- "react": "18.2.0",
21
- "react-native": "0.72.5",
22
- "react-native-config": "1.5.3",
23
- "react-native-device-info": "11.1.0",
24
- "react-native-fs": "2.20.0",
25
- "react-native-gesture-handler": "2.14.1",
26
- "react-native-permissions": "4.1.2",
27
- "react-native-safe-area-context": "4.7.4",
28
- "react-native-screens": "3.33.0",
29
- "react-native-svg": "15.0.0",
30
- "react-native-vision-camera": "4.0.1"
16
+ "@xrnjs/cli": "0.1.0",
17
+ "@xrnjs/core": "0.1.0"
31
18
  },
32
19
  "devDependencies": {
33
- "@babel/core": "^7.12.9",
34
- "@babel/runtime": "^7.12.5",
35
- "@react-native-community/eslint-config": "^2.0.0",
36
- "@react-native-oh/react-native-harmony": "0.72.38",
37
- "@react-native/metro-config": "^0.72.9",
38
- "@types/lodash": "^4.17.12",
39
- "@types/react": "18.0.25",
40
- "@types/react-native": "0.72.8",
41
- "@xrnjs/cli": "0.0.6",
42
- "eslint": "^7.32.0",
43
- "metro-react-native-babel-preset": "0.72.4",
44
- "patch-package": "^8.0.0"
20
+ "@react-native-oh/react-native-harmony-cli": "0.77.33-1",
21
+ "@react-native/metro-config": "0.77.1"
45
22
  },
46
23
  "resolutions": {
47
- "react-native-reanimated": "3.6.0",
48
- "@react-native-community/cli": "9.3.3",
49
- "metro-config": "0.72.4"
24
+ "react-native": "0.77.1",
25
+ "react-native-view-shot": "4.0.3"
26
+ },
27
+ "harmony": {
28
+ "codegenConfig": {
29
+ "specPaths": [
30
+ "./src"
31
+ ]
32
+ }
33
+ },
34
+ "codegenConfig": {
35
+ "name": "XrnAppSpec",
36
+ "type": "all",
37
+ "jsSrcsDir": "./src",
38
+ "android": {
39
+ "javaPackageName": "com.xrn"
40
+ },
41
+ "ios": {
42
+ "componentProvider": {}
43
+ }
50
44
  }
51
45
  }
@@ -1,59 +1,28 @@
1
+ // 去除 ReactModalHostView / ReactModalHostManager 的 final 修饰符(打包期)
2
+ // RemoveFinalPlugin Part2 通过 AGP InstrumentationScope.ALL 在 DEX 前修改字节码,
3
+ // 确保 APK 中的 ReactModalHostManager 也是 non-final,
4
+ // 否则运行时 XTModalHostViewManager 继承它会抛 java.lang.VerifyError。
5
+ // 必须在 com.android.application 之前 apply,否则 onVariants 会报 "too late"。
6
+ apply plugin: com.xtapp.RemoveFinalPlugin
1
7
  apply plugin: "com.android.application"
8
+ apply plugin: "org.jetbrains.kotlin.android"
2
9
  apply plugin: "com.facebook.react"
3
- apply plugin: 'org.jetbrains.kotlin.android'
4
- apply plugin: 'kotlin-android'
5
- apply plugin: 'kotlinx-serialization'
6
-
7
- apply from: "../../node_modules/@xrnjs/react-native-code-push/android/codepush.gradle"
8
- apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
9
10
 
10
11
  /**
11
12
  * This is the configuration block to customize your React Native Android app.
12
13
  * By default you don't need to apply any configuration, just uncomment the lines you need.
13
14
  */
14
15
  react {
15
- /* Folders */
16
- // The root of your project, i.e. where "package.json" lives. Default is '..'
17
- // root = file("../../")
18
- // The folder where the react-native NPM package is. Default is ../node_modules/react-native
19
- // reactNativeDir = file("../../node_modules/react-native")
20
- // The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
21
- // codegenDir = file("../../node_modules/@react-native/codegen")
22
- // The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
23
- // cliFile = file("../../node_modules/react-native/cli.js")
24
-
25
16
  /* Variants */
26
- // The list of variants to that are debuggable. For those we're going to
27
- // skip the bundling of the JS bundle and the assets. By default is just 'debug'.
28
- // If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
29
- // debuggableVariants = ["liteDebug", "prodDebug"]
17
+ // Multi-bundle app: JS bundles are pre-generated by @xrnjs/cli into
18
+ // app/src/main/assets, so every variant must skip Gradle's own bundling.
19
+ debuggableVariants = ["devChinaDebug", "devChinaNewDebug", "prodChinaDebug", "prodChinaNewDebug", "devChinaRelease", "devChinaNewRelease", "prodChinaRelease", "prodChinaNewRelease"]
30
20
 
31
21
  /* Bundling */
32
- // A list containing the node command and its flags. Default is just 'node'.
33
- nodeExecutableAndArgs = ["node"]
34
- //
35
- // The command to run when bundling. By default is 'bundle'
36
- // bundleCommand = "ram-bundle"
37
- //
38
- // The path to the CLI configuration file. Default is empty.
39
- // bundleConfig = file("../../metro.config.js")
40
- //
41
- // The name of the generated asset file containing your JS bundle
42
- // bundleAssetName = "MyApplication.android.bundle"
43
- //
44
- // The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
45
- entryFile = file("../../index.ts")
46
- //
47
- // A list of extra flags to pass to the 'bundle' commands.
48
- // See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
49
- // extraPackagerArgs = []
50
-
51
- /* Hermes Commands */
52
- // The hermes compiler command to run. By default it is 'hermesc'
53
- // hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
54
- //
55
- // The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
56
- // hermesFlags = ["-O", "-output-source-map"]
22
+ nodeExecutableAndArgs = ["node"]
23
+
24
+ /* Autolinking */
25
+ autolinkLibrariesWithApp()
57
26
  }
58
27
 
59
28
  /**
@@ -66,22 +35,13 @@ def enableProguardInReleaseBuilds = false
66
35
  *
67
36
  * For example, to use the international variant, you can use:
68
37
  * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
69
- *
70
- * The international variant includes ICU i18n library and necessary data
71
- * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
72
- * give correct results when using with locales other than en-US. Note that
73
- * this variant is about 6MiB larger per architecture than default.
74
38
  */
75
39
  def jscFlavor = 'org.webkit:android-jsc:+'
76
40
 
77
- ext {
78
- // REACT_NATIVE_NODE_MODULES_DIR = "../node_modules/react-native"
79
- }
80
-
81
41
  android {
82
42
  ndkVersion rootProject.ext.ndkVersion
83
-
84
- compileSdkVersion rootProject.ext.compileSdkVersion
43
+ buildToolsVersion rootProject.ext.buildToolsVersion
44
+ compileSdk rootProject.ext.compileSdkVersion
85
45
 
86
46
  namespace "com.xrn.template"
87
47
  defaultConfig {
@@ -89,8 +49,34 @@ android {
89
49
  minSdkVersion rootProject.ext.minSdkVersion
90
50
  targetSdkVersion rootProject.ext.targetSdkVersion
91
51
  versionName project.VERSIONNAME
92
- versionCode "${project.VERSIONCODE}0".toInteger()
52
+ versionCode project.VERSIONCODE.toInteger()
53
+ }
54
+
55
+ splits {
56
+ abi {
57
+ enable true
58
+ reset()
59
+ include "arm64-v8a"
60
+ universalApk false
61
+ }
62
+ }
63
+
64
+ flavorDimensions "env", "channel"
65
+ productFlavors {
66
+ dev {
67
+ dimension "env"
68
+ }
69
+ prod {
70
+ dimension "env"
71
+ }
72
+ china {
73
+ dimension "channel"
74
+ }
75
+ chinaNew {
76
+ dimension "channel"
77
+ }
93
78
  }
79
+
94
80
  signingConfigs {
95
81
  debug {
96
82
  storeFile file('debug.keystore')
@@ -103,6 +89,7 @@ android {
103
89
  debug {
104
90
  signingConfig signingConfigs.debug
105
91
  resValue "string", "codepush_public_key", '"debug"'
92
+ buildConfigField "String", "CODEPUSH_URL", '""'
106
93
  }
107
94
  release {
108
95
  // Caution! In production, you need to generate your own keystore file.
@@ -110,8 +97,8 @@ android {
110
97
  signingConfig signingConfigs.debug
111
98
  minifyEnabled enableProguardInReleaseBuilds
112
99
  proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
113
-
114
100
  resValue "string", "codepush_public_key", '"release"'
101
+ buildConfigField "String", "CODEPUSH_URL", '""'
115
102
  }
116
103
  }
117
104
 
@@ -119,6 +106,10 @@ android {
119
106
  enabled = true
120
107
  }
121
108
 
109
+ packagingOptions {
110
+ pickFirst 'META-INF/versions/9/OSGI-INF/MANIFEST.MF'
111
+ }
112
+
122
113
  compileOptions {
123
114
  sourceCompatibility = JavaVersion.VERSION_17
124
115
  targetCompatibility = JavaVersion.VERSION_17
@@ -135,18 +126,16 @@ dependencies {
135
126
  // The version of react-native is set by the React Native Gradle Plugin
136
127
  implementation("com.facebook.react:react-android")
137
128
 
138
- implementation project(':xrnjs_multi-bundle')
139
- implementation project(':xrnjs_bundle')
140
- implementation project(':xrnjs_debug-tools')
141
129
  implementation project(':xrnjs_react-native-code-push')
130
+ implementation project(':xrnjs_bundle')
131
+ implementation project(':xrnjs-multi-bundle')
142
132
 
143
133
  implementation "androidx.multidex:multidex:2.0.1"
144
134
 
145
- implementation "androidx.core:core:1.6.0"
146
- implementation 'androidx.core:core-ktx:1.6.0'
147
- implementation 'androidx.appcompat:appcompat:1.6.1'
148
- implementation 'com.google.android.material:material:1.12.0'
149
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
135
+ implementation 'androidx.core:core-ktx:1.16.0'
136
+ implementation 'androidx.appcompat:appcompat:1.7.1'
137
+ implementation 'com.google.android.material:material:1.13.0'
138
+ implementation 'androidx.constraintlayout:constraintlayout:2.2.1'
150
139
 
151
140
  implementation 'com.blankj:utilcodex:1.31.1'
152
141
  implementation 'com.github.princekin-f:EasyFloat:2.0.4'
@@ -155,14 +144,10 @@ dependencies {
155
144
  implementation 'com.facebook.fresco:animated-gif:2.6.0'
156
145
  implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
157
146
 
158
- debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
159
- exclude group: 'com.facebook.fbjni'
160
- }
147
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
161
148
  debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
162
- exclude group: 'com.facebook.flipper'
163
149
  exclude group:'com.squareup.okhttp3', module:'okhttp'
164
150
  }
165
-
166
151
  debugImplementation("com.facebook.flipper:flipper-fresco-plugin:0.182.0") {
167
152
  exclude group: 'com.facebook.flipper'
168
153
  }
@@ -172,5 +157,3 @@ dependencies {
172
157
  implementation jscFlavor
173
158
  }
174
159
  }
175
-
176
- apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
@@ -7,67 +7,46 @@
7
7
  package com.xrn.template;
8
8
 
9
9
  import android.content.Context;
10
+
10
11
  import com.facebook.flipper.android.AndroidFlipperClient;
11
12
  import com.facebook.flipper.android.utils.FlipperUtils;
12
13
  import com.facebook.flipper.core.FlipperClient;
13
14
  import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14
15
  import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15
- import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16
16
  import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17
17
  import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18
18
  import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
19
  import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
20
  import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21
21
  import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22
- import com.facebook.react.ReactInstanceEventListener;
23
- import com.facebook.react.ReactInstanceManager;
24
- import com.facebook.react.bridge.ReactContext;
22
+ import com.facebook.react.ReactHost;
25
23
  import com.facebook.react.modules.network.NetworkingModule;
24
+
26
25
  import okhttp3.OkHttpClient;
27
26
 
28
27
  public class ReactNativeFlipper {
29
- public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
30
- if (FlipperUtils.shouldEnableFlipper(context)) {
31
- final FlipperClient client = AndroidFlipperClient.getInstance(context);
28
+ public static void initializeFlipper(Context context, ReactHost reactHost) {
29
+ if (FlipperUtils.shouldEnableFlipper(context)) {
30
+ final FlipperClient client = AndroidFlipperClient.getInstance(context);
32
31
 
33
- client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
34
- client.addPlugin(new ReactFlipperPlugin());
35
- client.addPlugin(new DatabasesFlipperPlugin(context));
36
- client.addPlugin(new SharedPreferencesFlipperPlugin(context));
37
- client.addPlugin(CrashReporterPlugin.getInstance());
32
+ client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33
+ client.addPlugin(new ReactFlipperPlugin());
34
+ client.addPlugin(new DatabasesFlipperPlugin(context));
35
+ client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36
+ client.addPlugin(CrashReporterPlugin.getInstance());
38
37
 
39
- NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
40
- NetworkingModule.setCustomClientBuilder(
41
- new NetworkingModule.CustomClientBuilder() {
42
- @Override
43
- public void apply(OkHttpClient.Builder builder) {
44
- builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
45
- }
46
- });
47
- client.addPlugin(networkFlipperPlugin);
48
- client.start();
49
-
50
- // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
51
- // Hence we run if after all native modules have been initialized
52
- ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
53
- if (reactContext == null) {
54
- reactInstanceManager.addReactInstanceEventListener(
55
- new ReactInstanceEventListener() {
56
- @Override
57
- public void onReactContextInitialized(ReactContext reactContext) {
58
- reactInstanceManager.removeReactInstanceEventListener(this);
59
- reactContext.runOnNativeModulesQueueThread(
60
- new Runnable() {
61
- @Override
62
- public void run() {
63
- client.addPlugin(new FrescoFlipperPlugin());
64
- }
38
+ NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39
+ NetworkingModule.setCustomClientBuilder(
40
+ new NetworkingModule.CustomClientBuilder() {
41
+ @Override
42
+ public void apply(OkHttpClient.Builder builder) {
43
+ builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44
+ }
65
45
  });
66
- }
67
- });
68
- } else {
69
- client.addPlugin(new FrescoFlipperPlugin());
70
- }
46
+ client.addPlugin(networkFlipperPlugin);
47
+ client.start();
48
+
49
+ // FrescoFlipperPlugin 不支持 0.77,很多类找不到,暂不注册
50
+ }
71
51
  }
72
- }
73
52
  }
@@ -1 +1 @@
1
- {"dependencies":{"@bam.tech/react-native-image-resizer":"3.0.9","@react-native-async-storage/async-storage":"1.21.0","@react-native-camera-roll/camera-roll":"7.8.3","@react-native-clipboard/clipboard":"1.13.2","@react-native-community/netinfo":"11.3.2","@react-native-community/push-notification-ios":"1.11.0","@react-native-cookies/cookies":"6.2.1","@react-native-oh/react-native-harmony":"0.72.38","@react-native-picker/picker":"2.6.1","@sdcx/pull-to-refresh":"0.21.0","@sentry/react-native":"4.15.2","@xrnjs/core":"0.0.2-beta.33","@yidun/quickpass-plugin-rn":"1.3.4","lottie-react-native":"6.4.1","react":"18.2.0","react-native":"0.72.5","react-native-adjust":"4.38.0","react-native-blob-util":"0.19.11","react-native-config":"1.5.3","react-native-device-info":"11.1.0","react-native-document-picker":"9.2.0","react-native-fast-image":"8.6.3","react-native-fs":"2.20.0","react-native-gesture-handler":"2.14.1","react-native-get-random-values":"1.11.0","react-native-image-picker":"7.0.3","react-native-keyboard-manager":"6.5.16-0","react-native-keychain":"8.1.2","react-native-linear-gradient":"3.0.0-alpha.1","react-native-localize":"3.1.0","react-native-modpow":"1.1.1-0","react-native-orientation-locker":"1.7.0","react-native-pdf":"6.7.4","react-native-permissions":"4.1.2","react-native-place-module":"0.1.1","react-native-reanimated":"3.6.0","react-native-safe-area-context":"4.7.4","react-native-screens":"3.33.0","react-native-svg":"15.0.0","react-native-touch-id":"4.4.1","react-native-update-in-app-xt":"1.0.5","react-native-video":"6.0.0-alpha.9","react-native-vision-camera":"4.0.1","react-native-webview":"13.10.2"},"commonBaseLine":{"modules":{},"id":0,"hash":"","useOldApp":true}}
1
+ {"dependencies":{"@xrnjs/cli":"0.1.0","@xrnjs/core":"0.1.0","@xrnjs/navigation":"0.1.0"},"commonBaseLine":{"modules":{},"id":0,"hash":"","useOldApp":true}}
@@ -1,91 +1,80 @@
1
1
  package com.xrn.template
2
2
 
3
3
  import android.content.Context
4
- import androidx.multidex.MultiDexApplication
5
- import com.blankj.utilcode.util.ActivityUtils
6
- import com.facebook.react.ReactApplication
7
- import com.facebook.react.ReactInstanceManager
8
- import com.facebook.react.ReactNativeHost
4
+ import com.blankj.utilcode.util.ReflectUtils
5
+ import com.facebook.react.ReactHost
6
+ import com.facebook.react.config.ReactFeatureFlags
9
7
  import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
8
+ import com.facebook.react.soloader.OpenSourceMergedSoMapping
10
9
  import com.facebook.soloader.SoLoader
11
- import com.xrn.template.multibundle.XBundleInfoHook
12
- import com.xrn.template.multibundle.XDevSupportParams
13
- import com.xrn.template.multibundle.XRNHostParams
10
+ import com.xrn.template.multibundle.XRNReactHostDelegate
14
11
  import com.xrn.template.navigation.MainClazzFactory
15
- import xrn.modules.multibundle.bundle.BundleInfoManager.initWithRawFile
16
- import xrn.modules.multibundle.bundle.RNHostManager.getMainRNHost
17
- import xrn.modules.multibundle.bundle.RNHostManager.init
18
- import xrn.modules.multibundle.bundle.RNHostManagerParams
19
- import xrn.modules.multibundle.view.RNContainerActivity
20
- import xrn.modules.navigation.Navigation.initialize
21
- import xrn.modules.navigation.kotlin.exception.NavigationException
12
+ import xrn.modules.multibundle.ReactHostManager
13
+ import xrn.modules.multibundle.XRNApplication
14
+ import xrn.modules.multibundle.bundle.BundleInfoManager
15
+ import xrn.modules.multibundle.runtime.XRNReactHostFactory
16
+ import xrn.modules.multibundle.runtime.XRNReactHostImpl
17
+ import xrn.modules.multibundle.runtime.pool.XRNReactHostPool
18
+ import xrn.modules.multibundle.runtime.pool.XRNReactHostPoolImpl
19
+ import xrn.modules.multibundle.runtime.toReactHost
20
+ import xrn.modules.navigation.Navigation
22
21
  import java.lang.reflect.InvocationTargetException
23
22
 
24
23
 
25
- class MainApplication : MultiDexApplication(), ReactApplication {
26
- override fun getReactNativeHost(): ReactNativeHost {
27
- val topActivity = ActivityUtils.getTopActivity()
28
- if (topActivity is RNContainerActivity) {
29
- return topActivity.getRNHost()!!
24
+ class MainApplication : XRNApplication() {
25
+
26
+ private val mReactHostPool = XRNReactHostPoolImpl(!BuildConfig.DEBUG, 4, object : XRNReactHostFactory {
27
+ override fun createReactHost(
28
+ bundleName: String,
29
+ commonOnly: Boolean
30
+ ): XRNReactHostImpl {
31
+ return XRNReactHostDelegate(
32
+ this@MainApplication,
33
+ bundleName,
34
+ commonOnly
35
+ ).toReactHost(this@MainApplication)
30
36
  }
31
- return getMainRNHost()!!
32
- }
37
+ })
38
+
39
+ override val reactHostPool: XRNReactHostPool = mReactHostPool
33
40
 
34
41
  override fun onCreate() {
35
42
  super.onCreate()
43
+ initRN()
36
44
  initMultiBundle()
37
- initNavigation()
38
- SoLoader.init(this, /* native exopackage */false)
45
+ initializeFlipper(this, reactHost)
46
+ Navigation.initialize(MainClazzFactory())
47
+ }
48
+
49
+ private fun initRN() {
50
+ ReactFeatureFlags.dispatchPointerEvents = true
51
+ SoLoader.init(this, OpenSourceMergedSoMapping)
39
52
  if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
40
53
  // If you opted-in for the New Architecture, we load the native entry point for this app.
41
- load()
54
+ load(turboModulesEnabled = true, fabricEnabled = true, bridgelessEnabled = true)
42
55
  }
43
- initializeFlipper(this, reactNativeHost.reactInstanceManager)
44
56
  }
45
57
 
46
58
  private fun initMultiBundle() {
47
- initWithRawFile(this, R.raw.bundle_config, XBundleInfoHook())
48
- val params = RNHostManagerParams()
49
- params.isProd = !BuildConfig.DEBUG
50
- params.rnHostParams = XRNHostParams(this)
51
- params.devSupportParams = XDevSupportParams()
52
- params.onError = { e: Exception, map: Map<String, Any?>? ->
53
- e.printStackTrace()
54
- Unit
55
- }
56
- init(this, params)
59
+ BundleInfoManager.initWithRawFile(this, R.raw.bundle_config)
60
+ ReactHostManager.init(this)
57
61
  }
58
62
 
59
- private fun initNavigation() {
60
- initialize(MainClazzFactory()) { e: NavigationException ->
61
- e.printStackTrace()
62
- }
63
- }
64
-
65
- companion object {
66
- private fun initializeFlipper(
67
- context: Context, reactInstanceManager: ReactInstanceManager
68
- ) {
69
- if (BuildConfig.DEBUG) {
70
- try {
71
- val aClass = Class.forName("com.xrn.template.ReactNativeFlipper")
72
- aClass
73
- .getMethod(
74
- "initializeFlipper",
75
- Context::class.java,
76
- ReactInstanceManager::class.java
77
- )
78
- .invoke(null, context, reactInstanceManager)
79
- } catch (e: ClassNotFoundException) {
80
- e.printStackTrace()
81
- } catch (e: NoSuchMethodException) {
82
- e.printStackTrace()
83
- } catch (e: IllegalAccessException) {
84
- e.printStackTrace()
85
- } catch (e: InvocationTargetException) {
86
- e.printStackTrace()
87
- }
63
+ private fun initializeFlipper(context: Context, reactHost: ReactHost) {
64
+ if (BuildConfig.DEBUG) {
65
+ try {
66
+ ReflectUtils.reflect("com.xrn.template.ReactNativeFlipper")
67
+ .method("initializeFlipper", context, reactHost)
68
+ } catch (e: ClassNotFoundException) {
69
+ e.printStackTrace();
70
+ } catch (e: NoSuchMethodException) {
71
+ e.printStackTrace();
72
+ } catch (e: IllegalAccessException) {
73
+ e.printStackTrace();
74
+ } catch (e: InvocationTargetException) {
75
+ e.printStackTrace();
88
76
  }
89
77
  }
90
78
  }
79
+
91
80
  }
@@ -0,0 +1,65 @@
1
+ package com.xrn.template.multibundle
2
+
3
+ import android.os.Bundle
4
+ import com.blankj.utilcode.util.ReflectUtils
5
+ import com.facebook.react.ReactInstanceEventListener
6
+ import com.facebook.react.bridge.ReactContext
7
+ import com.microsoft.codepush.react.SettingsManager
8
+ import xrn.modules.navigation.kotlin.BaseRNContainerActivity
9
+
10
+ open class CodePushBundleActivity : BaseRNContainerActivity() {
11
+
12
+ val listener: ReactInstanceEventListener by lazy {
13
+ object : ReactInstanceEventListener {
14
+ override fun onReactContextInitialized(context: ReactContext) {
15
+ initializeUpdateAfterRestart()
16
+ }
17
+ }
18
+ }
19
+
20
+ override fun onCreate(savedInstanceState: Bundle?) {
21
+ super.onCreate(savedInstanceState)
22
+ initializeCodePush()
23
+ }
24
+
25
+ override fun onDestroy() {
26
+ super.onDestroy()
27
+ reactHost.removeReactInstanceEventListener(listener)
28
+ }
29
+
30
+ private fun initializeCodePush() {
31
+ val reactHost = reactHost
32
+
33
+ /*
34
+ * CodePush initializeUpdateAfterRestart 方法需要把 pendingPackage 的 loading 状态设置为 true,CodePush 回滚逻辑才能正常运行。
35
+ *
36
+ * 预加载模式下,我们不会真正的渲染页面。需要在 runApplication 之前调用 initializeUpdateAfterRestart 设置相关状态
37
+ *
38
+ * */
39
+
40
+ /*
41
+ * ReactInstanceManager createContext 方法未完成前代表 runJSBundle 未执行完。
42
+ * runJSBundle 未执行完代表热更新未完成。
43
+ * 需要监听 createContext 完成后再执行 initializeUpdateAfterRestart。
44
+ *
45
+ * */
46
+ if (reactHost.currentReactContext == null) {
47
+ reactHost.addReactInstanceEventListener(listener)
48
+ } else {
49
+ initializeUpdateAfterRestart()
50
+ }
51
+ }
52
+
53
+ private fun initializeUpdateAfterRestart() {
54
+ val codePush = CodePushUtils.getOrCreate(getBundleName())
55
+ .getReactPackage()
56
+
57
+ val settingsManager = ReflectUtils.reflect(codePush).field("mSettingsManager")
58
+ .get<SettingsManager>()
59
+
60
+ if (settingsManager.isPendingUpdate(codePush.runningPackageHash)) {
61
+ codePush.initializeUpdateAfterRestart()
62
+ }
63
+ }
64
+
65
+ }
@@ -0,0 +1,18 @@
1
+ package com.xrn.template.multibundle
2
+
3
+ import android.app.Application
4
+ import xrn.modules.multibundle.runtime.XRNJSBundleLoader
5
+ import xrn.modules.multibundle.runtime.JSBundleFileHolder
6
+
7
+
8
+ open class CodePushJSBundleLoader(
9
+ override val application: Application,
10
+ override var bundleName: String,
11
+ override var loadCommonOnly: Boolean,
12
+ override val jsBundleFileHolder: JSBundleFileHolder
13
+ ) : XRNJSBundleLoader(
14
+ application,
15
+ bundleName,
16
+ loadCommonOnly,
17
+ jsBundleFileHolder,
18
+ )