@rnx-kit/react-native-host 0.2.8 → 0.3.0

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.
@@ -9,7 +9,14 @@ repository = package['repository']
9
9
  repo_dir = repository['directory']
10
10
 
11
11
  new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
12
- preprocessor_definitions = ['FOLLY_NO_CONFIG=1', 'FOLLY_MOBILE=1', 'FOLLY_USE_LIBCPP=1']
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',
19
+ ]
13
20
  if new_arch_enabled
14
21
  preprocessor_definitions << 'RCT_NEW_ARCH_ENABLED=1'
15
22
  preprocessor_definitions << 'USE_FABRIC=1'
@@ -17,7 +24,7 @@ if new_arch_enabled
17
24
  end
18
25
 
19
26
  Pod::Spec.new do |s|
20
- s.name = 'ReactNativeHost'
27
+ s.name = File.basename(__FILE__, '.podspec')
21
28
  s.version = version
22
29
  s.author = { package['author']['name'] => package['author']['email'] }
23
30
  s.license = package['license']
@@ -38,10 +45,11 @@ Pod::Spec.new do |s|
38
45
  if new_arch_enabled
39
46
  s.dependency 'React-RCTAppDelegate'
40
47
  s.dependency 'React-RCTFabric'
48
+ s.dependency 'Yoga'
41
49
  end
42
50
 
43
51
  s.pod_target_xcconfig = {
44
- 'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++17',
52
+ 'CLANG_CXX_LANGUAGE_STANDARD' => 'gnu++20',
45
53
  'DEFINES_MODULE' => 'YES',
46
54
  'GCC_PREPROCESSOR_DEFINITIONS' => preprocessor_definitions,
47
55
  'HEADER_SEARCH_PATHS' => [
@@ -50,6 +58,7 @@ Pod::Spec.new do |s|
50
58
  '$(PODS_ROOT)/RCT-Folly',
51
59
  '$(PODS_ROOT)/DoubleConversion',
52
60
  '$(PODS_ROOT)/Headers/Private/React-Core',
61
+ '$(PODS_ROOT)/Headers/Private/Yoga',
53
62
  ],
54
63
  }
55
64
 
@@ -1,6 +1,12 @@
1
1
  #import "RNXTurboModuleAdapter.h"
2
2
 
3
- #define FOLLY_NO_CONFIG 1
3
+ #include <folly/Portability.h>
4
+ #if FOLLY_HAS_COROUTINES
5
+ // TODO: `FOLLY_CFG_NO_COROUTINES` was added in 0.73. We can drop this block
6
+ // when we drop support for 0.72:
7
+ // https://github.com/facebook/react-native/commit/17154a661fe06ed25bf599f47bd4193eba011971
8
+ #define FOLLY_HAS_COROUTINES 0
9
+ #endif
4
10
  #pragma clang diagnostic push
5
11
  #pragma clang diagnostic ignored "-Wcomma"
6
12
  #import <cxxreact/JSExecutor.h>
@@ -21,13 +27,17 @@
21
27
  // 0.72 bits. AFAICT, `RCTLegacyInteropComponents.h` is a new addition in 0.72
22
28
  // in both react-native and react-native-macos.
23
29
  #if __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>)
30
+ #import <React-RCTAppDelegate/RCTLegacyInteropComponents.h>
31
+ #import <React/RCTLegacyViewManagerInteropComponentView.h>
24
32
  #import <react/renderer/runtimescheduler/RuntimeScheduler.h>
25
33
  #import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
26
34
  #if __has_include(<React/RCTRuntimeExecutorFromBridge.h>)
27
35
  #import <React/RCTRuntimeExecutorFromBridge.h>
28
36
  #endif // __has_include(<React/RCTRuntimeExecutorFromBridge.h>)
37
+ #define SUPPORTS_LEGACY_COMPONENTS 1
29
38
  #define USE_RUNTIME_SCHEDULER 1
30
39
  #else
40
+ #define SUPPORTS_LEGACY_COMPONENTS 0
31
41
  #define USE_RUNTIME_SCHEDULER 0
32
42
  #endif // __has_include(<React-RCTAppDelegate/RCTLegacyInteropComponents.h>)
33
43
 
@@ -48,31 +58,19 @@
48
58
  (RCTBridge *)bridge
49
59
  {
50
60
  #if USE_TURBOMODULE
61
+ [self registerLegacyViewManagers];
51
62
  // jsExecutorFactoryForBridge: (USE_TURBOMODULE=1)
52
- #if USE_RUNTIME_SCHEDULER
53
- _runtimeScheduler =
54
- std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));
55
- auto callInvoker =
56
- std::make_shared<facebook::react::RuntimeSchedulerCallInvoker>(_runtimeScheduler);
57
- _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
58
- delegate:self
59
- jsInvoker:callInvoker];
60
- return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager, _runtimeScheduler);
61
- #else
62
- _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
63
- delegate:self
64
- jsInvoker:bridge.jsCallInvoker];
65
- return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
66
- #endif // USE_RUNTIME_SCHEDULER
63
+ return [self initJsExecutorFactoryWithBridge:bridge];
67
64
  #else
68
65
  // jsExecutorFactoryForBridge: (USE_TURBOMODULE=0)
69
66
  return nullptr;
70
67
  #endif // USE_TURBOMODULE
71
68
  }
72
69
 
73
- // MARK: - RCTTurboModuleManagerDelegate details
74
70
  #if USE_TURBOMODULE
75
71
 
72
+ // MARK: - RCTTurboModuleManagerDelegate details
73
+
76
74
  - (Class)getModuleClassFromName:(const char *)name
77
75
  {
78
76
  return RCTCoreModulesClassProvider(name);
@@ -90,6 +88,36 @@
90
88
  return RCTAppSetupDefaultModuleFromClass(moduleClass);
91
89
  }
92
90
 
91
+ // MARK: - Private
92
+
93
+ - (std::unique_ptr<facebook::react::JSExecutorFactory>)initJsExecutorFactoryWithBridge:(RCTBridge *)bridge
94
+ {
95
+ #if USE_RUNTIME_SCHEDULER
96
+ _runtimeScheduler =
97
+ std::make_shared<facebook::react::RuntimeScheduler>(RCTRuntimeExecutorFromBridge(bridge));
98
+ auto callInvoker =
99
+ std::make_shared<facebook::react::RuntimeSchedulerCallInvoker>(_runtimeScheduler);
100
+ _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
101
+ delegate:self
102
+ jsInvoker:callInvoker];
103
+ return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager, _runtimeScheduler);
104
+ #else
105
+ _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge
106
+ delegate:self
107
+ jsInvoker:bridge.jsCallInvoker];
108
+ return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager);
109
+ #endif // USE_RUNTIME_SCHEDULER
110
+ }
111
+
112
+ - (void)registerLegacyViewManagers
113
+ {
114
+ #if SUPPORTS_LEGACY_COMPONENTS
115
+ for (NSString *legacyComponent in [RCTLegacyInteropComponents legacyInteropComponents]) {
116
+ [RCTLegacyViewManagerInteropComponentView supportLegacyViewManagerWithName:legacyComponent];
117
+ }
118
+ #endif // SUPPORTS_LEGACY_COMPONENTS
119
+ }
120
+
93
121
  #endif // USE_TURBOMODULE
94
122
 
95
123
  @end
@@ -1,8 +1,13 @@
1
1
  #import "ReactNativeHost.h"
2
2
 
3
3
  #ifdef USE_FABRIC
4
+ #if __has_include(<React/RCTFabricSurfaceHostingProxyRootView.h>)
4
5
  #import <React/RCTFabricSurfaceHostingProxyRootView.h>
5
6
  #else
7
+ #import <React/RCTFabricSurface.h>
8
+ #import <React/RCTSurfaceHostingProxyRootView.h>
9
+ #endif // __has_include(<React/RCTFabricSurfaceHostingProxyRootView.h>)
10
+ #else
6
11
  #import <React/RCTRootView.h>
7
12
  #endif // USE_FABRIC
8
13
 
@@ -31,9 +36,16 @@
31
36
  initialProperties:(NSDictionary *)initialProperties;
32
37
  {
33
38
  #ifdef USE_FABRIC
39
+ #if __has_include(<React/RCTFabricSurfaceHostingProxyRootView.h>)
34
40
  return [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:self.bridge
35
41
  moduleName:moduleName
36
42
  initialProperties:initialProperties];
43
+ #else
44
+ RCTFabricSurface *surface = [[RCTFabricSurface alloc] initWithBridge:self.bridge
45
+ moduleName:moduleName
46
+ initialProperties:initialProperties];
47
+ return [[RCTSurfaceHostingProxyRootView alloc] initWithSurface:surface];
48
+ #endif // __has_include(<React/RCTFabricSurfaceHostingProxyRootView.h>)
37
49
  #else
38
50
  return [[RCTRootView alloc] initWithBridge:self.bridge
39
51
  moduleName:moduleName
@@ -1,6 +1,12 @@
1
1
  #import "ReactNativeHost.h"
2
2
 
3
- #define FOLLY_NO_CONFIG 1
3
+ #include <folly/Portability.h>
4
+ #if FOLLY_HAS_COROUTINES
5
+ // TODO: `FOLLY_CFG_NO_COROUTINES` was added in 0.73. We can drop this block
6
+ // when we drop support for 0.72:
7
+ // https://github.com/facebook/react-native/commit/17154a661fe06ed25bf599f47bd4193eba011971
8
+ #define FOLLY_HAS_COROUTINES 0
9
+ #endif
4
10
  #pragma clang diagnostic push
5
11
  #pragma clang diagnostic ignored "-Wcomma"
6
12
  #import <cxxreact/JSExecutor.h>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnx-kit/react-native-host",
3
- "version": "0.2.8",
3
+ "version": "0.3.0",
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",
@@ -21,10 +21,10 @@
21
21
  "scripts": {
22
22
  "format": "rnx-kit-scripts format",
23
23
  "format:c": "clang-format -i $(git ls-files '*.c' '*.cpp' '*.h' '*.m' '*.mm')",
24
- "lint:kt": "ktlint --relative --verbose 'android/src/**/*.kt'"
24
+ "lint:kt": "ktlint --relative 'android/src/**/*.kt'"
25
25
  },
26
26
  "peerDependencies": {
27
- "react-native": ">=0.64"
27
+ "react-native": ">=0.66"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@rnx-kit/scripts": "*",