react-native 0.73.0-rc.2 → 0.73.0-rc.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.
Files changed (72) hide show
  1. package/Libraries/Animated/nodes/AnimatedStyle.js +1 -1
  2. package/Libraries/AppDelegate/RCTAppDelegate.mm +1 -1
  3. package/Libraries/AppDelegate/React-RCTAppDelegate.podspec +6 -2
  4. package/Libraries/Core/ReactNativeVersion.js +1 -1
  5. package/Libraries/LogBox/Data/LogBoxData.js +2 -1
  6. package/Libraries/promiseRejectionTrackingOptions.js +21 -7
  7. package/React/Base/RCTBridgeProxy.mm +11 -3
  8. package/React/Base/RCTConstants.h +1 -1
  9. package/React/Base/RCTConstants.m +1 -1
  10. package/React/Base/RCTVersion.m +1 -1
  11. package/React/Base/Surface/RCTSurfaceRootShadowView.h +1 -1
  12. package/React/Base/Surface/RCTSurfaceRootShadowView.m +1 -1
  13. package/React/CoreModules/RCTDeviceInfo.mm +1 -1
  14. package/React/CoreModules/React-CoreModules.podspec +1 -1
  15. package/React/Modules/RCTUIManager.h +7 -0
  16. package/React/Modules/RCTUIManager.m +1 -1
  17. package/React/Views/RCTComponentData.m +1 -1
  18. package/React/Views/RCTLayout.h +1 -1
  19. package/React/Views/RCTRootShadowView.h +1 -1
  20. package/React/Views/RCTRootShadowView.m +1 -1
  21. package/React/Views/RCTShadowView.m +1 -1
  22. package/React/Views/ScrollView/RCTScrollView.m +1 -1
  23. package/React-Core.podspec +1 -1
  24. package/ReactAndroid/gradle.properties +1 -1
  25. package/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +0 -1
  26. package/ReactAndroid/src/main/java/com/facebook/react/ReactApplication.kt +0 -1
  27. package/ReactAndroid/src/main/java/com/facebook/react/ReactDelegate.java +0 -1
  28. package/ReactAndroid/src/main/java/com/facebook/react/{interfaces/ReactHost.kt → ReactHost.kt} +2 -3
  29. package/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +1 -1
  30. package/ReactAndroid/src/main/java/com/facebook/react/common/annotations/UnstableReactNativeAPI.kt +1 -1
  31. package/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +58 -8
  32. package/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactNativeHost.kt +16 -0
  33. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java +0 -11
  34. package/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerBase.java +5 -1
  35. package/ReactAndroid/src/main/java/com/facebook/react/modules/devloading/DevLoadingModule.java +6 -10
  36. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  37. package/ReactAndroid/src/main/java/com/facebook/react/runtime/BridgelessReactContext.java +8 -0
  38. package/ReactAndroid/src/main/java/com/facebook/react/runtime/CoreReactPackage.java +5 -0
  39. package/ReactAndroid/src/main/java/com/facebook/react/runtime/JSTimerExecutor.java +4 -1
  40. package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostImpl.java +6 -1
  41. package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +41 -4
  42. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/FabricViewStateManager.java +95 -0
  43. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNode.java +2 -2
  44. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/ReactShadowNodeImpl.java +25 -6
  45. package/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +33 -23
  46. package/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +4 -1
  47. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  48. package/ReactCommon/hermes/executor/HermesExecutorFactory.cpp +10 -7
  49. package/ReactCommon/react/bridging/Object.h +1 -1
  50. package/ReactCommon/react/renderer/attributedstring/conversions.h +6 -0
  51. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/LegacyViewManagerInteropComponentDescriptor.mm +31 -3
  52. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.h +3 -1
  53. package/ReactCommon/react/renderer/components/legacyviewmanagerinterop/RCTLegacyViewManagerInteropCoordinator.mm +46 -10
  54. package/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +17 -17
  55. package/gradle/libs.versions.toml +1 -1
  56. package/package.json +10 -10
  57. package/scripts/cocoapods/utils.rb +4 -23
  58. package/scripts/codegen/generate-legacy-interop-components.js +8 -2
  59. package/scripts/react_native_pods.rb +1 -1
  60. package/sdks/hermes-engine/hermes-engine.podspec +7 -1
  61. package/sdks/hermes-engine/hermes-utils.rb +9 -6
  62. package/sdks/hermes-engine/utils/replace_hermes_version.js +8 -8
  63. package/sdks/hermesc/osx-bin/hermes +0 -0
  64. package/sdks/hermesc/osx-bin/hermesc +0 -0
  65. package/sdks/hermesc/win64-bin/hermesc.exe +0 -0
  66. package/template/android/app/build.gradle +1 -1
  67. package/template/android/app/src/main/java/com/helloworld/MainApplication.kt +3 -10
  68. package/template/package.json +2 -2
  69. package/third-party-podspecs/glog.podspec +14 -1
  70. package/ReactCommon/jsinspector/.clang-tidy +0 -6
  71. package/ReactCommon/jsinspector/InspectorInterfaces.cpp +0 -106
  72. package/ReactCommon/jsinspector/InspectorInterfaces.h +0 -92
@@ -30,7 +30,7 @@ function createAnimatedStyle(
30
30
  const animatedStyles: any = {};
31
31
  for (const key in style) {
32
32
  const value = style[key];
33
- if (key === 'transform') {
33
+ if (value != null && key === 'transform') {
34
34
  animatedStyles[key] =
35
35
  ReactNativeFeatureFlags.shouldUseAnimatedObjectForTransform()
36
36
  ? new AnimatedObject(value)
@@ -192,7 +192,7 @@ static NSString *const kRNConcurrentRoot = @"concurrentRoot";
192
192
  interfaceOrientation:(UIInterfaceOrientation)previousInterfaceOrientation
193
193
  traitCollection:(UITraitCollection *)previousTraitCollection API_AVAILABLE(ios(13.0))
194
194
  {
195
- [[NSNotificationCenter defaultCenter] postNotificationName:RCTRootViewFrameDidChangeNotification object:self];
195
+ [[NSNotificationCenter defaultCenter] postNotificationName:RCTWindowFrameDidChangeNotification object:self];
196
196
  }
197
197
 
198
198
  #pragma mark - RCTCxxBridgeDelegate
@@ -117,15 +117,19 @@ Pod::Spec.new do |s|
117
117
  s.dependency "React-debug"
118
118
  s.dependency "React-rendererdebug"
119
119
 
120
+ rel_path_from_pods_root_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(Pod::Config.instance.installation_root)
121
+ rel_path_from_pods_to_app = Pathname.new(ENV['APP_PATH']).relative_path_from(File.join(Pod::Config.instance.installation_root, 'Pods'))
122
+
123
+
120
124
  s.script_phases = {
121
125
  :name => "Generate Legacy Components Interop",
122
126
  :script => "
123
127
  WITH_ENVIRONMENT=\"$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh\"
124
128
  source $WITH_ENVIRONMENT
125
- ${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{ENV['APP_PATH']} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
129
+ ${NODE_BINARY} ${REACT_NATIVE_PATH}/scripts/codegen/generate-legacy-interop-components.js -p #{rel_path_from_pods_to_app} -o ${REACT_NATIVE_PATH}/Libraries/AppDelegate
126
130
  ",
127
131
  :execution_position => :before_compile,
128
- :input_files => ["#{ENV['APP_PATH']}/react-native.config.js"],
132
+ :input_files => ["#{rel_path_from_pods_root_to_app}/react-native.config.js"],
129
133
  :output_files => ["${REACT_NATIVE_PATH}/Libraries/AppDelegate/RCTLegacyInteropComponents.mm"],
130
134
  }
131
135
  end
@@ -13,5 +13,5 @@ exports.version = {
13
13
  major: 0,
14
14
  minor: 73,
15
15
  patch: 0,
16
- prerelease: 'rc.2',
16
+ prerelease: 'rc.4',
17
17
  };
@@ -30,6 +30,7 @@ export type LogData = $ReadOnly<{|
30
30
  message: Message,
31
31
  category: Category,
32
32
  componentStack: ComponentStack,
33
+ stack?: string,
33
34
  |}>;
34
35
 
35
36
  export type Observer = (
@@ -198,7 +199,7 @@ export function addLog(log: LogData): void {
198
199
  // otherwise spammy logs would pause rendering.
199
200
  setImmediate(() => {
200
201
  try {
201
- const stack = parseErrorStack(errorForStackTrace?.stack);
202
+ const stack = parseErrorStack(log.stack ?? errorForStackTrace?.stack);
202
203
 
203
204
  appendNewLog(
204
205
  new LogBoxLog({
@@ -10,6 +10,8 @@
10
10
 
11
11
  import typeof {enable} from 'promise/setimmediate/rejection-tracking';
12
12
 
13
+ import LogBox from './LogBox/LogBox';
14
+
13
15
  let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
14
16
  allRejections: true,
15
17
  onUnhandled: (id, rejection = {}) => {
@@ -34,17 +36,29 @@ let rejectionTrackingOptions: $NonMaybeType<Parameters<enable>[0]> = {
34
36
  }
35
37
  }
36
38
 
37
- const warning =
38
- `Possible Unhandled Promise Rejection (id: ${id}):\n` +
39
- `${message ?? ''}\n` +
40
- (stack == null ? '' : stack);
41
- console.warn(warning);
39
+ const warning = `Possible unhandled promise rejection (id: ${id}):\n${
40
+ message ?? ''
41
+ }`;
42
+ if (__DEV__) {
43
+ LogBox.addLog({
44
+ level: 'warn',
45
+ message: {
46
+ content: warning,
47
+ substitutions: [],
48
+ },
49
+ componentStack: [],
50
+ stack,
51
+ category: 'possible_unhandled_promise_rejection',
52
+ });
53
+ } else {
54
+ console.warn(warning);
55
+ }
42
56
  },
43
57
  onHandled: id => {
44
58
  const warning =
45
- `Promise Rejection Handled (id: ${id})\n` +
59
+ `Promise rejection handled (id: ${id})\n` +
46
60
  'This means you can ignore any previous messages of the form ' +
47
- `"Possible Unhandled Promise Rejection (id: ${id}):"`;
61
+ `"Possible unhandled promise rejection (id: ${id}):"`;
48
62
  console.warn(warning);
49
63
  },
50
64
  };
@@ -351,6 +351,11 @@ using namespace facebook;
351
351
  return (RCTUIManager *)_uiManagerProxy;
352
352
  }
353
353
 
354
+ - (RCTBridgeProxy *)object
355
+ {
356
+ return self;
357
+ }
358
+
354
359
  /**
355
360
  * NSProxy setup
356
361
  */
@@ -387,12 +392,14 @@ using namespace facebook;
387
392
 
388
393
  @implementation RCTUIManagerProxy {
389
394
  RCTViewRegistry *_viewRegistry;
395
+ NSMutableDictionary<NSNumber *, UIView *> *_legacyViewRegistry;
390
396
  }
391
397
  - (instancetype)initWithViewRegistry:(RCTViewRegistry *)viewRegistry
392
398
  {
393
399
  self = [super self];
394
400
  if (self) {
395
401
  _viewRegistry = viewRegistry;
402
+ _legacyViewRegistry = [NSMutableDictionary new];
396
403
  }
397
404
  return self;
398
405
  }
@@ -404,20 +411,21 @@ using namespace facebook;
404
411
  {
405
412
  [self logWarning:@"Please migrate to RCTViewRegistry: @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED."
406
413
  cmd:_cmd];
407
- return [_viewRegistry viewForReactTag:reactTag];
414
+ return [_viewRegistry viewForReactTag:reactTag] ? [_viewRegistry viewForReactTag:reactTag]
415
+ : [_legacyViewRegistry objectForKey:reactTag];
408
416
  }
409
417
 
410
418
  - (void)addUIBlock:(RCTViewManagerUIBlock)block
411
419
  {
412
420
  [self
413
421
  logWarning:
414
- @"This method isn't implemented faithfully: the viewRegistry passed to RCTViewManagerUIBlock is nil. Please migrate to RCTViewRegistry: @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED."
422
+ @"This method isn't implemented faithfully. Please migrate to RCTViewRegistry if possible: @synthesize viewRegistry_DEPRECATED = _viewRegistry_DEPRECATED."
415
423
  cmd:_cmd];
416
424
  __weak __typeof(self) weakSelf = self;
417
425
  RCTExecuteOnMainQueue(^{
418
426
  __typeof(self) strongSelf = weakSelf;
419
427
  if (strongSelf) {
420
- block((RCTUIManager *)strongSelf, nil);
428
+ block((RCTUIManager *)strongSelf, strongSelf->_legacyViewRegistry);
421
429
  }
422
430
  });
423
431
  }
@@ -12,7 +12,7 @@ RCT_EXTERN NSString *const RCTPlatformName;
12
12
  RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotification;
13
13
  RCT_EXTERN NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey;
14
14
 
15
- RCT_EXTERN NSString *const RCTRootViewFrameDidChangeNotification;
15
+ RCT_EXTERN NSString *const RCTWindowFrameDidChangeNotification;
16
16
 
17
17
  /**
18
18
  * This notification fires when the bridge initializes.
@@ -12,7 +12,7 @@ NSString *const RCTPlatformName = @"ios";
12
12
  NSString *const RCTUserInterfaceStyleDidChangeNotification = @"RCTUserInterfaceStyleDidChangeNotification";
13
13
  NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey = @"traitCollection";
14
14
 
15
- NSString *const RCTRootViewFrameDidChangeNotification = @"RCTRootViewFrameDidChangeNotification";
15
+ NSString *const RCTWindowFrameDidChangeNotification = @"RCTWindowFrameDidChangeNotification";
16
16
 
17
17
  NSString *const RCTJavaScriptDidFailToLoadNotification = @"RCTJavaScriptDidFailToLoadNotification";
18
18
  NSString *const RCTJavaScriptDidLoadNotification = @"RCTJavaScriptDidLoadNotification";
@@ -24,7 +24,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(73),
26
26
  RCTVersionPatch: @(0),
27
- RCTVersionPrerelease: @"rc.2",
27
+ RCTVersionPrerelease: @"rc.4",
28
28
  };
29
29
  });
30
30
  return __rnVersion;
@@ -27,6 +27,6 @@
27
27
  */
28
28
  @property (nonatomic, assign) YGDirection baseDirection;
29
29
 
30
- - (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews;
30
+ - (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews;
31
31
 
32
32
  @end
@@ -41,7 +41,7 @@
41
41
  }
42
42
  }
43
43
 
44
- - (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews
44
+ - (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews
45
45
  {
46
46
  NSHashTable<NSString *> *other = [NSHashTable new];
47
47
 
@@ -73,7 +73,7 @@ RCT_EXPORT_MODULE()
73
73
 
74
74
  [[NSNotificationCenter defaultCenter] addObserver:self
75
75
  selector:@selector(interfaceFrameDidChange)
76
- name:RCTRootViewFrameDidChangeNotification
76
+ name:RCTWindowFrameDidChangeNotification
77
77
  object:nil];
78
78
  }
79
79
 
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -Wno-comma -Wno-shorten-64-to-32'
20
20
  folly_version = '2022.05.16.00'
21
- socket_rocket_version = '0.6.0'
21
+ socket_rocket_version = '0.6.1'
22
22
 
23
23
  header_search_paths = [
24
24
  "\"$(PODS_TARGET_SRCROOT)/React/CoreModules\"",
@@ -9,6 +9,7 @@
9
9
 
10
10
  #import <React/RCTBridge.h>
11
11
  #import <React/RCTBridgeModule.h>
12
+ #import <React/RCTBridgeProxy.h>
12
13
  #import <React/RCTInvalidating.h>
13
14
  #import <React/RCTRootView.h>
14
15
  #import <React/RCTViewManager.h>
@@ -173,6 +174,12 @@ RCT_EXTERN NSString *const RCTUIManagerWillUpdateViewsDueToContentSizeMultiplier
173
174
 
174
175
  @end
175
176
 
177
+ @interface RCTBridgeProxy (RCTUIManager)
178
+
179
+ @property (nonatomic, readonly) RCTUIManager *uiManager;
180
+
181
+ @end
182
+
176
183
  RCT_EXTERN NSMutableDictionary<NSString *, id> *RCTModuleConstantsForDestructuredComponent(
177
184
  NSMutableDictionary<NSString *, NSDictionary *> *directEvents,
178
185
  NSMutableDictionary<NSString *, NSDictionary *> *bubblingEvents,
@@ -534,7 +534,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
534
534
  {
535
535
  RCTAssertUIManagerQueue();
536
536
 
537
- NSHashTable<RCTShadowView *> *affectedShadowViews = [NSHashTable weakObjectsHashTable];
537
+ NSPointerArray *affectedShadowViews = [NSPointerArray weakObjectsPointerArray];
538
538
  [rootShadowView layoutWithAffectedShadowViews:affectedShadowViews];
539
539
 
540
540
  if (!affectedShadowViews.count) {
@@ -71,7 +71,7 @@ static SEL selectorForType(NSString *type)
71
71
  object:nil
72
72
  userInfo:@{@"module" : _bridgelessViewManager}];
73
73
  }
74
- return _manager ?: _bridgelessViewManager;
74
+ return _manager ? _manager : _bridgelessViewManager;
75
75
  }
76
76
 
77
77
  RCT_NOT_IMPLEMENTED(-(instancetype)init)
@@ -31,7 +31,7 @@ typedef struct CG_BOXABLE RCTLayoutMetrics RCTLayoutMetrics;
31
31
 
32
32
  struct RCTLayoutContext {
33
33
  CGPoint absolutePosition;
34
- __unsafe_unretained NSHashTable<RCTShadowView *> *_Nonnull affectedShadowViews;
34
+ __unsafe_unretained NSPointerArray *_Nonnull affectedShadowViews;
35
35
  __unsafe_unretained NSHashTable<NSString *> *_Nonnull other;
36
36
  };
37
37
  typedef struct CG_BOXABLE RCTLayoutContext RCTLayoutContext;
@@ -29,6 +29,6 @@
29
29
  */
30
30
  @property (nonatomic, assign) YGDirection baseDirection;
31
31
 
32
- - (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews;
32
+ - (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews;
33
33
 
34
34
  @end
@@ -23,7 +23,7 @@
23
23
  return self;
24
24
  }
25
25
 
26
- - (void)layoutWithAffectedShadowViews:(NSHashTable<RCTShadowView *> *)affectedShadowViews
26
+ - (void)layoutWithAffectedShadowViews:(NSPointerArray *)affectedShadowViews
27
27
  {
28
28
  NSHashTable<NSString *> *other = [NSHashTable new];
29
29
 
@@ -304,7 +304,7 @@ static void RCTProcessMetaPropsBorder(const YGValue metaProps[META_PROP_COUNT],
304
304
  {
305
305
  if (!RCTLayoutMetricsEqualToLayoutMetrics(self.layoutMetrics, layoutMetrics)) {
306
306
  self.layoutMetrics = layoutMetrics;
307
- [layoutContext.affectedShadowViews addObject:self];
307
+ [layoutContext.affectedShadowViews addPointer:((__bridge void *)self)];
308
308
  }
309
309
  }
310
310
 
@@ -1058,7 +1058,7 @@ RCT_SET_AND_PRESERVE_OFFSET(setScrollIndicatorInsets, scrollIndicatorInsets, UIE
1058
1058
  }
1059
1059
 
1060
1060
  CGPoint offset = scrollView.contentOffset;
1061
- if ([UIApplication sharedApplication].userInterfaceLayoutDirection == UIUserInterfaceLayoutDirectionRightToLeft) {
1061
+ if ([self reactLayoutDirection] == UIUserInterfaceLayoutDirectionRightToLeft) {
1062
1062
  offset.x = scrollView.contentSize.width - scrollView.frame.size.width - offset.x;
1063
1063
  }
1064
1064
 
@@ -18,7 +18,7 @@ end
18
18
 
19
19
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -Wno-comma -Wno-shorten-64-to-32'
20
20
  folly_version = '2022.05.16.00'
21
- socket_rocket_version = '0.6.0'
21
+ socket_rocket_version = '0.6.1'
22
22
  boost_compiler_flags = '-Wno-documentation'
23
23
 
24
24
  use_hermes = ENV['USE_HERMES'] == nil || ENV['USE_HERMES'] == '1'
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.73.0-rc.2
1
+ VERSION_NAME=0.73.0-rc.4
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -19,7 +19,6 @@ import androidx.annotation.Nullable;
19
19
  import com.facebook.infer.annotation.Assertions;
20
20
  import com.facebook.react.bridge.Callback;
21
21
  import com.facebook.react.config.ReactFeatureFlags;
22
- import com.facebook.react.interfaces.ReactHost;
23
22
  import com.facebook.react.modules.core.PermissionListener;
24
23
 
25
24
  /**
@@ -8,7 +8,6 @@
8
8
  package com.facebook.react
9
9
 
10
10
  import com.facebook.react.common.annotations.UnstableReactNativeAPI
11
- import com.facebook.react.interfaces.ReactHost
12
11
 
13
12
  @OptIn(UnstableReactNativeAPI::class)
14
13
  /** Interface that represents an instance of a React Native application */
@@ -16,7 +16,6 @@ import androidx.annotation.Nullable;
16
16
  import com.facebook.infer.annotation.Assertions;
17
17
  import com.facebook.react.config.ReactFeatureFlags;
18
18
  import com.facebook.react.devsupport.DoubleTapReloadRecognizer;
19
- import com.facebook.react.interfaces.ReactHost;
20
19
  import com.facebook.react.interfaces.fabric.ReactSurface;
21
20
  import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
22
21
 
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- package com.facebook.react.interfaces
8
+ package com.facebook.react
9
9
 
10
10
  import android.app.Activity
11
11
  import android.content.Context
@@ -13,8 +13,8 @@ import android.os.Bundle
13
13
  import com.facebook.react.bridge.ReactContext
14
14
  import com.facebook.react.bridge.queue.ReactQueueConfiguration
15
15
  import com.facebook.react.common.LifecycleState
16
- import com.facebook.react.common.annotations.UnstableReactNativeAPI
17
16
  import com.facebook.react.devsupport.interfaces.DevSupportManager
17
+ import com.facebook.react.interfaces.TaskInterface
18
18
  import com.facebook.react.interfaces.fabric.ReactSurface
19
19
  import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
20
20
 
@@ -25,7 +25,6 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
25
25
  *
26
26
  * The implementation of this interface should be Thread Safe
27
27
  */
28
- @UnstableReactNativeAPI
29
28
  interface ReactHost {
30
29
 
31
30
  /** The current [LifecycleState] for React Host */
@@ -71,7 +71,7 @@ public class ReactContext extends ContextWrapper {
71
71
  private @Nullable JSExceptionHandler mExceptionHandlerWrapper;
72
72
  private @Nullable WeakReference<Activity> mCurrentActivity;
73
73
 
74
- private @Nullable InteropModuleRegistry mInteropModuleRegistry;
74
+ protected @Nullable InteropModuleRegistry mInteropModuleRegistry;
75
75
  private boolean mIsInitialized = false;
76
76
 
77
77
  public ReactContext(Context base) {
@@ -8,7 +8,7 @@
8
8
  package com.facebook.react.common.annotations
9
9
 
10
10
  @Retention(AnnotationRetention.RUNTIME)
11
- @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
11
+ @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY)
12
12
  @RequiresOptIn(
13
13
  level = RequiresOptIn.Level.ERROR,
14
14
  message = "This API is experimental and is likely to change or to be removed in the future")
@@ -8,20 +8,41 @@
8
8
  package com.facebook.react.defaults
9
9
 
10
10
  import android.content.Context
11
+ import com.facebook.react.JSEngineResolutionAlgorithm
12
+ import com.facebook.react.ReactHost
13
+ import com.facebook.react.ReactNativeHost
11
14
  import com.facebook.react.ReactPackage
12
15
  import com.facebook.react.bridge.JSBundleLoader
13
16
  import com.facebook.react.common.annotations.UnstableReactNativeAPI
14
17
  import com.facebook.react.fabric.ComponentFactory
15
- import com.facebook.react.interfaces.ReactHost
16
18
  import com.facebook.react.interfaces.exceptionmanager.ReactJsExceptionHandler
17
19
  import com.facebook.react.runtime.JSCInstance
18
20
  import com.facebook.react.runtime.ReactHostImpl
19
21
  import com.facebook.react.runtime.hermes.HermesInstance
20
22
 
21
- @UnstableReactNativeAPI
23
+ /**
24
+ * A utility class that allows you to simplify the setup of a [ReactHost] for new apps in Open
25
+ * Source.
26
+ *
27
+ * [ReactHost] is an interface responsible of handling the lifecycle of a React Native app when
28
+ * running in bridgeless mode.
29
+ */
22
30
  object DefaultReactHost {
23
31
  private var reactHost: ReactHost? = null
24
32
 
33
+ /**
34
+ * Util function to create a default [ReactHost] to be used in your application. This method is
35
+ * used by the New App template.
36
+ *
37
+ * @param context the Android [Context] to use for creating the [ReactHost]
38
+ * @param packageList the list of [ReactPackage]s to use for creating the [ReactHost]
39
+ * @param jsMainModulePath the path to your app's main module on Metro. Usually `index` or
40
+ * `index.<platform>`
41
+ * @param jsBundleAssetPath the path to the JS bundle relative to the assets directory. Will be
42
+ * composed in a `asset://...` URL
43
+ * @param isHermesEnabled whether to use Hermes as the JS engine, default to true.
44
+ */
45
+ @OptIn(UnstableReactNativeAPI::class)
25
46
  @JvmStatic
26
47
  fun getDefaultReactHost(
27
48
  context: Context,
@@ -47,13 +68,42 @@ object DefaultReactHost {
47
68
  // TODO: T164788699 find alternative of accessing ReactHostImpl for initialising reactHost
48
69
  reactHost =
49
70
  ReactHostImpl(
50
- context,
51
- defaultReactHostDelegate,
52
- componentFactory,
53
- true,
54
- reactJsExceptionHandler,
55
- true)
71
+ context,
72
+ defaultReactHostDelegate,
73
+ componentFactory,
74
+ true,
75
+ reactJsExceptionHandler,
76
+ true)
77
+ .apply {
78
+ jsEngineResolutionAlgorithm =
79
+ if (isHermesEnabled) {
80
+ JSEngineResolutionAlgorithm.HERMES
81
+ } else {
82
+ JSEngineResolutionAlgorithm.JSC
83
+ }
84
+ }
56
85
  }
57
86
  return reactHost as ReactHost
58
87
  }
88
+
89
+ /**
90
+ * Util function to create a default [ReactHost] to be used in your application. This method is
91
+ * used by the New App template.
92
+ *
93
+ * This method takes in input a [ReactNativeHost] (bridge-mode) and uses its configuration to
94
+ * create an equivalent [ReactHost] (bridgeless-mode).
95
+ *
96
+ * @param context the Android [Context] to use for creating the [ReactHost]
97
+ * @param reactNativeHost the [ReactNativeHost] to use for creating the [ReactHost]
98
+ */
99
+ @JvmStatic
100
+ fun getDefaultReactHost(
101
+ context: Context,
102
+ reactNativeHost: ReactNativeHost,
103
+ ): ReactHost {
104
+ require(reactNativeHost is DefaultReactNativeHost) {
105
+ "You can call getDefaultReactHost only with instances of DefaultReactNativeHost"
106
+ }
107
+ return reactNativeHost.toReactHost(context)
108
+ }
59
109
  }
@@ -8,7 +8,9 @@
8
8
  package com.facebook.react.defaults
9
9
 
10
10
  import android.app.Application
11
+ import android.content.Context
11
12
  import com.facebook.react.JSEngineResolutionAlgorithm
13
+ import com.facebook.react.ReactHost
12
14
  import com.facebook.react.ReactNativeHost
13
15
  import com.facebook.react.ReactPackageTurboModuleManagerDelegate
14
16
  import com.facebook.react.bridge.JSIModulePackage
@@ -68,4 +70,18 @@ protected constructor(
68
70
  */
69
71
  protected open val isHermesEnabled: Boolean?
70
72
  get() = null
73
+
74
+ /**
75
+ * Converts this [ReactNativeHost] (bridge-mode) to a [ReactHost] (bridgeless-mode).
76
+ *
77
+ * @param context the Android [Context] to use for creating the [ReactHost]
78
+ */
79
+ fun toReactHost(context: Context): ReactHost =
80
+ DefaultReactHost.getDefaultReactHost(
81
+ context,
82
+ packages,
83
+ jsMainModuleName,
84
+ bundleAssetName ?: "index",
85
+ isHermesEnabled ?: true,
86
+ )
71
87
  }
@@ -86,9 +86,6 @@ public final class BridgeDevSupportManager extends DevSupportManagerBase {
86
86
  surfaceDelegateFactory,
87
87
  devLoadingViewManager);
88
88
 
89
- mReactInstanceManagerHelper = reactInstanceManagerHelper;
90
- mDevLoadingViewManager = devLoadingViewManager;
91
-
92
89
  if (getDevSettings().isStartSamplingProfilerOnInit()) {
93
90
  // Only start the profiler. If its already running, there is an error
94
91
  if (!mIsSamplingProfilerEnabled) {
@@ -112,14 +109,6 @@ public final class BridgeDevSupportManager extends DevSupportManagerBase {
112
109
  });
113
110
  }
114
111
 
115
- public DevLoadingViewManager getDevLoadingViewManager() {
116
- return mDevLoadingViewManager;
117
- }
118
-
119
- public ReactInstanceDevHelper getReactInstanceManagerHelper() {
120
- return mReactInstanceManagerHelper;
121
- }
122
-
123
112
  @Override
124
113
  protected String getUniqueTag() {
125
114
  return "Bridge";
@@ -695,7 +695,11 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
695
695
  return mDevServerHelper;
696
696
  }
697
697
 
698
- protected ReactInstanceDevHelper getReactInstanceDevHelper() {
698
+ public DevLoadingViewManager getDevLoadingViewManager() {
699
+ return mDevLoadingViewManager;
700
+ }
701
+
702
+ public ReactInstanceDevHelper getReactInstanceDevHelper() {
699
703
  return mReactInstanceDevHelper;
700
704
  }
701
705
 
@@ -13,8 +13,7 @@ import com.facebook.react.bridge.JSExceptionHandler;
13
13
  import com.facebook.react.bridge.NativeModule;
14
14
  import com.facebook.react.bridge.ReactApplicationContext;
15
15
  import com.facebook.react.bridge.UiThreadUtil;
16
- import com.facebook.react.devsupport.BridgeDevSupportManager;
17
- import com.facebook.react.devsupport.DefaultDevLoadingViewImplementation;
16
+ import com.facebook.react.devsupport.DevSupportManagerBase;
18
17
  import com.facebook.react.devsupport.interfaces.DevLoadingViewManager;
19
18
  import com.facebook.react.module.annotations.ReactModule;
20
19
 
@@ -28,14 +27,9 @@ public class DevLoadingModule extends NativeDevLoadingViewSpec {
28
27
  public DevLoadingModule(ReactApplicationContext reactContext) {
29
28
  super(reactContext);
30
29
  mJSExceptionHandler = reactContext.getJSExceptionHandler();
31
- if (mJSExceptionHandler != null && mJSExceptionHandler instanceof BridgeDevSupportManager) {
30
+ if (mJSExceptionHandler != null && mJSExceptionHandler instanceof DevSupportManagerBase) {
32
31
  mDevLoadingViewManager =
33
- ((BridgeDevSupportManager) mJSExceptionHandler).getDevLoadingViewManager();
34
- mDevLoadingViewManager =
35
- mDevLoadingViewManager != null
36
- ? mDevLoadingViewManager
37
- : new DefaultDevLoadingViewImplementation(
38
- ((BridgeDevSupportManager) mJSExceptionHandler).getReactInstanceManagerHelper());
32
+ ((DevSupportManagerBase) mJSExceptionHandler).getDevLoadingViewManager();
39
33
  }
40
34
  }
41
35
 
@@ -46,7 +40,9 @@ public class DevLoadingModule extends NativeDevLoadingViewSpec {
46
40
  new Runnable() {
47
41
  @Override
48
42
  public void run() {
49
- mDevLoadingViewManager.showMessage(message);
43
+ if (mDevLoadingViewManager != null) {
44
+ mDevLoadingViewManager.showMessage(message);
45
+ }
50
46
  }
51
47
  });
52
48
  }
@@ -18,5 +18,5 @@ public class ReactNativeVersion {
18
18
  "major", 0,
19
19
  "minor", 73,
20
20
  "patch", 0,
21
- "prerelease", "rc.2");
21
+ "prerelease", "rc.4");
22
22
  }