Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,11 @@ jobs:
default: false
environment:
- ANDROID_HOME: "C:\\Android\\android-sdk"
- ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\20.1.5948944"
- ANDROID_NDK: "C:\\Android\\android-sdk\\ndk\\19.2.5345600"
- ANDROID_BUILD_VERSION: 28
- ANDROID_TOOLS_VERSION: 29.0.3
- GRADLE_OPTS: -Dorg.gradle.daemon=false
- NDK_VERSION: 20.1.5948944
- NDK_VERSION: 19.2.5345600
steps:
- checkout

Expand Down Expand Up @@ -781,34 +781,30 @@ workflows:
run_unit_tests: true
requires:
- setup_ios
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
# - test_ios:
# name: test_ios_unit_frameworks_jsc
# use_frameworks: true
# run_unit_tests: true
# requires:
# - setup_ios
- test_ios:
name: test_ios_unit_frameworks_jsc
use_frameworks: true
run_unit_tests: true
requires:
- setup_ios
- test_ios:
name: test_ios_unit_hermes
use_hermes: true
run_unit_tests: true
requires:
- setup_ios
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
# - test_ios:
# name: test_ios_unit_frameworks_hermes
# use_hermes: true
# use_frameworks: true
# run_unit_tests: true
# requires:
# - setup_ios
# DISABLED: Detox tests need to be fixed
- test_ios:
name: test_ios_unit_frameworks_hermes
use_hermes: true
use_frameworks: true
run_unit_tests: true
requires:
- setup_ios
# - test_ios:
# name: test_ios_detox
# run_detox_tests: true
# requires:
# - setup_ios
# DISABLED: USE_FRAMEWORKS=1 not supported by Flipper
# - test_ios:
# name: test_ios_detox_frameworks
# use_frameworks: true
Expand Down
6 changes: 3 additions & 3 deletions Libraries/Animated/components/AnimatedImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const createAnimatedComponent = require('../createAnimatedComponent');

import type {AnimatedComponentType} from '../createAnimatedComponent';

module.exports = (createAnimatedComponent((Image: $FlowFixMe), {
collapsable: false,
}): AnimatedComponentType<
module.exports = (createAnimatedComponent(
(Image: $FlowFixMe),
): AnimatedComponentType<
React.ElementConfig<typeof Image>,
React.ElementRef<typeof Image>,
>);
6 changes: 3 additions & 3 deletions Libraries/Animated/components/AnimatedScrollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ const ScrollViewWithEventThrottle = React.forwardRef((props, ref) => (
<ScrollView scrollEventThrottle={0.0001} {...props} ref={ref} />
));

module.exports = (createAnimatedComponent(ScrollViewWithEventThrottle, {
collapsable: false,
}): AnimatedComponentType<
module.exports = (createAnimatedComponent(
ScrollViewWithEventThrottle,
): AnimatedComponentType<
React.ElementConfig<typeof ScrollView>,
React.ElementRef<typeof ScrollView>,
>);
6 changes: 3 additions & 3 deletions Libraries/Animated/components/AnimatedText.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ const createAnimatedComponent = require('../createAnimatedComponent');

import type {AnimatedComponentType} from '../createAnimatedComponent';

module.exports = (createAnimatedComponent((Text: $FlowFixMe), {
collapsable: false,
}): AnimatedComponentType<
module.exports = (createAnimatedComponent(
(Text: $FlowFixMe),
): AnimatedComponentType<
React.ElementConfig<typeof Text>,
React.ElementRef<typeof Text>,
>);
4 changes: 1 addition & 3 deletions Libraries/Animated/components/AnimatedView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const createAnimatedComponent = require('../createAnimatedComponent');

import type {AnimatedComponentType} from '../createAnimatedComponent';

module.exports = (createAnimatedComponent(View, {
collapsable: true,
}): AnimatedComponentType<
module.exports = (createAnimatedComponent(View): AnimatedComponentType<
React.ElementConfig<typeof View>,
React.ElementRef<typeof View>,
>);
35 changes: 11 additions & 24 deletions Libraries/Animated/createAnimatedComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ export type AnimatedComponentType<
Instance,
>;

type AnimatedComponentOptions = {
collapsable?: boolean,
};

function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
Component: React.AbstractComponent<Props, Instance>,
options?: AnimatedComponentOptions,
): AnimatedComponentType<Props, Instance> {
invariant(
typeof Component !== 'function' ||
Expand Down Expand Up @@ -84,9 +79,6 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
}

_isFabric = (): boolean => {
// 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.
if (this._component == null) {
return false;
}
Expand Down Expand Up @@ -221,28 +213,23 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
const {style: passthruStyle = {}, ...passthruProps} =
this.props.passthroughAnimatedPropExplicitValues || {};
const mergedStyle = {...style, ...passthruStyle};
const forceNativeId =
props.collapsable ??
(this._propsAnimated.__isNative ||
this._isFabric() ||
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
// go through the NativeViewHierarchyManager since it operates on the shadow
// thread. TODO: T68258846
const collapsableProps = forceNativeId
? {
nativeID: props.nativeID ?? 'animatedComponent',
collapsable: false,
}
: {};
return (
<Component
{...props}
{...passthruProps}
{...collapsableProps}
style={mergedStyle}
ref={this._setComponentRef}
nativeID={
props.nativeID ??
(this._isFabric() ? 'animatedComponent' : undefined)
} /* TODO: T68258846. */
// 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
// go through the NativeViewHierarchyManager since it operates on the shadow
// thread.
collapsable={
this._propsAnimated.__isNative ? false : props.collapsable
}
/>
);
}
Expand Down
6 changes: 3 additions & 3 deletions Libraries/AppState/AppState.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import invariant from 'invariant';
*
* See https://reactnative.dev/docs/appstate.html
*/
class AppState extends NativeEventEmitter<$FlowFixMe> {
class AppState extends NativeEventEmitter {
_eventHandlers: Object;
_supportedEvents = ['change', 'memoryWarning', 'blur', 'focus'];
currentState: ?string;
Expand Down Expand Up @@ -142,7 +142,7 @@ function throwMissingNativeModule() {
);
}

class MissingNativeAppStateShim extends EventEmitter<$FlowFixMe> {
class MissingNativeAppStateShim extends EventEmitter {
// AppState
isAvailable: boolean = false;
currentState: ?string = null;
Expand All @@ -156,7 +156,7 @@ class MissingNativeAppStateShim extends EventEmitter<$FlowFixMe> {
}

// EventEmitter
addListener(): any {
addListener() {
throwMissingNativeModule();
}

Expand Down
1 change: 0 additions & 1 deletion Libraries/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ fb_native.genrule(

rn_codegen_modules(
name = "FBReactNativeSpec",
android_package_name = "com.facebook.fbreact.specs",
library_labels = ["supermodule:xplat/default/public.react_native.infra"],
native_module_spec_name = "FBReactNativeSpec",
schema_target = ":react_native_codegen_schema",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,9 @@ const AccessibilityInfo = {
if (eventName === 'change') {
listener = RCTDeviceEventEmitter.addListener(
CHANGE_EVENT_NAME.screenReaderChanged,
// $FlowFixMe[incompatible-call]
handler,
);
} else if (CHANGE_EVENT_NAME[eventName]) {
// $FlowFixMe[incompatible-call]
listener = RCTDeviceEventEmitter.addListener(eventName, handler);
}

Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/Keyboard/Keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import LayoutAnimation from '../../LayoutAnimation/LayoutAnimation';
import dismissKeyboard from '../../Utilities/dismissKeyboard';
import NativeKeyboardObserver from './NativeKeyboardObserver';
import invariant from 'invariant';
const KeyboardEventEmitter: NativeEventEmitter<$FlowFixMe> = new NativeEventEmitter(
const KeyboardEventEmitter: NativeEventEmitter = new NativeEventEmitter(
NativeKeyboardObserver,
);

Expand Down
4 changes: 2 additions & 2 deletions Libraries/Components/ScrollResponder.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,8 @@ const ScrollResponderMixin = {
this.preventNegativeScrollOffset = false;
},

scrollResponderTextInputFocusError: function() {
console.warn('Error measuring text field.');
scrollResponderTextInputFocusError: function(msg: string) {
console.error('Error measuring text field: ', msg);
},

/**
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Components/StatusBar/StatusBarIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS';
/**
* Use `StatusBar` for mutating the status bar.
*/
class StatusBarIOS extends NativeEventEmitter<$FlowFixMe> {}
class StatusBarIOS extends NativeEventEmitter {}

module.exports = (new StatusBarIOS(NativeStatusBarManagerIOS): StatusBarIOS);
4 changes: 1 addition & 3 deletions Libraries/Core/setUpReactRefresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,5 @@ if (__DEV__) {
},
};

// The metro require polyfill can not have dependencies (applies for all polyfills).
// Expose `Refresh` by assigning it to global to make it available in the polyfill.
global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__ReactRefresh'] = Refresh;
(require: any).Refresh = Refresh;
}
4 changes: 1 addition & 3 deletions Libraries/EventEmitter/NativeEventEmitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ const DEFAULT_NATIVE_EVENT_EMITTER_OPTIONS = {
* Abstract base class for implementing event-emitting modules. This implements
* a subset of the standard EventEmitter node module API.
*/
export default class NativeEventEmitter<
_GenericArgumentPlaceholder,
> extends EventEmitter {
export default class NativeEventEmitter extends EventEmitter {
_nativeModule: ?NativeModule;
_disableCallsIntoModule: boolean;

Expand Down
36 changes: 34 additions & 2 deletions Libraries/FBReactNativeSpec/FBReactNativeSpec.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,44 @@
# LICENSE file in the root directory of this source tree.

require "json"
require_relative "../../scripts/react_native_pods.rb"

package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']

source = { :git => 'https://github.com/facebook/react-native.git' }
codegen_path_prefix = ".."
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
codegen_path_prefix = "packages"
else
source[:tag] = "v#{version}"
end

react_native_path = File.join(__dir__, "..", "..")
srcs_dir = File.join(__dir__, "..")
codegen_script_path = File.join(react_native_path, "scripts", "generate-specs.sh")
codegen_path = File.join(react_native_path, codegen_path_prefix, "react-native-codegen")
codegen_command = "CODEGEN_PATH=#{codegen_path} sh '#{codegen_script_path}' | tee \"${SCRIPT_OUTPUT_FILE_0}\""
modules_output_dir = File.join(__dir__, "FBReactNativeSpec")
components_output_dir = File.join(react_native_path, "ReactCommon", "react", "renderer", "components", "rncore")
generated_filenames = [ "FBReactNativeSpec.h", "FBReactNativeSpec-generated.mm" ]
generated_files = generated_filenames.map { |filename| File.join(modules_output_dir, filename) }

if ENV['USE_FABRIC'] == '1'
components_generated_filenames = [
"ComponentDescriptors.h",
"EventEmitters.cpp",
"EventEmitters.h",
"Props.cpp",
"Props.h",
"RCTComponentViewHelpers.h",
"ShadowNodes.cpp",
"ShadowNodes.h"
]
generated_files = generated_files.concat(components_generated_filenames.map { |filename| File.join(components_output_dir, filename) })
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'

Expand Down Expand Up @@ -47,5 +72,12 @@ Pod::Spec.new do |s|
s.dependency "React-jsi", version
s.dependency "ReactCommon/turbomodule/core", version

use_react_native_codegen! (s)
s.prepare_command = "mkdir -p #{modules_output_dir} #{components_output_dir} && touch #{generated_files.reduce() { |str, file| str + " " + file }}"
s.script_phase = {
:name => 'Generate Specs',
:input_files => [srcs_dir],
:output_files => ["$(DERIVED_FILE_DIR)/codegen.log"],
:script => codegen_command,
:execution_position => :before_compile
}
end
2 changes: 1 addition & 1 deletion Libraries/Interaction/InteractionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import EventEmitter from '../vendor/emitter/EventEmitter';
export type Handle = number;
import type {Task} from './TaskQueue';

const _emitter = new EventEmitter<$FlowFixMe>();
const _emitter = new EventEmitter();

const DEBUG_DELAY: 0 = 0;
const DEBUG: false = false;
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Linking/Linking.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import nullthrows from 'nullthrows';
*
* See https://reactnative.dev/docs/linking.html
*/
class Linking extends NativeEventEmitter<$FlowFixMe> {
class Linking extends NativeEventEmitter {
constructor() {
super(Platform.OS === 'ios' ? nullthrows(NativeLinkingManager) : undefined);
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import RCTModalHostView from './RCTModalHostViewNativeComponent';

const ModalEventEmitter =
Platform.OS === 'ios' && NativeModalManager != null
? new NativeEventEmitter<$FlowFixMe>(NativeModalManager)
? new NativeEventEmitter(NativeModalManager)
: null;

/**
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Network/RCTNetworking.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function generateRequestId(): number {
* This class is a wrapper around the native RCTNetworking module. It adds a necessary unique
* requestId to each network request that can be used to abort that request later on.
*/
class RCTNetworking extends NativeEventEmitter<$FlowFixMe> {
class RCTNetworking extends NativeEventEmitter {
constructor() {
super(NativeNetworkingAndroid);
}
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Network/RCTNetworking.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {NativeResponseType} from './XMLHttpRequest';
import convertRequestBody from './convertRequestBody';
import type {RequestBody} from './convertRequestBody';

class RCTNetworking extends NativeEventEmitter<$FlowFixMe> {
class RCTNetworking extends NativeEventEmitter {
constructor() {
const disableCallsIntoModule =
typeof global.__disableRCTNetworkingExtraneousModuleCalls === 'function'
Expand Down
8 changes: 5 additions & 3 deletions Libraries/Performance/Systrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ const Systrace = {
};

if (__DEV__) {
// The metro require polyfill can not have dependencies (true for all polyfills).
// Ensure that `Systrace` is available in polyfill by exposing it globally.
global[(global.__METRO_GLOBAL_PREFIX__ || '') + '__SYSTRACE'] = Systrace;
// This is needed, because require callis in polyfills are not processed as
// other files. Therefore, calls to `require('moduleId')` are not replaced
// with numeric IDs
// TODO(davidaurelio) Scan polyfills for dependencies, too (t9759686)
(require: $FlowFixMe).Systrace = Systrace;
}

module.exports = Systrace;
2 changes: 1 addition & 1 deletion Libraries/PushNotificationIOS/PushNotificationIOS.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import NativeEventEmitter from '../EventEmitter/NativeEventEmitter';
import NativePushNotificationManagerIOS from './NativePushNotificationManagerIOS';
import invariant from 'invariant';

const PushNotificationEmitter = new NativeEventEmitter<$FlowFixMe>(
const PushNotificationEmitter = new NativeEventEmitter(
NativePushNotificationManagerIOS,
);

Expand Down
Loading