@rnx-kit/react-native-host 0.4.3 → 0.4.5
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/cocoa/RNXBridgelessHeaders.h +9 -0
- package/cocoa/ReactNativeHost.mm +33 -14
- package/package.json +1 -1
|
@@ -18,6 +18,15 @@ using SharedJSRuntimeFactory = std::shared_ptr<facebook::react::JSEngineInstance
|
|
|
18
18
|
using SharedJSRuntimeFactory = std::shared_ptr<facebook::react::JSRuntimeFactory>;
|
|
19
19
|
#endif // __has_include(<react/runtime/JSEngineInstance.h>)
|
|
20
20
|
|
|
21
|
+
// For details, see
|
|
22
|
+
// https://github.com/facebook/react-native/commit/c3b0a8f1626939cf5c7b3864a5acf9d3dad26fb3
|
|
23
|
+
@interface RCTHost (Compatibility)
|
|
24
|
+
@property (nonatomic, readonly) RCTModuleRegistry *moduleRegistry; // Introduced in 0.74
|
|
25
|
+
@property (nonatomic, readonly) RCTSurfacePresenter *surfacePresenter; // Introduced in 0.74
|
|
26
|
+
- (RCTModuleRegistry *)getModuleRegistry; // Deprecated in 0.74, and removed in 0.75
|
|
27
|
+
- (RCTSurfacePresenter *)getSurfacePresenter; // Deprecated in 0.74, and removed in 0.75
|
|
28
|
+
@end
|
|
29
|
+
|
|
21
30
|
#elif USE_FABRIC
|
|
22
31
|
|
|
23
32
|
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
package/cocoa/ReactNativeHost.mm
CHANGED
|
@@ -79,9 +79,10 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
|
|
|
79
79
|
|
|
80
80
|
- (RCTBridge *)bridge
|
|
81
81
|
{
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
if (self.isBridgelessEnabled) {
|
|
83
|
+
return nil;
|
|
84
|
+
}
|
|
85
|
+
|
|
85
86
|
if (![_isShuttingDown tryLock]) {
|
|
86
87
|
NSAssert(NO, @"Tried to access the bridge while shutting down");
|
|
87
88
|
return nil;
|
|
@@ -98,13 +99,14 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
|
|
|
98
99
|
} @finally {
|
|
99
100
|
[_isShuttingDown unlock];
|
|
100
101
|
}
|
|
101
|
-
#endif // USE_BRIDGELESS
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
- (RCTSurfacePresenter *)surfacePresenter
|
|
105
105
|
{
|
|
106
106
|
#if USE_BRIDGELESS
|
|
107
|
-
return [_reactHost
|
|
107
|
+
return [_reactHost respondsToSelector:@selector(surfacePresenter)]
|
|
108
|
+
? _reactHost.surfacePresenter
|
|
109
|
+
: [_reactHost getSurfacePresenter];
|
|
108
110
|
#elif USE_FABRIC
|
|
109
111
|
return [_surfacePresenterBridgeAdapter surfacePresenter];
|
|
110
112
|
#else
|
|
@@ -137,8 +139,18 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
|
|
|
137
139
|
return;
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
if (!self.isBridgelessEnabled) {
|
|
143
|
+
block([self.bridge moduleForClass:moduleClass]);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
#if USE_BRIDGELESS
|
|
148
|
+
const char *moduleName = RCTBridgeModuleNameForClass(moduleClass).UTF8String;
|
|
149
|
+
RCTModuleRegistry *moduleRegistry = [_reactHost respondsToSelector:@selector(moduleRegistry)]
|
|
150
|
+
? _reactHost.moduleRegistry
|
|
151
|
+
: [_reactHost getModuleRegistry];
|
|
152
|
+
block([moduleRegistry moduleForName:moduleName]);
|
|
153
|
+
#endif // USE_BRIDGELESS
|
|
142
154
|
}
|
|
143
155
|
|
|
144
156
|
// MARK: - RCTBridgeDelegate details
|
|
@@ -193,6 +205,18 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
|
|
|
193
205
|
|
|
194
206
|
// MARK: - Private
|
|
195
207
|
|
|
208
|
+
- (BOOL)isBridgelessEnabled
|
|
209
|
+
{
|
|
210
|
+
#if USE_BRIDGELESS
|
|
211
|
+
// Bridgeless mode is enabled if it was turned on with a build flag, unless
|
|
212
|
+
// `isBridgelessEnabled` is explicitly implemented and returns false.
|
|
213
|
+
return ![_config respondsToSelector:@selector(isBridgelessEnabled)] ||
|
|
214
|
+
[_config isBridgelessEnabled];
|
|
215
|
+
#else
|
|
216
|
+
return NO;
|
|
217
|
+
#endif // USE_BRIDGELESS
|
|
218
|
+
}
|
|
219
|
+
|
|
196
220
|
- (void)enableTurboModule
|
|
197
221
|
{
|
|
198
222
|
#if USE_FABRIC
|
|
@@ -203,15 +227,12 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
|
|
|
203
227
|
|
|
204
228
|
- (void)initializeReactHost
|
|
205
229
|
{
|
|
206
|
-
|
|
207
|
-
// Bridgeless mode is enabled if it was turned on with a build flag, unless
|
|
208
|
-
// `isBridgelessEnabled` is explicitly implemented and returns false.
|
|
209
|
-
if ([_config respondsToSelector:@selector(isBridgelessEnabled)] &&
|
|
210
|
-
![_config isBridgelessEnabled]) {
|
|
230
|
+
if (!self.isBridgelessEnabled) {
|
|
211
231
|
(void)self.bridge; // Initialize the bridge now
|
|
212
232
|
return;
|
|
213
233
|
}
|
|
214
234
|
|
|
235
|
+
#if USE_BRIDGELESS
|
|
215
236
|
RCTSetUseNativeViewConfigsInBridgelessMode(YES);
|
|
216
237
|
RCTEnableTurboModuleInterop(YES);
|
|
217
238
|
RCTEnableTurboModuleInteropBridgeProxy(YES);
|
|
@@ -241,8 +262,6 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
|
|
|
241
262
|
|
|
242
263
|
[_reactHost setContextContainerHandler:self];
|
|
243
264
|
[_reactHost start];
|
|
244
|
-
#else
|
|
245
|
-
(void)self.bridge;
|
|
246
265
|
#endif // USE_BRIDGELESS
|
|
247
266
|
}
|
|
248
267
|
|
package/package.json
CHANGED