Skip to content

Commit

Permalink
Merge branch 'master' into feature/line-break-strategy-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
bang9 authored May 28, 2021
2 parents 4c58683 + d1ab032 commit e4b1139
Show file tree
Hide file tree
Showing 509 changed files with 38,567 additions and 29,250 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ executors:
reactnativeios:
<<: *defaults
macos:
xcode: &_XCODE_VERSION "12.1.0"
xcode: &_XCODE_VERSION "12.4.0"

# -------------------------
# COMMANDS
Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ indent_size = 4

[BUCK]
indent_size = 4

# Windows files
[*.bat]
end_of_line = crlf
4 changes: 3 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ emoji=true

exact_by_default=true

format.bracket_spacing=false

module.file_ext=.js
module.file_ext=.json
module.file_ext=.ios.js
Expand Down Expand Up @@ -68,4 +70,4 @@ untyped-import
untyped-type-import

[version]
^0.148.0
^0.152.0
4 changes: 3 additions & 1 deletion .flowconfig.android
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ emoji=true

exact_by_default=true

format.bracket_spacing=false

module.file_ext=.js
module.file_ext=.json
module.file_ext=.android.js
Expand Down Expand Up @@ -68,4 +70,4 @@ untyped-import
untyped-type-import

[version]
^0.148.0
^0.152.0
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ The process of proposing a change to React Native can be summarized as follows:
8. Create a pull request to the React Native repository.
9. Review and address comments on your pull request.
1. A bot may comment with suggestions. Generally we ask you to resolve these first before a maintainer will review your code.
2. If changes are requested and addressed, please [request review](https://docs.github.com/en/github/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/requesting-a-pull-request-review) to notify reviewers to take another look.
10. If you haven't already, please complete the [Contributor License Agreement](https://github.com/facebook/react-native/wiki/Contributor-License-Agreement) ("CLA"). **[Complete your CLA here.](https://code.facebook.com/cla)**

If all goes well, your pull request will be merged. If it is not merged, maintainers will do their best to explain the reason why.
Expand Down
2 changes: 1 addition & 1 deletion IntegrationTests/GlobalEvalWithSourceUrlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

import type {ExtendedError} from 'react-native/Libraries/Core/Devtools/parseErrorStack';
import type {ExtendedError} from 'react-native/Libraries/Core/ExtendedError';

const React = require('react');
const ReactNative = require('react-native');
Expand Down
2 changes: 0 additions & 2 deletions Libraries/Animated/AnimatedImplementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,4 @@ module.exports = {
* Expose Event class, so it can be used as a type for type checkers.
*/
Event: AnimatedEvent,

__PropsOnlyForTests: AnimatedProps,
};
1 change: 0 additions & 1 deletion Libraries/Animated/AnimatedMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,4 @@ module.exports = {
forkEvent: AnimatedImplementation.forkEvent,
unforkEvent: AnimatedImplementation.unforkEvent,
Event: AnimatedEvent,
__PropsOnlyForTests: AnimatedProps,
};
21 changes: 16 additions & 5 deletions Libraries/Animated/__tests__/Animated-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @emails oncall+react_native
*/

import AnimatedProps from '../nodes/AnimatedProps';
import TestRenderer from 'react-test-renderer';
import * as React from 'react';

Expand All @@ -21,6 +22,7 @@ jest.mock('../../BatchedBridge/NativeModules', () => ({
}));

let Animated = require('../Animated');

describe('Animated tests', () => {
beforeEach(() => {
jest.resetModules();
Expand All @@ -32,7 +34,7 @@ describe('Animated tests', () => {

const callback = jest.fn();

const node = new Animated.__PropsOnlyForTests(
const node = new AnimatedProps(
{
style: {
backgroundColor: 'red',
Expand All @@ -55,8 +57,6 @@ describe('Animated tests', () => {
callback,
);

expect(anim.__getChildren().length).toBe(3);

expect(node.__getValue()).toEqual({
style: {
backgroundColor: 'red',
Expand All @@ -69,6 +69,12 @@ describe('Animated tests', () => {
},
});

expect(anim.__getChildren().length).toBe(0);

node.__attach();

expect(anim.__getChildren().length).toBe(3);

anim.setValue(0.5);

expect(callback).toBeCalled();
Expand Down Expand Up @@ -786,7 +792,7 @@ describe('Animated tests', () => {

const callback = jest.fn();

const node = new Animated.__PropsOnlyForTests(
const node = new AnimatedProps(
{
style: {
opacity: vec.x.interpolate({
Expand All @@ -809,6 +815,10 @@ describe('Animated tests', () => {
},
});

node.__attach();

expect(callback.mock.calls.length).toBe(0);

vec.setValue({x: 42, y: 1492});

expect(callback.mock.calls.length).toBe(2); // once each for x, y
Expand Down Expand Up @@ -890,7 +900,7 @@ describe('Animated tests', () => {
const value3 = new Animated.Value(0);
const value4 = Animated.add(value3, Animated.multiply(value1, value2));
const callback = jest.fn();
const view = new Animated.__PropsOnlyForTests(
const view = new AnimatedProps(
{
style: {
transform: [
Expand All @@ -902,6 +912,7 @@ describe('Animated tests', () => {
},
callback,
);
view.__attach();
const listener = jest.fn();
const id = value4.addListener(listener);
value3.setValue(137);
Expand Down
18 changes: 1 addition & 17 deletions Libraries/Animated/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,11 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
_attachProps(nextProps) {
const oldPropsAnimated = this._propsAnimated;

if (nextProps === oldPropsAnimated) {
return;
}

this._propsAnimated = new AnimatedProps(
nextProps,
this._animatedPropsCallback,
);
this._propsAnimated.__attach();

// When you call detach, it removes the element from the parent list
// of children. If it goes to 0, then the parent also detaches itself
Expand All @@ -202,19 +199,6 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
setLocalRef: ref => {
this._prevComponent = this._component;
this._component = ref;

// TODO: Delete this in a future release.
if (ref != null && ref.getNode == null) {
ref.getNode = () => {
console.warn(
'%s: Calling `getNode()` on the ref of an Animated component ' +
'is no longer necessary. You can now directly use the ref ' +
'instead. This method will be removed in a future release.',
ref.constructor.name ?? '<<anonymous>>',
);
return ref;
};
}
},
});

Expand Down
1 change: 0 additions & 1 deletion Libraries/Animated/nodes/AnimatedProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class AnimatedProps extends AnimatedNode {
}
this._props = props;
this._callback = callback;
this.__attach();
}

__getValue(): Object {
Expand Down
21 changes: 20 additions & 1 deletion Libraries/Animated/nodes/AnimatedValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ function _flush(rootNode: AnimatedValue): void {
animatedStyles.forEach(animatedStyle => animatedStyle.update());
}

/**
* Some operations are executed only on batch end, which is _mostly_ scheduled when
* Animated component props change. For some of the changes which require immediate execution
* (e.g. setValue), we create a separate batch in case none is scheduled.
*/
function _executeAsAnimatedBatch(id: string, operation: () => void) {
NativeAnimatedAPI.setWaitingForIdentifier(id);
operation();
NativeAnimatedAPI.unsetWaitingForIdentifier(id);
}

/**
* Standard value for driving animations. One `Animated.Value` can drive
* multiple properties in a synchronized fashion, but can only be driven by one
Expand Down Expand Up @@ -115,7 +126,9 @@ class AnimatedValue extends AnimatedWithChildren {
!this.__isNative /* don't perform a flush for natively driven values */,
);
if (this.__isNative) {
NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value);
_executeAsAnimatedBatch(this.__getNativeTag().toString(), () => {
NativeAnimatedAPI.setAnimatedNodeValue(this.__getNativeTag(), value);
});
}
}

Expand Down Expand Up @@ -183,6 +196,12 @@ class AnimatedValue extends AnimatedWithChildren {
resetAnimation(callback?: ?(value: number) => void): void {
this.stopAnimation(callback);
this._value = this._startingValue;
if (this.__isNative) {
NativeAnimatedAPI.setAnimatedNodeValue(
this.__getNativeTag(),
this._startingValue,
);
}
}

_onAnimatedValueUpdateReceived(value: number): void {
Expand Down
2 changes: 2 additions & 0 deletions Libraries/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ rn_codegen(
name = "FBReactNativeSpec",
android_package_name = "com.facebook.fbreact.specs",
codegen_modules = True,
ios_assume_nonnull = False,
library_labels = ["supermodule:xplat/default/public.react_native.infra"],
native_module_spec_name = "FBReactNativeSpec",
)
Expand All @@ -20,5 +21,6 @@ rn_codegen(
rn_codegen(
name = "FBReactNativeComponentSpec",
codegen_components = True,
ios_assume_nonnull = False,
library_labels = ["supermodule:xplat/default/public.react_native.infra"],
)
2 changes: 1 addition & 1 deletion Libraries/BatchedBridge/NativeModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const BatchedBridge = require('./BatchedBridge');

const invariant = require('invariant');

import type {ExtendedError} from '../Core/Devtools/parseErrorStack';
import type {ExtendedError} from '../Core/ExtendedError';

export type ModuleConfig = [
string /* name */,
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Blob/RCTBlobManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
#import <React/RCTBridge.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTURLRequestHandler.h>
#import <React/RCTInitializing.h>

@interface RCTBlobManager : NSObject <RCTBridgeModule, RCTURLRequestHandler>
@interface RCTBlobManager : NSObject <RCTBridgeModule, RCTURLRequestHandler, RCTInitializing>

- (NSString *)store:(NSData *)data;

Expand Down
4 changes: 1 addition & 3 deletions Libraries/Blob/RCTBlobManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ @implementation RCTBlobManager
@synthesize moduleRegistry = _moduleRegistry;
@synthesize methodQueue = _methodQueue;

- (void)setBridge:(RCTBridge *)bridge
- (void)initialize
{
_bridge = bridge;

std::lock_guard<std::mutex> lock(_blobsMutex);
_blobs = [NSMutableDictionary new];

Expand Down
7 changes: 4 additions & 3 deletions Libraries/Blob/RCTBlobPlugins.mm
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
#import <unordered_map>

Class RCTBlobClassProvider(const char *name) {
static std::unordered_map<std::string, Class (*)(void)> sCoreModuleClassMap = {
// Intentionally leak to avoid crashing after static destructors are run.
static const auto sCoreModuleClassMap = new const std::unordered_map<std::string, Class (*)(void)>{
{"FileReaderModule", RCTFileReaderModuleCls},
{"BlobModule", RCTBlobManagerCls},
};

auto p = sCoreModuleClassMap.find(name);
if (p != sCoreModuleClassMap.end()) {
auto p = sCoreModuleClassMap->find(name);
if (p != sCoreModuleClassMap->end()) {
auto classFunc = p->second;
return classFunc();
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ else
end

folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
folly_version = '2020.01.13.00'
folly_version = '2021.04.26.00'

Pod::Spec.new do |s|
s.name = "React-RCTBlob"
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Blob/URL.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class URLSearchParams {

function validateBaseUrl(url: string) {
// from this MIT-licensed gist: https://gist.github.com/dperini/729294
return /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,}))?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(
return /^(?:(?:(?:https?|ftp):)?\/\/)(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)*(?:[a-z\u00a1-\uffff]{2,}\.?))(?::\d{2,5})?(?:[/?#]\S*)?$/.test(
url,
);
}
Expand Down
10 changes: 4 additions & 6 deletions Libraries/Components/ActivityIndicator/ActivityIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
*/

'use strict';

const Platform = require('../../Utilities/Platform');
const React = require('react');
const StyleSheet = require('../../StyleSheet/StyleSheet');
const View = require('../View/View');
import * as React from 'react';
import Platform from '../../Utilities/Platform';
import StyleSheet, {type ColorValue} from '../../StyleSheet/StyleSheet';
import View from '../View/View';
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import type {ColorValue} from '../../StyleSheet/StyleSheet';

const PlatformActivityIndicator =
Platform.OS === 'android'
Expand Down
Loading

0 comments on commit e4b1139

Please sign in to comment.