react-native-update 10.31.0-beta.3 → 10.31.0-beta.4

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/.cursor/mcp.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "mcpServers": {
3
3
  "RadonAi": {
4
- "url": "http://127.0.0.1:51686/mcp",
4
+ "url": "http://127.0.0.1:58829/mcp",
5
5
  "type": "http",
6
6
  "headers": {
7
- "nonce": "b4c4a571-2531-4040-967d-932c873b8ff9"
7
+ "nonce": "23c8f821-564e-4c78-a4ee-3ca5ff7788c1"
8
8
  }
9
9
  }
10
10
  }
@@ -23,6 +23,38 @@ import java.util.Map;
23
23
  public class UpdateModuleImpl {
24
24
 
25
25
  public static final String NAME = "Pushy";
26
+
27
+ /**
28
+ * 获取字段的兼容性方法,尝试带m前缀和不带m前缀的字段名
29
+ * @param clazz 目标类
30
+ * @param fieldName 基础字段名(不带m前缀)
31
+ * @return 找到的字段对象
32
+ * @throws NoSuchFieldException 如果两种命名都找不到字段
33
+ */
34
+ private static Field getCompatibleField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
35
+ // 首先尝试带m前缀的字段名
36
+ try {
37
+ return clazz.getDeclaredField("m" + capitalize(fieldName));
38
+ } catch (NoSuchFieldException e) {
39
+ // 如果找不到带m前缀的,尝试不带m前缀的
40
+ try {
41
+ return clazz.getDeclaredField(fieldName);
42
+ } catch (NoSuchFieldException e2) {
43
+ // 如果都找不到,抛出异常并包含两种尝试的信息
44
+ throw new NoSuchFieldException("Field not found with either name: m" + capitalize(fieldName) + " or " + fieldName);
45
+ }
46
+ }
47
+ }
48
+
49
+ /**
50
+ * 首字母大写的辅助方法
51
+ */
52
+ private static String capitalize(String str) {
53
+ if (str == null || str.length() == 0) {
54
+ return str;
55
+ }
56
+ return str.substring(0, 1).toUpperCase() + str.substring(1);
57
+ }
26
58
 
27
59
  public static void downloadFullUpdate(UpdateContext updateContext, final ReadableMap options, final Promise promise) {
28
60
  String url = options.getString("updateUrl");
@@ -143,16 +175,16 @@ public class UpdateModuleImpl {
143
175
  ReactDelegate reactDelegate = (ReactDelegate)
144
176
  getReactDelegateMethod.invoke(currentActivity);
145
177
 
146
- Field reactHostField = ReactDelegate.class.getDeclaredField("mReactHost");
178
+ Field reactHostField = getCompatibleField(ReactDelegate.class, "reactHost");
147
179
  reactHostField.setAccessible(true);
148
180
  Object reactHost = reactHostField.get(reactDelegate);
149
181
 
150
- Field devSupport = reactHost.getClass().getDeclaredField("mUseDevSupport");
182
+ Field devSupport = getCompatibleField(reactHost.getClass(), "useDevSupport");
151
183
  devSupport.setAccessible(true);
152
184
  devSupport.set(reactHost, false);
153
185
 
154
- // Access the mReactHostDelegate field
155
- Field reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate");
186
+ // Access the ReactHostDelegate field (compatible with mReactHostDelegate/reactHostDelegate)
187
+ Field reactHostDelegateField = getCompatibleField(reactHost.getClass(), "reactHostDelegate");
156
188
  reactHostDelegateField.setAccessible(true);
157
189
  Object reactHostDelegate = reactHostDelegateField.get(reactHost);
158
190
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-update",
3
- "version": "10.31.0-beta.3",
3
+ "version": "10.31.0-beta.4",
4
4
  "description": "react-native hot update",
5
5
  "main": "src/index",
6
6
  "scripts": {