@rnx-kit/react-native-host 0.5.2 → 0.5.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.
@@ -10,7 +10,10 @@
10
10
  #import <ReactCommon/RCTJscInstance.h>
11
11
  #endif // USE_HERMES
12
12
 
13
+ #if __has_include(<react/config/ReactNativeConfig.h>)
13
14
  #import <react/config/ReactNativeConfig.h>
15
+ #define USE_REACT_NATIVE_CONFIG
16
+ #endif // __has_include(<react/config/ReactNativeConfig.h>)
14
17
 
15
18
  #if __has_include(<react/featureflags/ReactNativeFeatureFlags.h>)
16
19
  #import <react/featureflags/ReactNativeFeatureFlags.h>
@@ -18,6 +21,12 @@
18
21
  #define USE_FEATURE_FLAGS
19
22
  #endif // __has_include(<react/featureflags/ReactNativeFeatureFlags.h>)
20
23
 
24
+ #if __has_include(<ReactCodegen/RCTThirdPartyComponentsProvider.h>)
25
+ #define USE_CODEGEN_PROVIDER 1
26
+ #import <ReactCodegen/RCTThirdPartyComponentsProvider.h>
27
+ #import <React/RCTComponentViewFactory.h>
28
+ #endif // __has_include(<ReactCodegen/RCTThirdPartyComponentsProvider.h>)
29
+
21
30
  #if __has_include(<react/runtime/JSEngineInstance.h>)
22
31
  using SharedJSRuntimeFactory = std::shared_ptr<facebook::react::JSEngineInstance>;
23
32
  #else
@@ -1,6 +1,8 @@
1
1
  #import "ReactNativeHost.h"
2
2
 
3
+ // clang-format off
3
4
  #include "FollyConfig.h"
5
+ // clang-format on
4
6
 
5
7
  #import <React/RCTBridge.h>
6
8
  #import <React/RCTBundleURLProvider.h>
@@ -16,7 +18,9 @@
16
18
 
17
19
  @class RCTSurfacePresenter;
18
20
 
21
+ #ifdef USE_REACT_NATIVE_CONFIG
19
22
  using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
23
+ #endif // USE_REACT_NATIVE_CONFIG
20
24
 
21
25
  #if USE_BRIDGELESS
22
26
  @interface ReactNativeHost () <RCTContextContainerHandling>
@@ -25,6 +29,11 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
25
29
  #endif // USE_BRIDGELESS
26
30
  @end
27
31
 
32
+ #ifdef USE_CODEGEN_PROVIDER
33
+ @interface ReactNativeHost () <RCTComponentViewFactoryComponentProvider>
34
+ @end
35
+ #endif // USE_CODEGEN_PROVIDER
36
+
28
37
  @implementation ReactNativeHost {
29
38
  __weak id<RNXHostConfig> _config;
30
39
  NSDictionary *_launchOptions;
@@ -34,7 +43,9 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
34
43
  RCTHost *_reactHost;
35
44
  NSLock *_isShuttingDown;
36
45
  RNXHostReleaser *_hostReleaser;
46
+ #ifdef USE_REACT_NATIVE_CONFIG
37
47
  std::shared_ptr<ReactNativeConfig> _reactNativeConfig;
48
+ #endif // USE_REACT_NATIVE_CONFIG
38
49
  }
39
50
 
40
51
  - (instancetype)initWithConfig:(id<RNXHostConfig>)config
@@ -55,6 +66,11 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
55
66
  _hostReleaser = [[RNXHostReleaser alloc] initWithHost:self];
56
67
  }
57
68
 
69
+ #ifdef USE_CODEGEN_PROVIDER
70
+ [RCTComponentViewFactory currentComponentViewFactory].thirdPartyFabricComponentsProvider =
71
+ self;
72
+ #endif // USE_CODEGEN_PROVIDER
73
+
58
74
  #ifdef USE_FEATURE_FLAGS
59
75
  if (self.isBridgelessEnabled) {
60
76
  facebook::react::ReactNativeFeatureFlags::override(
@@ -197,7 +213,9 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
197
213
  - (void)didCreateContextContainer:
198
214
  (std::shared_ptr<facebook::react::ContextContainer>)contextContainer
199
215
  {
216
+ #ifdef USE_REACT_NATIVE_CONFIG
200
217
  contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
218
+ #endif // USE_REACT_NATIVE_CONFIG
201
219
  }
202
220
 
203
221
  #else // USE_BRIDGELESS
@@ -218,6 +236,15 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
218
236
 
219
237
  #endif // USE_BRIDGELESS
220
238
 
239
+ // MARK: - RCTComponentViewFactoryComponentProvider details
240
+
241
+ #ifdef USE_CODEGEN_PROVIDER
242
+ - (NSDictionary<NSString *, Class<RCTComponentViewProtocol>> *)thirdPartyFabricComponents
243
+ {
244
+ return [RCTThirdPartyComponentsProvider thirdPartyFabricComponents];
245
+ }
246
+ #endif // USE_CODEGEN_PROVIDER
247
+
221
248
  // MARK: - Private
222
249
 
223
250
  - (BOOL)isBridgelessEnabled
@@ -254,15 +281,21 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
254
281
  RCTEnableTurboModuleInterop(YES);
255
282
  RCTEnableTurboModuleInteropBridgeProxy(YES);
256
283
 
284
+ #ifdef USE_REACT_NATIVE_CONFIG
257
285
  _reactNativeConfig = std::make_shared<ReactNativeConfig>();
258
286
  std::weak_ptr<ReactNativeConfig> reactNativeConfig{_reactNativeConfig};
287
+ #endif // USE_REACT_NATIVE_CONFIG
259
288
 
260
289
  SharedJSRuntimeFactory (^jsEngineProvider)() = ^SharedJSRuntimeFactory {
261
290
  #if USE_HERMES
291
+ #ifdef USE_REACT_NATIVE_CONFIG
262
292
  auto config = reactNativeConfig.lock();
263
293
  NSAssert(config, @"Expected nonnull ReactNativeConfig instance");
264
294
  return std::make_shared<facebook::react::RCTHermesInstance>(config, nullptr);
265
295
  #else
296
+ return std::make_shared<facebook::react::RCTHermesInstance>(nullptr, false);
297
+ #endif // USE_REACT_NATIVE_CONFIG
298
+ #else // USE_HERMES
266
299
  return std::make_shared<facebook::react::RCTJscInstance>();
267
300
  #endif // USE_HERMES
268
301
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/react-native-host",
3
- "version": "0.5.2",
3
+ "version": "0.5.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",