@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.
- package/$package.json +30 -36
- package/android/app/build.gradle +56 -73
- package/android/app/src/debug/java/com/xrn/template/ReactNativeFlipper.java +23 -44
- package/android/app/src/main/assets/xrn-manifest.json +1 -1
- package/android/app/src/main/java/com/xrn/template/MainApplication.kt +54 -65
- package/android/app/src/main/java/com/xrn/template/multibundle/CodePushBundleActivity.kt +65 -0
- package/android/app/src/main/java/com/xrn/template/multibundle/CodePushJSBundleLoader.kt +18 -0
- package/android/app/src/main/java/com/xrn/template/multibundle/CodePushUtils.kt +263 -0
- package/android/app/src/main/java/com/xrn/template/multibundle/XBundleTool.kt +9 -0
- package/android/app/src/main/java/com/xrn/template/multibundle/XRNReactHostDelegate.kt +56 -0
- package/android/app/src/main/java/com/xrn/template/navigation/XBundleActivity.kt +10 -7
- package/android/app/src/main/res/raw/bundle_config.json +2 -6
- package/android/build.gradle +40 -39
- package/android/buildSrc/build.gradle.kts +15 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +3 -1
- package/android/gradle.properties +17 -10
- package/android/settings.gradle +40 -12
- package/harmony/.clang-tidy +1 -1
- package/harmony/.clangd +3 -1
- package/harmony/AppScope/app.json5 +1 -1
- package/harmony/build-profile.json5 +8 -8
- package/harmony/entry/oh-package-lock.json5 +283 -262
- package/harmony/entry/oh-package.json5 +35 -36
- package/harmony/entry/src/main/cpp/CMakeLists.txt +37 -17
- package/harmony/entry/src/main/cpp/PackageProvider.cpp +20 -2
- package/harmony/entry/src/main/cpp/generated/BundleNavigation.cpp +3 -0
- package/harmony/entry/src/main/cpp/generated/RNOHGeneratedPackage.h +31 -87
- package/harmony/entry/src/main/cpp/generated/RTNCodePush.cpp +7 -1
- package/harmony/entry/src/main/cpp/generated/XRNBundleModule.cpp +9 -0
- package/harmony/entry/src/main/cpp/generated/XRNDebugToolsModule.cpp +10 -0
- package/harmony/entry/src/main/cpp/generated/{ImageResizer.cpp → XRNImageView.cpp} +6 -3
- package/harmony/entry/src/main/cpp/generated/{ImageResizer.h → XRNImageView.h} +2 -2
- package/harmony/entry/src/main/cpp/generated/{RNCWebViewComponentDescriptor.h → XRNImageViewComponentDescriptor.h} +11 -10
- package/harmony/entry/src/main/cpp/generated/XRNImageViewJSIBinder.h +58 -0
- package/harmony/entry/src/main/cpp/generated/XRNKeyboard.cpp +23 -0
- package/harmony/entry/src/main/cpp/generated/{RNLocalize.h → XRNKeyboard.h} +2 -2
- package/harmony/entry/src/main/cpp/generated/XRNNavigation.cpp +5 -0
- package/harmony/entry/src/main/cpp/generated/{RNCWebViewModule.cpp → XRNNetworkModule.cpp} +2 -4
- package/harmony/entry/src/main/cpp/generated/{RNCWebViewModule.h → XRNNetworkModule.h} +2 -2
- package/harmony/entry/src/main/ets/BundleHelper.ets +41 -45
- package/harmony/entry/src/main/ets/MainAbilityStage.ets +9 -4
- package/harmony/entry/src/main/ets/entryability/EntryAbility.ets +1 -1
- package/harmony/entry/src/main/ets/navDestination/BizModuleContainer.ets +2 -2
- package/harmony/entry/src/main/ets/navDestination/MainModuleContainer.ets +2 -2
- package/harmony/entry/src/main/ets/navDestination/Splash.ets +1 -2
- package/harmony/entry/src/main/ets/pages/Index.ets +4 -4
- package/harmony/entry/src/main/resources/rawfile/bundle_config.json5 +2 -6
- package/harmony/entry/src/main/resources/rawfile/xrn-manifest.json +1 -0
- package/harmony/oh-package-lock.json5 +2 -1
- package/harmony/oh-package.json5 +12 -4
- package/index.ts +0 -0
- package/ios/BundleEventCenter/Hooks/XRNCustomKeyborad+XTHooks.h +16 -0
- package/ios/BundleEventCenter/Hooks/XRNCustomKeyborad+XTHooks.mm +40 -0
- package/ios/BundleEventCenter/Hooks/XTIQKeyboardManagerBridge.h +15 -0
- package/ios/BundleEventCenter/Hooks/XTIQKeyboardManagerBridge.m +22 -0
- package/ios/BundleEventCenter/XTBundleProvider.m +98 -72
- package/ios/BundleEventCenter/XTBundleViewControllerFactory.m +4 -15
- package/ios/BundleEventCenter/bundleController/XTBundleViewController.mm +43 -0
- package/ios/BundleEventCenter/bundleController/XTMainBundleViewController.mm +48 -0
- package/ios/BundleEventCenter/bundleController/xtBundles.plist +1 -1
- package/ios/Podfile +234 -151
- package/ios/Podfile.lock +2810 -594
- package/ios/RNDebug/DebugPlugin/XTPluginManage.m +5 -5
- package/ios/RNDebug/MotroTools/XTMetroAutoConnector.h +21 -0
- package/ios/RNDebug/MotroTools/XTMetroAutoConnector.m +124 -0
- package/ios/RNDebug/MotroTools/XTReloadCommandHelper.h +30 -0
- package/ios/RNDebug/MotroTools/XTReloadCommandHelper.mm +128 -0
- package/ios/RNDebug/Views/XTScanQRPlugin.swift +9 -4
- package/ios/XRNTemplate/AppDelegate.h +3 -3
- package/ios/XRNTemplate/AppDelegate.mm +40 -102
- package/ios/XRNTemplate/Info.plist +4 -4
- package/ios/XRNTemplate/PrivacyInfo.xcprivacy +48 -0
- package/ios/XRNTemplate-Bridging-Header.h +2 -1
- package/ios/XRNTemplate.xcodeproj/project.pbxproj +68 -77
- package/ios/ios_patches/fixed_glog_config.h +195 -0
- package/ios/ios_patches/xt_IQKeyboardManager+Position.swift +1341 -0
- package/ios/ios_patches/xt_IQKeyboardManager.swift +454 -0
- package/ios/subBundles/.gitkeep +0 -0
- package/main-bundle/babel.config.js +2 -2
- package/main-bundle/package.json +11 -20
- package/main-bundle/yarn.lock +14655 -9651
- package/metro.config.js +21 -0
- package/package.json +2 -2
- package/react-native.config.js +3 -45
- package/src/.gitkeep +0 -0
- package/sub-bundle/babel.config.js +2 -2
- package/sub-bundle/package.json +11 -20
- package/sub-bundle/react-native.config.js +4 -0
- package/sub-bundle/yarn.lock +14655 -9651
- package/xrn.config.json +12 -12
- package/android/app/src/main/java/com/xrn/template/multibundle/XDevSupportParams.kt +0 -6
- package/android/app/src/main/java/com/xrn/template/multibundle/XRNHostParams.kt +0 -82
- package/harmony/entry/src/main/cpp/generated/ConfigNativeModule.cpp +0 -21
- package/harmony/entry/src/main/cpp/generated/ConfigNativeModule.h +0 -21
- package/harmony/entry/src/main/cpp/generated/GetRandomValuesNativeModule.cpp +0 -21
- package/harmony/entry/src/main/cpp/generated/GetRandomValuesNativeModule.h +0 -21
- package/harmony/entry/src/main/cpp/generated/NativeHarmonyTouchId.cpp +0 -22
- package/harmony/entry/src/main/cpp/generated/NativeHarmonyTouchId.h +0 -21
- package/harmony/entry/src/main/cpp/generated/OreitationLockerNativeModule.cpp +0 -31
- package/harmony/entry/src/main/cpp/generated/OreitationLockerNativeModule.h +0 -21
- package/harmony/entry/src/main/cpp/generated/RNCCameraRoll.cpp +0 -28
- package/harmony/entry/src/main/cpp/generated/RNCCameraRoll.h +0 -21
- package/harmony/entry/src/main/cpp/generated/RNCCameraRollPermission.cpp +0 -26
- package/harmony/entry/src/main/cpp/generated/RNCCameraRollPermission.h +0 -21
- package/harmony/entry/src/main/cpp/generated/RNCWebViewJSIBinder.h +0 -120
- package/harmony/entry/src/main/cpp/generated/RNDeviceInfo.cpp +0 -164
- package/harmony/entry/src/main/cpp/generated/RNDeviceInfo.h +0 -21
- package/harmony/entry/src/main/cpp/generated/RNDocumentPicker.cpp +0 -24
- package/harmony/entry/src/main/cpp/generated/RNDocumentPicker.h +0 -21
- package/harmony/entry/src/main/cpp/generated/RNGestureHandlerButtonComponentDescriptor.h +0 -43
- package/harmony/entry/src/main/cpp/generated/RNGestureHandlerButtonJSIBinder.h +0 -38
- package/harmony/entry/src/main/cpp/generated/RNGestureHandlerModule.cpp +0 -28
- package/harmony/entry/src/main/cpp/generated/RNGestureHandlerModule.h +0 -21
- package/harmony/entry/src/main/cpp/generated/RNGestureHandlerRootViewComponentDescriptor.h +0 -43
- package/harmony/entry/src/main/cpp/generated/RNGestureHandlerRootViewJSIBinder.h +0 -31
- package/harmony/entry/src/main/cpp/generated/RNLocalize.cpp +0 -31
- package/harmony/entry/src/main/cpp/generated/ReactNativeBlobUtil.cpp +0 -51
- package/harmony/entry/src/main/cpp/generated/ReactNativeBlobUtil.h +0 -21
- package/harmony/entry/src/main/cpp/generated/XRNAssetLoaderModule.cpp +0 -21
- package/harmony/entry/src/main/cpp/generated/XRNAssetLoaderModule.h +0 -21
- package/harmony/entry/src/main/cpp/generated/XRNFileModule.cpp +0 -22
- package/harmony/entry/src/main/cpp/generated/XRNFileModule.h +0 -21
- package/ios/BundleEventCenter/bundleController/XTBundleViewController.m +0 -35
- package/ios/BundleEventCenter/bundleController/XTMainBundleViewController.m +0 -41
|
@@ -7,121 +7,147 @@
|
|
|
7
7
|
|
|
8
8
|
#import "XTBundleProvider.h"
|
|
9
9
|
#import <CodePush/CodePush.h>
|
|
10
|
-
#import "XTJSBundleModel.h"
|
|
11
10
|
#import "XTJSBundleTool.h"
|
|
12
|
-
#import "RCTBridge+XTExtension.h"
|
|
13
11
|
#import "XRNTemplate-Swift.h"
|
|
14
12
|
#import "XTPluginManage.h"
|
|
15
13
|
|
|
14
|
+
#if DEBUG
|
|
15
|
+
#import "XTMetroAutoConnector.h"
|
|
16
|
+
#import <React/RCTBundleURLProvider.h>
|
|
17
|
+
#import <React/RCTInspectorDevServerHelper.h>
|
|
18
|
+
#endif
|
|
19
|
+
|
|
16
20
|
@interface XTBundleProvider ()
|
|
17
21
|
|
|
18
22
|
@property (nonatomic, weak) XTBundleData *bundleData;
|
|
19
23
|
@property (strong, nonatomic) CodePush *codePush;
|
|
20
24
|
@property (strong, nonatomic) NSURL *bizBundleURL;
|
|
25
|
+
@property (assign, nonatomic) BOOL bizBundleLoadStarted;
|
|
21
26
|
|
|
22
27
|
#if DEBUG
|
|
23
28
|
@property (assign, nonatomic) BOOL isDebug;
|
|
29
|
+
- (BOOL)resolveMetroDebugForBundleData:(XTBundleData *)bundleData context:(XTJSRuntimeContext *)context;
|
|
30
|
+
- (void)attachMetroPackagerConnectionForContext:(XTJSRuntimeContext *)context bundleData:(XTBundleData *)bundleData;
|
|
24
31
|
#endif
|
|
32
|
+
|
|
25
33
|
@end
|
|
26
34
|
|
|
27
35
|
@implementation XTBundleProvider
|
|
28
36
|
|
|
29
|
-
- (
|
|
30
|
-
|
|
31
|
-
if (self) {
|
|
32
|
-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didLoadJS:) name:RCTJavaScriptDidLoadNotification object:nil];
|
|
33
|
-
}
|
|
34
|
-
return self;
|
|
37
|
+
- (NSURL *)commonBundleURL {
|
|
38
|
+
return [[NSBundle mainBundle] URLForResource:[XTJSBundleTool.shared getCommonBundleName] withExtension:@"jsbundle"];
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
- (
|
|
38
|
-
|
|
41
|
+
- (NSURL *)embeddedBizBundleURL:(XTBundleData *)bundleData {
|
|
42
|
+
NSURL *url = [self.codePush bundleURLForResource:bundleData.jsBundleName];
|
|
43
|
+
if (!url) {
|
|
44
|
+
url = [[NSBundle mainBundle] URLForResource:bundleData.jsBundleName withExtension:@"jsbundle"];
|
|
45
|
+
}
|
|
46
|
+
return url;
|
|
39
47
|
}
|
|
40
48
|
|
|
49
|
+
#pragma mark -- Metro(仅 DEBUG;能力对齐主工程)
|
|
50
|
+
#if DEBUG
|
|
51
|
+
- (BOOL)resolveMetroDebugForBundleData:(XTBundleData *)bundleData context:(XTJSRuntimeContext *)context {
|
|
52
|
+
self.isDebug = NO;
|
|
53
|
+
BOOL enableDebug = [XTMetroAutoConnector checkMetroConnection:bundleData.jsBundleName];
|
|
54
|
+
if (!enableDebug) {
|
|
55
|
+
return NO;
|
|
56
|
+
}
|
|
57
|
+
self.isDebug = YES;
|
|
58
|
+
|
|
59
|
+
NSString *host = [[XTPluginManage shareInstance] getLocalHost];
|
|
60
|
+
NSString *port = bundleData.portNum.length > 0 ? bundleData.portNum : [XTJSBundleTool.shared getMainBundlePort];
|
|
61
|
+
// 不走拆包:Metro 可达时直接加载全量业务包
|
|
62
|
+
NSURL *bundleUrl = [NSURL URLWithString:[NSString stringWithFormat:
|
|
63
|
+
@"http://%@:%@/index.bundle?platform=ios&dev=true&lazy=false&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&excludeSource=true&sourcePaths=url-server&app=XRNTemplate&port=%@",
|
|
64
|
+
host, port, port]];
|
|
65
|
+
self.bizBundleURL = bundleUrl;
|
|
66
|
+
context.bizBundleURL = bundleUrl;
|
|
67
|
+
NSLog(@"[XTBundleProvider] Host Debug Metro 全量包(%@):%@", bundleData.jsBundleName, bundleUrl);
|
|
68
|
+
return YES;
|
|
69
|
+
}
|
|
41
70
|
|
|
42
|
-
- (void)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// [bridge loadAndExecuteSplitBundleURL:bizBundleURL onError:^(NSError *error) {
|
|
52
|
-
// NSLog(@"🐯 error---%@", error);
|
|
53
|
-
// [[XTPluginManage shareInstance] pushJSErrorTipPanel:bridge.xt_jsBundleName];
|
|
54
|
-
// } onComplete:^{
|
|
55
|
-
// NSLog(@"🐯 complete---");
|
|
56
|
-
// }];
|
|
57
|
-
// #else
|
|
58
|
-
// NSData *subBundleData = [NSData dataWithContentsOfURL:bizBundleURL];
|
|
59
|
-
// [bridge.batchedBridge executeSourceCode:subBundleData withSourceURL:bizBundleURL sync:NO];
|
|
60
|
-
// #endif
|
|
61
|
-
// }
|
|
71
|
+
- (void)attachMetroPackagerConnectionForContext:(XTJSRuntimeContext *)context bundleData:(XTBundleData *)bundleData {
|
|
72
|
+
NSURL *metroURL = context.bizBundleURL ?: self.bizBundleURL;
|
|
73
|
+
if (!metroURL || metroURL.isFileURL || !context.host) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
[RCTInspectorDevServerHelper connectWithBundleURL:metroURL];
|
|
77
|
+
NSString *hostStr = [[XTPluginManage shareInstance] getLocalHost];
|
|
78
|
+
if (hostStr.length > 0 && bundleData.portNum.length > 0) {
|
|
79
|
+
[[RCTBundleURLProvider sharedSettings] setJsLocation:[NSString stringWithFormat:@"%@:%@", hostStr, bundleData.portNum]];
|
|
62
80
|
}
|
|
81
|
+
NSLog(@"[XTBundleProvider] Host Metro packager 已注册:%@ port=%@ url=%@", bundleData.jsBundleName, bundleData.portNum, metroURL);
|
|
63
82
|
}
|
|
83
|
+
#endif
|
|
64
84
|
|
|
85
|
+
/// RCTHost.start 会先调一次 BundleURLProvider,随后 Instance 再 load 时又会走 Delegation.resolve。
|
|
86
|
+
- (BOOL)isIdempotentBundleURLResolveForContext:(XTJSRuntimeContext *)context bundleData:(XTBundleData *)bundleData {
|
|
87
|
+
return context.providerCodePush != nil && self.codePush == context.providerCodePush;
|
|
88
|
+
}
|
|
65
89
|
|
|
66
|
-
|
|
67
|
-
/// - Parameters:
|
|
68
|
-
/// - bridge: bridge description
|
|
69
|
-
/// - bundleData: bundleData description
|
|
70
|
-
- (NSURL *_Nonnull)sourceURLForBridge:(RCTBridge *_Nonnull)bridge bundleData:(XTBundleData *_Nonnull)bundleData {
|
|
90
|
+
- (NSURL *_Nonnull)bundleURLForContext:(XTJSRuntimeContext *_Nonnull)context bundleData:(XTBundleData *_Nonnull)bundleData {
|
|
71
91
|
self.bundleData = bundleData;
|
|
72
|
-
|
|
92
|
+
|
|
93
|
+
if ([self isIdempotentBundleURLResolveForContext:context bundleData:bundleData]) {
|
|
94
|
+
// 不走拆包:幂等二次解析仍返回业务包
|
|
95
|
+
return self.bizBundleURL ?: context.bizBundleURL;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
self.bizBundleLoadStarted = NO;
|
|
99
|
+
|
|
73
100
|
NSString *deploymentKey = bundleData.codePushKey;
|
|
74
101
|
NSString *localCodePsuhKey = [[XTPluginManage shareInstance] getLocalCodePushKey:bundleData.jsBundleName];
|
|
75
102
|
deploymentKey = localCodePsuhKey ?: deploymentKey;
|
|
76
|
-
|
|
103
|
+
|
|
77
104
|
#if DEBUG
|
|
78
105
|
deploymentKey = @"";
|
|
79
106
|
#endif
|
|
80
|
-
|
|
81
|
-
self.codePush = [[CodePush alloc] initWithDeploymentKey:deploymentKey];
|
|
82
|
-
|
|
83
|
-
|
|
107
|
+
|
|
108
|
+
self.codePush = [[CodePush alloc] initWithDeploymentKey:deploymentKey isPreDownload:NO];
|
|
109
|
+
context.providerCodePush = self.codePush;
|
|
110
|
+
|
|
111
|
+
NSURL *bizBundleURL = [self embeddedBizBundleURL:bundleData];
|
|
84
112
|
self.bizBundleURL = bizBundleURL;
|
|
113
|
+
context.bizBundleURL = bizBundleURL;
|
|
114
|
+
|
|
85
115
|
#if DEBUG
|
|
86
|
-
self
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
self.isDebug = [localBundleDebug boolValue];
|
|
116
|
+
if ([self resolveMetroDebugForBundleData:bundleData context:context]) {
|
|
117
|
+
// Metro 可达:直接加载全量业务包
|
|
118
|
+
return self.bizBundleURL;
|
|
90
119
|
}
|
|
91
|
-
|
|
120
|
+
#endif
|
|
121
|
+
|
|
122
|
+
// Debug(Metro 不可达)/ Release:不走 common 拆包,直接加载本地业务包
|
|
123
|
+
NSAssert(self.bizBundleURL != nil, @"Host: missing biz jsbundle %@", bundleData.jsBundleName);
|
|
124
|
+
return self.bizBundleURL;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (BOOL)shouldLoadBizForContext:(XTJSRuntimeContext *)context bundleData:(XTBundleData *)bundleData preLoadCommon:(BOOL)preLoadCommon {
|
|
128
|
+
// 首包已是全量业务包,不再二次 load biz
|
|
129
|
+
return NO;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
- (NSURL *)bizBundleURLForContext:(XTJSRuntimeContext *)context bundleData:(XTBundleData *)bundleData preLoadCommon:(BOOL)preLoadCommon {
|
|
133
|
+
// 不走拆包,无二次 biz 加载
|
|
134
|
+
return nil;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
#if DEBUG
|
|
138
|
+
- (void)hostContextDidLoadBiz:(XTJSRuntimeContext *)context bundleData:(XTBundleData *)bundleData {
|
|
92
139
|
if (self.isDebug) {
|
|
93
|
-
|
|
94
|
-
NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
|
|
95
|
-
NSString *appVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
|
|
96
|
-
NSString *appVersionParam = supportCommon ? [NSString stringWithFormat:@"&appVersion=%@", appVersion] : @"";
|
|
97
|
-
NSString *host = [[XTPluginManage shareInstance] getLocalHost];
|
|
98
|
-
NSURL *bundleUrl = [NSURL URLWithString:[NSString stringWithFormat:@"http://%@:%@/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=XRNTemplate%@", host, bundleData.portNum, appVersionParam]];
|
|
99
|
-
bizBundleURL = bundleUrl;
|
|
100
|
-
self.bizBundleURL = bizBundleURL;
|
|
101
|
-
bridge.bizBundleURL = bizBundleURL;
|
|
102
|
-
return supportCommon ? [[NSBundle mainBundle] URLForResource:[XTJSBundleTool.shared getCommonBundleName] withExtension:@"jsbundle"] : bizBundleURL;
|
|
140
|
+
[self attachMetroPackagerConnectionForContext:context bundleData:bundleData];
|
|
103
141
|
}
|
|
104
|
-
#endif
|
|
105
|
-
bridge.bizBundleURL = bizBundleURL;
|
|
106
|
-
// return [[NSBundle mainBundle] URLForResource:[XTJSBundleTool.shared getCommonBundleName] withExtension:@"jsbundle"];
|
|
107
|
-
// return [[NSBundle mainBundle] URLForResource:bundleData.jsBundleName withExtension:@"jsbundle"];
|
|
108
|
-
return bizBundleURL;
|
|
109
142
|
}
|
|
143
|
+
#endif
|
|
110
144
|
|
|
111
|
-
- (NSArray<id<RCTBridgeModule>> *_Nonnull)
|
|
112
|
-
return @[self.codePush];
|
|
145
|
+
- (NSArray<id<RCTBridgeModule>> *_Nonnull)extraModulesForContext:(XTJSRuntimeContext *_Nullable)context bundleData:(XTBundleData *_Nonnull)bundleData {
|
|
146
|
+
return self.codePush ? @[self.codePush] : @[];
|
|
113
147
|
}
|
|
114
148
|
|
|
115
149
|
- (BOOL)supportCommonBundleForBundleData:(XTBundleData *_Nonnull)bundleModel {
|
|
116
|
-
//
|
|
117
|
-
// #if DEBUG
|
|
118
|
-
// if (!self.isDebug) {
|
|
119
|
-
// return YES;
|
|
120
|
-
// }
|
|
121
|
-
// NSString *enbaleCommon = [NSUserDefaults.standardUserDefaults stringForKey:[NSString stringWithFormat:@"%@-supportCommon", bundleModel.jsBundleName]];
|
|
122
|
-
// supportCommon = ![enbaleCommon isEqualToString:@"0"];
|
|
123
|
-
// #endif
|
|
124
|
-
// return supportCommon;
|
|
150
|
+
// Debug / Release 均不走 common 拆包
|
|
125
151
|
return NO;
|
|
126
152
|
}
|
|
127
153
|
|
|
@@ -9,31 +9,20 @@
|
|
|
9
9
|
#import "XTBundleViewControllerFactory.h"
|
|
10
10
|
#import "XTMainBundleViewController.h"
|
|
11
11
|
#import "XTBundleViewController.h"
|
|
12
|
-
#import "XRNToastView.h"
|
|
13
|
-
#import "JSONUtils.h"
|
|
14
|
-
#import "XTJSBundleTool.h"
|
|
15
|
-
#import "RCTBridge+XTExtension.h"
|
|
16
12
|
|
|
17
13
|
@implementation XTBundleViewControllerFactory
|
|
18
14
|
|
|
19
|
-
|
|
20
|
-
/// create bundle controller
|
|
21
|
-
/// - Parameters:
|
|
22
|
-
/// - isMain: isMain description
|
|
23
|
-
/// - bridge: bridge description
|
|
24
|
-
/// - moduleName: moduleName description
|
|
25
|
-
/// - initialProperties: initialProperties description
|
|
26
|
-
- (UIViewController<XTViewControllerProtocol> *)createViewControllerWithIsMain:(BOOL)isMain bridge:(RCTBridge *)bridge moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties {
|
|
15
|
+
- (UIViewController<XTViewControllerProtocol> *)createViewControllerWithIsMain:(BOOL)isMain runtimeContext:(XTJSRuntimeContext *)runtimeContext moduleName:(NSString *)moduleName initialProperties:(NSDictionary *)initialProperties {
|
|
27
16
|
if (isMain) {
|
|
28
|
-
return [[XTMainBundleViewController alloc]
|
|
17
|
+
return [[XTMainBundleViewController alloc] initWithRuntimeContext:runtimeContext moduleName:moduleName initialProperties:initialProperties];
|
|
29
18
|
} else {
|
|
30
|
-
return [[XTBundleViewController alloc]
|
|
19
|
+
return [[XTBundleViewController alloc] initWithRuntimeContext:runtimeContext moduleName:moduleName initialProperties:initialProperties];
|
|
31
20
|
}
|
|
32
21
|
}
|
|
33
22
|
|
|
34
23
|
|
|
35
24
|
- (void)bundleNotFoundWith:(nonnull NSString *)bundleName moduleName:(nonnull NSString *)moduleName initialProperties:(nullable NSDictionary *)initialProperties {
|
|
36
|
-
|
|
25
|
+
|
|
37
26
|
}
|
|
38
27
|
|
|
39
28
|
@end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//
|
|
2
|
+
// XTBundleViewController.mm
|
|
3
|
+
// XRNTemplate
|
|
4
|
+
//
|
|
5
|
+
// Created by xtgq on 2025/6/27.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "XTBundleViewController.h"
|
|
9
|
+
|
|
10
|
+
#import <react-native-xrn-multi-bundle/XTMultiBundle.h>
|
|
11
|
+
#import <React/RCTFabricSurface.h>
|
|
12
|
+
#import <React/RCTSurfaceHostingProxyRootView.h>
|
|
13
|
+
#import <React/RCTSurfacePresenter.h>
|
|
14
|
+
#import <ReactCommon/RCTHost.h>
|
|
15
|
+
|
|
16
|
+
@implementation XTBundleViewController
|
|
17
|
+
|
|
18
|
+
- (void)loadView {
|
|
19
|
+
[super loadView];
|
|
20
|
+
|
|
21
|
+
RCTHost *host = (RCTHost *)self.runtimeContext.host;
|
|
22
|
+
NSAssert(host != nil, @"Host-only: XTBundleViewController requires runtimeContext.host");
|
|
23
|
+
|
|
24
|
+
NSMutableDictionary *mutInitialProps = [NSMutableDictionary dictionaryWithDictionary:self.initialProperties ?: @{}];
|
|
25
|
+
|
|
26
|
+
RCTFabricSurface *surface =
|
|
27
|
+
[[RCTFabricSurface alloc] initWithSurfacePresenter:host.surfacePresenter
|
|
28
|
+
moduleName:self.moduleName
|
|
29
|
+
initialProperties:mutInitialProps];
|
|
30
|
+
[self attachFabricSurface:surface toHost:host];
|
|
31
|
+
|
|
32
|
+
UIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
|
|
33
|
+
rootView.backgroundColor = UIColor.whiteColor;
|
|
34
|
+
self.view = rootView;
|
|
35
|
+
|
|
36
|
+
[self startSurfaceWhenBizReady];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)viewDidLoad {
|
|
40
|
+
[super viewDidLoad];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
// XTMainBundleViewController.mm
|
|
3
|
+
// XRNTemplate
|
|
4
|
+
//
|
|
5
|
+
// Created by xtgq on 2025/6/27.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
#import "XTMainBundleViewController.h"
|
|
9
|
+
|
|
10
|
+
#import <react-native-xrn-multi-bundle/XTMultiBundle.h>
|
|
11
|
+
#import <React/RCTFabricSurface.h>
|
|
12
|
+
#import <React/RCTSurfaceHostingProxyRootView.h>
|
|
13
|
+
#import <React/RCTSurfacePresenter.h>
|
|
14
|
+
#import <ReactCommon/RCTHost.h>
|
|
15
|
+
|
|
16
|
+
@implementation XTMainBundleViewController
|
|
17
|
+
|
|
18
|
+
- (void)viewDidLoad {
|
|
19
|
+
[super viewDidLoad];
|
|
20
|
+
[self loadMainView];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
- (void)loadMainView {
|
|
24
|
+
RCTHost *host = (RCTHost *)self.runtimeContext.host;
|
|
25
|
+
NSAssert(host != nil, @"Host-only: MainVC requires runtimeContext.host");
|
|
26
|
+
if (self.fabricSurface) {
|
|
27
|
+
[self startSurfaceWhenBizReady];
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
NSMutableDictionary *mutInitialProps = [NSMutableDictionary dictionaryWithDictionary:self.initialProperties];
|
|
32
|
+
[mutInitialProps setObject:self.moduleName ?: @"" forKey:@"moduleName"];
|
|
33
|
+
|
|
34
|
+
RCTFabricSurface *surface =
|
|
35
|
+
[[RCTFabricSurface alloc] initWithSurfacePresenter:host.surfacePresenter
|
|
36
|
+
moduleName:self.moduleName
|
|
37
|
+
initialProperties:mutInitialProps];
|
|
38
|
+
[self attachFabricSurface:surface toHost:host];
|
|
39
|
+
|
|
40
|
+
UIView *rootView = [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
|
|
41
|
+
rootView.backgroundColor = [UIColor whiteColor];
|
|
42
|
+
rootView.frame = CGRectMake(0, 0, UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.height);
|
|
43
|
+
[self.view insertSubview:rootView atIndex:0];
|
|
44
|
+
|
|
45
|
+
[self startSurfaceWhenBizReady];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@end
|