diff --git a/.flowconfig b/.flowconfig index 76be8b92eb..c4759ad565 100644 --- a/.flowconfig +++ b/.flowconfig @@ -79,4 +79,4 @@ untyped-import untyped-type-import [version] -^0.158.0 +^0.159.0 diff --git a/.flowconfig.android b/.flowconfig.android index bf7ae39967..2d334fcbaa 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -82,4 +82,4 @@ untyped-import untyped-type-import [version] -^0.158.0 +^0.159.0 diff --git a/.flowconfig.macos b/.flowconfig.macos index 3f5f932eb5..6f7a2828dd 100644 --- a/.flowconfig.macos +++ b/.flowconfig.macos @@ -79,4 +79,4 @@ untyped-import untyped-type-import [version] -^0.158.0 +^0.159.0 diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 541245effa..b1d45c967a 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -1275,11 +1275,6 @@ class ScrollView extends React.Component { ); } } - if (Platform.OS === 'android') { - if (this.props.keyboardDismissMode === 'on-drag' && this._isTouching) { - dismissKeyboard(); - } - } this._observedScrollSinceBecomingResponder = true; this.props.onScroll && this.props.onScroll(e); }; @@ -1396,6 +1391,14 @@ class ScrollView extends React.Component { */ _handleScrollBeginDrag: (e: ScrollEvent) => void = (e: ScrollEvent) => { FrameRateLogger.beginScroll(); // TODO: track all scrolls after implementing onScrollEndAnimation + + if ( + Platform.OS === 'android' && + this.props.keyboardDismissMode === 'on-drag' + ) { + dismissKeyboard(); + } + this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e); }; diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js index f530be6116..ea21ce221b 100644 --- a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +++ b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js @@ -4,25 +4,29 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @flow strict-local + * @flow * @format */ -import type {LayoutEvent} from '../../Types/CoreEventTypes'; -import setAndForwardRef from 'react-native/Libraries/Utilities/setAndForwardRef'; -import Platform from '../../Utilities/Platform'; -import StyleSheet from '../../StyleSheet/StyleSheet'; -import Animated from '../../Animated/Animated'; -import * as React from 'react'; -import {useEffect, useMemo, useRef, useCallback} from 'react'; +import AnimatedImplementation from '../../Animated/AnimatedImplementation'; +import AnimatedAddition from '../../Animated/nodes/AnimatedAddition'; +import AnimatedDiffClamp from '../../Animated/nodes/AnimatedDiffClamp'; +import AnimatedNode from '../../Animated/nodes/AnimatedNode'; -const AnimatedView = Animated.View; +import * as React from 'react'; +import StyleSheet from '../../StyleSheet/StyleSheet'; +import View from '../View/View'; +import Platform from '../../Utilities/Platform'; + +import type {LayoutEvent} from '../../Types/CoreEventTypes'; + +const AnimatedView = AnimatedImplementation.createAnimatedComponent(View); export type Props = $ReadOnly<{ - children?: React.Element<$FlowFixMe>, + children?: React.Element, nextHeaderLayoutY: ?number, onLayout: (event: LayoutEvent) => void, - scrollAnimatedValue: Animated.Value, + scrollAnimatedValue: AnimatedImplementation.Value, // Will cause sticky headers to stick at the bottom of the ScrollView instead // of the top. inverted: ?boolean, @@ -32,275 +36,287 @@ export type Props = $ReadOnly<{ hiddenOnScroll?: ?boolean, }>; -const ScrollViewStickyHeaderWithForwardedRef: React.AbstractComponent< - Props, - $ReadOnly<{ - setNextHeaderY: number => void, - ...$Exact>, - }>, -> = React.forwardRef(function ScrollViewStickyHeader(props, forwardedRef) { - const { - inverted, - scrollViewHeight, - hiddenOnScroll, - scrollAnimatedValue, - nextHeaderLayoutY: _nextHeaderLayoutY, - } = props; +type State = { + measured: boolean, + layoutY: number, + layoutHeight: number, + nextHeaderLayoutY: ?number, + translateY: ?number, + ... +}; - const [measured, setMeasured] = React.useState(false); - const [layoutY, setLayoutY] = React.useState(0); - const [layoutHeight, setLayoutHeight] = React.useState(0); - const [translateY, setTranslateY] = React.useState(null); - const [nextHeaderLayoutY, setNextHeaderLayoutY] = React.useState( - _nextHeaderLayoutY, - ); - const [isFabric, setIsFabric] = React.useState(false); +class ScrollViewStickyHeader extends React.Component { + state: State = { + measured: false, + layoutY: 0, + layoutHeight: 0, + nextHeaderLayoutY: this.props.nextHeaderLayoutY, + translateY: null, + }; - const componentRef = React.useRef>(); - const _setNativeRef = setAndForwardRef({ - getForwardedRef: () => forwardedRef, - setLocalRef: ref => { - componentRef.current = ref; - if (ref) { - ref.setNextHeaderY = value => { - setNextHeaderLayoutY(value); - }; - setIsFabric( - !!( - // An internal transform mangles variables with leading "_" as private. - // eslint-disable-next-line dot-notation - ref['_internalInstanceHandle']?.stateNode?.canonical - ), - ); - } - }, - }); + _translateY: ?AnimatedNode = null; + _shouldRecreateTranslateY: boolean = true; + _haveReceivedInitialZeroTranslateY: boolean = true; + _ref: any; // TODO T53738161: flow type this, and the whole file - const offset = useMemo( - () => - hiddenOnScroll === true - ? Animated.diffClamp( - scrollAnimatedValue - .interpolate({ - extrapolateLeft: 'clamp', - inputRange: [layoutY, layoutY + 1], - outputRange: ([0, 1]: Array), - }) - .interpolate({ - inputRange: [0, 1], - outputRange: ([0, -1]: Array), - }), - -layoutHeight, - 0, - ) - : null, - [scrollAnimatedValue, layoutHeight, layoutY, hiddenOnScroll], - ); + // Fabric-only: + _timer: ?TimeoutID; + _animatedValueListenerId: string; + _animatedValueListener: (valueObject: $ReadOnly<{|value: number|}>) => void; + _debounceTimeout: number = Platform.OS === 'android' ? 15 : 64; - const [ - animatedTranslateY, - setAnimatedTranslateY, - ] = React.useState(() => { - const inputRange: Array = [-1, 0]; - const outputRange: Array = [0, 0]; - const initialTranslateY: Animated.Interpolation = scrollAnimatedValue.interpolate( - { - inputRange, - outputRange, - }, - ); + setNextHeaderY: (y: number) => void = (y: number): void => { + this._shouldRecreateTranslateY = true; + this.setState({nextHeaderLayoutY: y}); + }; - if (offset != null) { - return Animated.add(initialTranslateY, offset); + componentWillUnmount() { + if (this._translateY != null && this._animatedValueListenerId != null) { + this._translateY.removeListener(this._animatedValueListenerId); } - return initialTranslateY; - }); - - const _haveReceivedInitialZeroTranslateY = useRef(true); - const _timer = useRef(null); - - useEffect(() => { - if (translateY !== 0 && translateY != null) { - _haveReceivedInitialZeroTranslateY.current = false; + if (this._timer) { + clearTimeout(this._timer); } - }, [translateY]); + } - // This is called whenever the (Interpolated) Animated Value - // updates, which is several times per frame during scrolling. - // To ensure that the Fabric ShadowTree has the most recent - // translate style of this node, we debounce the value and then - // pass it through to the underlying node during render. - // This is: - // 1. Only an issue in Fabric. - // 2. Worse in Android than iOS. In Android, but not iOS, you - // can touch and move your finger slightly and still trigger - // a "tap" event. In iOS, moving will cancel the tap in - // both Fabric and non-Fabric. On Android when you move - // your finger, the hit-detection moves from the Android - // platform to JS, so we need the ShadowTree to have knowledge - // of the current position. - const animatedValueListener = useCallback( - ({value}) => { - const _debounceTimeout: number = Platform.OS === 'android' ? 15 : 64; - // When the AnimatedInterpolation is recreated, it always initializes - // to a value of zero and emits a value change of 0 to its listeners. - if (value === 0 && !_haveReceivedInitialZeroTranslateY.current) { - _haveReceivedInitialZeroTranslateY.current = true; - return; - } - if (_timer.current != null) { - clearTimeout(_timer.current); - } - _timer.current = setTimeout(() => { - if (value !== translateY) { - setTranslateY(value); + UNSAFE_componentWillReceiveProps(nextProps: Props) { + if ( + nextProps.scrollViewHeight !== this.props.scrollViewHeight || + nextProps.scrollAnimatedValue !== this.props.scrollAnimatedValue || + nextProps.inverted !== this.props.inverted + ) { + this._shouldRecreateTranslateY = true; + } + } + + updateTranslateListener( + translateY: AnimatedImplementation.Interpolation, + isFabric: boolean, + offset: AnimatedDiffClamp | null, + ) { + if (this._translateY != null && this._animatedValueListenerId != null) { + this._translateY.removeListener(this._animatedValueListenerId); + } + offset + ? (this._translateY = new AnimatedAddition(translateY, offset)) + : (this._translateY = translateY); + + this._shouldRecreateTranslateY = false; + + if (!isFabric) { + return; + } + + if (!this._animatedValueListener) { + // This is called whenever the (Interpolated) Animated Value + // updates, which is several times per frame during scrolling. + // To ensure that the Fabric ShadowTree has the most recent + // translate style of this node, we debounce the value and then + // pass it through to the underlying node during render. + // This is: + // 1. Only an issue in Fabric. + // 2. Worse in Android than iOS. In Android, but not iOS, you + // can touch and move your finger slightly and still trigger + // a "tap" event. In iOS, moving will cancel the tap in + // both Fabric and non-Fabric. On Android when you move + // your finger, the hit-detection moves from the Android + // platform to JS, so we need the ShadowTree to have knowledge + // of the current position. + this._animatedValueListener = ({value}) => { + // When the AnimatedInterpolation is recreated, it always initializes + // to a value of zero and emits a value change of 0 to its listeners. + if (value === 0 && !this._haveReceivedInitialZeroTranslateY) { + this._haveReceivedInitialZeroTranslateY = true; + return; } - }, _debounceTimeout); - }, - [translateY], - ); - - useEffect(() => { - const inputRange: Array = [-1, 0]; - const outputRange: Array = [0, 0]; - - if (measured) { - if (inverted === true) { - // The interpolation looks like: - // - Negative scroll: no translation - // - `stickStartPoint` is the point at which the header will start sticking. - // It is calculated using the ScrollView viewport height so it is a the bottom. - // - Headers that are in the initial viewport will never stick, `stickStartPoint` - // will be negative. - // - From 0 to `stickStartPoint` no translation. This will cause the header - // to scroll normally until it reaches the top of the scroll view. - // - From `stickStartPoint` to when the next header y hits the bottom edge of the header: translate - // equally to scroll. This will cause the header to stay at the top of the scroll view. - // - Past the collision with the next header y: no more translation. This will cause the - // header to continue scrolling up and make room for the next sticky header. - // In the case that there is no next header just translate equally to - // scroll indefinitely. - if (scrollViewHeight != null) { - const stickStartPoint = layoutY + layoutHeight - scrollViewHeight; - if (stickStartPoint > 0) { - inputRange.push(stickStartPoint); - outputRange.push(0); - inputRange.push(stickStartPoint + 1); - outputRange.push(1); - // If the next sticky header has not loaded yet (probably windowing) or is the last - // we can just keep it sticked forever. - const collisionPoint = - (nextHeaderLayoutY || 0) - layoutHeight - scrollViewHeight; - if (collisionPoint > stickStartPoint) { - inputRange.push(collisionPoint, collisionPoint + 1); - outputRange.push( - collisionPoint - stickStartPoint, - collisionPoint - stickStartPoint, - ); - } + if (this._timer) { + clearTimeout(this._timer); + } + this._timer = setTimeout(() => { + if (value !== this.state.translateY) { + this.setState({ + translateY: value, + }); } - } - } else { - // The interpolation looks like: - // - Negative scroll: no translation - // - From 0 to the y of the header: no translation. This will cause the header - // to scroll normally until it reaches the top of the scroll view. - // - From header y to when the next header y hits the bottom edge of the header: translate - // equally to scroll. This will cause the header to stay at the top of the scroll view. - // - Past the collision with the next header y: no more translation. This will cause the - // header to continue scrolling up and make room for the next sticky header. - // In the case that there is no next header just translate equally to - // scroll indefinitely. - inputRange.push(layoutY); - outputRange.push(0); - // If the next sticky header has not loaded yet (probably windowing) or is the last - // we can just keep it sticked forever. - const collisionPoint = (nextHeaderLayoutY || 0) - layoutHeight; - if (collisionPoint >= layoutY) { - inputRange.push(collisionPoint, collisionPoint + 1); - outputRange.push(collisionPoint - layoutY, collisionPoint - layoutY); - } else { - inputRange.push(layoutY + 1); - outputRange.push(1); - } - } + }, this._debounceTimeout); + }; + } + if (this.state.translateY !== 0 && this.state.translateY != null) { + this._haveReceivedInitialZeroTranslateY = false; + } + this._animatedValueListenerId = translateY.addListener( + this._animatedValueListener, + ); + } + + _onLayout = event => { + const layoutY = event.nativeEvent.layout.y; + const layoutHeight = event.nativeEvent.layout.height; + const measured = true; + + if ( + layoutY !== this.state.layoutY || + layoutHeight !== this.state.layoutHeight || + measured !== this.state.measured + ) { + this._shouldRecreateTranslateY = true; } - let newAnimatedTranslateY: Animated.Node = scrollAnimatedValue.interpolate({ - inputRange, - outputRange, + this.setState({ + measured, + layoutY, + layoutHeight, }); - if (offset != null) { - newAnimatedTranslateY = Animated.add(newAnimatedTranslateY, offset); - } - - // add the event listener - let animatedListenerId; - if (isFabric) { - animatedListenerId = newAnimatedTranslateY.addListener( - animatedValueListener, - ); - } - - setAnimatedTranslateY(newAnimatedTranslateY); - - // clean up the event listener and timer - return () => { - if (animatedListenerId) { - newAnimatedTranslateY.removeListener(animatedListenerId); - } - if (_timer.current != null) { - clearTimeout(_timer.current); - } - }; - }, [nextHeaderLayoutY, measured, layoutHeight, layoutY, scrollViewHeight, scrollAnimatedValue, inverted, offset, animatedValueListener, isFabric]); - - const _onLayout = (event: LayoutEvent) => { - setLayoutY(event.nativeEvent.layout.y); - setLayoutHeight(event.nativeEvent.layout.height); - setMeasured(true); - - props.onLayout(event); - const child = React.Children.only(props.children); + this.props.onLayout(event); + const child = React.Children.only(this.props.children); if (child.props.onLayout) { child.props.onLayout(event); } }; - const child = React.Children.only(props.children); + _setComponentRef = ref => { + this._ref = ref; + }; - // TODO T68319535: remove this if NativeAnimated is rewritten for Fabric - const passthroughAnimatedPropExplicitValues = - isFabric && translateY != null - ? { - style: {transform: [{translateY: translateY}]}, + render(): React.Node { + // Fabric Detection + const isFabric = !!( + // An internal transform mangles variables with leading "_" as private. + // eslint-disable-next-line dot-notation + (this._ref && this._ref['_internalInstanceHandle']?.stateNode?.canonical) + ); + // Initially and in the case of updated props or layout, we + // recreate this interpolated value. Otherwise, we do not recreate + // when there are state changes. + if (this._shouldRecreateTranslateY) { + const {inverted, scrollViewHeight} = this.props; + const {measured, layoutHeight, layoutY, nextHeaderLayoutY} = this.state; + const inputRange: Array = [-1, 0]; + const outputRange: Array = [0, 0]; + + if (measured) { + if (inverted) { + // The interpolation looks like: + // - Negative scroll: no translation + // - `stickStartPoint` is the point at which the header will start sticking. + // It is calculated using the ScrollView viewport height so it is a the bottom. + // - Headers that are in the initial viewport will never stick, `stickStartPoint` + // will be negative. + // - From 0 to `stickStartPoint` no translation. This will cause the header + // to scroll normally until it reaches the top of the scroll view. + // - From `stickStartPoint` to when the next header y hits the bottom edge of the header: translate + // equally to scroll. This will cause the header to stay at the top of the scroll view. + // - Past the collision with the next header y: no more translation. This will cause the + // header to continue scrolling up and make room for the next sticky header. + // In the case that there is no next header just translate equally to + // scroll indefinitely. + if (scrollViewHeight != null) { + const stickStartPoint = layoutY + layoutHeight - scrollViewHeight; + if (stickStartPoint > 0) { + inputRange.push(stickStartPoint); + outputRange.push(0); + inputRange.push(stickStartPoint + 1); + outputRange.push(1); + // If the next sticky header has not loaded yet (probably windowing) or is the last + // we can just keep it sticked forever. + const collisionPoint = + (nextHeaderLayoutY || 0) - layoutHeight - scrollViewHeight; + if (collisionPoint > stickStartPoint) { + inputRange.push(collisionPoint, collisionPoint + 1); + outputRange.push( + collisionPoint - stickStartPoint, + collisionPoint - stickStartPoint, + ); + } + } + } + } else { + // The interpolation looks like: + // - Negative scroll: no translation + // - From 0 to the y of the header: no translation. This will cause the header + // to scroll normally until it reaches the top of the scroll view. + // - From header y to when the next header y hits the bottom edge of the header: translate + // equally to scroll. This will cause the header to stay at the top of the scroll view. + // - Past the collision with the next header y: no more translation. This will cause the + // header to continue scrolling up and make room for the next sticky header. + // In the case that there is no next header just translate equally to + // scroll indefinitely. + inputRange.push(layoutY); + outputRange.push(0); + // If the next sticky header has not loaded yet (probably windowing) or is the last + // we can just keep it sticked forever. + const collisionPoint = (nextHeaderLayoutY || 0) - layoutHeight; + if (collisionPoint >= layoutY) { + inputRange.push(collisionPoint, collisionPoint + 1); + outputRange.push( + collisionPoint - layoutY, + collisionPoint - layoutY, + ); + } else { + inputRange.push(layoutY + 1); + outputRange.push(1); + } } - : null; + } - return ( - /* $FlowFixMe[prop-missing] passthroughAnimatedPropExplicitValues isn't properly - included in the Animated.View flow type. */ - - {React.cloneElement(child, { - style: styles.fill, // We transfer the child style to the wrapper. - onLayout: undefined, // we call this manually through our this._onLayout - })} - - ); -}); + this.updateTranslateListener( + this.props.scrollAnimatedValue.interpolate({ + inputRange, + outputRange, + }), + isFabric, + this.props.hiddenOnScroll + ? new AnimatedDiffClamp( + this.props.scrollAnimatedValue + .interpolate({ + extrapolateLeft: 'clamp', + inputRange: [layoutY, layoutY + 1], + outputRange: ([0, 1]: Array), + }) + .interpolate({ + inputRange: [0, 1], + outputRange: ([0, -1]: Array), + }), + -this.state.layoutHeight, + 0, + ) + : null, + ); + } + + const child = React.Children.only(this.props.children); + + // TODO T68319535: remove this if NativeAnimated is rewritten for Fabric + const passthroughAnimatedPropExplicitValues = + isFabric && this.state.translateY != null + ? { + style: {transform: [{translateY: this.state.translateY}]}, + } + : null; + + return ( + + {React.cloneElement(child, { + style: styles.fill, // We transfer the child style to the wrapper. + onLayout: undefined, // we call this manually through our this._onLayout + })} + + ); + } +} const styles = StyleSheet.create({ header: { @@ -312,4 +328,4 @@ const styles = StyleSheet.create({ }, }); -export default ScrollViewStickyHeaderWithForwardedRef; +module.exports = ScrollViewStickyHeader; diff --git a/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m b/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m index 102234798b..91acd7dcba 100644 --- a/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m +++ b/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m @@ -16,7 +16,6 @@ @implementation RCTPropsAnimatedNode { NSNumber *_connectedViewTag; - NSNumber *_rootTag; NSString *_connectedViewName; __weak RCTBridge *_bridge; __weak id _surfacePresenter; @@ -48,7 +47,6 @@ _connectedViewTag = viewTag; _connectedViewName = viewName; _managedByFabric = RCTUIManagerTypeForTagIsFabric(viewTag); - _rootTag = nil; } - (void)disconnectFromView:(NSNumber *)viewTag @@ -58,7 +56,6 @@ _connectedViewTag = nil; _connectedViewName = nil; _managedByFabric = NO; - _rootTag = nil; } - (void)updateView diff --git a/React/Base/RCTBridge+Private.h b/React/Base/RCTBridge+Private.h index 70a20f0b00..9dd96a5cd1 100644 --- a/React/Base/RCTBridge+Private.h +++ b/React/Base/RCTBridge+Private.h @@ -7,6 +7,7 @@ #import +@class RCTModuleRegistry; @class RCTModuleData; @protocol RCTJavaScriptExecutor; @@ -62,6 +63,13 @@ RCT_EXTERN void RCTRegisterModule(Class); */ @property (nonatomic, strong, readwrite) NSURL *bundleURL; +/** + * An object that allows one to require NativeModules/TurboModules. + * RCTModuleRegistry is implemented in bridgeless mode and bridge mode. + * Used by RCTRootView. + */ +@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry; + @end @interface RCTBridge (RCTCxxBridge) diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index ef6f76b059..fe345ceb1a 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -258,6 +258,11 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init) }); } +- (RCTModuleRegistry *)moduleRegistry +{ + return self.batchedBridge.moduleRegistry; +} + - (NSArray *)moduleClasses { return self.batchedBridge.moduleClasses; diff --git a/React/Base/RCTEventDispatcherProtocol.h b/React/Base/RCTEventDispatcherProtocol.h index 31ab9e6818..60213482d3 100644 --- a/React/Base/RCTEventDispatcherProtocol.h +++ b/React/Base/RCTEventDispatcherProtocol.h @@ -81,6 +81,8 @@ typedef NS_ENUM(NSInteger, RCTTextEventType) { */ @protocol RCTEventDispatcherProtocol +- (void)sendViewEventWithName:(NSString *)name reactTag:(NSNumber *)reactTag; + /** * Deprecated, do not use. */ diff --git a/React/Base/RCTRootView.h b/React/Base/RCTRootView.h index 839e0574f2..57a427a68c 100644 --- a/React/Base/RCTRootView.h +++ b/React/Base/RCTRootView.h @@ -8,6 +8,8 @@ #import // TODO(macOS GH#774) #import +#import +#import @protocol RCTRootViewDelegate; @@ -75,6 +77,19 @@ extern initialProperties:(nullable NSDictionary *)initialProperties launchOptions:(nullable NSDictionary *)launchOptions; +/** + * This API allows RCTRootView users to know if the root view is backed by the bridge. + */ +@property (nonatomic, readonly) BOOL hasBridge; + +/** + * This API allows users of RCTRootView to access other NativeModules, without + * directly accessing the bridge. + */ +@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry; + +@property (nonatomic, strong, readonly) id eventDispatcher; + /** * The name of the JavaScript module to execute within the * specified scriptURL (required). Setting this will not have diff --git a/React/Base/RCTRootView.m b/React/Base/RCTRootView.m index 87e563f72e..dca1b2faf1 100644 --- a/React/Base/RCTRootView.m +++ b/React/Base/RCTRootView.m @@ -136,6 +136,21 @@ NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotificat RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder) +- (BOOL)hasBridge +{ + return _bridge != nil; +} + +- (RCTModuleRegistry *)moduleRegistry +{ + return _bridge.moduleRegistry; +} + +- (id)eventDispatcher +{ + return [self.moduleRegistry moduleForName:"EventDispatcher"]; +} + #pragma mark - passThroughTouches - (BOOL)passThroughTouches diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h index a9b0d2aa2d..8ad4104586 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h @@ -26,6 +26,9 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy, readonly) NSString *moduleName; @property (nonatomic, strong, readonly) RCTBridge *bridge; +@property (nonatomic, readonly) BOOL hasBridge; +@property (nonatomic, strong, readonly) RCTModuleRegistry *moduleRegistry; +@property (nonatomic, strong, readonly) id eventDispatcher; @property (nonatomic, copy, readwrite) NSDictionary *appProperties; @property (nonatomic, assign) RCTRootViewSizeFlexibility sizeFlexibility; @property (nonatomic, weak) id delegate; diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm index 146f2719b5..6eabd2c4d1 100644 --- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm +++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm @@ -10,6 +10,7 @@ #import #import "RCTAssert.h" +#import "RCTBridge+Private.h" #import "RCTBridge.h" #import "RCTLog.h" #import "RCTPerformanceLogger.h" @@ -94,6 +95,21 @@ static RCTRootViewSizeFlexibility convertToRootViewSizeFlexibility(RCTSurfaceSiz return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties]; } +- (BOOL)hasBridge +{ + return _bridge != nil; +} + +- (RCTModuleRegistry *)moduleRegistry +{ + return _bridge.moduleRegistry; +} + +- (id)eventDispatcher +{ + return [self.moduleRegistry moduleForName:"EventDispatcher"]; +} + RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame) RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder) diff --git a/React/CoreModules/RCTEventDispatcher.mm b/React/CoreModules/RCTEventDispatcher.mm index 26fe90a93a..9ef374d19a 100644 --- a/React/CoreModules/RCTEventDispatcher.mm +++ b/React/CoreModules/RCTEventDispatcher.mm @@ -56,6 +56,11 @@ RCT_EXPORT_MODULE() _observersLock = [NSLock new]; } +- (void)sendViewEventWithName:(NSString *)name reactTag:(NSNumber *)reactTag +{ + [_callableJSModules invokeModule:@"RCTViewEventEmitter" method:@"emit" withArgs:@[ name, RCTNullIfNil(reactTag) ]]; +} + - (void)sendAppEventWithName:(NSString *)name body:(id)body { [_callableJSModules invokeModule:@"RCTNativeAppEventEmitter" diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 62db7d737f..1bea80ec31 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -245,6 +245,11 @@ struct RCTInstanceCallback : public InstanceCallback { @synthesize performanceLogger = _performanceLogger; @synthesize valid = _valid; +- (RCTModuleRegistry *)moduleRegistry +{ + return _objCModuleRegistry; +} + - (void)setRCTTurboModuleRegistry:(id)turboModuleRegistry { _turboModuleRegistry = turboModuleRegistry; diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm index beb1ed2b66..f09ae72ce4 100644 --- a/React/Fabric/Mounting/RCTMountingManager.mm +++ b/React/Fabric/Mounting/RCTMountingManager.mm @@ -10,6 +10,7 @@ #import #import +#import #import #import #import @@ -26,6 +27,18 @@ using namespace facebook::react; +static SurfaceId RCTSurfaceIdForView(UIView *view) +{ + do { + if (RCTIsReactRootView(@(view.tag))) { + return view.tag; + } + view = view.superview; + } while (view != nil); + + return -1; +} + static void RCTPerformMountInstructions( ShadowViewMutationList const &mutations, RCTComponentViewRegistry *registry, @@ -282,9 +295,10 @@ static void RCTPerformMountInstructions( { RCTAssertMainQueue(); UIView *componentView = [_componentViewRegistry findComponentViewWithTag:reactTag]; + SurfaceId surfaceId = RCTSurfaceIdForView(componentView); SharedProps oldProps = [componentView props]; SharedProps newProps = componentDescriptor.cloneProps( - PropsParserContext{-1, *_contextContainer.get()}, oldProps, RawProps(convertIdToFollyDynamic(props))); + PropsParserContext{surfaceId, *_contextContainer.get()}, oldProps, RawProps(convertIdToFollyDynamic(props))); NSSet *propKeys = componentView.propKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN ?: [NSSet new]; propKeys = [propKeys setByAddingObjectsFromArray:props.allKeys]; diff --git a/ReactAndroid/src/main/java/com/facebook/react/BUCK b/ReactAndroid/src/main/java/com/facebook/react/BUCK index b550756ae1..a32feeb61c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/BUCK @@ -49,7 +49,6 @@ rn_android_library( react_native_target("java/com/facebook/react/config:config"), react_native_target("java/com/facebook/react/turbomodule/core:core"), react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"), - react_native_target("java/com/facebook/react/runtimescheduler:runtimescheduler"), ], exported_deps = [ react_native_target("java/com/facebook/react/modules/core:core"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java index d73c8f7e1e..4c8a8f9797 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java @@ -92,7 +92,6 @@ import com.facebook.react.modules.core.ReactChoreographer; import com.facebook.react.modules.debug.interfaces.DeveloperSettings; import com.facebook.react.modules.fabric.ReactFabric; import com.facebook.react.packagerconnection.RequestHandler; -import com.facebook.react.runtimescheduler.RuntimeSchedulerManager; import com.facebook.react.surface.ReactStage; import com.facebook.react.turbomodule.core.TurboModuleManager; import com.facebook.react.turbomodule.core.TurboModuleManagerDelegate; @@ -167,7 +166,6 @@ public class ReactInstanceManager { private final boolean mUseDeveloperSupport; private final boolean mRequireActivity; private @Nullable ComponentNameResolverManager mComponentNameResolverManager; - private @Nullable RuntimeSchedulerManager mRuntimeSchedulerManager; private final @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener; private final Object mReactContextLock = new Object(); private @Nullable volatile ReactContext mCurrentReactContext; @@ -759,7 +757,6 @@ public class ReactInstanceManager { mViewManagerNames = null; } mComponentNameResolverManager = null; - mRuntimeSchedulerManager = null; FLog.d(ReactConstants.TAG, "ReactInstanceManager has been destroyed"); } @@ -1394,9 +1391,6 @@ public class ReactInstanceManager { }); catalystInstance.setGlobalVariable("__fbStaticViewConfig", "true"); } - if (ReactFeatureFlags.enableRuntimeScheduler) { - mRuntimeSchedulerManager = new RuntimeSchedulerManager(catalystInstance.getRuntimeExecutor()); - } ReactMarker.logMarker(ReactMarkerConstants.PRE_RUN_JS_BUNDLE_START); Systrace.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "runJSBundle"); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java index 2370e84ba2..ca2c7df44f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountItemDispatcher.java @@ -13,6 +13,7 @@ import static com.facebook.react.fabric.FabricUIManager.ENABLE_FABRIC_LOGS; import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT; import android.os.SystemClock; +import android.view.View; import androidx.annotation.AnyThread; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -274,10 +275,17 @@ public class MountItemDispatcher { executeOrEnqueue(mountItem); } catch (Throwable e) { // If there's an exception, we want to log diagnostics in prod and rethrow. - FLog.e(TAG, "dispatchMountItems: caught exception, displaying all MountItems", e); + FLog.e(TAG, "dispatchMountItems: caught exception, displaying mount state", e); for (MountItem m : mountItemsToDispatch) { printMountItem(m, "dispatchMountItems: mountItem"); } + if (mountItem.getSurfaceId() != View.NO_ID) { + SurfaceMountingManager surfaceManager = + mMountingManager.getSurfaceManager(mountItem.getSurfaceId()); + if (surfaceManager != null) { + surfaceManager.printSurfaceState(); + } + } if (ReactIgnorableMountingException.isIgnorable(e)) { ReactSoftExceptionLogger.logSoftException(TAG, e); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java index 1f05f824c8..f93d1c20dc 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java @@ -963,6 +963,25 @@ public class SurfaceMountingManager { return (ViewGroupManager) viewState.mViewManager; } + public void printSurfaceState() { + FLog.e(TAG, "Views created for surface {%d}:", getSurfaceId()); + for (ViewState viewState : mTagToViewState.values()) { + String viewManagerName = + viewState.mViewManager != null ? viewState.mViewManager.getName() : null; + @Nullable View view = viewState.mView; + @Nullable View parent = view != null ? (View) view.getParent() : null; + @Nullable Integer parentTag = parent != null ? parent.getId() : null; + + FLog.e( + TAG, + "<%s id=%d parentTag=%s isRoot=%b />", + viewManagerName, + viewState.mReactTag, + parentTag, + viewState.mIsRoot); + } + } + /** * This class holds view state for react tags. Objects of this class are stored into the {@link * #mTagToViewState}, and they should be updated in the same thread. diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/BUCK b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/BUCK deleted file mode 100644 index a68079db76..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/BUCK +++ /dev/null @@ -1,20 +0,0 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_target", "rn_android_library") - -rn_android_library( - name = "runtimescheduler", - srcs = glob(["**/*.java"]), - autoglob = False, - is_androidx = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], - visibility = [ - "PUBLIC", - ], - deps = [ - react_native_target("java/com/facebook/react/runtimescheduler/jni:jni"), - react_native_dep("third-party/android/androidx:annotation"), - react_native_dep("third-party/java/infer-annotations:infer-annotations"), - react_native_dep("libraries/fbjni:java"), - react_native_target("java/com/facebook/react/bridge:bridge"), - react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"), - ], -) diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/RuntimeSchedulerManager.java b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/RuntimeSchedulerManager.java deleted file mode 100644 index d7846b568c..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/RuntimeSchedulerManager.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -package com.facebook.react.runtimescheduler; - -import com.facebook.jni.HybridData; -import com.facebook.proguard.annotations.DoNotStrip; -import com.facebook.proguard.annotations.DoNotStripAny; -import com.facebook.react.bridge.RuntimeExecutor; -import com.facebook.soloader.SoLoader; - -@DoNotStripAny -public class RuntimeSchedulerManager { - - static { - staticInit(); - } - - @DoNotStrip - @SuppressWarnings("unused") - private final HybridData mHybridData; - - public RuntimeSchedulerManager(RuntimeExecutor runtimeExecutor) { - mHybridData = initHybrid(runtimeExecutor); - installJSIBindings(); - } - - private native HybridData initHybrid(RuntimeExecutor runtimeExecutor); - - private native void installJSIBindings(); - - private static void staticInit() { - SoLoader.loadLibrary("runtimeschedulerjni"); - } -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/Android.mk deleted file mode 100644 index bb4e320112..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/Android.mk +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := runtimeschedulerjni - -LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) - -LOCAL_SHARED_LIBRARIES := libglog libfb libfbjni libglog_init libreact_render_runtimescheduler librrc_native - -LOCAL_STATIC_LIBRARIES := - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ - -LOCAL_CFLAGS := \ - -DLOG_TAG=\"ReacTNative\" - -LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,fbgloginit) -$(call import-module,fb) -$(call import-module,fbjni) -$(call import-module,glog) - -$(call import-module,react/renderer/runtimescheduler) diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/BUCK deleted file mode 100644 index 426b06a139..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/BUCK +++ /dev/null @@ -1,35 +0,0 @@ -load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_native_target", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob") - -rn_xplat_cxx_library( - name = "jni", - srcs = glob(["*.cpp"]), - headers = glob(["*.h"]), - header_namespace = "", - exported_headers = subdir_glob( - [ - ("", "**/*.h"), - ], - prefix = "react/runtimescheduler", - ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], - fbandroid_allow_jni_merging = True, - labels = ["supermodule:xplat/default/public.react_native.infra"], - platforms = ANDROID, - preprocessor_flags = [ - "-DLOG_TAG=\"ReactNative\"", - "-DWITH_FBSYSTRACE=1", - ], - soname = "libruntimeschedulerjni.$(ext)", - visibility = ["PUBLIC"], - deps = [ - react_native_xplat_target("react/renderer/runtimescheduler:runtimescheduler"), - react_native_xplat_target("runtimeexecutor:runtimeexecutor"), - react_native_target("jni/react/jni:jni"), - FBJNI_TARGET, - ], -) diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/OnLoad.cpp b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/OnLoad.cpp deleted file mode 100644 index 189de80dfc..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/OnLoad.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include - -#include "RuntimeSchedulerManager.h" - -JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) { - return facebook::jni::initialize( - vm, [] { facebook::react::RuntimeSchedulerManager::registerNatives(); }); -} diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.cpp b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.cpp deleted file mode 100644 index 2b0d893370..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include -#include -#include - -#include "RuntimeSchedulerManager.h" - -namespace facebook { -namespace react { - -RuntimeSchedulerManager::RuntimeSchedulerManager( - RuntimeExecutor runtimeExecutor) - : runtimeExecutor_(runtimeExecutor) {} - -jni::local_ref -RuntimeSchedulerManager::initHybrid( - jni::alias_ref, - jni::alias_ref runtimeExecutor) { - return makeCxxInstance(runtimeExecutor->cthis()->get()); -} - -void RuntimeSchedulerManager::registerNatives() { - registerHybrid({ - makeNativeMethod("initHybrid", RuntimeSchedulerManager::initHybrid), - makeNativeMethod( - "installJSIBindings", RuntimeSchedulerManager::installJSIBindings), - }); -} - -void RuntimeSchedulerManager::installJSIBindings() { - runtimeExecutor_([runtimeExecutor = runtimeExecutor_](jsi::Runtime &runtime) { - auto runtimeScheduler = std::make_shared(runtimeExecutor); - RuntimeSchedulerBinding::createAndInstallIfNeeded( - runtime, runtimeScheduler); - }); -} - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.h b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.h deleted file mode 100644 index 6456c7176f..0000000000 --- a/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include -#include -#include - -namespace facebook { -namespace react { - -class RuntimeSchedulerManager - : public facebook::jni::HybridClass { - public: - static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/runtimescheduler/RuntimeSchedulerManager;"; - - static facebook::jni::local_ref initHybrid( - jni::alias_ref, - facebook::jni::alias_ref runtimeExecutor); - - static void registerNatives(); - - private: - friend HybridBase; - RuntimeExecutor runtimeExecutor_; - - void installJSIBindings(); - - explicit RuntimeSchedulerManager(RuntimeExecutor runtimeExecutor); -}; - -} // namespace react -} // namespace facebook diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java index 7ce861de7b..64135eda4f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java @@ -56,6 +56,7 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie private boolean mAdjustsFontSizeToFit = false; private int mLinkifyMaskType = 0; private boolean mNotifyOnInlineViewLayout; + private boolean mTextIsSelectable = false; private ReactViewBackgroundManager mReactBackgroundManager; private Spannable mSpanned; @@ -433,9 +434,16 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie } } + @Override + public void setTextIsSelectable(boolean selectable) { + mTextIsSelectable = selectable; + super.setTextIsSelectable(selectable); + } + @Override public void onAttachedToWindow() { super.onAttachedToWindow(); + setTextIsSelectable(mTextIsSelectable); if (mContainsImages && getText() instanceof Spanned) { Spanned text = (Spanned) getText(); TextInlineImageSpan[] spans = text.getSpans(0, text.length(), TextInlineImageSpan.class); diff --git a/ReactCommon/react/renderer/attributedstring/AttributedString.h b/ReactCommon/react/renderer/attributedstring/AttributedString.h index f3ed792238..a1058c510b 100644 --- a/ReactCommon/react/renderer/attributedstring/AttributedString.h +++ b/ReactCommon/react/renderer/attributedstring/AttributedString.h @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/ReactCommon/react/renderer/attributedstring/TextAttributes.h index 87bbffc30e..b7f07b962d 100644 --- a/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -10,8 +10,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/ReactCommon/react/renderer/core/ConcreteShadowNode.h b/ReactCommon/react/renderer/core/ConcreteShadowNode.h index d441f326a0..8ad8820f59 100644 --- a/ReactCommon/react/renderer/core/ConcreteShadowNode.h +++ b/ReactCommon/react/renderer/core/ConcreteShadowNode.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include diff --git a/ReactCommon/react/renderer/core/Props.h b/ReactCommon/react/renderer/core/Props.h index 3321310b43..5d99a0139a 100644 --- a/ReactCommon/react/renderer/core/Props.h +++ b/ReactCommon/react/renderer/core/Props.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include diff --git a/ReactCommon/react/renderer/core/PropsParserContext.h b/ReactCommon/react/renderer/core/PropsParserContext.h index 9b9d10d2dc..df4b16d70a 100644 --- a/ReactCommon/react/renderer/core/PropsParserContext.h +++ b/ReactCommon/react/renderer/core/PropsParserContext.h @@ -7,6 +7,7 @@ #pragma once +#include #include namespace facebook { @@ -20,8 +21,8 @@ struct PropsParserContext { PropsParserContext(const PropsParserContext &) = delete; PropsParserContext &operator=(const PropsParserContext &) = delete; - int surfaceId; // TODO: use SurfaceId type - const ContextContainer &contextContainer; + SurfaceId const surfaceId; + ContextContainer const &contextContainer; }; } // namespace react diff --git a/ReactCommon/react/renderer/core/ReactPrimitives.h b/ReactCommon/react/renderer/core/ReactPrimitives.h index 4954fcfff9..28738394bf 100644 --- a/ReactCommon/react/renderer/core/ReactPrimitives.h +++ b/ReactCommon/react/renderer/core/ReactPrimitives.h @@ -8,8 +8,6 @@ #pragma once #include -#include -#include #include #include diff --git a/ReactCommon/react/renderer/core/ShadowNodeFamily.h b/ReactCommon/react/renderer/core/ShadowNodeFamily.h index 2f57666c17..07746e3550 100644 --- a/ReactCommon/react/renderer/core/ShadowNodeFamily.h +++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.h @@ -10,6 +10,7 @@ #include #include +#include #include #include diff --git a/ReactCommon/react/renderer/runtimescheduler/BUCK b/ReactCommon/react/renderer/runtimescheduler/BUCK index 7cdf02a763..8303728982 100644 --- a/ReactCommon/react/renderer/runtimescheduler/BUCK +++ b/ReactCommon/react/renderer/runtimescheduler/BUCK @@ -50,7 +50,6 @@ rn_xplat_cxx_library( tests = [":tests"], visibility = ["PUBLIC"], deps = [ - react_native_xplat_target("react/renderer/core:core"), react_native_xplat_target("runtimeexecutor:runtimeexecutor"), react_native_xplat_target("react/renderer/debug:debug"), react_native_xplat_target("better:better"), diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp index d1550bc85b..fd47ab4303 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp @@ -7,7 +7,8 @@ #include "RuntimeScheduler.h" -namespace facebook::react { +namespace facebook { +namespace react { #pragma mark - Public @@ -113,4 +114,5 @@ void RuntimeScheduler::startWorkLoop(jsi::Runtime &runtime) const { isPerformingWork_ = false; } -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h index b5dad38ae2..5d18a7d9ea 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.h @@ -14,7 +14,8 @@ #include #include -namespace facebook::react { +namespace facebook { +namespace react { class RuntimeScheduler final { public: @@ -100,4 +101,5 @@ class RuntimeScheduler final { mutable bool isPerformingWork_{false}; }; -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp index 05a3d3395a..92525118e2 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.cpp @@ -10,11 +10,11 @@ #include "primitives.h" #include -#include #include #include -namespace facebook::react { +namespace facebook { +namespace react { std::shared_ptr RuntimeSchedulerBinding::createAndInstallIfNeeded( @@ -167,4 +167,5 @@ jsi::Value RuntimeSchedulerBinding::get( return jsi::Value::undefined(); } -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h index cc4544d6a8..27c1ad9f31 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerBinding.h @@ -10,7 +10,8 @@ #include #include -namespace facebook::react { +namespace facebook { +namespace react { /* * Exposes RuntimeScheduler to JavaScript realm. @@ -39,4 +40,5 @@ class RuntimeSchedulerBinding : public jsi::HostObject { std::shared_ptr runtimeScheduler_; }; -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h index 25e8b327db..51652ee0a0 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeSchedulerClock.h @@ -9,7 +9,8 @@ #include -namespace facebook::react { +namespace facebook { +namespace react { /* * Represents a monotonic clock suitable for measuring intervals. @@ -19,4 +20,5 @@ using RuntimeSchedulerClock = std::chrono::steady_clock; using RuntimeSchedulerTimePoint = RuntimeSchedulerClock::time_point; using RuntimeSchedulerDuration = RuntimeSchedulerClock::duration; -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h b/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h index 4b5a1b7eab..329fe252aa 100644 --- a/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h +++ b/ReactCommon/react/renderer/runtimescheduler/SchedulerPriority.h @@ -8,10 +8,10 @@ #pragma once #include -#include #include -namespace facebook::react { +namespace facebook { +namespace react { enum class SchedulerPriority : int { ImmediatePriority = 1, @@ -61,4 +61,5 @@ static inline std::chrono::milliseconds timeoutForSchedulerPriority( } } -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/Task.cpp b/ReactCommon/react/renderer/runtimescheduler/Task.cpp index b44d9719a1..bd87944afa 100644 --- a/ReactCommon/react/renderer/runtimescheduler/Task.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/Task.cpp @@ -7,7 +7,8 @@ #include "RuntimeScheduler.h" -namespace facebook::react { +namespace facebook { +namespace react { Task::Task( SchedulerPriority priority, @@ -32,4 +33,5 @@ jsi::Value Task::execute(jsi::Runtime &runtime) { return result; } -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/Task.h b/ReactCommon/react/renderer/runtimescheduler/Task.h index 74c387636e..87676d5db7 100644 --- a/ReactCommon/react/renderer/runtimescheduler/Task.h +++ b/ReactCommon/react/renderer/runtimescheduler/Task.h @@ -12,7 +12,8 @@ #include #include -namespace facebook::react { +namespace facebook { +namespace react { class RuntimeScheduler; class TaskPriorityComparer; @@ -43,4 +44,5 @@ class TaskPriorityComparer { } }; -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/primitives.h b/ReactCommon/react/renderer/runtimescheduler/primitives.h index 7679494145..2283b4cad2 100644 --- a/ReactCommon/react/renderer/runtimescheduler/primitives.h +++ b/ReactCommon/react/renderer/runtimescheduler/primitives.h @@ -11,7 +11,8 @@ #include #include -namespace facebook::react { +namespace facebook { +namespace react { struct TaskWrapper : public jsi::HostObject { TaskWrapper(std::shared_ptr const &task) : task(task) {} @@ -36,4 +37,5 @@ inline static std::shared_ptr taskFromValue( return value.getObject(runtime).getHostObject(runtime)->task; } -} // namespace facebook::react +} // namespace react +} // namespace facebook diff --git a/gradle.properties b/gradle.properties index e785ec12c9..223dcfb79c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ org.gradle.parallel=true ANDROID_NDK_VERSION=21.4.7075529 android.useAndroidX=true -kotlin_version=1.4.21 +kotlin_version=1.4.32 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 29e4134576..af7be50b10 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew.bat b/gradlew.bat index ac1b06f938..107acd32c4 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/package.json b/package.json index 3be3a40df1..c491f7fabe 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-native": "^3.11.0", "eslint-plugin-relay": "1.8.1", - "flow-bin": "^0.158.0", + "flow-bin": "^0.159.0", "jest": "^26.6.3", "jest-junit": "^10.0.0", "jscodeshift": "^0.11.0", diff --git a/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties b/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties index 29e4134576..af7be50b10 100644 --- a/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties +++ b/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/packages/react-native-codegen/android/gradlew.bat b/packages/react-native-codegen/android/gradlew.bat index ac1b06f938..107acd32c4 100644 --- a/packages/react-native-codegen/android/gradlew.bat +++ b/packages/react-native-codegen/android/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 189493875d..59fd47af0b 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -419,6 +419,7 @@ DEPENDENCIES: - FlipperKit/FlipperKitUserDefaultsPlugin (= 0.99.0) - FlipperKit/SKIOSNetworkPlugin (= 0.99.0) - glog (from `../../third-party-podspecs/glog.podspec`) + - OpenSSL-Universal (= 1.1.180) - RCT-Folly (from `../../third-party-podspecs/RCT-Folly.podspec`) - RCTRequired (from `../../Libraries/RCTRequired`) - RCTTypeSafety (from `../../Libraries/TypeSafety`) diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index e10eb92828..bb13cb4d0f 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -1683,7 +1683,6 @@ "$(inherited)", "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)", "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)", - "\"$(SDKROOT)/usr/lib/swift\"", ); OTHER_CFLAGS = ( "$(inherited)", diff --git a/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js index 2312ee69c2..158590e4ad 100644 --- a/packages/rn-tester/js/components/ListExampleShared.js +++ b/packages/rn-tester/js/components/ListExampleShared.js @@ -57,13 +57,14 @@ class ItemComponent extends React.PureComponent<{ onPress: (key: string) => void, onShowUnderlay?: () => void, onHideUnderlay?: () => void, + textSelectable?: ?boolean, ... }> { _onPress = () => { this.props.onPress(this.props.item.key); }; render(): React.Node { - const {fixedHeight, horizontal, item} = this.props; + const {fixedHeight, horizontal, item, textSelectable} = this.props; const itemHash = Math.abs(hashCode(item.title)); const imgSource = THUMB_URLS[itemHash % THUMB_URLS.length]; return ( @@ -81,6 +82,7 @@ class ItemComponent extends React.PureComponent<{ {!item.noImage && } {item.title} - {item.text} diff --git a/packages/rn-tester/js/examples/FlatList/FlatListExample.js b/packages/rn-tester/js/examples/FlatList/FlatListExample.js index 4606d68090..93d7eb2de4 100644 --- a/packages/rn-tester/js/examples/FlatList/FlatListExample.js +++ b/packages/rn-tester/js/examples/FlatList/FlatListExample.js @@ -59,6 +59,8 @@ type State = {| empty: boolean, useFlatListItemComponent: boolean, fadingEdgeLength: number, + onPressDisabled: boolean, + textSelectable: boolean, |}; class FlatListExample extends React.PureComponent { @@ -74,6 +76,8 @@ class FlatListExample extends React.PureComponent { empty: false, useFlatListItemComponent: false, fadingEdgeLength: 0, + onPressDisabled: false, + textSelectable: true, }; _onChangeFilterText = filterText => { @@ -161,6 +165,16 @@ class FlatListExample extends React.PureComponent { this.state.debug, this._setBooleanValue('debug'), )} + {renderSmallSwitchOption( + 'onPress Disabled', + this.state.onPressDisabled, + this._setBooleanValue('onPressDisabled'), + )} + {renderSmallSwitchOption( + 'Text Selectable', + this.state.textSelectable, + this._setBooleanValue('textSelectable'), + )} {renderSmallSwitchOption( 'Use FlatListItemComponent', this.state.useFlatListItemComponent, @@ -236,6 +250,12 @@ class FlatListExample extends React.PureComponent { data: state.data.concat(genItemData(100, state.data.length)), })); }; + _onPressCallback = () => { + const {onPressDisabled} = this.state; + const warning = () => console.log('onPress disabled'); + const onPressAction = onPressDisabled ? warning : this._pressItem; + return onPressAction; + }; _onRefresh = () => Alert.alert('onRefresh: nothing to refresh :P'); _renderItemComponent = () => { const flatListPropKey = this.state.useFlatListItemComponent @@ -253,9 +273,10 @@ class FlatListExample extends React.PureComponent { item={item} horizontal={this.state.horizontal} fixedHeight={this.state.fixedHeight} - onPress={this._pressItem} + onPress={this._onPressCallback()} onShowUnderlay={separators.highlight} onHideUnderlay={separators.unhighlight} + textSelectable={this.state.textSelectable} /> ); }, diff --git a/repo-config/package.json b/repo-config/package.json index 7f99208f9d..7d68c10aba 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -36,7 +36,7 @@ "eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-native": "^3.11.0", "eslint-plugin-relay": "^1.8.2", - "flow-bin": "^0.158.0", + "flow-bin": "^0.159.0", "jest": "^26.6.3", "jest-junit": "^10.0.0", "jscodeshift": "^0.11.0", diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb index 992bf2ef70..db8130c8e1 100644 --- a/scripts/react_native_pods.rb +++ b/scripts/react_native_pods.rb @@ -82,6 +82,7 @@ def use_flipper!(versions = {}, configurations: ['Debug']) versions['Flipper-Glog'] ||= '0.3.6' versions['Flipper-PeerTalk'] ||= '0.0.4' versions['Flipper-RSocket'] ||= '1.4.3' + versions['OpenSSL-Universal'] ||= '1.1.180' pod 'FlipperKit', versions['Flipper'], :configurations => configurations pod 'FlipperKit/FlipperKitLayoutPlugin', versions['Flipper'], :configurations => configurations pod 'FlipperKit/SKIOSNetworkPlugin', versions['Flipper'], :configurations => configurations @@ -105,6 +106,7 @@ def use_flipper!(versions = {}, configurations: ['Debug']) pod 'FlipperKit/FlipperKitHighlightOverlay', versions['Flipper'], :configurations => configurations pod 'FlipperKit/FlipperKitLayoutTextSearchable', versions['Flipper'], :configurations => configurations pod 'FlipperKit/FlipperKitNetworkPlugin', versions['Flipper'], :configurations => configurations + pod 'OpenSSL-Universal', versions['OpenSSL-Universal'], :configurations => configurations end def has_pod(installer, name) diff --git a/template/_flowconfig b/template/_flowconfig index e4eec7ee02..50317312eb 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -65,4 +65,4 @@ untyped-import untyped-type-import [version] -^0.158.0 +^0.159.0 diff --git a/template/android/gradle/wrapper/gradle-wrapper.properties b/template/android/gradle/wrapper/gradle-wrapper.properties index 29e4134576..af7be50b10 100644 --- a/template/android/gradle/wrapper/gradle-wrapper.properties +++ b/template/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/template/android/gradlew.bat b/template/android/gradlew.bat index ac1b06f938..107acd32c4 100644 --- a/template/android/gradlew.bat +++ b/template/android/gradlew.bat @@ -1,89 +1,89 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/template/ios/HelloWorld.xcodeproj/project.pbxproj b/template/ios/HelloWorld.xcodeproj/project.pbxproj index 5bc15e455c..fbe9f29272 100644 --- a/template/ios/HelloWorld.xcodeproj/project.pbxproj +++ b/template/ios/HelloWorld.xcodeproj/project.pbxproj @@ -439,7 +439,6 @@ "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", "\"$(inherited)\"", - "\"$(SDKROOT)/usr/lib/swift\"", ); MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -498,7 +497,6 @@ "\"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)\"", "\"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)\"", "\"$(inherited)\"", - "\"$(SDKROOT)/usr/lib/swift\"", ); MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; diff --git a/yarn.lock b/yarn.lock index 03e56c8f12..0f0874469e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3993,10 +3993,10 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3" integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg== -flow-bin@^0.158.0: - version "0.158.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.158.0.tgz#0a09763d41eb8ec7135ced6a3b9f8fa370a393d8" - integrity sha512-Gk5md8XTwk/M+J5M+rFyS1LJfFen6ldY60jM9+meWixlKf4b0vwdoUO8R7oo471pze+GY+blrnskUeqLDxFJfg== +flow-bin@^0.159.0: + version "0.159.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.159.0.tgz#f788480d54db6da021e3440648c1dbb5dbc8aee8" + integrity sha512-5SugX7mOdfruzn2/+42DF74bxJO2SGmSEzCvTH9wOoBi98Ie87D5Hmb9OoGfwAE5SnXJmB6OCwN2WDiJe4lI+w== flow-parser@0.*: version "0.176.2"