@rnx-kit/react-native-host 0.4.5 → 0.4.7

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/README.md CHANGED
@@ -53,16 +53,18 @@ For example, if you previously had something like this:
53
53
  @end
54
54
 
55
55
  // AppDelegate.m
56
- @implementation AppDelegate
56
+ @implementation AppDelegate {
57
+ RCTBridge *_bridge;
58
+ }
57
59
 
58
60
  - (BOOL)application:(UIApplication *)application
59
61
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
60
62
  {
61
63
  ...
62
64
 
63
- RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self
64
- launchOptions:launchOptions];
65
- RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
65
+ _bridge = [[RCTBridge alloc] initWithDelegate:self
66
+ launchOptions:launchOptions];
67
+ RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:_bridge
66
68
  moduleName:moduleName
67
69
  initialProperties:initialProperties];
68
70
 
@@ -83,16 +85,18 @@ You should instead have:
83
85
  @end
84
86
 
85
87
  // AppDelegate.m
86
- @implementation AppDelegate
88
+ @implementation AppDelegate {
89
+ ReactNativeHost *_host;
90
+ }
87
91
 
88
92
  - (BOOL)application:(UIApplication *)application
89
93
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
90
94
  {
91
95
  ...
92
96
 
93
- ReactNativeHost *host = [[ReactNativeHost alloc] initWithConfig:self];
94
- UIView *rootView = [host viewWithModuleName:moduleName
95
- initialProperties:initialProperties];
97
+ _host = [[ReactNativeHost alloc] initWithConfig:self];
98
+ UIView *rootView = [_host viewWithModuleName:moduleName
99
+ initialProperties:initialProperties];
96
100
 
97
101
  ...
98
102
  }
@@ -10,12 +10,7 @@ repo_dir = repository['directory']
10
10
 
11
11
  new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
12
12
  preprocessor_definitions = [
13
- 'FOLLY_CFG_NO_COROUTINES=1',
14
- 'FOLLY_HAVE_CLOCK_GETTIME=1',
15
- 'FOLLY_HAVE_PTHREAD=1',
16
- 'FOLLY_MOBILE=1',
17
- 'FOLLY_NO_CONFIG=1',
18
- 'FOLLY_USE_LIBCPP=1',
13
+ '$(inherit)',
19
14
  "USE_HERMES=#{ENV['USE_HERMES'] || '0'}",
20
15
  ]
21
16
  if new_arch_enabled
@@ -51,17 +46,13 @@ Pod::Spec.new do |s|
51
46
  end
52
47
 
53
48
  s.pod_target_xcconfig = {
54
- 'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++20',
49
+ 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++20',
55
50
  'DEFINES_MODULE' => 'YES',
56
51
  'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_definitions,
57
52
  'HEADER_SEARCH_PATHS' => [
58
- '$(PODS_ROOT)/boost',
59
- '$(PODS_ROOT)/boost-for-react-native',
60
- '$(PODS_ROOT)/RCT-Folly',
61
- '$(PODS_ROOT)/DoubleConversion',
62
53
  '$(PODS_ROOT)/Headers/Private/React-Core',
63
- '$(PODS_ROOT)/Headers/Private/Yoga',
64
- ],
54
+ '$(PODS_CONFIGURATION_BUILD_DIR)/React-runtimescheduler/React_runtimescheduler.framework/Headers',
55
+ ].join(' '),
65
56
  }
66
57
 
67
58
  # Include both package and repository relative paths to allow the podspec to
@@ -71,4 +62,6 @@ Pod::Spec.new do |s|
71
62
  "#{repo_dir}/#{source_files}" # :podspec
72
63
  s.public_header_files = public_header_files, # :path
73
64
  "#{repo_dir}/#{public_header_files}" # :podspec
65
+
66
+ install_modules_dependencies(s)
74
67
  end
@@ -23,6 +23,21 @@ using SharedJSRuntimeFactory = std::shared_ptr<facebook::react::JSRuntimeFactory
23
23
  @interface RCTHost (Compatibility)
24
24
  @property (nonatomic, readonly) RCTModuleRegistry *moduleRegistry; // Introduced in 0.74
25
25
  @property (nonatomic, readonly) RCTSurfacePresenter *surfacePresenter; // Introduced in 0.74
26
+
27
+ // Introduced in 0.74
28
+ - (instancetype)initWithBundleURLProvider:(RCTHostBundleURLProvider)provider
29
+ hostDelegate:(id<RCTHostDelegate>)hostDelegate
30
+ turboModuleManagerDelegate:
31
+ (id<RCTTurboModuleManagerDelegate>)turboModuleManagerDelegate
32
+ jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider
33
+ launchOptions:(nullable NSDictionary *)launchOptions;
34
+
35
+ // Deprecated in 0.74
36
+ - (instancetype)initWithBundleURL:(NSURL *)bundleURL
37
+ hostDelegate:(id<RCTHostDelegate>)hostDelegate
38
+ turboModuleManagerDelegate:(id<RCTTurboModuleManagerDelegate>)turboModuleManagerDelegate
39
+ jsEngineProvider:(RCTHostJSEngineProvider)jsEngineProvider;
40
+
26
41
  - (RCTModuleRegistry *)getModuleRegistry; // Deprecated in 0.74, and removed in 0.75
27
42
  - (RCTSurfacePresenter *)getSurfacePresenter; // Deprecated in 0.74, and removed in 0.75
28
43
  @end
@@ -34,9 +34,9 @@
34
34
  #if !TARGET_OS_OSX
35
35
  // This may initialize `RCTAccessibilityManager` and must therefore be run
36
36
  // on the main queue.
37
- __weak typeof(self) weakSelf = self;
37
+ __weak __typeof(self) weakSelf = self;
38
38
  RCTExecuteOnMainQueue(^{
39
- typeof(self) strongSelf = weakSelf;
39
+ __typeof(self) strongSelf = weakSelf;
40
40
  if (strongSelf == nil) {
41
41
  return;
42
42
  }
@@ -50,7 +50,7 @@
50
50
  RCTExecuteOnUIManagerQueue(^{
51
51
  [manager addUIBlock:^(RCTUIManager *uiManager,
52
52
  NSDictionary<NSNumber *, UIView *> *viewRegistry) {
53
- typeof(self) strongSelf = weakSelf;
53
+ __typeof(self) strongSelf = weakSelf;
54
54
  if (strongSelf == nil) {
55
55
  return;
56
56
  }
@@ -13,23 +13,36 @@
13
13
  #if __has_include(<React/RCTAppSetupUtils.h>) // <0.72
14
14
  #import <React/RCTAppSetupUtils.h>
15
15
  #else
16
+
17
+ #if __has_include(<React-RCTAppDelegate/RCTAppSetupUtils.h>)
16
18
  #import <React-RCTAppDelegate/RCTAppSetupUtils.h>
19
+ #elif __has_include(<React_RCTAppDelegate/RCTAppSetupUtils.h>) // use_frameworks!
20
+ #import <React_RCTAppDelegate/RCTAppSetupUtils.h>
21
+ #endif // __has_include(<React-RCTAppDelegate/RCTAppSetupUtils.h>)
22
+
17
23
  #import <React/RCTSurfacePresenterBridgeAdapter.h>
18
24
 
19
25
  // We still get into this path because react-native-macos 0.71 picked up some
20
26
  // 0.72 bits. AFAICT, `SchedulerPriorityUtils.h` is a new addition in 0.72 in
21
27
  // both react-native and react-native-macos.
22
28
  #if __has_include(<react/renderer/runtimescheduler/SchedulerPriorityUtils.h>)
29
+
23
30
  #if __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>) // <0.74
24
31
  #import <React-RCTAppDelegate/RCTLegacyInteropComponents.h>
25
32
  #define MANUALLY_REGISTER_LEGACY_COMPONENTS 1
33
+ #elif __has_include(<React_RCTAppDelegate/RCTLegacyInteropComponents.h>) // use_frameworks!
34
+ #import <React_RCTAppDelegate/RCTLegacyInteropComponents.h>
35
+ #define MANUALLY_REGISTER_LEGACY_COMPONENTS 1
26
36
  #endif // __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>)
37
+
27
38
  #import <React/RCTLegacyViewManagerInteropComponentView.h>
28
39
  #import <react/renderer/runtimescheduler/RuntimeScheduler.h>
29
40
  #import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
41
+
30
42
  #if __has_include(<React/RCTRuntimeExecutorFromBridge.h>)
31
43
  #import <React/RCTRuntimeExecutorFromBridge.h>
32
44
  #endif // __has_include(<React/RCTRuntimeExecutorFromBridge.h>)
45
+
33
46
  #define USE_RUNTIME_SCHEDULER 1
34
47
  #endif // __has_include(<react/renderer/runtimescheduler/SchedulerPriorityUtils.h>)
35
48
 
@@ -24,8 +24,11 @@ NS_ASSUME_NONNULL_BEGIN
24
24
 
25
25
  - (instancetype)init NS_UNAVAILABLE;
26
26
 
27
- - (instancetype)initWithConfig:(id<RNXHostConfig>)config NS_DESIGNATED_INITIALIZER
28
- NS_SWIFT_NAME(init(_:));
27
+ - (instancetype)initWithConfig:(id<RNXHostConfig>)config NS_SWIFT_NAME(init(_:));
28
+
29
+ - (instancetype)initWithConfig:(id<RNXHostConfig>)config
30
+ launchOptions:(nullable NSDictionary *)launchOptions NS_DESIGNATED_INITIALIZER
31
+ NS_SWIFT_NAME(init(_:launchOptions:));
29
32
 
30
33
  - (void)shutdown;
31
34
 
@@ -31,6 +31,7 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
31
31
 
32
32
  @implementation ReactNativeHost {
33
33
  __weak id<RNXHostConfig> _config;
34
+ NSDictionary *_launchOptions;
34
35
  RNXTurboModuleAdapter *_turboModuleAdapter;
35
36
  RCTSurfacePresenterBridgeAdapter *_surfacePresenterBridgeAdapter;
36
37
  RCTBridge *_bridge;
@@ -41,6 +42,11 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
41
42
  }
42
43
 
43
44
  - (instancetype)initWithConfig:(id<RNXHostConfig>)config
45
+ {
46
+ return [self initWithConfig:config launchOptions:nil];
47
+ }
48
+
49
+ - (instancetype)initWithConfig:(id<RNXHostConfig>)config launchOptions:(NSDictionary *)launchOptions
44
50
  {
45
51
  if (self = [super init]) {
46
52
  if ([config respondsToSelector:@selector(isDevLoadingViewEnabled)]) {
@@ -64,6 +70,7 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
64
70
  }
65
71
 
66
72
  _config = config;
73
+ _launchOptions = launchOptions;
67
74
  [self enableTurboModule];
68
75
  _isShuttingDown = [[NSLock alloc] init];
69
76
 
@@ -90,7 +97,7 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
90
97
 
91
98
  @try {
92
99
  if (_bridge == nil) {
93
- _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil];
100
+ _bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:_launchOptions];
94
101
  _surfacePresenterBridgeAdapter = RNXInstallSurfacePresenterBridgeAdapter(_bridge);
95
102
  [_hostReleaser setBridge:_bridge];
96
103
  }
@@ -250,12 +257,26 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
250
257
  #endif // USE_HERMES
251
258
  };
252
259
 
253
- _reactHost = [[RCTHost alloc] initWithBundleURL:[self sourceURLForBridge:nil]
254
- hostDelegate:nil
255
- turboModuleManagerDelegate:_turboModuleAdapter
256
- jsEngineProvider:jsEngineProvider];
257
-
258
260
  __weak __typeof(self) weakSelf = self;
261
+ if ([RCTHost instancesRespondToSelector:@selector
262
+ (initWithBundleURLProvider:
263
+ hostDelegate:turboModuleManagerDelegate:jsEngineProvider
264
+ :launchOptions:)]) {
265
+ _reactHost = [[RCTHost alloc]
266
+ initWithBundleURLProvider:^{
267
+ return [weakSelf sourceURLForBridge:nil];
268
+ }
269
+ hostDelegate:nil
270
+ turboModuleManagerDelegate:_turboModuleAdapter
271
+ jsEngineProvider:jsEngineProvider
272
+ launchOptions:_launchOptions];
273
+ } else {
274
+ _reactHost = [[RCTHost alloc] initWithBundleURL:[self sourceURLForBridge:nil]
275
+ hostDelegate:nil
276
+ turboModuleManagerDelegate:_turboModuleAdapter
277
+ jsEngineProvider:jsEngineProvider];
278
+ }
279
+
259
280
  [_reactHost setBundleURLProvider:^NSURL *() {
260
281
  return [weakSelf sourceURLForBridge:nil];
261
282
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/react-native-host",
3
- "version": "0.4.5",
3
+ "version": "0.4.7",
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",
@@ -10,8 +10,10 @@
10
10
  },
11
11
  "files": [
12
12
  "ReactNativeHost.podspec",
13
- "android/",
14
- "cocoa/"
13
+ "android/build.gradle",
14
+ "android/gradle.properties",
15
+ "android/src",
16
+ "cocoa"
15
17
  ],
16
18
  "repository": {
17
19
  "type": "git",