Skip to content

Commit

Permalink
Merge commit '03a51da727022d96f7f9bbc0840b1409121d0429' into features…
Browse files Browse the repository at this point in the history
…/expose_host_delegate
  • Loading branch information
zhongwuzw committed Apr 22, 2024
2 parents 73a19ba + 03a51da commit dd31921
Show file tree
Hide file tree
Showing 57 changed files with 592 additions and 505 deletions.
18 changes: 16 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@
- Add errata for fix to marginStart/End for row-reverse flex direction ([2dad663c28](https://github.com/facebook/react-native/commit/2dad663c2870e0c098649854c8c9333e07be1793) by [@joevilches](https://github.com/joevilches))
- Remove web performance logging from GlobalPerformanceLogger ([53a2742e13](https://github.com/facebook/react-native/commit/53a2742e13f55c3e412bde2ac7b56f6950e44b17) by [@rshest](https://github.com/rshest))
- Rename AbsolutePositioning errata ([08eb985c33](https://github.com/facebook/react-native/commit/08eb985c333bca4fc47c854b51ad84f1353d344c) by [@joevilches](https://github.com/joevilches))
- Refactor React to get rid of JSIModule and its dependencies ([6555205539](https://github.com/facebook/react-native/commit/65552055392a5996bf50548018953875dde4560b) by [@arushikesarwani](https://github.com/arushikesarwani94))
- Get rid of old APIs in FabricUIManagerProvider ([c2c346ccaf](https://github.com/facebook/react-native/commit/c2c346ccaf9912f129b945944575c818eac99a6d) by [@arushikesarwani](https://github.com/arushikesarwani94))
- Refactor React to get rid of JSIModule and its dependencies ([6555205539](https://github.com/facebook/react-native/commit/65552055392a5996bf50548018953875dde4560b) by [@arushikesarwani94](https://github.com/arushikesarwani94))
- Get rid of old APIs in FabricUIManagerProvider ([c2c346ccaf](https://github.com/facebook/react-native/commit/c2c346ccaf9912f129b945944575c818eac99a6d) by [@arushikesarwani94](https://github.com/arushikesarwani94))

#### Android specific

Expand Down Expand Up @@ -810,6 +810,20 @@
- Fix race condition between A11yManager and UIManager ([f39f34ed82](https://github.com/facebook/react-native/commit/f39f34ed82997d0595522a285c3cb8693594e718) by [@cipolleschi](https://github.com/cipolleschi))
- Fix symbol not found _jump_fcontext with use_frameworks ([a2771ce58a](https://github.com/facebook/react-native/commit/a2771ce58ac221d1ac0de265c1ce571212fbcf83) by [@cipolleschi](https://github.com/cipolleschi))

## v0.72.13

### Added

#### iOS specific

- Add privacy manifest to pod install ([d39712f54a](https://github.com/facebook/react-native/commit/d39712f54a95e6dcdf1d2f80d9581211ab03c157) by [@philIip](https://github.com/philIip))

### Fixed

#### Android specific

- Fixed possible deadlock in dispatchViewUpdates ([b2ca41eef5](https://github.com/facebook/react-native/commit/b2ca41eef59b17d212b35baa4a28c4b27a465b5c) by [@EvertEt](https://github.com/EvertEt))

## v0.72.12

### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/debugger-frontend/BUILD_INFO
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@generated SignedSource<<e6e7eb6c3f3fa15eb6ccc02fda3aaeaf>>
Git revision: 1467870f834c61c6f00ce2577c41bb159d2d1ef8
@generated SignedSource<<17fe87ecb6f67eaa8d7f9ba699b7ace7>>
Git revision: b6c974c203394400867d959480187a996f0dbadb
Built with --nohooks: false
Is local checkout: false
Remote URL: https://github.com/facebookexperimental/rn-chrome-devtools-frontend
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export type PopupMenuAndroidInstance = {
type Props = {
menuItems: $ReadOnlyArray<string>,
onSelectionChange: number => void,
onPopupDismiss?: () => void,
onDismiss?: () => void,
children: React.Node,
instanceRef: RefObject<?PopupMenuAndroidInstance>,
};

export default function PopupMenuAndroid({
menuItems,
onSelectionChange,
onPopupDismiss,
onDismiss,
children,
instanceRef,
}: Props): React.Node {
Expand All @@ -53,11 +53,11 @@ export default function PopupMenuAndroid({
},
[onSelectionChange],
);
const _onPopupDismiss = useCallback(
const _onDismiss = useCallback(
(event: PopupMenuDismissEvent) => {
onPopupDismiss?.();
onDismiss?.();
},
[onPopupDismiss],
[onDismiss],
);

useImperativeHandle(instanceRef, ItemViewabilityInstance => {
Expand All @@ -72,7 +72,7 @@ export default function PopupMenuAndroid({
<PopupMenuAndroidNativeComponent
ref={nativeRef}
onPopupMenuSelectionChange={_onSelectionChange}
onPopupMenuDismiss={_onPopupDismiss}
onPopupMenuDismiss={_onDismiss}
menuItems={menuItems}>
{children}
</PopupMenuAndroidNativeComponent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type PopupMenuAndroidInstance = {
type Props = {
menuItems: Array<string>;
onSelectionChange: (number) => void;
onDismiss: () => void;
children: React.ReactNode | undefined;
instanceRef: React.ElementRef<HostComponent<PopupMenuAndroidInstance>>;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export type PopupMenuAndroidInstance = {
type Props = {
menuItems: $ReadOnlyArray<string>,
onSelectionChange: number => void,
onPopupDismiss?: () => void,
onDismiss?: () => void,
children: Node,
instanceRef: RefObject<?PopupMenuAndroidInstance>,
};
Expand Down
16 changes: 1 addition & 15 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,7 @@ - (RCTRootViewFactory *)createRCTRootViewFactory

#pragma mark - Feature Flags

class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
public:
bool useModernRuntimeScheduler() override
{
return true;
}
bool enableMicrotasks() override
{
return true;
}
bool batchRenderingUpdatesInEventLoop() override
{
return true;
}
};
class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {};

- (void)_setUpFeatureFlags
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@protocol RCTComponentViewFactoryComponentProvider;
@protocol RCTTurboModuleManagerDelegate;
@class RCTBridge;
@class RCTHost;
@class RCTRootView;
@class RCTSurfacePresenterBridgeAdapter;
@class RCTHost;
Expand Down Expand Up @@ -171,6 +172,7 @@ typedef void (^RCTHostDidReceiveJSErrorStackBlock)(
@interface RCTRootViewFactory : NSObject

@property (nonatomic, strong, nullable) RCTBridge *bridge;
@property (nonatomic, strong, nullable) RCTHost *reactHost;
@property (nonatomic, strong, nullable) RCTSurfacePresenterBridgeAdapter *bridgeAdapter;

- (instancetype)initWithConfiguration:(RCTRootViewFactoryConfiguration *)configuration
Expand All @@ -194,6 +196,10 @@ typedef void (^RCTHostDidReceiveJSErrorStackBlock)(

- (UIView *_Nonnull)viewWithModuleName:(NSString *)moduleName;

#pragma mark - RCTRootViewFactory Helpers

- (RCTHost *)createReactHost:(NSDictionary *__nullable)launchOptions;

@end

NS_ASSUME_NONNULL_END
31 changes: 18 additions & 13 deletions packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ @interface RCTRootViewFactory () <RCTCxxBridgeDelegate> {
@end

@implementation RCTRootViewFactory {
RCTHost *_reactHost;
RCTRootViewFactoryConfiguration *_configuration;
__weak id<RCTTurboModuleManagerDelegate> _turboModuleManagerDelegate;
}
Expand Down Expand Up @@ -144,7 +143,7 @@ - (UIView *)viewWithModuleName:(NSString *)moduleName

[self createReactHostIfNeeded:launchOptions];

RCTFabricSurface *surface = [_reactHost createSurfaceWithModuleName:moduleName initialProperties:initProps];
RCTFabricSurface *surface = [self.reactHost createSurfaceWithModuleName:moduleName initialProperties:initProps];

RCTSurfaceHostingProxyRootView *surfaceHostingProxyRootView = [[RCTSurfaceHostingProxyRootView alloc]
initWithSurface:surface
Expand Down Expand Up @@ -248,23 +247,29 @@ - (void)createBridgeAdapterIfNeeded

- (void)createReactHostIfNeeded:(NSDictionary *)launchOptions
{
if (_reactHost) {
if (self.reactHost) {
return;
}
self.reactHost = [self createReactHost:launchOptions];
}

- (RCTHost *)createReactHost:(NSDictionary *)launchOptions
{
__weak __typeof(self) weakSelf = self;
_reactHost = [[RCTHost alloc] initWithBundleURLProvider:self->_configuration.bundleURLBlock
hostDelegate:self
turboModuleManagerDelegate:_turboModuleManagerDelegate
jsEngineProvider:^std::shared_ptr<facebook::react::JSRuntimeFactory>() {
return [weakSelf createJSRuntimeFactory];
}
launchOptions:launchOptions];
[_reactHost setBundleURLProvider:^NSURL *() {
RCTHost *reactHost =
[[RCTHost alloc] initWithBundleURLProvider:self->_configuration.bundleURLBlock
hostDelegate:self
turboModuleManagerDelegate:_turboModuleManagerDelegate
jsEngineProvider:^std::shared_ptr<facebook::react::JSRuntimeFactory>() {
return [weakSelf createJSRuntimeFactory];
}
launchOptions:launchOptions];
[reactHost setBundleURLProvider:^NSURL *() {
return [weakSelf bundleURL];
}];
[_reactHost setContextContainerHandler:self];
[_reactHost start];
[reactHost setContextContainerHandler:self];
[reactHost start];
return reactHost;
}

- (std::shared_ptr<facebook::react::JSRuntimeFactory>)createJSRuntimeFactory
Expand Down
116 changes: 116 additions & 0 deletions packages/react-native/Libraries/Core/ErrorHandlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow strict
*/

'use strict';

import type {ExtendedError} from './ExtendedError';

import {SyntheticError, handleException} from './ExceptionsManager';

type ErrorInfo = {
+componentStack?: ?string,
// $FlowFixMe[unclear-type] unknown props and state.
+errorBoundary?: ?React$Component<any, any>,
};

export function onUncaughtError(errorValue: mixed, errorInfo: ErrorInfo): void {
let error;

// Typically, `errorValue` should be an error. However, other values such as
// strings (or even null) are sometimes thrown.
if (errorValue instanceof Error) {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (errorValue: ExtendedError);
} else if (typeof errorValue === 'string') {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (new SyntheticError(errorValue): ExtendedError);
} else {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (new SyntheticError('Unspecified error'): ExtendedError);
}
try {
// $FlowFixMe[incompatible-use] this is in try/catch.
error.componentStack = errorInfo.componentStack;
error.isComponentError = true;
} catch {
// Ignored.
}

// Uncaught errors are fatal.
handleException(error, true);
}

export function onCaughtError(errorValue: mixed, errorInfo: ErrorInfo): void {
let error;

// Typically, `errorValue` should be an error. However, other values such as
// strings (or even null) are sometimes thrown.
if (errorValue instanceof Error) {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (errorValue: ExtendedError);
} else if (typeof errorValue === 'string') {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (new SyntheticError(errorValue): ExtendedError);
} else {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (new SyntheticError('Unspecified error'): ExtendedError);
}
try {
// $FlowFixMe[incompatible-use] this is in try/catch.
error.componentStack = errorInfo.componentStack;
error.isComponentError = true;
} catch {
// Ignored.
}

// Caught errors are not fatal.
handleException(error, false);
}

export function onRecoverableError(
errorValue: mixed,
errorInfo: ErrorInfo,
): void {
let error;

// Typically, `errorValue` should be an error. However, other values such as
// strings (or even null) are sometimes thrown.
if (errorValue instanceof Error) {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (errorValue: ExtendedError);
} else if (typeof errorValue === 'string') {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (new SyntheticError(errorValue): ExtendedError);
} else {
/* $FlowFixMe[class-object-subtyping] added when improving typing for
* this parameters */
error = (new SyntheticError('Unspecified error'): ExtendedError);
}
try {
// $FlowFixMe[incompatible-use] this is in try/catch.
error.componentStack = errorInfo.componentStack;
error.isComponentError = true;
} catch {
// Ignored.
}

// Recoverable errors should only be warnings.
// This will make it a soft error in LogBox.
// TODO: improve the logging for recoverable errors in prod.
console.warn(error);
}
Loading

0 comments on commit dd31921

Please sign in to comment.