@onekeyfe/react-native-split-bundle-loader 1.1.53 → 1.1.54
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/ios/SplitBundleLoader.mm +8 -21
- package/package.json +1 -1
package/ios/SplitBundleLoader.mm
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
#import "SplitBundleLoader.h"
|
|
2
2
|
#import "SBLLogger.h"
|
|
3
|
-
#import <
|
|
3
|
+
#import <ReactCommon/RCTHost.h>
|
|
4
|
+
#import <ReactCommon/RCTHost+Internal.h>
|
|
5
|
+
#import <ReactCommon/RCTInstance.h>
|
|
4
6
|
#import <objc/runtime.h>
|
|
5
7
|
#include <jsi/jsi.h>
|
|
6
8
|
|
|
7
|
-
// Bridgeless (New Architecture) support: RCTHost segment registration
|
|
8
|
-
@interface RCTHost (SplitBundle)
|
|
9
|
-
- (void)registerSegmentWithId:(NSNumber *)segmentId path:(NSString *)path;
|
|
10
|
-
@end
|
|
11
|
-
|
|
12
9
|
@implementation SplitBundleLoader
|
|
13
10
|
|
|
14
11
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
@@ -66,26 +63,16 @@
|
|
|
66
63
|
|
|
67
64
|
// MARK: - Segment registration helper
|
|
68
65
|
|
|
69
|
-
/// Registers a segment with the current runtime
|
|
70
|
-
/// and bridgeless (RCTHost) architectures (#13).
|
|
66
|
+
/// Registers a segment with the current runtime via bridgeless (RCTHost) architecture (#13).
|
|
71
67
|
///
|
|
72
68
|
/// Thread safety (#57): This method is called from the TurboModule (JS thread).
|
|
73
|
-
/// RCTBridge.registerSegmentWithId:path: internally registers the segment with
|
|
74
|
-
/// the Hermes runtime on the JS thread, which is the correct calling context.
|
|
75
69
|
/// No queue dispatch is needed.
|
|
76
70
|
+ (BOOL)registerSegment:(int)segmentId path:(NSString *)path error:(NSError **)outError
|
|
77
71
|
{
|
|
78
|
-
//
|
|
79
|
-
RCTBridge *bridge = [RCTBridge currentBridge];
|
|
80
|
-
if (bridge && [bridge respondsToSelector:@selector(registerSegmentWithId:path:)]) {
|
|
81
|
-
[bridge registerSegmentWithId:@(segmentId) path:path];
|
|
82
|
-
return YES;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Try bridgeless RCTHost via AppDelegate
|
|
72
|
+
// Bridgeless (New Architecture): get RCTHost via AppDelegate
|
|
86
73
|
id<UIApplicationDelegate> appDelegate = [UIApplication sharedApplication].delegate;
|
|
87
74
|
if ([appDelegate respondsToSelector:NSSelectorFromString(@"reactHost")]) {
|
|
88
|
-
|
|
75
|
+
RCTHost *host = [appDelegate performSelector:NSSelectorFromString(@"reactHost")];
|
|
89
76
|
if (host && [host respondsToSelector:@selector(registerSegmentWithId:path:)]) {
|
|
90
77
|
[host registerSegmentWithId:@(segmentId) path:path];
|
|
91
78
|
return YES;
|
|
@@ -95,7 +82,7 @@
|
|
|
95
82
|
if (outError) {
|
|
96
83
|
*outError = [NSError errorWithDomain:@"SplitBundleLoader"
|
|
97
84
|
code:1
|
|
98
|
-
userInfo:@{NSLocalizedDescriptionKey: @"
|
|
85
|
+
userInfo:@{NSLocalizedDescriptionKey: @"RCTHost not available for segment registration"}];
|
|
99
86
|
}
|
|
100
87
|
return NO;
|
|
101
88
|
}
|
|
@@ -205,7 +192,7 @@
|
|
|
205
192
|
return;
|
|
206
193
|
}
|
|
207
194
|
|
|
208
|
-
|
|
195
|
+
RCTInstance *instance = object_getIvar(host, ivar);
|
|
209
196
|
if (!instance) {
|
|
210
197
|
[SBLLogger warn:@"loadEntryBundle: _instance is nil"];
|
|
211
198
|
return;
|