Skip to content

Commit

Permalink
Merge branch 'master' into fix/multiple-modal-ios
Browse files Browse the repository at this point in the history
  • Loading branch information
intergalacticspacehighway committed May 10, 2021
2 parents abdad8f + ae4946f commit 4a939c0
Show file tree
Hide file tree
Showing 374 changed files with 34,665 additions and 27,111 deletions.
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.150.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.150.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
2 changes: 1 addition & 1 deletion Libraries/ActionSheetIOS/React-RCTActionSheet.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
end
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,
};
6 changes: 5 additions & 1 deletion Libraries/Animated/NativeAnimatedHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,11 @@ module.exports = {
// $FlowExpectedError[missing-type-arg] - unsafe getter lint suppresion
get nativeEventEmitter(): NativeEventEmitter {
if (!nativeEventEmitter) {
nativeEventEmitter = new NativeEventEmitter(NativeAnimatedModule);
nativeEventEmitter = new NativeEventEmitter(
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
// If you want to use the native module on other platforms, please remove this condition and test its behavior
Platform.OS !== 'ios' ? null : NativeAnimatedModule,
);
}
return nativeEventEmitter;
},
Expand Down
8 changes: 5 additions & 3 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 Down Expand Up @@ -786,7 +788,7 @@ describe('Animated tests', () => {

const callback = jest.fn();

const node = new Animated.__PropsOnlyForTests(
const node = new AnimatedProps(
{
style: {
opacity: vec.x.interpolate({
Expand Down Expand Up @@ -890,7 +892,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 Down
13 changes: 0 additions & 13 deletions Libraries/Animated/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,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
15 changes: 14 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
5 changes: 4 additions & 1 deletion Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {type EventSubscription} from '../vendor/emitter/EventEmitter';
import NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
import logError from '../Utilities/logError';
import NativeAppState from './NativeAppState';
import Platform from '../Utilities/Platform';

export type AppStateValues = 'inactive' | 'background' | 'active';

Expand Down Expand Up @@ -47,7 +48,9 @@ class AppState {
this.isAvailable = true;

const emitter: NativeEventEmitter<NativeAppStateEventDefinitions> = new NativeEventEmitter(
NativeAppState,
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
// If you want to use the native module on other platforms, please remove this condition and test its behavior
Platform.OS !== 'ios' ? null : NativeAppState,
);
this._emitter = emitter;

Expand Down
46 changes: 7 additions & 39 deletions Libraries/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,22 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load(
"//tools/build_defs/oss:rn_codegen_defs.bzl",
"rn_codegen_components",
"rn_codegen_modules",
)
load(
"//tools/build_defs/oss:rn_defs.bzl",
"react_native_root_target",
)

fb_native.genrule(
# The schema name must have the following format: "{name}-codegen-modules-schema"
# Why: Internally, we have build scripts that find all NativeModule schemas in the
# dependencies of an app, and build TurboModuleManager delegates. Those scripts assume
# that all schema targets have the aforementioned naming scheme.
name = "FBReactNativeSpec-codegen-modules-schema",
srcs = glob(
[
"**/*.js",
],
exclude = [
"**/__tests__/**/*",
],
),
cmd = "$(exe {}) $OUT $SRCS".format(react_native_root_target("packages/react-native-codegen:write_to_json")),
out = "schema.json",
labels = [
"codegen_rule",
"react_native_schema_target",
],
"rn_codegen",
)

rn_codegen_modules(
rn_codegen(
name = "FBReactNativeSpec",
android_package_name = "com.facebook.fbreact.specs",
codegen_modules = True,
library_labels = ["supermodule:xplat/default/public.react_native.infra"],
schema_target = ":FBReactNativeSpec-codegen-modules-schema",
native_module_spec_name = "FBReactNativeSpec",
)

rn_codegen_components(
# TODO: Merge this into FBReactNativeSpec
rn_codegen(
name = "FBReactNativeComponentSpec",
codegen_components = True,
library_labels = ["supermodule:xplat/default/public.react_native.infra"],
# Why does FBReactNativeComponentSpec depend on -codegen-modules-schema?
# The module codegen schema also contains components. We cannot change the name
# of the schema target, because internally, we have infra that depends on how
# it's named.
#
# TODO(T83341482): Clean up how OSS NativeModule codegen is declared
schema_target = ":FBReactNativeSpec-codegen-modules-schema",
)
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
4 changes: 2 additions & 2 deletions Libraries/Blob/React-RCTBlob.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ version = package['version']
source = { :git => 'https://github.com/facebook/react-native.git' }
if version == '1000.0.0'
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
source[:commit] = `git rev-parse HEAD`.strip
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
else
source[:tag] = "v#{version}"
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
17 changes: 8 additions & 9 deletions Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,17 @@

'use strict';

const Platform = require('../Utilities/Platform');
const React = require('react');
const StyleSheet = require('../StyleSheet/StyleSheet');
const Text = require('../Text/Text');
const TouchableNativeFeedback = require('./Touchable/TouchableNativeFeedback');
const TouchableOpacity = require('./Touchable/TouchableOpacity');
const View = require('./View/View');
const invariant = require('invariant');
import * as React from 'react';
import Platform from '../Utilities/Platform';
import StyleSheet, {type ColorValue} from '../StyleSheet/StyleSheet';
import Text from '../Text/Text';
import TouchableNativeFeedback from './Touchable/TouchableNativeFeedback';
import TouchableOpacity from './Touchable/TouchableOpacity';
import View from './View/View';
import invariant from 'invariant';

import type {AccessibilityState} from './View/ViewAccessibility';
import type {PressEvent} from '../Types/CoreEventTypes';
import type {ColorValue} from '../StyleSheet/StyleSheet';

type ButtonProps = $ReadOnly<{|
/**
Expand Down
9 changes: 4 additions & 5 deletions Libraries/Components/DatePicker/DatePickerIOS.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
*/

'use strict';

const React = require('react');
const StyleSheet = require('../../StyleSheet/StyleSheet');
const Text = require('../../Text/Text');
const View = require('../View/View');
import * as React from 'react';
import StyleSheet from '../../StyleSheet/StyleSheet';
import Text from '../../Text/Text';
import View from '../View/View';

class DummyDatePickerIOS extends React.Component {
render() {
Expand Down
Loading

0 comments on commit 4a939c0

Please sign in to comment.