@rnx-kit/react-native-host 0.4.3 → 0.4.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.
@@ -79,9 +79,10 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
79
79
 
80
80
  - (RCTBridge *)bridge
81
81
  {
82
- #if USE_BRIDGELESS
83
- return nil;
84
- #else
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,7 +99,6 @@ 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
@@ -137,8 +137,15 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
137
137
  return;
138
138
  }
139
139
 
140
- id<RCTBridgeModule> bridgeModule = [self.bridge moduleForClass:moduleClass];
141
- block(bridgeModule);
140
+ if (!self.isBridgelessEnabled) {
141
+ block([self.bridge moduleForClass:moduleClass]);
142
+ return;
143
+ }
144
+
145
+ #if USE_BRIDGELESS
146
+ const char *moduleName = RCTBridgeModuleNameForClass(moduleClass).UTF8String;
147
+ block([[_reactHost getModuleRegistry] moduleForName:moduleName]);
148
+ #endif // USE_BRIDGELESS
142
149
  }
143
150
 
144
151
  // MARK: - RCTBridgeDelegate details
@@ -193,6 +200,18 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
193
200
 
194
201
  // MARK: - Private
195
202
 
203
+ - (BOOL)isBridgelessEnabled
204
+ {
205
+ #if USE_BRIDGELESS
206
+ // Bridgeless mode is enabled if it was turned on with a build flag, unless
207
+ // `isBridgelessEnabled` is explicitly implemented and returns false.
208
+ return ![_config respondsToSelector:@selector(isBridgelessEnabled)] ||
209
+ [_config isBridgelessEnabled];
210
+ #else
211
+ return NO;
212
+ #endif // USE_BRIDGELESS
213
+ }
214
+
196
215
  - (void)enableTurboModule
197
216
  {
198
217
  #if USE_FABRIC
@@ -203,15 +222,12 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
203
222
 
204
223
  - (void)initializeReactHost
205
224
  {
206
- #if USE_BRIDGELESS
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]) {
225
+ if (!self.isBridgelessEnabled) {
211
226
  (void)self.bridge; // Initialize the bridge now
212
227
  return;
213
228
  }
214
229
 
230
+ #if USE_BRIDGELESS
215
231
  RCTSetUseNativeViewConfigsInBridgelessMode(YES);
216
232
  RCTEnableTurboModuleInterop(YES);
217
233
  RCTEnableTurboModuleInteropBridgeProxy(YES);
@@ -241,8 +257,6 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
241
257
 
242
258
  [_reactHost setContextContainerHandler:self];
243
259
  [_reactHost start];
244
- #else
245
- (void)self.bridge;
246
260
  #endif // USE_BRIDGELESS
247
261
  }
248
262
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/react-native-host",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Simplify React Native initialization",
5
5
  "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/react-native-host#readme",
6
6
  "license": "MIT",