@rnx-kit/react-native-host 0.4.4 → 0.4.6

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
@@ -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>
@@ -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
 
@@ -104,7 +104,9 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
104
104
  - (RCTSurfacePresenter *)surfacePresenter
105
105
  {
106
106
  #if USE_BRIDGELESS
107
- return [_reactHost getSurfacePresenter];
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
@@ -144,7 +146,10 @@ using ReactNativeConfig = facebook::react::EmptyReactNativeConfig const;
144
146
 
145
147
  #if USE_BRIDGELESS
146
148
  const char *moduleName = RCTBridgeModuleNameForClass(moduleClass).UTF8String;
147
- block([[_reactHost getModuleRegistry] moduleForName:moduleName]);
149
+ RCTModuleRegistry *moduleRegistry = [_reactHost respondsToSelector:@selector(moduleRegistry)]
150
+ ? _reactHost.moduleRegistry
151
+ : [_reactHost getModuleRegistry];
152
+ block([moduleRegistry moduleForName:moduleName]);
148
153
  #endif // USE_BRIDGELESS
149
154
  }
150
155
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/react-native-host",
3
- "version": "0.4.4",
3
+ "version": "0.4.6",
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",