@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
@@ -9,12 +9,12 @@
9
9
  #import "XTPluginManage.h"
10
10
  #import "XTSuspendBall.h"
11
11
  #import "BundleNavigation.h"
12
- #import "RCTBridge+XTExtension.h"
13
12
  #import "XTJSBundleTool.h"
14
13
  #import "JSONUtils.h"
15
14
  #import "XRNToastView.h"
16
15
  #import "RNCConfig.h"
17
16
  #import <React/RCTUtils.h>
17
+ #import <react-native-xrn-multi-bundle/XTMultiBundle.h>
18
18
  #import "XRNTemplate-Swift.h"
19
19
 
20
20
  @interface XTPluginManage ()<SuspendViewDelegate>
@@ -44,12 +44,12 @@
44
44
 
45
45
  - (void)suspendViewButtonClick:(nonnull UIButton *)sender {
46
46
  dispatch_async(dispatch_get_main_queue(), ^{
47
- RCTBridge *currentBridge = [[XTJSBundleTool shared] fetchCurrentBridge];
48
- if (currentBridge == nil) {
47
+ XTJSRuntimeContext *currentContext = [[XTJSBundleTool shared] fetchCurrentContext];
48
+ if (currentContext == nil) {
49
49
  return;
50
50
  }
51
-
52
- BundleNavigation *module = [currentBridge moduleForClass:[BundleNavigation class]];
51
+
52
+ BundleNavigation *module = [currentContext moduleForClass:[BundleNavigation class]];
53
53
  NSString *paramsStr = [JSONUtils dictionaryToJsonString:@{@"where":@"NATIVE"}];
54
54
  [module publishSingleBundleEvent:@"NATIVE_FLOAT_BAR_CLICK" params:paramsStr];
55
55
  });
@@ -0,0 +1,21 @@
1
+ //
2
+ // XTMetroAutoConnector.h
3
+ // xrngo
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ /// 自动探测 / 连接 Metro 服务
11
+ @interface XTMetroAutoConnector : NSObject
12
+
13
+ /// 检查当前 bundle 是否可连接 Metro
14
+ + (BOOL)checkMetroConnection:(NSString *)bundleName;
15
+
16
+ /// 切 bundle 时若 Metro 可达,更新 RCTBundleURLProvider.jsLocation
17
+ + (void)updateJsLocationForBundleName:(NSString *)bundleName;
18
+
19
+ @end
20
+
21
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,124 @@
1
+ //
2
+ // XTMetroAutoConnector.m
3
+ // xrngo
4
+ //
5
+
6
+ #import "XTMetroAutoConnector.h"
7
+ #import "XTPluginManage.h"
8
+ #import "XTJSBundleTool.h"
9
+ #import <React/RCTBundleURLProvider.h>
10
+
11
+ static NSMutableDictionary<NSString *, NSNumber *> *sMetroConnectionCache;
12
+ static dispatch_queue_t sMetroConnectionCacheQueue;
13
+ static NSString *sCurrentJsLocationBundleName;
14
+
15
+ @implementation XTMetroAutoConnector
16
+
17
+ + (void)initialize {
18
+ if (self == [XTMetroAutoConnector class]) {
19
+ sMetroConnectionCache = [NSMutableDictionary dictionary];
20
+ sMetroConnectionCacheQueue = dispatch_queue_create("com.xt.metro.connection.cache", DISPATCH_QUEUE_SERIAL);
21
+ }
22
+ }
23
+
24
+ + (BOOL)checkMetroConnection:(NSString *)bundleName {
25
+ if (bundleName.length == 0) {
26
+ return NO;
27
+ }
28
+ NSString *port = [self portForBundleName:bundleName];
29
+ if (port.length == 0) {
30
+ return NO;
31
+ }
32
+
33
+ __block NSNumber *cachedResult = nil;
34
+ dispatch_sync(sMetroConnectionCacheQueue, ^{
35
+ cachedResult = sMetroConnectionCache[bundleName];
36
+ });
37
+ if (cachedResult != nil) {
38
+ return cachedResult.boolValue;
39
+ }
40
+
41
+ BOOL isConnected = [self pingMetroOnPort:port];
42
+ dispatch_sync(sMetroConnectionCacheQueue, ^{
43
+ sMetroConnectionCache[bundleName] = @(isConnected);
44
+ });
45
+ return isConnected;
46
+ }
47
+
48
+ + (BOOL)pingMetroOnPort:(NSString *)port {
49
+ __block BOOL isConnection = NO;
50
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
51
+ NSString *host = [[XTPluginManage shareInstance] getLocalHost];
52
+ if (host.length == 0) {
53
+ return NO;
54
+ }
55
+ NSString *urlString = [NSString stringWithFormat:@"http://%@:%@/status", host, port];
56
+ NSURL *metroURL = [NSURL URLWithString:urlString];
57
+ if (!metroURL) {
58
+ return NO;
59
+ }
60
+
61
+ NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
62
+ config.timeoutIntervalForRequest = 5.0;
63
+ // 显式用独立队列,避免 completion 被派到主队列时与主线程上的 semaphore wait 死锁
64
+ NSOperationQueue *queue = [[NSOperationQueue alloc] init];
65
+ queue.maxConcurrentOperationCount = 1;
66
+ NSURLSession *session = [NSURLSession sessionWithConfiguration:config delegate:nil delegateQueue:queue];
67
+
68
+ NSURLSessionDataTask *task = [session dataTaskWithURL:metroURL
69
+ completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response, NSError *_Nullable error) {
70
+ NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
71
+ if (!error && httpResponse && httpResponse.statusCode == 200) {
72
+ isConnection = YES;
73
+ }
74
+ dispatch_semaphore_signal(semaphore);
75
+ }];
76
+ if (!task) {
77
+ return NO;
78
+ }
79
+ [task resume];
80
+
81
+ dispatch_time_t deadline = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC));
82
+ long waitResult = dispatch_semaphore_wait(semaphore, deadline);
83
+ if (waitResult != 0) {
84
+ [task cancel];
85
+ return NO;
86
+ }
87
+ return isConnection;
88
+ }
89
+
90
+ + (void)updateJsLocationForBundleName:(NSString *)bundleName {
91
+ if (bundleName.length == 0 || ![self checkMetroConnection:bundleName]) {
92
+ return;
93
+ }
94
+ if ([sCurrentJsLocationBundleName isEqualToString:bundleName]) {
95
+ return;
96
+ }
97
+ sCurrentJsLocationBundleName = [bundleName copy];
98
+ [[RCTBundleURLProvider sharedSettings] setJsLocation:[self jsLocationStringForBundleName:bundleName]];
99
+ }
100
+
101
+ + (NSString *)jsLocationStringForBundleName:(NSString *)bundleName {
102
+ NSString *host = [[XTPluginManage shareInstance] getLocalHost];
103
+ NSString *port = [self portForBundleName:bundleName];
104
+ return [NSString stringWithFormat:@"%@:%@", host, port];
105
+ }
106
+
107
+ + (NSString *)portForBundleName:(NSString *)bundleName {
108
+ if (bundleName.length == 0) {
109
+ return @"8081";
110
+ }
111
+ NSArray *bundleList = [[XTJSBundleTool shared] getBundleList];
112
+ for (NSDictionary *bundleInfo in bundleList) {
113
+ if ([bundleInfo[@"bundleName"] isEqualToString:bundleName]) {
114
+ NSString *port = bundleInfo[@"port"];
115
+ if ([port isKindOfClass:[NSString class]] && port.length > 0) {
116
+ return port;
117
+ }
118
+ break;
119
+ }
120
+ }
121
+ return @"8081";
122
+ }
123
+
124
+ @end
@@ -0,0 +1,30 @@
1
+ //
2
+ // XTReloadCommandHelper.h
3
+ // xrngo
4
+ //
5
+
6
+ #import <Foundation/Foundation.h>
7
+
8
+ NS_ASSUME_NONNULL_BEGIN
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ /// Cmd+R / DevMenu reload 前:用当前前台 bundle 的 Metro biz URL 更新 RCTReloadCommand.bundleURL
15
+ void XTReloadCommandUpdateBundleURLFromCurrentContext(void);
16
+
17
+ /// Metro reload 前:只对匹配的 Host 清拆包闸门
18
+ void XTReloadCommandPrepareMatchingHosts(NSURL *_Nullable commandBundleURL);
19
+
20
+ /// 是否应对该 reload listener(RCTHost)执行 reload
21
+ BOOL XTReloadCommandShouldReloadListener(id listener, NSURL *_Nullable commandBundleURL);
22
+
23
+ /// 多 Host 下摇一摇 DevMenu:仅当前前台 Host 的 DevMenu 可弹出
24
+ BOOL XTDevMenuShouldPresentOnShake(id devMenu);
25
+
26
+ #ifdef __cplusplus
27
+ }
28
+ #endif
29
+
30
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,128 @@
1
+ //
2
+ // XTReloadCommandHelper.mm
3
+ // xrngo
4
+ //
5
+
6
+ #import "XTReloadCommandHelper.h"
7
+
8
+ #import <React/RCTReloadCommand.h>
9
+ #import <React/RCTDevMenu.h>
10
+ #import <ReactCommon/RCTHost.h>
11
+ #import <react-native-xrn-multi-bundle/XTMultiBundle.h>
12
+ #import <react-native-xrn-multi-bundle/XTJSBridgeDelegation.h>
13
+ #import "XTJSBundleTool.h"
14
+
15
+ static NSString *XTReloadCommandPortStringFromURL(NSURL *_Nullable url)
16
+ {
17
+ if (!url) {
18
+ return nil;
19
+ }
20
+ if (url.port != nil) {
21
+ return url.port.stringValue;
22
+ }
23
+ NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
24
+ return components.port.stringValue;
25
+ }
26
+
27
+ static NSString *XTReloadCommandPortFromJsLocation(void)
28
+ {
29
+ NSString *jsLocation = [[NSUserDefaults standardUserDefaults] stringForKey:@"RCT_jsLocation"];
30
+ if (jsLocation.length == 0) {
31
+ return nil;
32
+ }
33
+ NSRange colonRange = [jsLocation rangeOfString:@":" options:NSBackwardsSearch];
34
+ if (colonRange.location == NSNotFound) {
35
+ return nil;
36
+ }
37
+ return [jsLocation substringFromIndex:colonRange.location + 1];
38
+ }
39
+
40
+ static NSString *XTReloadCommandTargetPort(NSURL *_Nullable commandBundleURL)
41
+ {
42
+ NSString *port = XTReloadCommandPortStringFromURL(commandBundleURL);
43
+ if (port.length > 0) {
44
+ return port;
45
+ }
46
+ return XTReloadCommandPortFromJsLocation();
47
+ }
48
+
49
+ static XTJSRuntimeContext *_Nullable XTReloadCommandContextForHost(RCTHost *host)
50
+ {
51
+ if (!host) {
52
+ return nil;
53
+ }
54
+ for (XTJSRuntimeContext *context in [[XTJSBridgePool shared] fetchAllRuntimeContext]) {
55
+ if (context.host == host) {
56
+ return context;
57
+ }
58
+ }
59
+ return nil;
60
+ }
61
+
62
+ static BOOL XTReloadCommandShouldReloadContext(XTJSRuntimeContext *context, NSURL *_Nullable commandBundleURL)
63
+ {
64
+ if (!context || !context.host) {
65
+ return NO;
66
+ }
67
+
68
+ NSURL *bizURL = context.bizBundleURL;
69
+ if (!bizURL || bizURL.isFileURL) {
70
+ return NO;
71
+ }
72
+
73
+ NSString *targetPort = XTReloadCommandTargetPort(commandBundleURL);
74
+ NSString *hostPort = XTReloadCommandPortStringFromURL(bizURL);
75
+ if (targetPort.length == 0 || hostPort.length == 0) {
76
+ return NO;
77
+ }
78
+ return [targetPort isEqualToString:hostPort];
79
+ }
80
+
81
+ #ifdef __cplusplus
82
+ extern "C" {
83
+ #endif
84
+
85
+ void XTReloadCommandUpdateBundleURLFromCurrentContext(void)
86
+ {
87
+ XTJSRuntimeContext *context = [[XTJSBundleTool shared] fetchCurrentContext];
88
+ NSURL *bizURL = context.bizBundleURL;
89
+ if (bizURL && !bizURL.isFileURL) {
90
+ RCTReloadCommandSetBundleURL(bizURL);
91
+ }
92
+ }
93
+
94
+ void XTReloadCommandPrepareMatchingHosts(NSURL *_Nullable commandBundleURL)
95
+ {
96
+ for (XTJSRuntimeContext *context in [[XTJSBridgePool shared] fetchAllRuntimeContext]) {
97
+ if (!XTReloadCommandShouldReloadContext(context, commandBundleURL)) {
98
+ continue;
99
+ }
100
+ XTJSBridgeDelegation *delegation = [[XTJSBridgePool shared] delegationForContext:context];
101
+ [delegation prepareForHostReload];
102
+ }
103
+ }
104
+
105
+ BOOL XTReloadCommandShouldReloadListener(id listener, NSURL *_Nullable commandBundleURL)
106
+ {
107
+ if (![listener isKindOfClass:[RCTHost class]]) {
108
+ return YES;
109
+ }
110
+ return XTReloadCommandShouldReloadContext(XTReloadCommandContextForHost((RCTHost *)listener), commandBundleURL);
111
+ }
112
+
113
+ BOOL XTDevMenuShouldPresentOnShake(id devMenu)
114
+ {
115
+ if (!devMenu) {
116
+ return NO;
117
+ }
118
+ XTJSRuntimeContext *context = [[XTJSBundleTool shared] fetchCurrentContext];
119
+ if (!context) {
120
+ return NO;
121
+ }
122
+ id currentDevMenu = [context moduleForClass:[RCTDevMenu class]];
123
+ return currentDevMenu == devMenu;
124
+ }
125
+
126
+ #ifdef __cplusplus
127
+ }
128
+ #endif
@@ -7,6 +7,7 @@
7
7
  //
8
8
 
9
9
  import Foundation
10
+ import XRNDebugTools
10
11
 
11
12
  #if DEBUG
12
13
  import swiftScan
@@ -56,7 +57,7 @@ extension XTScanQRPlugin: LBXScanViewControllerDelegate {
56
57
  UserDefaults.standard.setValue(ipAddress, forKey: "RCT_jsLocation")
57
58
  UserDefaults.standard.synchronize()
58
59
 
59
- let bundles = XTJSBundleTool.shared().getAllBundleInfo()
60
+ let bundles = XTJSBundleTool.shared().getBundleList()
60
61
  var bundleName = ""
61
62
  for bundle in bundles {
62
63
  if let bundleDict = bundle as? [String: Any] {
@@ -69,11 +70,15 @@ extension XTScanQRPlugin: LBXScanViewControllerDelegate {
69
70
  }
70
71
  }
71
72
  if !bundleName.isEmpty {
72
- UserDefaults.standard.set("1", forKey: "\(bundleName)-debug")
73
- UserDefaults.standard.synchronize()
73
+ var debugInfo = XTDebugStatus.shared.getDebugInfo(bundleName)
74
+ debugInfo["enableDebug"] = "1"
75
+ XTDebugStatus.shared.saveDebugInfo(bundleName, debugInfo: debugInfo)
74
76
  }
75
-
77
+
76
78
  XRNToastView.shared().showToast("ip地址绑定成功,重启APP生效!", duration: 3)
79
+ DispatchQueue.main.asyncAfter(deadline: .now() + 2.8) {
80
+ NotificationCenter.default.post(name: UIApplication.willTerminateNotification, object: nil)
81
+ }
77
82
  DispatchQueue.main.asyncAfter(deadline: .now() + 3.0) {
78
83
  exit(0)
79
84
  }
@@ -1,8 +1,8 @@
1
- #import <React/RCTBridgeDelegate.h>
1
+ #import <RCTAppDelegate.h>
2
2
  #import <UIKit/UIKit.h>
3
3
 
4
- @interface AppDelegate : UIResponder <UIApplicationDelegate>
4
+ @interface AppDelegate : RCTAppDelegate
5
5
 
6
6
  @property (nonatomic, copy) NSDictionary *launchOpptions;
7
- @property (nonatomic, strong) UIWindow *window;
7
+
8
8
  @end
@@ -1,15 +1,15 @@
1
1
  #import "AppDelegate.h"
2
2
 
3
3
  #import <React/RCTBridge.h>
4
- #import <React/RCTBundleURLProvider.h>
5
- #import <React/RCTRootView.h>
6
- #import <React/RCTDevSettings.h>
4
+ #import <React/RCTUtils.h>
5
+ #import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
6
+ #import <React/RCTComponentViewFactory.h>
7
+ #import <React/RCTColorSpaceUtils.h>
8
+ #import <react/featureflags/ReactNativeFeatureFlags.h>
9
+ #import <react/featureflags/ReactNativeFeatureFlagsDefaults.h>
7
10
 
8
11
  #import "XRNTemplate-Swift.h"
9
- #import "XTMultiBundleManager.h"
10
12
  #import "XTPluginManage.h"
11
- #import <CodePush/CodePush.h>
12
- #import "XTBundleViewController.h"
13
13
  #import "XTJSBundleTool.h"
14
14
  #import "XTMainBundleViewController.h"
15
15
  #import "XTNavigationViewController.h"
@@ -18,26 +18,18 @@
18
18
  #import "XTBundleProvider.h"
19
19
  #import "XTBundleViewControllerFactory.h"
20
20
 
21
- #if RCT_NEW_ARCH_ENABLED
22
- #import <React/CoreModulesPlugins.h>
23
- #import <React/RCTCxxBridgeDelegate.h>
24
- #import <React/RCTFabricSurfaceHostingProxyRootView.h>
25
- #import <React/RCTSurfacePresenter.h>
26
- #import <React/RCTSurfacePresenterBridgeAdapter.h>
27
- #import <ReactCommon/RCTTurboModuleManager.h>
21
+ namespace {
28
22
 
29
- #import <react/config/ReactNativeConfig.h>
23
+ class XTBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
24
+ public:
25
+ bool enableBridgelessArchitecture() override { return true; }
26
+ bool enableFabricRenderer() override { return true; }
27
+ bool useTurboModules() override { return true; }
28
+ bool useNativeViewConfigsInBridgelessMode() override { return true; }
29
+ bool enableFixForViewCommandRace() override { return true; }
30
+ };
30
31
 
31
- static NSString *const kRNConcurrentRoot = @"concurrentRoot";
32
-
33
- @interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
34
- RCTTurboModuleManager *_turboModuleManager;
35
- RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
36
- std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
37
- facebook::react::ContextContainer::Shared _contextContainer;
38
- }
39
- @end
40
- #endif
32
+ } // namespace
41
33
 
42
34
  @interface AppDelegate ()<XTMultiBundleDataSource>
43
35
 
@@ -48,40 +40,37 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
48
40
 
49
41
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
50
42
  {
51
- // RCTAppSetupPrepareApp(application);
52
-
43
+ self.automaticallyLoadReactNativeWindow = NO;
44
+ RCTEnableTurboModule(YES);
45
+ RCTSetNewArchEnabled(YES);
46
+ // Host 路径未走 RCTAppDelegate._setUpFeatureFlags,须手动开启 ViewConfig interop,
47
+ // 否则 BridgelessUIManager.getViewManagerConfig 不可用(gesture-handler / navigation 等报错)。
48
+ facebook::react::ReactNativeFeatureFlags::override(std::make_unique<XTBridgelessFeatureFlags>());
49
+ self.initialProps = @{};
50
+ self.dependencyProvider = [RCTAppDependencyProvider new];
51
+ [RCTColorSpaceUtils applyDefaultColorSpace:self.defaultColorSpace];
52
+ [RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider = (id)self;
53
+
53
54
  self.launchOpptions = launchOptions;
54
-
55
+
55
56
  [XTMultiBundleManager shared].dataSource = self;
56
57
  [[XTMultiBundleManager shared] startUp];
57
-
58
+
58
59
  [self loadMainVC];
59
-
60
+
60
61
  [[XTPluginManage shareInstance] addSuspendBallToWindow];
61
62
  return YES;
62
63
  }
63
64
 
64
- -(void)loadMainVC {
65
-
66
- RCTBridge *mainBridge = [XTMultiBundleManager.shared.pool fetchJSBridgeWithJSBundleName:[[XTJSBundleTool shared] getMainBundleName]];
67
- RCTDevSettings *decSetting = [mainBridge moduleForClass:[RCTDevSettings class]];
68
- decSetting.isShakeToShowDevMenuEnabled = NO;
69
-
65
+ - (void)loadMainVC {
66
+ XTJSRuntimeContext *mainContext = [XTMultiBundleManager.shared.pool fetchContextWithJSBundleName:[[XTJSBundleTool shared] getMainBundleName]];
70
67
  NSString *mainModuleName = [XTMultiBundleManager.shared.pool fetchDefaultModuleNameWithJSBundleName:[[XTJSBundleTool shared] getMainBundleName]];
71
-
72
- #if RCT_NEW_ARCH_ENABLED
73
- _contextContainer = std::make_shared<facebook::react::ContextContainer const>();
74
- _reactNativeConfig = std::make_shared<facebook::react::EmptyReactNativeConfig const>();
75
- _contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
76
- _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer];
77
- bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
78
- #endif
79
-
68
+
80
69
  XTBundleViewControllerFactory *bundleVCfactory = [[XTBundleViewControllerFactory alloc] init];
81
70
  [XTNativeRouterManager shared].bundleVCFactory = bundleVCfactory;
82
- XTMainBundleViewController *rootViewController = [[XTMainBundleViewController alloc] initWithBridge:mainBridge moduleName:mainModuleName initialProperties:self.launchOption];
71
+ XTMainBundleViewController *rootViewController = [[XTMainBundleViewController alloc] initWithRuntimeContext:mainContext moduleName:mainModuleName initialProperties:self.launchOption];
83
72
  rootViewController.view.backgroundColor = [UIColor whiteColor];
84
-
73
+
85
74
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
86
75
  XTNavigationViewController *nav = [[XTNavigationViewController alloc] initWithRootViewController:rootViewController];
87
76
  self.window.rootViewController = nav;
@@ -89,24 +78,24 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
89
78
  }
90
79
 
91
80
  - (NSArray <XTBundleData *>*_Nonnull)multiBundleForBundleModelArray {
92
-
81
+
93
82
  NSMutableArray <XTBundleData *>*bundleDataArray = [NSMutableArray arrayWithCapacity:10];
94
-
83
+
95
84
  NSString *mainDeploymentKey = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CodePushDeploymentKey"];
96
85
  NSString *mainBundleName = [XTJSBundleTool.shared getMainBundleName];
97
86
  NSString *mainModuleName = mainBundleName;
98
-
87
+
99
88
  XTBundleProvider *mainBundleProvider = [[XTBundleProvider alloc] init];
100
89
  XTBundleData *mainBundleData = [[XTBundleData alloc] initWithJSBundleName:mainBundleName moduleName:mainModuleName codePushKey:mainDeploymentKey portNum:[XTJSBundleTool.shared getMainBundlePort] isMain:YES provider:mainBundleProvider];
101
90
  [bundleDataArray addObject:mainBundleData];
102
-
91
+
103
92
  NSArray *xtBundlesArray = [XTJSBundleTool.shared getAllSubBundles];
104
93
  for (NSDictionary *obj in xtBundlesArray) {
105
94
  XTBundleProvider *bundleProvider = [[XTBundleProvider alloc] init];
106
95
  XTBundleData *bundleData = [[XTBundleData alloc] initWithJSBundleName:obj[@"jsBundleName"] moduleName:obj[@"jsBundleName"] codePushKey:obj[@"codePushKey"] portNum:obj[@"port"] isMain:NO provider:bundleProvider];
107
96
  [bundleDataArray addObject:bundleData];
108
97
  }
109
-
98
+
110
99
  return bundleDataArray;
111
100
  }
112
101
 
@@ -114,55 +103,4 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
114
103
  return self.launchOption;
115
104
  }
116
105
 
117
- /// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
118
- ///
119
- /// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
120
- /// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
121
- /// @return: `true` if the `concurrentRoot` feture is enabled. Otherwise, it returns `false`.
122
- - (BOOL)concurrentRootEnabled
123
- {
124
- // Switch this bool to turn on and off the concurrent root
125
- return true;
126
- }
127
-
128
- #if RCT_NEW_ARCH_ENABLED
129
-
130
- #pragma mark - RCTCxxBridgeDelegate
131
-
132
- - (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
133
- {
134
- _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
135
- delegate:self
136
- jsInvoker:bridge.jsCallInvoker];
137
- return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
138
- }
139
-
140
- #pragma mark RCTTurboModuleManagerDelegate
141
-
142
- - (Class)getModuleClassFromName:(const char *)name
143
- {
144
- return RCTCoreModulesClassProvider(name);
145
- }
146
-
147
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
148
- jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)jsInvoker
149
- {
150
- return nullptr;
151
- }
152
-
153
- - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
154
- initParams:
155
- (const facebook::react::ObjCTurboModule::InitParams &)params
156
- {
157
- return nullptr;
158
- }
159
-
160
- - (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
161
- {
162
- return RCTAppSetupDefaultModuleFromClass(moduleClass);
163
- }
164
-
165
- #endif
166
-
167
-
168
106
  @end
@@ -5,7 +5,7 @@
5
5
  <key>CFBundleDevelopmentRegion</key>
6
6
  <string>zh_CN</string>
7
7
  <key>CFBundleDisplayName</key>
8
- <string>XRNTemplate</string>
8
+ <string>$(DISPLAY_NAME)</string>
9
9
  <key>CFBundleExecutable</key>
10
10
  <string>$(EXECUTABLE_NAME)</string>
11
11
  <key>CFBundleIdentifier</key>
@@ -17,7 +17,7 @@
17
17
  <key>CFBundlePackageType</key>
18
18
  <string>APPL</string>
19
19
  <key>CFBundleShortVersionString</key>
20
- <string>$(MARKETING_VERSION)</string>
20
+ <string>1.0</string>
21
21
  <key>CFBundleSignature</key>
22
22
  <string>????</string>
23
23
  <key>CFBundleURLTypes</key>
@@ -34,11 +34,11 @@
34
34
  </dict>
35
35
  </array>
36
36
  <key>CFBundleVersion</key>
37
- <string>20250818104225</string>
37
+ <string>20260915164625</string>
38
38
  <key>CodePushDeploymentKey</key>
39
39
  <string>$(MAIN_CODEPUSH_KEY)</string>
40
40
  <key>CodePushServerURL</key>
41
- <string>http://xxxcodepush.cn</string>
41
+ <string>undefined</string>
42
42
  <key>CommonBundleName</key>
43
43
  <string>xt-app-common</string>
44
44
  <key>LSRequiresIPhoneOS</key>
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>NSPrivacyAccessedAPITypes</key>
6
+ <array>
7
+ <dict>
8
+ <key>NSPrivacyAccessedAPIType</key>
9
+ <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
10
+ <key>NSPrivacyAccessedAPITypeReasons</key>
11
+ <array>
12
+ <string>CA92.1</string>
13
+ </array>
14
+ </dict>
15
+ <dict>
16
+ <key>NSPrivacyAccessedAPIType</key>
17
+ <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
18
+ <key>NSPrivacyAccessedAPITypeReasons</key>
19
+ <array>
20
+ <string>C617.1</string>
21
+ <string>0A2A.1</string>
22
+ <string>3B52.1</string>
23
+ </array>
24
+ </dict>
25
+ <dict>
26
+ <key>NSPrivacyAccessedAPIType</key>
27
+ <string>NSPrivacyAccessedAPICategorySystemBootTime</string>
28
+ <key>NSPrivacyAccessedAPITypeReasons</key>
29
+ <array>
30
+ <string>35F9.1</string>
31
+ </array>
32
+ </dict>
33
+ <dict>
34
+ <key>NSPrivacyAccessedAPIType</key>
35
+ <string>NSPrivacyAccessedAPICategoryDiskSpace</string>
36
+ <key>NSPrivacyAccessedAPITypeReasons</key>
37
+ <array>
38
+ <string>85F4.1</string>
39
+ <string>E174.1</string>
40
+ </array>
41
+ </dict>
42
+ </array>
43
+ <key>NSPrivacyCollectedDataTypes</key>
44
+ <array/>
45
+ <key>NSPrivacyTracking</key>
46
+ <false/>
47
+ </dict>
48
+ </plist>
@@ -16,6 +16,7 @@
16
16
 
17
17
  #import "RNCConfig.h"
18
18
  #import "XTJSBundleTool.h"
19
+ #import <Sentry/Sentry.h>
19
20
  #import "BundleNavigation.h"
20
21
  #import "XTNativeRouterManager.h"
21
22
  #import "XTMainBundleViewController.h"
@@ -23,7 +24,7 @@
23
24
  #import "XTPluginManage.h"
24
25
  #import <RNDeviceInfo/DeviceUID.h>
25
26
  #import "XRNToastView.h"
26
- #import "RCTBridge+XTExtension.h"
27
27
  #import "XTMultiBundleManager.h"
28
+ #import <react-native-xrn-multi-bundle/XTJSRuntimeContext.h>
28
29
 
29
30
  #endif /* XRNTemplate_Bridging_Header__h */