Skip to content

Commit

Permalink
Merge branch 'master' into rotation-issue-sdk-24-28
Browse files Browse the repository at this point in the history
  • Loading branch information
fabOnReact authored Mar 3, 2021
2 parents e1fc40e + 84a81da commit e6658a2
Show file tree
Hide file tree
Showing 129 changed files with 879 additions and 1,265 deletions.
2 changes: 1 addition & 1 deletion .buckconfig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[android]
target = android-29
target = android-30

[download]
max_number_of_retries = 3
Expand Down
2 changes: 1 addition & 1 deletion .circleci/Dockerfiles/Dockerfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# and build a Android application that can be used to run the
# tests specified in the scripts/ directory.
#
FROM reactnativecommunity/react-native-android:2.1
FROM reactnativecommunity/react-native-android:3.2

LABEL Description="React Native Android Test Image"
LABEL maintainer="Héctor Ramos <[email protected]>"
Expand Down
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ executors:
reactnativeandroid:
<<: *defaults
docker:
- image: reactnativecommunity/react-native-android:2.1
- image: reactnativecommunity/react-native-android:3.2
resource_class: "large"
environment:
- TERM: "dumb"
Expand Down Expand Up @@ -617,7 +617,7 @@ jobs:
environment:
- ANDROID_HOME: "C:\\Android\\android-sdk"
- ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944"
- ANDROID_BUILD_VERSION: 28
- ANDROID_BUILD_VERSION: 30
- ANDROID_TOOLS_VERSION: 29.0.3
- GRADLE_OPTS: -Dorg.gradle.daemon=false
- NDK_VERSION: 20.1.5948944
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Configuration for Label Actions - https://github.com/marketplace/actions/label-actions
# Configuration for Respond To Issue Based on Label https://github.com/marketplace/actions/respond-to-issue-based-on-label

"Type: Invalid":
close: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: Label Actions
name: On Issue Labeled
# This workflow is triggered when a label is added to an issue.
on:
issues:
types: labeled

jobs:
processLabelAction:
name: Process Label Action
respondToIssueBasedOnLabel:
name: Respond to Issue Based on Label
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Process Label Action
uses: hramos/label-actions@v1
- name: Respond to Issue Based on Label
uses: hramos/respond-to-issue-based-on-label@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 19 additions & 1 deletion Libraries/Animated/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
// When called during the first render, `_component` is always null.
// Therefore, even if a component is rendered in Fabric, we can't detect
// that until ref is set, which happens sometime after the first render.
// In cases where this value switching between "false" and "true" on Fabric
// causes issues, add an additional check for _component nullity.
if (this._component == null) {
return false;
}
Expand Down Expand Up @@ -221,10 +223,24 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
const {style: passthruStyle = {}, ...passthruProps} =
this.props.passthroughAnimatedPropExplicitValues || {};
const mergedStyle = {...style, ...passthruStyle};

// On Fabric, we always want to ensure the container Animated View is *not*
// flattened.
// Because we do not get a host component ref immediately and thus cannot
// do a proper Fabric vs non-Fabric detection immediately, we default to assuming
// that Fabric *is* enabled until we know otherwise.
// Thus, in Fabric, this view will never be flattened. In non-Fabric, the view will
// not be flattened during the initial render but may be flattened in the second render
// and onwards.
const forceNativeIdFabric =
(this._component == null &&
(options?.collapsable === false || props.collapsable !== true)) ||
this._isFabric();

const forceNativeId =
props.collapsable ??
(this._propsAnimated.__isNative ||
this._isFabric() ||
forceNativeIdFabric ||
options?.collapsable === false);
// The native driver updates views directly through the UI thread so we
// have to make sure the view doesn't get optimized away because it cannot
Expand Down Expand Up @@ -283,6 +299,8 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
this._propsAnimated && this._propsAnimated.__detach();
this._detachNativeEvents();
this._markUpdateComplete();
this._component = null;
this._prevComponent = null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
* 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
* @format
* @flow strict-local
*/

import {type HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
import {type ViewProps as Props} from '../View/ViewPropTypes';
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';

const AndroidHorizontalScrollContentViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
'AndroidHorizontalScrollContentView',
() => ({
uiViewClassName: 'AndroidHorizontalScrollContentView',
bubblingEventTypes: {},
directEventTypes: {},
validAttributes: {},
}),
);
type NativeProps = $ReadOnly<{|
...ViewProps,
|}>;

export default AndroidHorizontalScrollContentViewNativeComponent;
type NativeType = HostComponent<NativeProps>;

export default (codegenNativeComponent<NativeProps>(
'AndroidHorizontalScrollContentView',
): NativeType);
9 changes: 9 additions & 0 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,13 @@ function InternalTextInput(props: Props): React.Node {
],
);

// Hide caret during test runs due to a flashing caret
// makes screenshot tests flakey
let caretHidden = props.caretHidden;
if (Platform.isTesting) {
caretHidden = true;
}

// TextInput handles onBlur and onFocus events
// so omitting onBlur and onFocus pressability handlers here.
const {onBlur, onFocus, ...eventHandlers} = usePressability(config) || {};
Expand All @@ -1105,6 +1112,7 @@ function InternalTextInput(props: Props): React.Node {
{...eventHandlers}
accessible={accessible}
blurOnSubmit={blurOnSubmit}
caretHidden={caretHidden}
dataDetectorTypes={props.dataDetectorTypes}
focusable={focusable}
mostRecentEventCount={mostRecentEventCount}
Expand Down Expand Up @@ -1143,6 +1151,7 @@ function InternalTextInput(props: Props): React.Node {
accessible={accessible}
autoCapitalize={autoCapitalize}
blurOnSubmit={blurOnSubmit}
caretHidden={caretHidden}
children={children}
disableFullscreenUI={props.disableFullscreenUI}
focusable={focusable}
Expand Down
2 changes: 2 additions & 0 deletions Libraries/Lists/FlatList.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,8 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
| ?React.ElementRef<typeof View>
| ?React.ElementRef<ScrollViewNativeComponent> {
if (this._listRef) {
/* $FlowFixMe[incompatible-return] Suppresses errors found when fixing
* TextInput typing */
return this._listRef.getScrollRef();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/NativeAnimation/React-RCTAnimation.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Pod::Spec.new do |s|
}

s.dependency "RCT-Folly", folly_version
s.dependency "FBReactNativeSpec", version
s.dependency "RCTTypeSafety", version
s.dependency "ReactCommon/turbomodule/core", version
s.dependency "React-jsi", version
s.dependency "FBReactNativeSpec", version
s.dependency "React-Core/RCTAnimationHeaders", version
end
1 change: 1 addition & 0 deletions Libraries/ReactNative/AppRegistry.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const AppRegistry = {
showArchitectureIndicator,
scopedPerformanceLogger,
appKey === 'LogBox',
appKey,
);
},
};
Expand Down
13 changes: 12 additions & 1 deletion Libraries/ReactNative/renderApplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ function renderApplication<Props: Object>(
showArchitectureIndicator?: boolean,
scopedPerformanceLogger?: IPerformanceLogger,
isLogBox?: boolean,
debugName?: string,
) {
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);

const performanceLogger = scopedPerformanceLogger ?? GlobalPerformanceLogger;

const renderable = (
let renderable = (
<PerformanceLoggerContext.Provider value={performanceLogger}>
<AppContainer
rootTag={rootTag}
Expand All @@ -47,6 +48,16 @@ function renderApplication<Props: Object>(
</PerformanceLoggerContext.Provider>
);

if (__DEV__ && debugName) {
const RootComponentWithMeaningfulName = ({children}) => children;
RootComponentWithMeaningfulName.displayName = `${debugName}(RootComponent)`;
renderable = (
<RootComponentWithMeaningfulName>
{renderable}
</RootComponentWithMeaningfulName>
);
}

performanceLogger.startTimespan('renderApplication_React_render');
performanceLogger.setExtra('usedReactFabric', fabric ? '1' : '0');

Expand Down
5 changes: 2 additions & 3 deletions Libraries/Renderer/shims/ReactNativeTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export type PartialViewConfig = $ReadOnly<{
validAttributes?: PartialAttributeConfiguration,
}>;

export type NativeMethods = {
export type NativeMethods = {|
blur(): void,
focus(): void,
measure(callback: MeasureOnSuccessCallback): void,
Expand All @@ -110,8 +110,7 @@ export type NativeMethods = {
onFail?: () => void,
): void,
setNativeProps(nativeProps: {...}): void,
...
};
|};

export type HostComponent<T> = AbstractComponent<T, $ReadOnly<NativeMethods>>;

Expand Down
4 changes: 4 additions & 0 deletions React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ RCT_EXTERN void RCTEnableTurboModuleEagerInit(BOOL enabled);
RCT_EXTERN BOOL RCTTurboModuleSharedMutexInitEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleSharedMutexInit(BOOL enabled);

// Turn on TurboModule shared mutex initialization
RCT_EXTERN BOOL RCTTurboModuleBlockGuardEnabled(void);
RCT_EXTERN void RCTEnableTurboModuleBlockGuard(BOOL enabled);

/**
* Async batched bridge used to communicate with the JavaScript application.
*/
Expand Down
11 changes: 11 additions & 0 deletions React/Base/RCTBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ void RCTEnableTurboModuleSharedMutexInit(BOOL enabled)
turboModuleSharedMutexInitEnabled = enabled;
}

static BOOL turboModuleBlockGuardEnabled = NO;
BOOL RCTTurboModuleBlockGuardEnabled(void)
{
return turboModuleBlockGuardEnabled;
}

void RCTEnableTurboModuleBlockGuard(BOOL enabled)
{
turboModuleBlockGuardEnabled = enabled;
}

@interface RCTBridge () <RCTReloadListener>
@end

Expand Down
10 changes: 9 additions & 1 deletion React/Base/RCTTouchHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#import "RCTTouchHandler.h"

#import <UIKit/UIGestureRecognizerSubclass.h>
#import <UIKit/UIKit.h>

#import "RCTAssert.h"
#import "RCTBridge.h"
Expand Down Expand Up @@ -39,6 +40,10 @@ @implementation RCTTouchHandler {

__weak UIView *_cachedRootView;

// See Touch.h and usage. This gives us a time-basis for a monotonic
// clock that acts like a timestamp of milliseconds elapsed since UNIX epoch.
NSTimeInterval _unixEpochBasisTime;

uint16_t _coalescingKey;
}

Expand All @@ -53,6 +58,9 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
_reactTouches = [NSMutableArray new];
_touchViews = [NSMutableArray new];

// Get a UNIX epoch basis time:
_unixEpochBasisTime = [[NSDate date] timeIntervalSince1970] - [NSProcessInfo processInfo].systemUptime;

// `cancelsTouchesInView` and `delaysTouches*` are needed in order to be used as a top level
// event delegated recognizer. Otherwise, lower-level components not built
// using RCT, will fail to recognize gestures.
Expand Down Expand Up @@ -159,7 +167,7 @@ - (void)_updateReactTouchAtIndex:(NSInteger)touchIndex
reactTouch[@"pageY"] = @(RCTSanitizeNaNValue(rootViewLocation.y, @"touchEvent.pageY"));
reactTouch[@"locationX"] = @(RCTSanitizeNaNValue(touchViewLocation.x, @"touchEvent.locationX"));
reactTouch[@"locationY"] = @(RCTSanitizeNaNValue(touchViewLocation.y, @"touchEvent.locationY"));
reactTouch[@"timestamp"] = @(nativeTouch.timestamp * 1000); // in ms, for JS
reactTouch[@"timestamp"] = @((_unixEpochBasisTime + nativeTouch.timestamp) * 1000); // in ms, for JS

// TODO: force for a 'normal' touch is usually 1.0;
// should we expose a `normalTouchForce` constant somewhere (which would
Expand Down
10 changes: 10 additions & 0 deletions React/CoreModules/RCTDevSettings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ - (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource
return self;
}

#if RCT_ENABLE_INSPECTOR
// In bridgeless mode, `setBridge` is not called, so dev server connection
// must be kicked off here.
- (void)setBundleURL:(NSURL *)bundleURL
{
_bundleURL = bundleURL;
[RCTInspectorDevServerHelper connectWithBundleURL:_bundleURL];
}
#endif

- (void)setBridge:(RCTBridge *)bridge
{
[super setBridge:bridge];
Expand Down
20 changes: 4 additions & 16 deletions React/Fabric/RCTScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#import <react/renderer/core/LayoutContext.h>
#import <react/renderer/mounting/MountingCoordinator.h>
#import <react/renderer/scheduler/SchedulerToolbox.h>
#import <react/renderer/scheduler/SurfaceHandler.h>
#import <react/utils/ContextContainer.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -47,26 +48,13 @@ NS_ASSUME_NONNULL_BEGIN

- (instancetype)initWithToolbox:(facebook::react::SchedulerToolbox)toolbox;

- (void)startSurfaceWithSurfaceId:(facebook::react::SurfaceId)surfaceId
moduleName:(NSString *)moduleName
initialProps:(NSDictionary *)initialProps
layoutConstraints:(facebook::react::LayoutConstraints)layoutConstraints
layoutContext:(facebook::react::LayoutContext)layoutContext;

- (void)stopSurfaceWithSurfaceId:(facebook::react::SurfaceId)surfaceId;

- (CGSize)measureSurfaceWithLayoutConstraints:(facebook::react::LayoutConstraints)layoutConstraints
layoutContext:(facebook::react::LayoutContext)layoutContext
surfaceId:(facebook::react::SurfaceId)surfaceId;

- (void)constraintSurfaceLayoutWithLayoutConstraints:(facebook::react::LayoutConstraints)layoutConstraints
layoutContext:(facebook::react::LayoutContext)layoutContext
surfaceId:(facebook::react::SurfaceId)surfaceId;
- (void)registerSurface:(facebook::react::SurfaceHandler const &)surfaceHandler;
- (void)unregisterSurface:(facebook::react::SurfaceHandler const &)surfaceHandler;

- (facebook::react::ComponentDescriptor const *)findComponentDescriptorByHandle_DO_NOT_USE_THIS_IS_BROKEN:
(facebook::react::ComponentHandle)handle;

- (facebook::react::MountingCoordinator::Shared)mountingCoordinatorWithSurfaceId:(facebook::react::SurfaceId)surfaceId;
- (void)setupAnimationDriver:(facebook::react::SurfaceHandler const &)surfaceHandler;

- (void)onAnimationStarted;

Expand Down
Loading

0 comments on commit e6658a2

Please sign in to comment.