From 4841e1bae068a1742cd195fa9fbf4b67531fd344 Mon Sep 17 00:00:00 2001
From: Joshua Gross
Date: Wed, 25 Aug 2021 02:19:40 -0700
Subject: [PATCH 001/986] Add first-class support to ReactInstanceManager for
Activity-less usage
Summary:
I'm not sure if we'll ever need to do more than this (probably!) but I want to have a specific option for Activity-less usage, so
that our logic in ReactInstanceManager and elsewhere is more clear. I want to be able to confidently assert that the Activity is present
and correct, or never present, depending on if this `requireActivity` flag is set; instead of adding else statements that imply "well, the Activity should be here, hope everything is okay" which feels hacky.
Doesn't change much for now, but it's an additional constraint in the RN Android codebase that we need to explicitly embed in code so that
we can point to it, and so that the logic is more clear.
Changelog: [Internal]
Reviewed By: javache, motiz88
Differential Revision: D30504616
fbshipit-source-id: d2abdb7c4765a16113c9517406cdbb8cf42822ff
---
.../facebook/react/ReactInstanceManager.java | 42 ++++++++++++-------
.../react/ReactInstanceManagerBuilder.java | 12 ++++++
.../com/facebook/react/ReactNativeHost.java | 6 +++
3 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
index 3792fe60c963..9980ff8c1c67 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
@@ -156,12 +156,14 @@ public interface ReactInstanceEventListener {
/* accessed from any thread */
private final JavaScriptExecutorFactory mJavaScriptExecutorFactory;
+ // See {@code ReactInstanceManagerBuilder} for description of all flags here.
private @Nullable List mViewManagerNames = null;
private final @Nullable JSBundleLoader mBundleLoader;
private final @Nullable String mJSMainModulePath; /* path to JS bundle root on Metro */
private final List mPackages;
private final DevSupportManager mDevSupportManager;
private final boolean mUseDeveloperSupport;
+ private final boolean mRequireActivity;
private @Nullable ComponentNameResolverManager mComponentNameResolverManager;
private @Nullable RuntimeSchedulerManager mRuntimeSchedulerManager;
private final @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
@@ -216,6 +218,7 @@ public static ReactInstanceManagerBuilder builder() {
@Nullable String jsMainModulePath,
List packages,
boolean useDeveloperSupport,
+ boolean requireActivity,
@Nullable NotThreadSafeBridgeIdleDebugListener bridgeIdleDebugListener,
LifecycleState initialLifecycleState,
@Nullable UIImplementationProvider mUIImplementationProvider,
@@ -233,6 +236,7 @@ public static ReactInstanceManagerBuilder builder() {
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);
+ // See {@code ReactInstanceManagerBuilder} for description of all flags here.
mApplicationContext = applicationContext;
mCurrentActivity = currentActivity;
mDefaultBackButtonImpl = defaultHardwareBackBtnHandler;
@@ -241,6 +245,7 @@ public static ReactInstanceManagerBuilder builder() {
mJSMainModulePath = jsMainModulePath;
mPackages = new ArrayList<>();
mUseDeveloperSupport = useDeveloperSupport;
+ mRequireActivity = requireActivity;
Systrace.beginSection(
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "ReactInstanceManager.initDevSupportManager");
mDevSupportManager =
@@ -558,16 +563,20 @@ public void onHostPause() {
* @param activity the activity being paused
*/
@ThreadConfined(UI)
- public void onHostPause(Activity activity) {
- Assertions.assertNotNull(mCurrentActivity);
- Assertions.assertCondition(
- activity == mCurrentActivity,
- "Pausing an activity that is not the current activity, this is incorrect! "
- + "Current activity: "
- + mCurrentActivity.getClass().getSimpleName()
- + " "
- + "Paused activity: "
- + activity.getClass().getSimpleName());
+ public void onHostPause(@Nullable Activity activity) {
+ if (mRequireActivity) {
+ Assertions.assertCondition(mCurrentActivity != null);
+ }
+ if (mCurrentActivity != null) {
+ Assertions.assertCondition(
+ activity == mCurrentActivity,
+ "Pausing an activity that is not the current activity, this is incorrect! "
+ + "Current activity: "
+ + mCurrentActivity.getClass().getSimpleName()
+ + " "
+ + "Paused activity: "
+ + activity.getClass().getSimpleName());
+ }
onHostPause();
}
@@ -583,7 +592,8 @@ public void onHostPause(Activity activity) {
* this instance of {@link ReactInstanceManager}.
*/
@ThreadConfined(UI)
- public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
+ public void onHostResume(
+ @Nullable Activity activity, DefaultHardwareBackBtnHandler defaultBackButtonImpl) {
UiThreadUtil.assertOnUiThread();
mDefaultBackButtonImpl = defaultBackButtonImpl;
@@ -592,7 +602,7 @@ public void onHostResume(Activity activity, DefaultHardwareBackBtnHandler defaul
/** Use this method when the activity resumes. */
@ThreadConfined(UI)
- public void onHostResume(Activity activity) {
+ public void onHostResume(@Nullable Activity activity) {
UiThreadUtil.assertOnUiThread();
mCurrentActivity = activity;
@@ -631,8 +641,8 @@ public void onViewDetachedFromWindow(View v) {
// activity is attached to window, we can enable dev support immediately
mDevSupportManager.setDevSupportEnabled(true);
}
- } else {
- // there is no activity, we can enable dev support
+ } else if (!mRequireActivity) {
+ // there is no activity, but we can enable dev support
mDevSupportManager.setDevSupportEnabled(true);
}
}
@@ -666,7 +676,9 @@ public void onHostDestroy() {
* @param activity the activity being destroyed
*/
@ThreadConfined(UI)
- public void onHostDestroy(Activity activity) {
+ public void onHostDestroy(@Nullable Activity activity) {
+ // In some cases, Activity may (correctly) be null.
+ // See mRequireActivity flag.
if (activity == mCurrentActivity) {
onHostDestroy();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java
index c06f71b9a594..36f700e49763 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManagerBuilder.java
@@ -45,6 +45,7 @@ public class ReactInstanceManagerBuilder {
private @Nullable NotThreadSafeBridgeIdleDebugListener mBridgeIdleDebugListener;
private @Nullable Application mApplication;
private boolean mUseDeveloperSupport;
+ private boolean mRequireActivity;
private @Nullable LifecycleState mInitialLifecycleState;
private @Nullable UIImplementationProvider mUIImplementationProvider;
private @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
@@ -171,6 +172,16 @@ public ReactInstanceManagerBuilder setUseDeveloperSupport(boolean useDeveloperSu
return this;
}
+ /**
+ * When {@code false}, indicates that correct usage of React Native will NOT involve an Activity.
+ * For the vast majority of Android apps in the ecosystem, this will not need to change. Unless
+ * you really know what you're doing, you should probably not change this!
+ */
+ public ReactInstanceManagerBuilder setRequireActivity(boolean requireActivity) {
+ mRequireActivity = requireActivity;
+ return this;
+ }
+
/**
* Sets the initial lifecycle state of the host. For example, if the host is already resumed at
* creation time, we wouldn't expect an onResume call until we get an onPause call.
@@ -283,6 +294,7 @@ public ReactInstanceManager build() {
mJSMainModulePath,
mPackages,
mUseDeveloperSupport,
+ mRequireActivity,
mBridgeIdleDebugListener,
Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
mUIImplementationProvider,
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java
index d4c457ff87de..dc313d33bc0f 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactNativeHost.java
@@ -68,6 +68,7 @@ protected ReactInstanceManager createReactInstanceManager() {
.setApplication(mApplication)
.setJSMainModulePath(getJSMainModuleName())
.setUseDeveloperSupport(getUseDeveloperSupport())
+ .setRequireActivity(getShouldRequireActivity())
.setRedBoxHandler(getRedBoxHandler())
.setJavaScriptExecutorFactory(getJavaScriptExecutorFactory())
.setUIImplementationProvider(getUIImplementationProvider())
@@ -124,6 +125,11 @@ protected UIImplementationProvider getUIImplementationProvider() {
return null;
}
+ /** Returns whether or not to treat it as normal if Activity is null. */
+ public boolean getShouldRequireActivity() {
+ return true;
+ }
+
/**
* Returns the name of the main module. Determines the URL used to fetch the JS bundle from Metro.
* It is only used when dev support is enabled. This is the first file to be executed once the
From ee3e71f536127295ba4ea377e618499409a2e9ba Mon Sep 17 00:00:00 2001
From: fabriziobertoglio1987
Date: Wed, 25 Aug 2021 04:55:24 -0700
Subject: [PATCH 002/986] onKeyPress event not fired with numeric keys (#29046)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/19507 fixes https://github.com/facebook/react-native/issues/30475 onKeyPress event not fired for numeric keyboard
The TextInput onKeyPress event is not fired when pressing numeric keys on Android.
The method sendKeyEvent will dispatchKeyEvent only for:
- ENTER_KEY_VALUE
- KEYCODE_DEL (delete key)
The solution proposed is trigger dispatchKeyEvent for KeyEvents with event.getUnicodeChar() value included between 47 and 58 (numeric keys 0-9)
## Changelog
[Android] [Fixed] - onKeyPress event not fired with numeric keys
Pull Request resolved: https://github.com/facebook/react-native/pull/29046
Test Plan:
**CLICK TO OPEN TESTS RESULTS**
Reviewed By: hramos, cortinico
Differential Revision: D30427789
Pulled By: sshic
fbshipit-source-id: b4e17ab94daa59fe28de5a5141b0fdd49bab72e3
---
.../views/textinput/ReactEditTextInputConnectionWrapper.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java
index 55ae040054b9..aa2f9a6462e5 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditTextInputConnectionWrapper.java
@@ -131,10 +131,13 @@ public boolean deleteSurroundingText(int beforeLength, int afterLength) {
@Override
public boolean sendKeyEvent(KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
+ boolean isNumberKey = event.getUnicodeChar() < 58 && event.getUnicodeChar() > 47;
if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
dispatchKeyEvent(BACKSPACE_KEY_VALUE);
} else if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
dispatchKeyEvent(ENTER_KEY_VALUE);
+ } else if (isNumberKey) {
+ dispatchKeyEvent(String.valueOf(event.getNumber()));
}
}
return super.sendKeyEvent(event);
From 1a42bd6e97ae44a3b38ca552865bac63a6f35da5 Mon Sep 17 00:00:00 2001
From: Jimmy Zhang
Date: Wed, 25 Aug 2021 05:09:10 -0700
Subject: [PATCH 003/986] Add UIAccessibilityTraitUpdatesFrequently to
progressBar role
Summary:
Changelog:
Add UIAccessibilityTraitUpdatesFrequently when the AccessibilityRole is set to progressBar. This trait tells the accessibility system where content may change with every percentage point, but without annoying the user with constant announcements.
Reviewed By: ikenwoo
Differential Revision: D30510587
fbshipit-source-id: e75690a2a56ce42476dc999383cf58c0811fcbdf
---
React/Views/RCTViewManager.m | 5 +++--
.../renderer/components/view/accessibilityPropsConversions.h | 4 ++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/React/Views/RCTViewManager.m b/React/Views/RCTViewManager.m
index e1218914e8d6..72e195c556b9 100644
--- a/React/Views/RCTViewManager.m
+++ b/React/Views/RCTViewManager.m
@@ -51,7 +51,7 @@ @implementation RCTConvert (UIAccessibilityTraits)
@"menu" : @(UIAccessibilityTraitNone),
@"menubar" : @(UIAccessibilityTraitNone),
@"menuitem" : @(UIAccessibilityTraitNone),
- @"progressbar" : @(UIAccessibilityTraitNone),
+ @"progressbar" : @(UIAccessibilityTraitUpdatesFrequently),
@"radio" : @(UIAccessibilityTraitNone),
@"radiogroup" : @(UIAccessibilityTraitNone),
@"scrollbar" : @(UIAccessibilityTraitNone),
@@ -172,7 +172,8 @@ - (RCTShadowView *)shadowView
const UIAccessibilityTraits AccessibilityRolesMask = UIAccessibilityTraitNone | UIAccessibilityTraitButton |
UIAccessibilityTraitLink | UIAccessibilityTraitSearchField | UIAccessibilityTraitImage |
UIAccessibilityTraitKeyboardKey | UIAccessibilityTraitStaticText | UIAccessibilityTraitAdjustable |
- UIAccessibilityTraitHeader | UIAccessibilityTraitSummaryElement | SwitchAccessibilityTrait;
+ UIAccessibilityTraitHeader | UIAccessibilityTraitSummaryElement | UIAccessibilityTraitTabBar |
+ UIAccessibilityTraitUpdatesFrequently | SwitchAccessibilityTrait;
view.reactAccessibilityElement.accessibilityTraits =
view.reactAccessibilityElement.accessibilityTraits & ~AccessibilityRolesMask;
UIAccessibilityTraits newTraits = json ? [RCTConvert UIAccessibilityTraits:json] : defaultView.accessibilityTraits;
diff --git a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h
index d06ee6546d96..92c52527cd55 100644
--- a/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h
+++ b/ReactCommon/react/renderer/components/view/accessibilityPropsConversions.h
@@ -98,6 +98,10 @@ inline void fromString(const std::string &string, AccessibilityTraits &result) {
result = AccessibilityTraits::TabBar;
return;
}
+ if (string == "progressbar") {
+ result = AccessibilityTraits::UpdatesFrequently;
+ return;
+ }
result = AccessibilityTraits::None;
}
From 2550948ec6fa480e4e483f997e91d691ea5f5cee Mon Sep 17 00:00:00 2001
From: Nick Gerleman
Date: Wed, 25 Aug 2021 12:12:45 -0700
Subject: [PATCH 004/986] Bump @react-native/polyfills version (#32074)
Summary:
https://github.com/facebook/react-native/commit/8a62583f794875e6dc5d1e4a24889b3b702d9f86 did some renaming inside of the react-native/polyfills project, with the jest preset updated to use the new name. The new package for polyfills has not yet been published, so the jest preset in the main branch will be looking for the new name, while the old name is provided by the currently published react-native/polyfills@1.0.0. This is not hit inside the repo, since the dependency is linked instead of using the published one.
Bump react-native/polyfills to 2.0 (breaking change), in preparation for publish.
## Changelog
[Internal][Fixed] - Bump react-native/polyfills version
Pull Request resolved: https://github.com/facebook/react-native/pull/32074
Reviewed By: lunaleaps, cortinico
Differential Revision: D30498104
Pulled By: yungsters
fbshipit-source-id: 92dcb159d76bd74cd93cfa09e2155c9c1b2c0a86
---
package.json | 2 +-
packages/polyfills/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/package.json b/package.json
index bf5c11886011..773a915a7985 100644
--- a/package.json
+++ b/package.json
@@ -95,7 +95,7 @@
"@react-native-community/cli-platform-ios": "^6.0.0",
"@react-native/assets": "1.0.0",
"@react-native/normalize-color": "1.0.0",
- "@react-native/polyfills": "1.0.0",
+ "@react-native/polyfills": "2.0.0",
"abort-controller": "^3.0.0",
"anser": "^1.4.9",
"base64-js": "^1.1.2",
diff --git a/packages/polyfills/package.json b/packages/polyfills/package.json
index 6f00c64c7fca..58a2b3a70494 100644
--- a/packages/polyfills/package.json
+++ b/packages/polyfills/package.json
@@ -1,6 +1,6 @@
{
"name": "@react-native/polyfills",
- "version": "1.0.0",
+ "version": "2.0.0",
"description": "Polyfills for React Native.",
"repository": {
"type": "git",
From 2bcc6fac3844f0752bc7067517c92a643679575e Mon Sep 17 00:00:00 2001
From: Connor Tumbleson
Date: Wed, 25 Aug 2021 12:45:10 -0700
Subject: [PATCH 005/986] feat: add Android 12 BLUETOOTH_ADVERTISE to
PermissionsAndroid (#32079)
Summary:
This PR adds BLUETOOTH_ADVERTISE, which showed up in the latest Android 12 Beta build as new `dangerous` permissions requiring approval for them.
https://developer.android.com/reference/android/Manifest.permission.html#BLUETOOTH_ADVERTISE
You can see the new set of `SCAN/ADVERTISE/CONNECT` added in this doc - https://developer.android.com/about/versions/12/features/bluetooth-permissions, previously SCAN/CONNECT were added in: https://github.com/facebook/react-native/pull/31488
## Changelog
[Android] [Changed] - Add BLUETOOTH_ADVERTISE to PermissionsAndroid
Pull Request resolved: https://github.com/facebook/react-native/pull/32079
Test Plan:
```
PermissionsAndroid.BLUETOOTH_ADVERTISE === 'android.permission.BLUETOOTH_ADVERTISE'
```
Reviewed By: cortinico
Differential Revision: D30532656
Pulled By: yungsters
fbshipit-source-id: 986ad8cbfc27913df13ab24bba36f6e13104e7d9
---
Libraries/PermissionsAndroid/NativePermissionsAndroid.js | 3 ++-
Libraries/PermissionsAndroid/PermissionsAndroid.js | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/Libraries/PermissionsAndroid/NativePermissionsAndroid.js b/Libraries/PermissionsAndroid/NativePermissionsAndroid.js
index 64d55e5f3342..358882c8ec48 100644
--- a/Libraries/PermissionsAndroid/NativePermissionsAndroid.js
+++ b/Libraries/PermissionsAndroid/NativePermissionsAndroid.js
@@ -43,7 +43,8 @@ export type PermissionType =
| 'android.permission.READ_EXTERNAL_STORAGE'
| 'android.permission.WRITE_EXTERNAL_STORAGE'
| 'android.permission.BLUETOOTH_CONNECT'
- | 'android.permission.BLUETOOTH_SCAN';
+ | 'android.permission.BLUETOOTH_SCAN'
+ | 'android.permission.BLUETOOTH_ADVERTISE';
*/
export interface Spec extends TurboModule {
diff --git a/Libraries/PermissionsAndroid/PermissionsAndroid.js b/Libraries/PermissionsAndroid/PermissionsAndroid.js
index c538dfd80354..1006cd319245 100644
--- a/Libraries/PermissionsAndroid/PermissionsAndroid.js
+++ b/Libraries/PermissionsAndroid/PermissionsAndroid.js
@@ -61,6 +61,7 @@ const PERMISSIONS = Object.freeze({
WRITE_EXTERNAL_STORAGE: 'android.permission.WRITE_EXTERNAL_STORAGE',
BLUETOOTH_CONNECT: 'android.permission.BLUETOOTH_CONNECT',
BLUETOOTH_SCAN: 'android.permission.BLUETOOTH_SCAN',
+ BLUETOOTH_ADVERTISE: 'android.permission.BLUETOOTH_ADVERTISE',
});
/**
@@ -75,6 +76,7 @@ class PermissionsAndroid {
ACCESS_COARSE_LOCATION: string,
ACCESS_FINE_LOCATION: string,
ADD_VOICEMAIL: string,
+ BLUETOOTH_ADVERTISE: string,
BLUETOOTH_CONNECT: string,
BLUETOOTH_SCAN: string,
BODY_SENSORS: string,
From 8c4912a42f0dcab709c1843e6e63308729295d4b Mon Sep 17 00:00:00 2001
From: Joshua Gross
Date: Wed, 25 Aug 2021 13:07:31 -0700
Subject: [PATCH 006/986] Fabric should be enabled or disabled app-wide without
entrypoint-specific options
Summary:
Add new ReactFeatureFlag to enable or disable Fabric appwide.
Changelog: [Internal]
Reviewed By: fkgozali
Differential Revision: D30504714
fbshipit-source-id: f615d4c888a89f5401b0ff8f8305fdfbdf75fba3
---
.../java/com/facebook/react/config/ReactFeatureFlags.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java
index 8513e6c0ccd4..077eb5fd7b26 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java
@@ -25,6 +25,12 @@ public class ReactFeatureFlags {
*/
public static volatile boolean useTurboModules = false;
+ /**
+ * Should this application use the new (Fabric) Renderer? If yes, all rendering in this app will
+ * use Fabric instead of the legacy renderer.
+ */
+ public static volatile boolean enableFabricRenderer = false;
+
/**
* After TurboModules and Fabric are enabled, we need to ensure that the legacy NativeModule isn't
* isn't used. So, turn this flag on to trigger warnings whenever the legacy NativeModule system
From 2fb102b601a929be74eb9042745a1bb63ed7bc6a Mon Sep 17 00:00:00 2001
From: alessandro
Date: Wed, 25 Aug 2021 13:07:41 -0700
Subject: [PATCH 007/986] refactor: remove DefeaultProps from the DatePickerIOS
component (#32064)
Summary:
Closes issue https://github.com/facebook/react-native/issues/31605.
This is part of a bigger issue that plans to remove defaultProps from class components in order to provide a smoother transition to functional components.
## Changelog
[General] [Changed] - Remove defaultProps from the DatePickerIOS Component.
[General] [Test] - Added snapshot test for the new component
Pull Request resolved: https://github.com/facebook/react-native/pull/32064
Test Plan: Compiled the rn-tester folder to check if the behavior is consistent with the previous versions.
Reviewed By: lunaleaps
Differential Revision: D30492515
Pulled By: yungsters
fbshipit-source-id: ed2c5f3211742d528ff3f8e406a53cd7ea43d7e7
---
.../DatePicker/DatePickerIOS.ios.js | 9 ++--
.../__tests__/DatePickerIOS-test.js | 14 ++++++
.../__snapshots__/DatePickerIOS-test.js.snap | 48 +++++++++++++++++++
3 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js
index 30cc13ad55f0..8295e3aeded2 100644
--- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js
+++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js
@@ -117,10 +117,6 @@ type Props = $ReadOnly<{|
* source of truth.
*/
class DatePickerIOS extends React.Component {
- static DefaultProps: {|mode: $TEMPORARY$string<'datetime'>|} = {
- mode: 'datetime',
- };
-
_picker: ?React.ElementRef = null;
componentDidUpdate() {
@@ -142,6 +138,7 @@ class DatePickerIOS extends React.Component {
render(): React.Node {
const props = this.props;
+ const mode = props.mode ?? 'datetime';
invariant(
props.date || props.initialDate,
'A selected date or initial date should be specified.',
@@ -153,7 +150,7 @@ class DatePickerIOS extends React.Component {
ref={picker => {
this._picker = picker;
}}
- style={getHeight(props.pickerStyle, props.mode)}
+ style={getHeight(props.pickerStyle, mode)}
date={
props.date
? props.date.getTime()
@@ -172,7 +169,7 @@ class DatePickerIOS extends React.Component {
minimumDate={
props.minimumDate ? props.minimumDate.getTime() : undefined
}
- mode={props.mode}
+ mode={mode}
minuteInterval={props.minuteInterval}
timeZoneOffsetInMinutes={props.timeZoneOffsetInMinutes}
onChange={this._onChange}
diff --git a/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js b/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js
index bcc029c47684..79579b82ee59 100644
--- a/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js
+++ b/Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js
@@ -32,4 +32,18 @@ describe('DatePickerIOS', () => {
},
);
});
+ it('should render DatePicker with the datetime mode if no mode is passed inside the props', () => {
+ ReactNativeTestTools.expectRendersMatchingSnapshot(
+ 'DatePickerIOS',
+ () => (
+
+ ),
+ () => {
+ jest.dontMock('../DatePickerIOS');
+ },
+ );
+ });
});
diff --git a/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap b/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap
index e463f9819141..55ce6c206714 100644
--- a/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap
+++ b/Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap
@@ -1,5 +1,53 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should deep render when mocked (please verify output manually) 1`] = `
+
+
+
+`;
+
+exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should deep render when not mocked (please verify output manually) 1`] = `
+
+
+
+`;
+
+exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should shallow render as when mocked 1`] = `
+
+`;
+
+exports[`DatePickerIOS should render DatePicker with the datetime mode if no mode is passed inside the props: should shallow render as when not mocked 1`] = `
+
+`;
+
exports[`DatePickerIOS should render as expected: should deep render when mocked (please verify output manually) 1`] = `
Date: Wed, 25 Aug 2021 13:23:40 -0700
Subject: [PATCH 008/986] Compare strings by value instead of reference
Summary:
LLD, our new iOS linker, is an ongoing effort to migrate our old outdated ld64 linker. As part of our effort to rollout LLD to all apps, we are making sure LLD reaches parity with ld64.
Due to Identical Code Folding (ICF), LLD and ld64 handles strings differently. LLD treats each string as a separate object in memory even if the values of the strings are the same. ld64 happens to aggregate these values across files. This behavior creates a subtle difference on our codebase when we start comparing by value or by reference.
`char * ` fields from `RawPropsKey.h` are using `==` which compares by its address. Here, we cast the buffer to a string to make the comparison, while avoiding the cast if one happens to be null.
Changelog: [Internal]
Reviewed By: int3, JoshuaGross
Differential Revision: D30444176
fbshipit-source-id: 74216926803adbece05206ddd8478cc3c8e6812e
---
ReactCommon/react/renderer/core/RawPropsKey.cpp | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/ReactCommon/react/renderer/core/RawPropsKey.cpp b/ReactCommon/react/renderer/core/RawPropsKey.cpp
index cdaab91f7d5e..35c8283f5e24 100644
--- a/ReactCommon/react/renderer/core/RawPropsKey.cpp
+++ b/ReactCommon/react/renderer/core/RawPropsKey.cpp
@@ -51,10 +51,18 @@ RawPropsKey::operator std::string() const noexcept {
return std::string{buffer, length};
}
+static bool areFieldsEqual(char const *lhs, char const *rhs) {
+ if (lhs == nullptr || rhs == nullptr) {
+ return lhs == rhs;
+ }
+ return std::string(lhs) == std::string(rhs);
+}
+
bool operator==(RawPropsKey const &lhs, RawPropsKey const &rhs) noexcept {
// Note: We check the name first.
- return lhs.name == rhs.name && lhs.prefix == rhs.prefix &&
- lhs.suffix == rhs.suffix;
+ return areFieldsEqual(lhs.name, rhs.name) &&
+ areFieldsEqual(lhs.prefix, rhs.prefix) &&
+ areFieldsEqual(lhs.suffix, rhs.suffix);
}
bool operator!=(RawPropsKey const &lhs, RawPropsKey const &rhs) noexcept {
From 7a770526c626e6659a12939f8c61057a688aa623 Mon Sep 17 00:00:00 2001
From: Andres Riveros Moya
Date: Wed, 25 Aug 2021 13:36:23 -0700
Subject: [PATCH 009/986] Remove DatePickerAndroid from react-native-github
Summary:
Changelog:
[JavaScript][Removed] - Remove DatePickerAndroid from React Native
Reviewed By: lunaleaps, yungsters
Differential Revision: D30281952
fbshipit-source-id: 5cd0ad2ad741afeef3e6f8a39635c6baf4b79b38
---
.../DatePickerAndroid.android.js | 87 ---------
.../DatePickerAndroid.ios.js | 30 ---
.../DatePickerAndroidTypes.js | 30 ---
.../java/com/facebook/react/tests/BUCK | 1 -
.../react/tests/DatePickerDialogTestCase.java | 172 ------------------
.../js/DatePickerDialogTestModule.js | 45 -----
ReactAndroid/src/androidTest/js/TestBundle.js | 7 -
.../facebook/react/modules/datepicker/BUCK | 27 ---
.../datepicker/DatePickerDialogFragment.java | 137 --------------
.../datepicker/DatePickerDialogModule.java | 153 ----------------
.../modules/datepicker/DatePickerMode.java | 15 --
.../DismissableDatePickerDialog.java | 117 ------------
.../main/java/com/facebook/react/shell/BUCK | 1 -
.../react/shell/MainReactPackage.java | 5 -
index.js | 25 ++-
15 files changed, 15 insertions(+), 837 deletions(-)
delete mode 100644 Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js
delete mode 100644 Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js
delete mode 100644 Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js
delete mode 100644 ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java
delete mode 100644 ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerMode.java
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java
diff --git a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js
deleted file mode 100644
index 9f29433e1e18..000000000000
--- a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js
+++ /dev/null
@@ -1,87 +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.
- *
- * @format
- * @flow strict-local
- */
-
-import type {Options, DatePickerOpenAction} from './DatePickerAndroidTypes';
-import NativeDatePickerAndroid from './NativeDatePickerAndroid';
-
-/**
- * Convert a Date to a timestamp.
- */
-function _toMillis(options: Options, key: string) {
- const dateVal = options[key];
- // Is it a Date object?
- if (typeof dateVal === 'object' && typeof dateVal.getMonth === 'function') {
- options[key] = dateVal.getTime();
- }
-}
-
-/**
- * Opens the standard Android date picker dialog.
- *
- * ### Example
- *
- * ```
- * try {
- * const {action, year, month, day} = await DatePickerAndroid.open({
- * // Use `new Date()` for current date.
- * // May 25 2020. Month 0 is January.
- * date: new Date(2020, 4, 25)
- * });
- * if (action !== DatePickerAndroid.dismissedAction) {
- * // Selected year, month (0-11), day
- * }
- * } catch ({code, message}) {
- * console.warn('Cannot open date picker', message);
- * }
- * ```
- */
-class DatePickerAndroid {
- /**
- * Opens the standard Android date picker dialog.
- *
- * The available keys for the `options` object are:
- *
- * - `date` (`Date` object or timestamp in milliseconds) - date to show by default
- * - `minDate` (`Date` or timestamp in milliseconds) - minimum date that can be selected
- * - `maxDate` (`Date` object or timestamp in milliseconds) - maximum date that can be selected
- * - `mode` (`enum('calendar', 'spinner', 'default')`) - To set the date-picker mode to calendar/spinner/default
- * - 'calendar': Show a date picker in calendar mode.
- * - 'spinner': Show a date picker in spinner mode.
- * - 'default': Show a default native date picker(spinner/calendar) based on android versions.
- *
- * Returns a Promise which will be invoked an object containing `action`, `year`, `month` (0-11),
- * `day` if the user picked a date. If the user dismissed the dialog, the Promise will
- * still be resolved with action being `DatePickerAndroid.dismissedAction` and all the other keys
- * being undefined. **Always** check whether the `action` before reading the values.
- *
- * Note the native date picker dialog has some UI glitches on Android 4 and lower
- * when using the `minDate` and `maxDate` options.
- */
- static async open(options: ?Options): Promise {
- const optionsMs = options;
- if (optionsMs != null) {
- _toMillis(optionsMs, 'date');
- _toMillis(optionsMs, 'minDate');
- _toMillis(optionsMs, 'maxDate');
- }
- return NativeDatePickerAndroid.open(options);
- }
-
- /**
- * A date has been selected.
- */
- static +dateSetAction: 'dateSetAction' = 'dateSetAction';
- /**
- * The dialog has been dismissed.
- */
- static +dismissedAction: 'dismissedAction' = 'dismissedAction';
-}
-
-module.exports = DatePickerAndroid;
diff --git a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js b/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js
deleted file mode 100644
index d16cb2bf6105..000000000000
--- a/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js
+++ /dev/null
@@ -1,30 +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.
- *
- * @format
- * @flow strict-local
- */
-
-'use strict';
-
-import type {Options, DatePickerOpenAction} from './DatePickerAndroidTypes';
-
-class DatePickerAndroid {
- static async open(options: ?Options): Promise {
- throw new Error('DatePickerAndroid is not supported on this platform.');
- }
-
- /**
- * A date has been selected.
- */
- static +dateSetAction: 'dateSetAction' = 'dateSetAction';
- /**
- * The dialog has been dismissed.
- */
- static +dismissedAction: 'dismissedAction' = 'dismissedAction';
-}
-
-module.exports = DatePickerAndroid;
diff --git a/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js b/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js
deleted file mode 100644
index 096d7b5e8d9a..000000000000
--- a/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js
+++ /dev/null
@@ -1,30 +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.
- *
- * @format
- * @flow strict-local
- */
-
-export type Options = $ReadOnly<{|
- date?: ?(Date | number),
- minDate?: ?(Date | number),
- maxDate?: ?(Date | number),
- mode?: ?('calendar' | 'spinner' | 'default'),
-|}>;
-
-export type DatePickerOpenAction =
- | {|
- action: 'dateSetAction',
- year: number,
- month: number,
- day: number,
- |}
- | {|
- action: 'dismissedAction',
- year: void,
- month: void,
- day: void,
- |};
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK
index 451cd7413b96..131dd4af63c3 100644
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK
+++ b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/BUCK
@@ -25,7 +25,6 @@ rn_android_library(
react_native_target("java/com/facebook/react/module/annotations:annotations"),
react_native_target("java/com/facebook/react/modules/appstate:appstate"),
react_native_target("java/com/facebook/react/modules/core:core"),
- react_native_target("java/com/facebook/react/modules/datepicker:datepicker"),
react_native_target("java/com/facebook/react/modules/deviceinfo:deviceinfo"),
react_native_target("java/com/facebook/react/modules/share:share"),
react_native_target("java/com/facebook/react/modules/systeminfo:systeminfo"),
diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java b/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java
deleted file mode 100644
index 93d3568fa24e..000000000000
--- a/ReactAndroid/src/androidTest/java/com/facebook/react/tests/DatePickerDialogTestCase.java
+++ /dev/null
@@ -1,172 +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.tests;
-
-import android.app.DatePickerDialog;
-import android.content.DialogInterface;
-import android.widget.DatePicker;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.Fragment;
-import com.facebook.react.bridge.BaseJavaModule;
-import com.facebook.react.bridge.JavaScriptModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.bridge.WritableNativeMap;
-import com.facebook.react.modules.datepicker.DatePickerDialogModule;
-import com.facebook.react.testing.ReactAppInstrumentationTestCase;
-import com.facebook.react.testing.ReactInstanceSpecForTest;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-/** Test case for {@link DatePickerDialogModule} options and callbacks. */
-public class DatePickerDialogTestCase extends ReactAppInstrumentationTestCase {
-
- private static interface DatePickerDialogTestModule extends JavaScriptModule {
- public void showDatePickerDialog(WritableMap options);
- }
-
- private static class DatePickerDialogRecordingModule extends BaseJavaModule {
-
- private final List mDates = new ArrayList();
- private int mDismissed = 0;
- private int mErrors = 0;
-
- @Override
- public String getName() {
- return "DatePickerDialogRecordingModule";
- }
-
- @ReactMethod
- public void recordDate(int year, int month, int day) {
- mDates.add(new Integer[] {year, month, day});
- }
-
- @ReactMethod
- public void recordDismissed() {
- mDismissed++;
- }
-
- @ReactMethod
- public void recordError() {
- mErrors++;
- }
-
- public List getDates() {
- return new ArrayList(mDates);
- }
-
- public int getDismissed() {
- return mDismissed;
- }
-
- public int getErrors() {
- return mErrors;
- }
- }
-
- final DatePickerDialogRecordingModule mRecordingModule = new DatePickerDialogRecordingModule();
-
- @Override
- protected ReactInstanceSpecForTest createReactInstanceSpecForTest() {
- return super.createReactInstanceSpecForTest().addNativeModule(mRecordingModule);
- }
-
- @Override
- protected String getReactApplicationKeyUnderTest() {
- return "DatePickerDialogTestApp";
- }
-
- private static long getDateInMillis(int year, int month, int date) {
- final Calendar c = Calendar.getInstance();
- c.set(Calendar.YEAR, year);
- c.set(Calendar.MONTH, month);
- c.set(Calendar.DATE, date);
- return c.getTimeInMillis();
- }
-
- private DatePickerDialogTestModule getTestModule() {
- return getReactContext().getCatalystInstance().getJSModule(DatePickerDialogTestModule.class);
- }
-
- private DialogFragment showDialog(WritableMap options) {
- getTestModule().showDatePickerDialog(options);
-
- waitForBridgeAndUIIdle();
- getInstrumentation().waitForIdleSync();
-
- return (DialogFragment)
- getActivity()
- .getSupportFragmentManager()
- .findFragmentByTag(DatePickerDialogModule.FRAGMENT_TAG);
- }
-
- public void testShowBasicDatePicker() {
- final Fragment datePickerFragment = showDialog(null);
-
- assertNotNull(datePickerFragment);
- }
-
- public void testPresetDate() {
- final WritableMap options = new WritableNativeMap();
- options.putDouble("date", getDateInMillis(2020, 5, 6));
-
- final DialogFragment datePickerFragment = showDialog(options);
- final DatePicker datePicker =
- ((DatePickerDialog) datePickerFragment.getDialog()).getDatePicker();
-
- assertEquals(2020, datePicker.getYear());
- assertEquals(5, datePicker.getMonth());
- assertEquals(6, datePicker.getDayOfMonth());
- }
-
- public void testCallback() throws Throwable {
- final WritableMap options = new WritableNativeMap();
- options.putDouble("date", getDateInMillis(2020, 5, 6));
-
- final DialogFragment datePickerFragment = showDialog(options);
-
- runTestOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- ((DatePickerDialog) datePickerFragment.getDialog())
- .getButton(DialogInterface.BUTTON_POSITIVE)
- .performClick();
- }
- });
-
- getInstrumentation().waitForIdleSync();
- waitForBridgeAndUIIdle();
-
- assertEquals(0, mRecordingModule.getErrors());
- assertEquals(1, mRecordingModule.getDates().size());
- assertEquals(2020, (int) mRecordingModule.getDates().get(0)[0]);
- assertEquals(5, (int) mRecordingModule.getDates().get(0)[1]);
- assertEquals(6, (int) mRecordingModule.getDates().get(0)[2]);
- }
-
- public void testDismissCallback() throws Throwable {
- final DialogFragment datePickerFragment = showDialog(null);
-
- runTestOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- datePickerFragment.getDialog().dismiss();
- }
- });
-
- getInstrumentation().waitForIdleSync();
- waitForBridgeAndUIIdle();
-
- assertEquals(0, mRecordingModule.getErrors());
- assertEquals(0, mRecordingModule.getDates().size());
- assertEquals(1, mRecordingModule.getDismissed());
- }
-}
diff --git a/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js b/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
deleted file mode 100644
index 5c23e61a5ec5..000000000000
--- a/ReactAndroid/src/androidTest/js/DatePickerDialogTestModule.js
+++ /dev/null
@@ -1,45 +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.
- *
- * @format
- */
-
-'use strict';
-
-const React = require('react');
-const {DatePickerAndroid, NativeModules, View} = require('react-native');
-const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridge');
-
-const {DatePickerDialogRecordingModule: RecordingModule} = NativeModules;
-
-class DatePickerDialogTestApp extends React.Component {
- render() {
- return ;
- }
-}
-
-const DatePickerDialogTestModule = {
- DatePickerDialogTestApp: DatePickerDialogTestApp,
- showDatePickerDialog: function(options) {
- DatePickerAndroid.open(options).then(
- ({action, year, month, day}) => {
- if (action === DatePickerAndroid.dateSetAction) {
- RecordingModule.recordDate(year, month, day);
- } else if (action === DatePickerAndroid.dismissedAction) {
- RecordingModule.recordDismissed();
- }
- },
- ({code, message}) => RecordingModule.recordError(),
- );
- },
-};
-
-BatchedBridge.registerCallableModule(
- 'DatePickerDialogTestModule',
- DatePickerDialogTestModule,
-);
-
-module.exports = DatePickerDialogTestModule;
diff --git a/ReactAndroid/src/androidTest/js/TestBundle.js b/ReactAndroid/src/androidTest/js/TestBundle.js
index 709f469b118d..b81937503589 100644
--- a/ReactAndroid/src/androidTest/js/TestBundle.js
+++ b/ReactAndroid/src/androidTest/js/TestBundle.js
@@ -20,9 +20,7 @@ require('./TestJSLocaleModule');
require('./TestJSToJavaParametersModule');
require('./TestJavaToJSReturnValuesModule');
require('./UIManagerTestModule');
-
require('./CatalystRootViewTestModule');
-require('./DatePickerDialogTestModule');
require('./MeasureLayoutTestModule');
require('./ScrollViewTestModule');
require('./ShareTestModule');
@@ -43,11 +41,6 @@ const apps = [
component: () =>
require('./CatalystRootViewTestModule').CatalystRootViewTestApp,
},
- {
- appKey: 'DatePickerDialogTestApp',
- component: () =>
- require('./DatePickerDialogTestModule').DatePickerDialogTestApp,
- },
{
appKey: 'JSResponderTestApp',
component: () => require('./JSResponderTestApp'),
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK
deleted file mode 100644
index 80a1af4bb9ac..000000000000
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/BUCK
+++ /dev/null
@@ -1,27 +0,0 @@
-load("//tools/build_defs/oss:rn_defs.bzl", "react_native_dep", "react_native_root_target", "react_native_target", "rn_android_library")
-
-rn_android_library(
- name = "datepicker",
- srcs = glob(["**/*.java"]),
- autoglob = False,
- is_androidx = True,
- labels = ["supermodule:xplat/default/public.react_native.infra"],
- provided_deps = [
- react_native_dep("third-party/android/androidx:annotation"),
- react_native_dep("third-party/android/androidx:core"),
- react_native_dep("third-party/android/androidx:fragment"),
- react_native_dep("third-party/android/androidx:legacy-support-core-ui"),
- react_native_dep("third-party/android/androidx:legacy-support-core-utils"),
- ],
- visibility = [
- "PUBLIC",
- ],
- deps = [
- react_native_dep("third-party/java/infer-annotations:infer-annotations"),
- react_native_dep("third-party/java/jsr-305:jsr-305"),
- react_native_target("java/com/facebook/react/bridge:bridge"),
- react_native_target("java/com/facebook/react/common:common"),
- react_native_target("java/com/facebook/react/module/annotations:annotations"),
- ],
- exported_deps = [react_native_root_target(":FBReactNativeSpec")],
-)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java
deleted file mode 100644
index f3d190b4432e..000000000000
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogFragment.java
+++ /dev/null
@@ -1,137 +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.modules.datepicker;
-
-import android.annotation.SuppressLint;
-import android.app.DatePickerDialog;
-import android.app.DatePickerDialog.OnDateSetListener;
-import android.app.Dialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnDismissListener;
-import android.graphics.drawable.ColorDrawable;
-import android.os.Bundle;
-import android.widget.DatePicker;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import java.util.Calendar;
-import java.util.Locale;
-
-@SuppressLint("ValidFragment")
-public class DatePickerDialogFragment extends DialogFragment {
-
- /** Minimum date supported by {@link DatePicker}, 01 Jan 1900 */
- private static final long DEFAULT_MIN_DATE = -2208988800001l;
-
- @Nullable private OnDateSetListener mOnDateSetListener;
- @Nullable private OnDismissListener mOnDismissListener;
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- Bundle args = getArguments();
- return createDialog(args, getActivity(), mOnDateSetListener);
- }
-
- /*package*/ static Dialog createDialog(
- Bundle args, Context activityContext, @Nullable OnDateSetListener onDateSetListener) {
- final Calendar c = Calendar.getInstance();
- if (args != null && args.containsKey(DatePickerDialogModule.ARG_DATE)) {
- c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_DATE));
- }
- final int year = c.get(Calendar.YEAR);
- final int month = c.get(Calendar.MONTH);
- final int day = c.get(Calendar.DAY_OF_MONTH);
-
- DatePickerMode mode = DatePickerMode.DEFAULT;
- if (args != null && args.getString(DatePickerDialogModule.ARG_MODE, null) != null) {
- mode =
- DatePickerMode.valueOf(
- args.getString(DatePickerDialogModule.ARG_MODE).toUpperCase(Locale.US));
- }
-
- DatePickerDialog dialog = null;
-
- switch (mode) {
- case CALENDAR:
- dialog =
- new DismissableDatePickerDialog(
- activityContext,
- activityContext
- .getResources()
- .getIdentifier(
- "CalendarDatePickerDialog", "style", activityContext.getPackageName()),
- onDateSetListener,
- year,
- month,
- day);
- break;
- case SPINNER:
- dialog =
- new DismissableDatePickerDialog(
- activityContext,
- android.R.style.Theme_Holo_Light_Dialog,
- onDateSetListener,
- year,
- month,
- day);
- dialog
- .getWindow()
- .setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
- break;
- case DEFAULT:
- dialog =
- new DismissableDatePickerDialog(activityContext, onDateSetListener, year, month, day);
- break;
- }
-
- final DatePicker datePicker = dialog.getDatePicker();
-
- if (args != null && args.containsKey(DatePickerDialogModule.ARG_MINDATE)) {
- // Set minDate to the beginning of the day. We need this because of clowniness in datepicker
- // that causes it to throw an exception if minDate is greater than the internal timestamp
- // that it generates from the y/m/d passed in the constructor.
- c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_MINDATE));
- c.set(Calendar.HOUR_OF_DAY, 0);
- c.set(Calendar.MINUTE, 0);
- c.set(Calendar.SECOND, 0);
- c.set(Calendar.MILLISECOND, 0);
- datePicker.setMinDate(c.getTimeInMillis());
- } else {
- // This is to work around a bug in DatePickerDialog where it doesn't display a title showing
- // the date under certain conditions.
- datePicker.setMinDate(DEFAULT_MIN_DATE);
- }
- if (args != null && args.containsKey(DatePickerDialogModule.ARG_MAXDATE)) {
- // Set maxDate to the end of the day, same reason as for minDate.
- c.setTimeInMillis(args.getLong(DatePickerDialogModule.ARG_MAXDATE));
- c.set(Calendar.HOUR_OF_DAY, 23);
- c.set(Calendar.MINUTE, 59);
- c.set(Calendar.SECOND, 59);
- c.set(Calendar.MILLISECOND, 999);
- datePicker.setMaxDate(c.getTimeInMillis());
- }
-
- return dialog;
- }
-
- @Override
- public void onDismiss(DialogInterface dialog) {
- super.onDismiss(dialog);
- if (mOnDismissListener != null) {
- mOnDismissListener.onDismiss(dialog);
- }
- }
-
- /*package*/ void setOnDateSetListener(@Nullable OnDateSetListener onDateSetListener) {
- mOnDateSetListener = onDateSetListener;
- }
-
- /*package*/ void setOnDismissListener(@Nullable OnDismissListener onDismissListener) {
- mOnDismissListener = onDismissListener;
- }
-}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java
deleted file mode 100644
index e69714648892..000000000000
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerDialogModule.java
+++ /dev/null
@@ -1,153 +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.modules.datepicker;
-
-import android.app.Activity;
-import android.app.DatePickerDialog.OnDateSetListener;
-import android.content.DialogInterface;
-import android.content.DialogInterface.OnDismissListener;
-import android.os.Bundle;
-import android.widget.DatePicker;
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.DialogFragment;
-import androidx.fragment.app.FragmentActivity;
-import androidx.fragment.app.FragmentManager;
-import com.facebook.fbreact.specs.NativeDatePickerAndroidSpec;
-import com.facebook.react.bridge.*;
-import com.facebook.react.common.annotations.VisibleForTesting;
-import com.facebook.react.module.annotations.ReactModule;
-
-/**
- * {@link NativeModule} that allows JS to show a native date picker dialog and get called back when
- * the user selects a date.
- */
-@ReactModule(name = DatePickerDialogModule.FRAGMENT_TAG)
-public class DatePickerDialogModule extends NativeDatePickerAndroidSpec {
-
- @VisibleForTesting public static final String FRAGMENT_TAG = "DatePickerAndroid";
-
- private static final String ERROR_NO_ACTIVITY = "E_NO_ACTIVITY";
-
- /* package */ static final String ARG_DATE = "date";
- /* package */ static final String ARG_MINDATE = "minDate";
- /* package */ static final String ARG_MAXDATE = "maxDate";
- /* package */ static final String ARG_MODE = "mode";
-
- /* package */ static final String ACTION_DATE_SET = "dateSetAction";
- /* package */ static final String ACTION_DISMISSED = "dismissedAction";
-
- public DatePickerDialogModule(ReactApplicationContext reactContext) {
- super(reactContext);
- }
-
- public @NonNull String getName() {
- return DatePickerDialogModule.FRAGMENT_TAG;
- }
-
- private class DatePickerDialogListener implements OnDateSetListener, OnDismissListener {
-
- private final Promise mPromise;
- private boolean mPromiseResolved = false;
-
- public DatePickerDialogListener(final Promise promise) {
- mPromise = promise;
- }
-
- @Override
- public void onDateSet(DatePicker view, int year, int month, int day) {
- if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
- WritableMap result = new WritableNativeMap();
- result.putString("action", ACTION_DATE_SET);
- result.putInt("year", year);
- result.putInt("month", month);
- result.putInt("day", day);
- mPromise.resolve(result);
- mPromiseResolved = true;
- }
- }
-
- @Override
- public void onDismiss(DialogInterface dialog) {
- if (!mPromiseResolved && getReactApplicationContext().hasActiveReactInstance()) {
- WritableMap result = new WritableNativeMap();
- result.putString("action", ACTION_DISMISSED);
- mPromise.resolve(result);
- mPromiseResolved = true;
- }
- }
- }
-
- /**
- * Show a date picker dialog.
- *
- * @param options a map containing options. Available keys are:
- *
- *
{@code date} (timestamp in milliseconds) the date to show by default
- *
{@code minDate} (timestamp in milliseconds) the minimum date the user should be
- * allowed to select
- *
{@code maxDate} (timestamp in milliseconds) the maximum date the user should be
- * allowed to select
- *
{@code mode} To set the date picker mode to 'calendar/spinner/default'
- *
- *
- * @param promise This will be invoked with parameters action, year, month (0-11), day, where
- * action is {@code dateSetAction} or {@code dismissedAction}, depending on what the user did.
- * If the action is dismiss, year, month and date are undefined.
- */
- @Override
- public void open(@Nullable final ReadableMap options, final Promise promise) {
- Activity raw_activity = getCurrentActivity();
- if (raw_activity == null || !(raw_activity instanceof FragmentActivity)) {
- promise.reject(
- ERROR_NO_ACTIVITY,
- "Tried to open a DatePicker dialog while not attached to a FragmentActivity");
- return;
- }
-
- FragmentActivity activity = (FragmentActivity) raw_activity;
-
- final FragmentManager fragmentManager = activity.getSupportFragmentManager();
- DialogFragment oldFragment = (DialogFragment) fragmentManager.findFragmentByTag(FRAGMENT_TAG);
- if (oldFragment != null) {
- oldFragment.dismiss();
- }
- activity.runOnUiThread(
- new Runnable() {
- @Override
- public void run() {
- DatePickerDialogFragment fragment = new DatePickerDialogFragment();
- if (options != null) {
- final Bundle args = createFragmentArguments(options);
- fragment.setArguments(args);
- }
- final DatePickerDialogListener listener = new DatePickerDialogListener(promise);
- fragment.setOnDismissListener(listener);
- fragment.setOnDateSetListener(listener);
- fragment.show(fragmentManager, FRAGMENT_TAG);
- }
- });
- }
-
- private Bundle createFragmentArguments(ReadableMap options) {
- final Bundle args = new Bundle();
- if (options.hasKey(ARG_DATE) && !options.isNull(ARG_DATE)) {
- args.putLong(ARG_DATE, (long) options.getDouble(ARG_DATE));
- }
- if (options.hasKey(ARG_MINDATE) && !options.isNull(ARG_MINDATE)) {
- args.putLong(ARG_MINDATE, (long) options.getDouble(ARG_MINDATE));
- }
- if (options.hasKey(ARG_MAXDATE) && !options.isNull(ARG_MAXDATE)) {
- args.putLong(ARG_MAXDATE, (long) options.getDouble(ARG_MAXDATE));
- }
- if (options.hasKey(ARG_MODE) && !options.isNull(ARG_MODE)) {
- args.putString(ARG_MODE, options.getString(ARG_MODE));
- }
- return args;
- }
-}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerMode.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerMode.java
deleted file mode 100644
index 3ed6f114724c..000000000000
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DatePickerMode.java
+++ /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.
- */
-
-package com.facebook.react.modules.datepicker;
-
-/** Date picker modes */
-public enum DatePickerMode {
- CALENDAR,
- SPINNER,
- DEFAULT
-}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java b/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java
deleted file mode 100644
index cfcc1fd3c774..000000000000
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/datepicker/DismissableDatePickerDialog.java
+++ /dev/null
@@ -1,117 +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.modules.datepicker;
-
-import android.app.DatePickerDialog;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.widget.DatePicker;
-import androidx.annotation.Nullable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-public class DismissableDatePickerDialog extends DatePickerDialog {
-
- public DismissableDatePickerDialog(
- Context context,
- @Nullable DatePickerDialog.OnDateSetListener callback,
- int year,
- int monthOfYear,
- int dayOfMonth) {
- super(context, callback, year, monthOfYear, dayOfMonth);
- fixSpinner(context, year, monthOfYear, dayOfMonth);
- }
-
- public DismissableDatePickerDialog(
- Context context,
- int theme,
- @Nullable DatePickerDialog.OnDateSetListener callback,
- int year,
- int monthOfYear,
- int dayOfMonth) {
- super(context, theme, callback, year, monthOfYear, dayOfMonth);
- fixSpinner(context, year, monthOfYear, dayOfMonth);
- }
-
- private void fixSpinner(Context context, int year, int month, int dayOfMonth) {
- if (Build.VERSION.SDK_INT == Build.VERSION_CODES.N) {
- try {
- // Get the theme's android:datePickerMode
- final int MODE_SPINNER = 2;
- Class> styleableClass = Class.forName("com.android.internal.R$styleable");
- Field datePickerStyleableField = styleableClass.getField("DatePicker");
- int[] datePickerStyleable = (int[]) datePickerStyleableField.get(null);
-
- final TypedArray a =
- context.obtainStyledAttributes(
- null, datePickerStyleable, android.R.attr.datePickerStyle, 0);
- Field datePickerModeStyleableField = styleableClass.getField("DatePicker_datePickerMode");
- int datePickerModeStyleable = datePickerModeStyleableField.getInt(null);
- final int mode = a.getInt(datePickerModeStyleable, MODE_SPINNER);
- a.recycle();
-
- if (mode == MODE_SPINNER) {
- DatePicker datePicker =
- (DatePicker)
- findField(DatePickerDialog.class, DatePicker.class, "mDatePicker").get(this);
- Class> delegateClass = Class.forName("android.widget.DatePickerSpinnerDelegate");
- Field delegateField = findField(DatePicker.class, delegateClass, "mDelegate");
- Object delegate = delegateField.get(datePicker);
- Class> spinnerDelegateClass;
- spinnerDelegateClass = Class.forName("android.widget.DatePickerSpinnerDelegate");
-
- // In 7.0 Nougat for some reason the datePickerMode is ignored and the delegate is
- // DatePickerClockDelegate
- if (delegate.getClass() != spinnerDelegateClass) {
- delegateField.set(datePicker, null); // throw out the DatePickerClockDelegate!
- datePicker.removeAllViews(); // remove the DatePickerClockDelegate views
- Method createSpinnerUIDelegate =
- DatePicker.class.getDeclaredMethod(
- "createSpinnerUIDelegate",
- Context.class,
- AttributeSet.class,
- int.class,
- int.class);
- createSpinnerUIDelegate.setAccessible(true);
-
- // Instantiate a DatePickerSpinnerDelegate throughout createSpinnerUIDelegate method
- delegate =
- createSpinnerUIDelegate.invoke(
- datePicker, context, null, android.R.attr.datePickerStyle, 0);
- delegateField.set(
- datePicker, delegate); // set the DatePicker.mDelegate to the spinner delegate
- datePicker.setCalendarViewShown(false);
- // Initialize the date for the DatePicker delegate again
- datePicker.init(year, month, dayOfMonth, this);
- }
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- private static Field findField(Class objectClass, Class fieldClass, String expectedName) {
- try {
- Field field = objectClass.getDeclaredField(expectedName);
- field.setAccessible(true);
- return field;
- } catch (NoSuchFieldException e) {
- } // ignore
- // search for it if it wasn't found under the expected ivar name
- for (Field searchField : objectClass.getDeclaredFields()) {
- if (searchField.getType() == fieldClass) {
- searchField.setAccessible(true);
- return searchField;
- }
- }
- return null;
- }
-}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK b/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK
index a5bb7403e8f6..84138c4394d9 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK
+++ b/ReactAndroid/src/main/java/com/facebook/react/shell/BUCK
@@ -34,7 +34,6 @@ rn_android_library(
react_native_target("java/com/facebook/react/modules/camera:camera"),
react_native_target("java/com/facebook/react/modules/clipboard:clipboard"),
react_native_target("java/com/facebook/react/modules/core:core"),
- react_native_target("java/com/facebook/react/modules/datepicker:datepicker"),
react_native_target("java/com/facebook/react/modules/debug:debug"),
react_native_target("java/com/facebook/react/modules/dialog:dialog"),
react_native_target("java/com/facebook/react/modules/fresco:fresco"),
diff --git a/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java
index 0dd8f31c5452..34dc28005784 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/shell/MainReactPackage.java
@@ -23,7 +23,6 @@
import com.facebook.react.modules.blob.FileReaderModule;
import com.facebook.react.modules.camera.ImageStoreManager;
import com.facebook.react.modules.clipboard.ClipboardModule;
-import com.facebook.react.modules.datepicker.DatePickerDialogModule;
import com.facebook.react.modules.dialog.DialogModule;
import com.facebook.react.modules.fresco.FrescoModule;
import com.facebook.react.modules.i18nmanager.I18nManagerModule;
@@ -72,7 +71,6 @@
FileReaderModule.class,
AsyncStorageModule.class,
ClipboardModule.class,
- DatePickerDialogModule.class,
DialogModule.class,
FrescoModule.class,
I18nManagerModule.class,
@@ -117,8 +115,6 @@ public MainReactPackage(MainPackageConfig config) {
return new AsyncStorageModule(context);
case ClipboardModule.NAME:
return new ClipboardModule(context);
- case DatePickerDialogModule.FRAGMENT_TAG:
- return new DatePickerDialogModule(context);
case DialogModule.NAME:
return new DialogModule(context);
case FrescoModule.NAME:
@@ -199,7 +195,6 @@ public ReactModuleInfoProvider getReactModuleInfoProvider() {
FileReaderModule.class,
AsyncStorageModule.class,
ClipboardModule.class,
- DatePickerDialogModule.class,
DialogModule.class,
FrescoModule.class,
I18nManagerModule.class,
diff --git a/index.js b/index.js
index 545554b3b39a..7ce52d8a4603 100644
--- a/index.js
+++ b/index.js
@@ -55,7 +55,6 @@ import typeof AppState from './Libraries/AppState/AppState';
import typeof AsyncStorage from './Libraries/Storage/AsyncStorage';
import typeof BackHandler from './Libraries/Utilities/BackHandler';
import typeof Clipboard from './Libraries/Components/Clipboard/Clipboard';
-import typeof DatePickerAndroid from './Libraries/Components/DatePickerAndroid/DatePickerAndroid';
import typeof DeviceInfo from './Libraries/Utilities/DeviceInfo';
import typeof DevSettings from './Libraries/Utilities/DevSettings';
import typeof Dimensions from './Libraries/Utilities/Dimensions';
@@ -297,15 +296,6 @@ module.exports = {
);
return require('./Libraries/Components/Clipboard/Clipboard');
},
- get DatePickerAndroid(): DatePickerAndroid {
- warnOnce(
- 'DatePickerAndroid-merged',
- 'DatePickerAndroid has been merged with DatePickerIOS and will be removed in a future release. ' +
- "It can now be installed and imported from '@react-native-community/datetimepicker' instead of 'react-native'. " +
- 'See https://github.com/react-native-datetimepicker/datetimepicker',
- );
- return require('./Libraries/Components/DatePickerAndroid/DatePickerAndroid');
- },
get DeviceInfo(): DeviceInfo {
return require('./Libraries/Utilities/DeviceInfo');
},
@@ -717,4 +707,19 @@ if (__DEV__) {
);
},
});
+ /* $FlowFixMe[prop-missing] This is intentional: Flow will error when
+ * attempting to access DatePickerAndroid. */
+ /* $FlowFixMe[invalid-export] This is intentional: Flow will error when
+ * attempting to access DatePickerAndroid. */
+ Object.defineProperty(module.exports, 'DatePickerAndroid', {
+ configurable: true,
+ get() {
+ invariant(
+ false,
+ 'DatePickerAndroid has been removed from React Native. ' +
+ "It can now be installed and imported from '@react-native-community/datetimepicker' instead of 'react-native'. " +
+ 'See https://github.com/react-native-datetimepicker/datetimepicker',
+ );
+ },
+ });
}
From 369a7ab5d332be945137aaa487f0c09fc7fa8c57 Mon Sep 17 00:00:00 2001
From: Joshua Selbo
Date: Wed, 25 Aug 2021 14:28:56 -0700
Subject: [PATCH 010/986] Update AndroidX test deps to 1.4.0 (#32084)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32084
Upgrade RN AndroidX test deps after an internal upgrade.
Changelog: [Internal] Update AndroidX test deps after internal upgrade
Reviewed By: sturmen
Differential Revision: D30546422
fbshipit-source-id: 644648c7dcf179e737fb967d996a789cc904a5ca
---
.../src/main/third-party/android/androidx/BUCK | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/ReactAndroid/src/main/third-party/android/androidx/BUCK b/ReactAndroid/src/main/third-party/android/androidx/BUCK
index accceafa0c5c..d8398497d336 100644
--- a/ReactAndroid/src/main/third-party/android/androidx/BUCK
+++ b/ReactAndroid/src/main/third-party/android/androidx/BUCK
@@ -690,20 +690,20 @@ fb_native.remote_file(
fb_native.remote_file(
name = "test-monitor-binary-aar",
- sha1 = "d2f75d117c055f35c8ebbd4f96fabc2137df9e4d",
- url = "mvn:androidx.test:monitor:aar:1.2.0",
+ sha1 = "4f3c15d0a1e0c943b233b0dc5d8f1e690cfe7c0a",
+ url = "mvn:androidx.test:monitor:aar:1.4.0",
)
fb_native.remote_file(
name = "test-rules-binary-aar",
- sha1 = "91904046e724ac82d9b7fe698e5fe92b871c726e",
- url = "mvn:androidx.test:rules:aar:1.2.0",
+ sha1 = "0984e8b5505f08489993c783702236af7a4a18c8",
+ url = "mvn:androidx.test:rules:aar:1.4.0",
)
fb_native.remote_file(
name = "test-runner-binary-aar",
- sha1 = "237b061c45b3b450f88dd8cde87375ab22b0496a",
- url = "mvn:androidx.test:runner:aar:1.2.0",
+ sha1 = "44d79420baf7ac208e33b35df8756f0e912ced38",
+ url = "mvn:androidx.test:runner:aar:1.4.0",
)
fb_native.remote_file(
From ee868091b104f4e8744172e45ca01d9b8e60879b Mon Sep 17 00:00:00 2001
From: Xuan Huang
Date: Wed, 25 Aug 2021 14:33:00 -0700
Subject: [PATCH 011/986] Add instructions to test RNTester with Hermes on
Android (#32085)
Summary:
Title said it all.
## Changelog
[Internal]
Pull Request resolved: https://github.com/facebook/react-native/pull/32085
Reviewed By: TheSavior
Differential Revision: D30555218
Pulled By: Huxpro
fbshipit-source-id: 857ee81d4f402209bb2db2e1f4a2956d46ea3a54
---
packages/rn-tester/README.md | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/packages/rn-tester/README.md b/packages/rn-tester/README.md
index 3043578eddc1..5f5e1d7c2065 100644
--- a/packages/rn-tester/README.md
+++ b/packages/rn-tester/README.md
@@ -24,9 +24,12 @@ You'll need to have all the [prerequisites](https://github.com/facebook/react-na
Start an Android emulator.
- cd react-native
- ./gradlew :packages:rn-tester:android:app:installJscDebug
- ./scripts/packager.sh
+```sh
+cd react-native
+# In order to use Hermes engine, run `installHermesDebug` instead.
+./gradlew :packages:rn-tester:android:app:installJscDebug
+./scripts/packager.sh
+```
_Note: Building for the first time can take a while._
From 2abacace54dc72bac1a5d7f2fb795edd89374b1c Mon Sep 17 00:00:00 2001
From: Matthew Gray
Date: Wed, 25 Aug 2021 16:27:58 -0700
Subject: [PATCH 012/986] Adding Accessibility Display Options Enabled to
RNTester (#29231)
Summary:
Currently there isn't any way to test if the Accessibility Display Options or the event listeners for them were working properly within RNTester. It turns out that because of changes to the accessibility API Apple made when they added Smart Invert AccessibilityInfo.isInvertColorsEnabled() and the associated event listener are working incorrectly. You can see this if you take a look at how RNTester (with this PR incorporated) responds to toggling Invert Colors. I've submitted a bug report to Apple, but this might have been caught earlier if this had been implemented.
## Changelog
[General] [Added] - Adding Accessibility Display Options Enabled to RNTester
Pull Request resolved: https://github.com/facebook/react-native/pull/29231
Test Plan:
1. Build iOS app
2. Navigate to the Accessibility page
3. Switch over to settings and change any of the settings at
- Settings>Accessibility>Display and Text Size>Bold Text
- Settings>Accessibility>Display and Text Size>Color Filters>Grayscale
- Settings>Accessibility>Display and Text Size>Smart Invert (or Classic Invert)
- Settings>Accessibility>Motion>Reduce Motion
- Settings>Accessibility>VoiceOver>VoiceOver
4. Switch back to the app and see the results


Modified it a bit to only show relevant statuses for the Platform
| {F656951547} | {F656951643} |
Reviewed By: TheSavior
Differential Revision: D29531642
Pulled By: lunaleaps
fbshipit-source-id: f54fb3216ef663428c23b613f0a3b10b01d7f24d
---
.../Accessibility/AccessibilityExample.js | 72 +++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js
index 001464fd63d9..6133080a4adf 100644
--- a/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js
+++ b/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js
@@ -1024,6 +1024,72 @@ class EnabledExample extends React.Component<
}
}
+class DisplayOptionsStatusExample extends React.Component<{}> {
+ render(): React.Node {
+ const isAndroid = Platform.OS === 'android';
+ return (
+
+
+
+ {isAndroid ? null : (
+ <>
+
+
+
+
+ >
+ )}
+
+ );
+ }
+}
+
+function DisplayOptionStatusExample({optionName, optionChecker, notification}) {
+ const [statusEnabled, setStatusEnabled] = React.useState(false);
+ React.useEffect(() => {
+ AccessibilityInfo.addEventListener(notification, setStatusEnabled);
+ optionChecker().then(isEnabled => {
+ setStatusEnabled(isEnabled);
+ });
+ return function cleanup() {
+ AccessibilityInfo.removeEventListener(notification, setStatusEnabled);
+ };
+ }, [optionChecker, notification]);
+ return (
+
+
+ {optionName}
+ {' is '}
+ {statusEnabled ? 'enabled' : 'disabled'}.
+
+
+ );
+}
+
exports.title = 'Accessibility';
exports.documentationURL = 'https://reactnative.dev/docs/accessibilityinfo';
exports.description = 'Examples of using Accessibility APIs.';
@@ -1058,6 +1124,12 @@ exports.examples = [
return ;
},
},
+ {
+ title: 'Check if the display options are enabled',
+ render(): React.Element {
+ return ;
+ },
+ },
{
title: 'Check if the screen reader announces',
render(): React.Element {
From 8da6964d80ecbdcd2baf1c10db05d67e068d9a49 Mon Sep 17 00:00:00 2001
From: Keion Anvaripour
Date: Wed, 25 Aug 2021 16:40:31 -0700
Subject: [PATCH 013/986] Refactor Image to log component stacktraces for
images rendering non-fb sources
Summary:
This diff refactors the Image component in order to log the component hierarchy stacktraces for images rendering non-fb sources
Changelog: [Internal] internal
Reviewed By: fkgozali
Differential Revision: D30504483
fbshipit-source-id: 1e41a67d5b9643730360bce7e787ee3427d931e8
---
Libraries/Image/Image.ios.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Libraries/Image/Image.ios.js b/Libraries/Image/Image.ios.js
index 5cadc1db9dcb..3dab5cc8c1f7 100644
--- a/Libraries/Image/Image.ios.js
+++ b/Libraries/Image/Image.ios.js
@@ -12,6 +12,7 @@ import DeprecatedImagePropType from '../DeprecatedPropTypes/DeprecatedImagePropT
import * as React from 'react';
import StyleSheet from '../StyleSheet/StyleSheet';
+import ImageInjection from './ImageInjection';
import ImageAnalyticsTagContext from './ImageAnalyticsTagContext';
import flattenStyle from '../StyleSheet/flattenStyle';
import resolveAssetSource from './resolveAssetSource';
@@ -168,6 +169,11 @@ Image = React.forwardRef<
ImagePropsType,
React.ElementRef,
>(Image);
+
+if (ImageInjection.unstable_createImageComponent != null) {
+ Image = ImageInjection.unstable_createImageComponent(Image);
+}
+
Image.displayName = 'Image';
/**
From ad9030ca9ae3861d079c16d3ce610edc1bedc54c Mon Sep 17 00:00:00 2001
From: Luna Wei
Date: Wed, 25 Aug 2021 16:48:13 -0700
Subject: [PATCH 014/986] Include Swift lib in LIBRARY_SEARCH_PATHS
Summary:
changelog: Fix Xcode 13 build error in RNTester
Including `usr/lib/swift` fixes error:
{F642876047}
Reviewed By: fkgozali
Differential Revision: D30559838
fbshipit-source-id: 65aad16b550d156c8670eaefcc8bedae99606329
---
packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj | 2 ++
1 file changed, 2 insertions(+)
diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
index 334d7ae082ad..d47d63409c25 100644
--- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
+++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
@@ -787,6 +787,7 @@
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",
+ "\"$(SDKROOT)/usr/lib/swift\"",
);
"LIBRARY_SEARCH_PATHS[arch=*]" = "$(inherited)";
OTHER_LDFLAGS = (
@@ -821,6 +822,7 @@
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",
+ "\"$(SDKROOT)/usr/lib/swift\"",
);
OTHER_LDFLAGS = (
"$(inherited)",
From e60ad0837e16389a5c71b2189360278c2ee9364c Mon Sep 17 00:00:00 2001
From: Xuan Huang
Date: Thu, 26 Aug 2021 01:05:06 -0700
Subject: [PATCH 015/986] Type more globals
Summary:
Changelog: [Internal]
This diff add types to some of the common globals so uses of
them through `global` are now typed.
All the globals are marked as read-only for their intented uses.
However, some of them do have write cites (mostly are in tests to
deliberately set up a special test environment). Those write cites
are considered as "necessary evil" and annotated as `FlowFixMe`.
Reviewed By: yungsters
Differential Revision: D30158145
fbshipit-source-id: 93a99063361a4b7a1e33d9fc97a661be30a4d8f9
---
Libraries/Animated/NativeAnimatedHelper.js | 2 +-
Libraries/Core/ExceptionsManager.js | 4 +-
Libraries/Core/setUpBatchedBridge.js | 2 +-
Libraries/Core/setUpGlobals.js | 2 +
Libraries/Core/setUpTimers.js | 4 +-
Libraries/TurboModule/TurboModuleRegistry.js | 2 +-
Libraries/Utilities/HMRClient.js | 2 +-
Libraries/Utilities/deprecatedPropType.js | 2 +-
flow/global.js | 41 ++++++++++++++++++++
9 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js
index 297b53c68c7b..6bac8cb1fbd8 100644
--- a/Libraries/Animated/NativeAnimatedHelper.js
+++ b/Libraries/Animated/NativeAnimatedHelper.js
@@ -24,7 +24,7 @@ import invariant from 'invariant';
// TODO T69437152 @petetheheat - Delete this fork when Fabric ships to 100%.
const NativeAnimatedModule =
- Platform.OS === 'ios' && global.RN$Bridgeless
+ Platform.OS === 'ios' && global.RN$Bridgeless === true
? NativeAnimatedTurboModule
: NativeAnimatedNonTurboModule;
diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js
index 6e64a40ad48a..d4826d4b54ab 100644
--- a/Libraries/Core/ExceptionsManager.js
+++ b/Libraries/Core/ExceptionsManager.js
@@ -76,7 +76,9 @@ function reportException(
e.jsEngine == null ? message : `${message}, js engine: ${e.jsEngine}`;
const isHandledByLogBox =
- e.forceRedbox !== true && !global.RN$Bridgeless && !global.RN$Express;
+ e.forceRedbox !== true &&
+ global.RN$Bridgeless !== true &&
+ !global.RN$Express;
const data = preprocessException({
message,
diff --git a/Libraries/Core/setUpBatchedBridge.js b/Libraries/Core/setUpBatchedBridge.js
index 49747fd7576c..0f16dd84e74c 100644
--- a/Libraries/Core/setUpBatchedBridge.js
+++ b/Libraries/Core/setUpBatchedBridge.js
@@ -11,7 +11,7 @@
'use strict';
let registerModule;
-if (global.RN$Bridgeless && global.RN$registerCallableModule) {
+if (global.RN$Bridgeless === true && global.RN$registerCallableModule) {
registerModule = global.RN$registerCallableModule;
} else {
const BatchedBridge = require('../BatchedBridge/BatchedBridge');
diff --git a/Libraries/Core/setUpGlobals.js b/Libraries/Core/setUpGlobals.js
index ea6da8fbbbe3..a8ce63d13236 100644
--- a/Libraries/Core/setUpGlobals.js
+++ b/Libraries/Core/setUpGlobals.js
@@ -19,10 +19,12 @@ if (global.GLOBAL === undefined) {
}
if (global.window === undefined) {
+ // $FlowFixMe[cannot-write]
global.window = global;
}
if (global.self === undefined) {
+ // $FlowFixMe[cannot-write]
global.self = global;
}
diff --git a/Libraries/Core/setUpTimers.js b/Libraries/Core/setUpTimers.js
index 9d2020f83641..7048b32c4fdf 100644
--- a/Libraries/Core/setUpTimers.js
+++ b/Libraries/Core/setUpTimers.js
@@ -28,7 +28,7 @@ const hasNativePromise = isNativeFunction(Promise);
const hasPromiseQueuedToJSVM = hasNativePromise || hasHermesPromiseQueuedToJSVM;
// In bridgeless mode, timers are host functions installed from cpp.
-if (!global.RN$Bridgeless) {
+if (global.RN$Bridgeless !== true) {
/**
* Set up timers.
* You can use this module directly, or just require InitializeCore.
@@ -65,7 +65,7 @@ if (hasPromiseQueuedToJSVM) {
// When promise was polyfilled hence is queued to the RN microtask queue,
// we polyfill the immediate APIs as aliases to the ReactNativeMicrotask APIs.
// Note that in bridgeless mode, immediate APIs are installed from cpp.
- if (!global.RN$Bridgeless) {
+ if (global.RN$Bridgeless !== true) {
polyfillGlobal(
'setImmediate',
() => require('./Timers/JSTimers').queueReactNativeMicrotask,
diff --git a/Libraries/TurboModule/TurboModuleRegistry.js b/Libraries/TurboModule/TurboModuleRegistry.js
index 90e30dd08159..9e2f762937cc 100644
--- a/Libraries/TurboModule/TurboModuleRegistry.js
+++ b/Libraries/TurboModule/TurboModuleRegistry.js
@@ -16,7 +16,7 @@ const turboModuleProxy = global.__turboModuleProxy;
function requireModule(name: string): ?T {
// Bridgeless mode requires TurboModules
- if (!global.RN$Bridgeless) {
+ if (global.RN$Bridgeless !== true) {
// Backward compatibility layer during migration.
const legacyModule = NativeModules[name];
if (legacyModule != null) {
diff --git a/Libraries/Utilities/HMRClient.js b/Libraries/Utilities/HMRClient.js
index 15bd443fd082..e1d8f56c49ab 100644
--- a/Libraries/Utilities/HMRClient.js
+++ b/Libraries/Utilities/HMRClient.js
@@ -119,7 +119,7 @@ const HMRClient: HMRClientNativeInterface = {
JSON.stringify({
type: 'log',
level,
- mode: global.RN$Bridgeless ? 'NOBRIDGE' : 'BRIDGE',
+ mode: global.RN$Bridgeless === true ? 'NOBRIDGE' : 'BRIDGE',
data: data.map(item =>
typeof item === 'string'
? item
diff --git a/Libraries/Utilities/deprecatedPropType.js b/Libraries/Utilities/deprecatedPropType.js
index 454b9bc855e9..1801f98cb1c2 100644
--- a/Libraries/Utilities/deprecatedPropType.js
+++ b/Libraries/Utilities/deprecatedPropType.js
@@ -20,7 +20,7 @@ function deprecatedPropType(
return function validate(props, propName, componentName, ...rest) {
// Don't warn for native components.
if (
- !global.RN$Bridgeless &&
+ global.RN$Bridgeless !== true &&
UIManager.hasViewManagerConfig(componentName) &&
props[propName] !== undefined
) {
diff --git a/flow/global.js b/flow/global.js
index 3c32ec6796c8..850b53d3db2a 100644
--- a/flow/global.js
+++ b/flow/global.js
@@ -16,8 +16,49 @@
* writeability (`+`) when defining types.
*/
declare var global: {
+ // setUpGlobals
+ +window: typeof global;
+ +self: typeof global;
+
+ // setXHR
+ +XMLHttpRequest: typeof XMLHttpRequest;
+ +FormData: typeof FormData;
+ +fetch: typeof fetch;
+ +Headers: typeof Headers;
+ +Request: typeof Request;
+ +Response: typeof Response;
+ +WebSocket: typeof WebSocket;
+ +Blob: typeof Blob;
+ +File: typeof File;
+ +FileReader: typeof FileReader;
+ +URL: typeof URL;
+ +URLSearchParams: typeof URLSearchParams;
+ +AbortController: typeof AbortController;
+ +AbortSignal: typeof AbortSignal;
+
+ // setUpAlert
+ +alert: typeof alert;
+
+ // setUpTimers
+ +clearInterval: typeof clearInterval,
+ +clearTimeout: typeof clearTimeout,
+ +setInterval: typeof setInterval,
+ +setTimeout: typeof setTimeout,
+ +requestAnimationFrame: typeof requestAnimationFrame,
+ +cancelAnimationFrame: typeof cancelAnimationFrame,
+ +requestIdleCallback: typeof requestIdleCallback,
+ +cancelIdleCallback: typeof cancelIdleCallback,
+ +setTimeout: typeof setTimeout,
+
+ +console: typeof console,
+
+ // JavaScript environments specific
+HermesInternal: ?$HermesInternalType,
+ // Internal-specific
+ +__DEV__?: boolean,
+ +RN$Bridgeless?: boolean,
+
// Undeclared properties are implicitly `any`.
[string | symbol]: any,
};
From a8e2415a9138f9e19f41590ea772a5c27d25746a Mon Sep 17 00:00:00 2001
From: Xuan Huang
Date: Thu, 26 Aug 2021 01:05:06 -0700
Subject: [PATCH 016/986] Type global queueMicrotask
Summary:
Changelog: [Internal]
This diff
- add `queueMicrotask` to eslint and metro so it's globally available.
- add `queueMicrotask` to the global libdef of react native so the type
is available to `global.queueMicrotask` (which is common) as well.
Reviewed By: yungsters
Differential Revision: D30158144
fbshipit-source-id: 00a62193b838745c91179ff1e983636200560690
---
flow/global.js | 4 ++++
packages/eslint-config-react-native-community/index.js | 1 +
2 files changed, 5 insertions(+)
diff --git a/flow/global.js b/flow/global.js
index 850b53d3db2a..fe06097b0f0e 100644
--- a/flow/global.js
+++ b/flow/global.js
@@ -49,6 +49,10 @@ declare var global: {
+requestIdleCallback: typeof requestIdleCallback,
+cancelIdleCallback: typeof cancelIdleCallback,
+setTimeout: typeof setTimeout,
+ // TODO(T97509743): use `typeof` when the next Flow release is available.
+ +queueMicrotask: >(
+ jobCallback: (...args: TArguments) => mixed,
+ ) => void;
+console: typeof console,
diff --git a/packages/eslint-config-react-native-community/index.js b/packages/eslint-config-react-native-community/index.js
index 320ef4daf2b1..be5396609391 100644
--- a/packages/eslint-config-react-native-community/index.js
+++ b/packages/eslint-config-react-native-community/index.js
@@ -114,6 +114,7 @@ module.exports = {
setImmediate: true,
setInterval: false,
setTimeout: false,
+ queueMicrotask: true,
URL: false,
URLSearchParams: false,
WebSocket: true,
From 4a9621647cde0ba14e7589295c0fbb9dcb300cde Mon Sep 17 00:00:00 2001
From: Dmitry Rykun
Date: Thu, 26 Aug 2021 06:55:31 -0700
Subject: [PATCH 017/986] TextTransform prop implemented
Summary:
Changelog: [iOS] [Fixed]
TextTransform is applied when constructing NSAttributedString from C++ AttributedString in Fabric.
Reviewed By: sammy-SC
Differential Revision: D30515821
fbshipit-source-id: 8a824ff89919832f79ace693dfe3cf7ed35c3beb
---
.../platform/ios/RCTAttributedTextUtils.h | 2 ++
.../platform/ios/RCTAttributedTextUtils.mm | 19 +++++++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h
index 373e78daac32..3a8ff540741b 100644
--- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h
+++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.h
@@ -35,6 +35,8 @@ NSAttributedString *RCTNSAttributedStringFromAttributedStringBox(
facebook::react::AttributedStringBox RCTAttributedStringBoxFromNSAttributedString(
NSAttributedString *nsAttributedString);
+NSString *RCTNSStringFromStringApplyingTextTransform(NSString *string, facebook::react::TextTransform textTransform);
+
@interface RCTWeakEventEmitterWrapper : NSObject
@property (nonatomic, assign) facebook::react::SharedEventEmitter eventEmitter;
@end
diff --git a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm
index 5df0cd9cad73..7e63b2df90b3 100644
--- a/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm
+++ b/ReactCommon/react/renderer/textlayoutmanager/platform/ios/RCTAttributedTextUtils.mm
@@ -335,6 +335,11 @@ inline static CGFloat RCTEffectiveFontSizeMultiplierFromTextAttributes(const Tex
} else {
NSString *string = [NSString stringWithCString:fragment.string.c_str() encoding:NSUTF8StringEncoding];
+ if (fragment.textAttributes.textTransform.hasValue()) {
+ auto textTransform = fragment.textAttributes.textTransform.value();
+ string = RCTNSStringFromStringApplyingTextTransform(string, textTransform);
+ }
+
nsAttributedStringFragment = [[NSMutableAttributedString alloc]
initWithString:string
attributes:RCTNSTextAttributesFromTextAttributes(fragment.textAttributes)];
@@ -373,3 +378,17 @@ AttributedStringBox RCTAttributedStringBoxFromNSAttributedString(NSAttributedStr
{
return nsAttributedString.length ? AttributedStringBox{wrapManagedObject(nsAttributedString)} : AttributedStringBox{};
}
+
+NSString *RCTNSStringFromStringApplyingTextTransform(NSString *string, TextTransform textTransform)
+{
+ switch (textTransform) {
+ case TextTransform::Uppercase:
+ return [string uppercaseString];
+ case TextTransform::Lowercase:
+ return [string lowercaseString];
+ case TextTransform::Capitalize:
+ return [string capitalizedString];
+ default:
+ return string;
+ }
+}
From d6c879edbad068d0f461381875b7fae6db99d18d Mon Sep 17 00:00:00 2001
From: Sota Ogo
Date: Thu, 26 Aug 2021 10:04:29 -0700
Subject: [PATCH 018/986] Show RedBox for C++ errors
Summary:
This diff is hooking up cxx error with redbox. Before this diff, cxx errors were only shown in log and there was no visible user feedback.
Changelog:
[Android] [Added] - Show Redbox for C++ errors.
Reviewed By: JoshuaGross
Differential Revision: D30421355
fbshipit-source-id: ad473337ba301feb08ba31ee8d82ebaa771ecaeb
---
.../facebook/react/ReactInstanceManager.java | 20 ++++++++++
.../react/bridge/ReactCxxErrorHandler.java | 39 +++++++++++++++++++
.../jni/react/jni/CatalystInstanceImpl.cpp | 2 +
.../jni/react/jni/JReactCxxErrorHandler.cpp | 18 +++++++++
.../jni/react/jni/JReactCxxErrorHandler.h | 25 ++++++++++++
5 files changed, 104 insertions(+)
create mode 100644 ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.java
create mode 100644 ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp
create mode 100644 ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h
diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
index 9980ff8c1c67..d73c8f7e1eca 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/ReactInstanceManager.java
@@ -65,6 +65,7 @@
import com.facebook.react.bridge.ProxyJavaScriptExecutor;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
+import com.facebook.react.bridge.ReactCxxErrorHandler;
import com.facebook.react.bridge.ReactMarker;
import com.facebook.react.bridge.ReactMarkerConstants;
import com.facebook.react.bridge.ReactNoCrashSoftException;
@@ -107,6 +108,7 @@
import com.facebook.soloader.SoLoader;
import com.facebook.systrace.Systrace;
import com.facebook.systrace.SystraceMessage;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -291,6 +293,8 @@ public void invokeDefaultOnBackPressed() {
if (mUseDeveloperSupport) {
mDevSupportManager.startInspector();
}
+
+ registerCxxErrorHandlerFunc();
}
private ReactInstanceDevHelper createDevHelperInterface() {
@@ -364,6 +368,22 @@ public List getPackages() {
return new ArrayList<>(mPackages);
}
+ public void handleCxxError(Exception e) {
+ mDevSupportManager.handleException(e);
+ }
+
+ public void registerCxxErrorHandlerFunc() {
+ Class[] parameterTypes = new Class[1];
+ parameterTypes[0] = Exception.class;
+ Method handleCxxErrorFunc = null;
+ try {
+ handleCxxErrorFunc = ReactInstanceManager.class.getMethod("handleCxxError", parameterTypes);
+ } catch (NoSuchMethodException e) {
+ FLog.e("ReactInstanceHolder", "Failed to set cxx error hanlder function", e);
+ }
+ ReactCxxErrorHandler.setHandleErrorFunc(this, handleCxxErrorFunc);
+ }
+
static void initializeSoLoaderIfNecessary(Context applicationContext) {
// Call SoLoader.initialize here, this is required for apps that does not use exopackage and
// does not use SoLoader for loading other native code except from the one used by React Native
diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.java
new file mode 100644
index 000000000000..f5efbf1fadf9
--- /dev/null
+++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactCxxErrorHandler.java
@@ -0,0 +1,39 @@
+/*
+ * 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.bridge;
+
+import com.facebook.common.logging.FLog;
+import com.facebook.proguard.annotations.DoNotStrip;
+import java.lang.reflect.Method;
+
+@DoNotStrip
+public class ReactCxxErrorHandler {
+
+ private static Method mHandleErrorFunc;
+ private static Object mObject;
+
+ @DoNotStrip
+ public static void setHandleErrorFunc(Object object, Method handleErrorFunc) {
+ mObject = object;
+ mHandleErrorFunc = handleErrorFunc;
+ }
+
+ @DoNotStrip
+ // For use from within the C++ JReactCxxErrorHandler
+ private static void handleError(final String message) {
+ if (mHandleErrorFunc != null) {
+ try {
+ Object[] parameters = new Object[1];
+ parameters[0] = new Exception(message);
+ mHandleErrorFunc.invoke(mObject, parameters);
+ } catch (Exception e) {
+ FLog.e("ReactCxxErrorHandler", "Failed to invole error hanlder function", e);
+ }
+ }
+ }
+}
diff --git a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp
index d9e5ac34b411..6b1f09f2720f 100644
--- a/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp
+++ b/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp
@@ -32,6 +32,7 @@
#include "CxxModuleWrapper.h"
#include "JNativeRunnable.h"
+#include "JReactCxxErrorHandler.h"
#include "JReactSoftExceptionLogger.h"
#include "JavaScriptExecutorHolder.h"
#include "JniJSModulesUnbundle.h"
@@ -155,6 +156,7 @@ void log(ReactNativeLogLevel level, const char *message) {
break;
case ReactNativeLogLevelError:
LOG(ERROR) << message;
+ JReactCxxErrorHandler::handleError(message);
break;
case ReactNativeLogLevelFatal:
LOG(FATAL) << message;
diff --git a/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp b/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp
new file mode 100644
index 000000000000..5b3409eb1b47
--- /dev/null
+++ b/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.cpp
@@ -0,0 +1,18 @@
+/*
+ * 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 "JReactCxxErrorHandler.h"
+
+using namespace facebook::react;
+
+void JReactCxxErrorHandler::handleError(std::string message) {
+ static const auto handleError =
+ javaClassStatic()->getStaticMethod(
+ "handleError");
+
+ return handleError(javaClassStatic(), message);
+}
diff --git a/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h b/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h
new file mode 100644
index 000000000000..0ed379b9f139
--- /dev/null
+++ b/ReactAndroid/src/main/jni/react/jni/JReactCxxErrorHandler.h
@@ -0,0 +1,25 @@
+/*
+ * 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
+
+namespace facebook {
+namespace react {
+
+class JReactCxxErrorHandler : public jni::JavaClass {
+ public:
+ static constexpr const char *kJavaDescriptor =
+ "Lcom/facebook/react/bridge/ReactCxxErrorHandler;";
+
+ static void handleError(std::string message);
+};
+
+} // namespace react
+} // namespace facebook
From 8f7e23ae44672f8a227f387c0aa7f00065151415 Mon Sep 17 00:00:00 2001
From: Andrei Shikov
Date: Thu, 26 Aug 2021 10:29:25 -0700
Subject: [PATCH 019/986] Update format to fix CircleCI failure (#32095)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32095
Found by running `yarn run prettier` and including relevant files
Changelog:
[Internal] Fix formatting of `global.js`
Reviewed By: cortinico
Differential Revision: D30573273
fbshipit-source-id: 94854d3d3178533ad8a6323006eaca279a931fa7
---
flow/global.js | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/flow/global.js b/flow/global.js
index fe06097b0f0e..b2e76fe8d232 100644
--- a/flow/global.js
+++ b/flow/global.js
@@ -17,27 +17,27 @@
*/
declare var global: {
// setUpGlobals
- +window: typeof global;
- +self: typeof global;
+ +window: typeof global,
+ +self: typeof global,
// setXHR
- +XMLHttpRequest: typeof XMLHttpRequest;
- +FormData: typeof FormData;
- +fetch: typeof fetch;
- +Headers: typeof Headers;
- +Request: typeof Request;
- +Response: typeof Response;
- +WebSocket: typeof WebSocket;
- +Blob: typeof Blob;
- +File: typeof File;
- +FileReader: typeof FileReader;
- +URL: typeof URL;
- +URLSearchParams: typeof URLSearchParams;
- +AbortController: typeof AbortController;
- +AbortSignal: typeof AbortSignal;
+ +XMLHttpRequest: typeof XMLHttpRequest,
+ +FormData: typeof FormData,
+ +fetch: typeof fetch,
+ +Headers: typeof Headers,
+ +Request: typeof Request,
+ +Response: typeof Response,
+ +WebSocket: typeof WebSocket,
+ +Blob: typeof Blob,
+ +File: typeof File,
+ +FileReader: typeof FileReader,
+ +URL: typeof URL,
+ +URLSearchParams: typeof URLSearchParams,
+ +AbortController: typeof AbortController,
+ +AbortSignal: typeof AbortSignal,
// setUpAlert
- +alert: typeof alert;
+ +alert: typeof alert,
// setUpTimers
+clearInterval: typeof clearInterval,
@@ -52,7 +52,7 @@ declare var global: {
// TODO(T97509743): use `typeof` when the next Flow release is available.
+queueMicrotask: >(
jobCallback: (...args: TArguments) => mixed,
- ) => void;
+ ) => void,
+console: typeof console,
From a0d30b848a07480d0fccec608a62a505c71f8cac Mon Sep 17 00:00:00 2001
From: Genki Kondo
Date: Thu, 26 Aug 2021 10:38:36 -0700
Subject: [PATCH 020/986] Remove unsupported values for
android_hyphenationFrequency
Summary:
hyphenationStrategy must be one of one of Layout#HYPHENATION_FREQUENCY_NONE, Layout#HYPHENATION_FREQUENCY_NORMAL, Layout#HYPHENATION_FREQUENCY_FULL: (https://developer.android.com/reference/android/widget/TextView#setHyphenationFrequency(int))
Thus "high" and "balanced" are not only redundant, but actually don't do what the value indicates - Layout#BREAK_STRATEGY_BALANCED (constant value: 2) and Layout#BREAK_STRATEGY_HIGH_QUALITY (constant value: 1) are only meant to be used for android:breakStrategy
Changelog:
[Android][Changed] - Remove `"high"` and `"balanced"` as values for `android_hyphenationFrequency` on `Text`
Reviewed By: JoshuaGross
Differential Revision: D30531096
fbshipit-source-id: 1a0b6e733bb21ce6b2f104a2025a79c16de3cfea
---
Libraries/Text/TextProps.js | 8 +-------
.../views/text/ReactTextAnchorViewManager.java | 4 ----
.../js/examples/Text/TextExample.android.js | 14 +++-----------
3 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/Libraries/Text/TextProps.js b/Libraries/Text/TextProps.js
index b2a39e58df76..3942a5998cd3 100644
--- a/Libraries/Text/TextProps.js
+++ b/Libraries/Text/TextProps.js
@@ -66,13 +66,7 @@ export type TextProps = $ReadOnly<{|
* Set hyphenation strategy on Android.
*
*/
- android_hyphenationFrequency?: ?(
- | 'normal'
- | 'none'
- | 'full'
- | 'high'
- | 'balanced'
- ),
+ android_hyphenationFrequency?: ?('normal' | 'none' | 'full'),
children?: ?Node,
/**
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java
index ffc8655c0a47..6ee067cb661a 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextAnchorViewManager.java
@@ -110,10 +110,6 @@ public void setAndroidHyphenationFrequency(ReactTextView view, @Nullable String
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE);
} else if (frequency.equals("full")) {
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_FULL);
- } else if (frequency.equals("balanced")) {
- view.setHyphenationFrequency(Layout.BREAK_STRATEGY_BALANCED);
- } else if (frequency.equals("high")) {
- view.setHyphenationFrequency(Layout.BREAK_STRATEGY_HIGH_QUALITY);
} else if (frequency.equals("normal")) {
view.setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
} else {
diff --git a/packages/rn-tester/js/examples/Text/TextExample.android.js b/packages/rn-tester/js/examples/Text/TextExample.android.js
index 6b3668663d82..d44aff22b429 100644
--- a/packages/rn-tester/js/examples/Text/TextExample.android.js
+++ b/packages/rn-tester/js/examples/Text/TextExample.android.js
@@ -216,23 +216,15 @@ class TextExample extends React.Component<{...}> {
Normal:
- WillHaveAnHyphenWhenBreakingForNewLine
+ WillHaveAHyphenWhenBreakingForNewLine
None:
- WillNotHaveAnHyphenWhenBreakingForNewLine
+ WillNotHaveAHyphenWhenBreakingForNewLine
Full:
- WillHaveAnHyphenWhenBreakingForNewLine
-
-
- High:
- WillHaveAnHyphenWhenBreakingForNewLine
-
-
- Balanced:
- WillHaveAnHyphenWhenBreakingForNewLine
+ WillHaveAHyphenWhenBreakingForNewLine
From 362511dc939b6784ab25c4238c70a019faf414af Mon Sep 17 00:00:00 2001
From: Tommy Nguyen <4123478+tido64@users.noreply.github.com>
Date: Thu, 26 Aug 2021 12:00:48 -0700
Subject: [PATCH 021/986] chore: prefer the local react-native-codegen package
(#32096)
Summary:
Currently, the build breaks if we move `react-native-codegen` from the template's dependencies to root. This is due to `scripts/generate-specs-cli.js` using the one installed under `node_modules` instead of the local one.
## Changelog
[Internal] [Fixed] - `scripts/generate-specs-cli.js` should prefer the local `react-native-codegen` package
Pull Request resolved: https://github.com/facebook/react-native/pull/32096
Test Plan:
1. Make the following changes
```diff
diff --git a/package.json b/package.json
index 847c726a69b..78da8232988 100644
--- a/package.json
+++ b/package.json
@@ -107,6 +107,7 @@
"promise": "^8.0.3",
"prop-types": "^15.7.2",
"react-devtools-core": "^4.13.0",
+ "react-native-codegen": "^0.0.7",
"react-refresh": "^0.4.0",
"regenerator-runtime": "^0.13.2",
"scheduler": "^0.20.2",
diff --git a/template/package.json b/template/package.json
index 715614112ac..5e0762b1b25 100644
--- a/template/package.json
+++ b/template/package.json
@@ -21,7 +21,6 @@
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
- "react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.2"
},
"jest": {
```
2. Run `scripts/test-manual-e2e.sh`
## Expected Behavior
Task `:ReactAndroid:buildReactNdkLib` succeeds.
## Actual Behavior
```
> Task :ReactAndroid:buildReactNdkLib FAILED
make: Entering directory '~/Source/react-native/ReactAndroid/src/main/jni/react/jni'
fcntl(): Bad file descriptor
make: Leaving directory '~/Source/react-native/ReactAndroid/src/main/jni/react/jni'
~/Library/Android/sdk/ndk/21.4.7075529/build/core/build-binary.mk:651: Android NDK: Module react_codegen_rncore depends on undefined modules: react_render_components_view
~/Library/Android/sdk/ndk/21.4.7075529/build/core/build-binary.mk:664: *** Android NDK: Note that old versions of ndk-build silently ignored this error case. If your project worked on those versions, the missing libraries were not needed and you can remove those dependencies from the module to fix your build. Alternatively, set APP_ALLOW_MISSING_DEPS=true to allow missing dependencies. . Stop.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':ReactAndroid:buildReactNdkLib'.
> Process 'command '~/Library/Android/sdk/ndk/21.4.7075529/ndk-build'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.9/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 19s
20 actionable tasks: 20 executed
Couldn't generate artifacts
```
Reviewed By: ShikaSD
Differential Revision: D30581194
Pulled By: hramos
fbshipit-source-id: 3f7a707b33377042502e50887856ff5641fdd52c
---
scripts/generate-specs-cli.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/generate-specs-cli.js b/scripts/generate-specs-cli.js
index 53b263faccdf..427eff561044 100644
--- a/scripts/generate-specs-cli.js
+++ b/scripts/generate-specs-cli.js
@@ -11,9 +11,9 @@
let RNCodegen;
try {
- RNCodegen = require('react-native-codegen/lib/generators/RNCodegen.js');
-} catch (e) {
RNCodegen = require('../packages/react-native-codegen/lib/generators/RNCodegen.js');
+} catch (e) {
+ RNCodegen = require('react-native-codegen/lib/generators/RNCodegen.js');
if (!RNCodegen) {
throw 'RNCodegen not found.';
}
From 732ac170992ca7b94e2419603d1f1095a878bbe3 Mon Sep 17 00:00:00 2001
From: Luna Wei
Date: Thu, 26 Aug 2021 14:58:39 -0700
Subject: [PATCH 022/986] Update manual testing script to also test Hermes for
RNTester
Summary: Changelog: [Internal] - Update test-manual-e2e.sh to test Hermes for RNTester
Reviewed By: ShikaSD
Differential Revision: D30569403
fbshipit-source-id: fd45c8158c4c5ad93f33bc7b80464c5fc387a737
---
scripts/test-manual-e2e.sh | 47 +++++++++++++++++++++++++++++---------
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git a/scripts/test-manual-e2e.sh b/scripts/test-manual-e2e.sh
index 10ac45b971d1..e6a138d45c44 100755
--- a/scripts/test-manual-e2e.sh
+++ b/scripts/test-manual-e2e.sh
@@ -4,8 +4,6 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
-JAVA_VERSION="1.7"
-
RED="\033[0;31m"
GREEN="\033[0;32m"
BLUE="\033[0;35m"
@@ -49,28 +47,55 @@ lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill
info "Start the packager in another terminal by running 'npm start' from the root"
info "and then press any key."
info ""
-read -n 1
+read -r -n 1
./gradlew :packages:rn-tester:android:app:installJscDebug || error "Couldn't build RNTester Android"
info "Press any key to run RNTester in an already running Android emulator/device"
info ""
-read -n 1
+read -r -n 1
adb shell am start -n com.facebook.react.uiapp/.RNTesterActivity
-success "Installing CocoaPods dependencies"
+
+info "Once done testing, keep emulator running"
+info "Press any key to run RNTester on Android with Hermes enabled"
+read -r -n 1
+
+./gradlew :packages:rn-tester:android:app:installHermesDebug || error "Couldn't build RNTester Android"
+adb shell am start -n com.facebook.react.uiapp/.RNTesterActivity
+
+info "When done testing RNTester on Android,"
+info "Press any key to start testing RNTester in iOS"
+read -r -n 1
+
+success "About to test iOS JSC... "
+success "Installing CocoaPods dependencies..."
rm -rf packages/rn-tester/Pods
(cd packages/rn-tester && pod install)
info "Press any key to open the workspace in Xcode, then build and test manually."
info ""
-read -n 1
+read -r -n 1
+
+open "packages/rn-tester/RNTesterPods.xcworkspace"
+
+info "When done testing iOS JSC, press any key to test iOS Hermes"
+read -r -n 1
+
+success "About to test iOS Hermes... "
+success "Installing CocoaPods dependencies..."
+rm -rf packages/rn-tester/Pods
+(cd packages/rn-tester && USE_HERMES=1 pod install)
+
+info "Press any key to open the workspace in Xcode, then build and test manually."
+info ""
+read -r -n 1
open "packages/rn-tester/RNTesterPods.xcworkspace"
info "When done testing RNTester app on iOS and Android press any key to continue."
info ""
-read -n 1
+read -r -n 1
success "Killing packager"
lsof -i :8081 | grep LISTEN
@@ -86,7 +111,7 @@ success "React Native version changed in the template"
project_name="RNTestProject"
-cd /tmp/
+cd /tmp/ || exit
rm -rf "$project_name"
node "$repo_root/cli.js" init "$project_name" --template "$repo_root"
@@ -102,7 +127,7 @@ info " - Verify 'Reload JS' works"
info ""
info "Press any key to run the sample in Android emulator/device"
info ""
-read -n 1
+read -r -n 1
cd "/tmp/${project_name}" && npx react-native run-android
info "Test the following on iOS:"
@@ -115,10 +140,10 @@ info " - Disable Fast Refresh."
info ""
info "Press any key to open the project in Xcode"
info ""
-read -n 1
+read -r -n 1
open "/tmp/${project_name}/ios/${project_name}.xcworkspace"
-cd "$repo_root"
+cd "$repo_root" || exit
info "Next steps:"
info " - https://github.com/facebook/react-native/blob/HEAD/Releases.md"
From ca60be8882522b707ddb710bdbda9ba673cdc22f Mon Sep 17 00:00:00 2001
From: Genki Kondo
Date: Thu, 26 Aug 2021 18:51:02 -0700
Subject: [PATCH 023/986] Add android_hyphenationStrategy to
ParagraphAttributes
Summary:
Expose android_hyphenationFrequency in Fabric as part of ParagraphAttributes
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D30583215
fbshipit-source-id: f4e9e9d6ea8efcfc10db29e1fbd651462f442837
---
.../attributedstring/ParagraphAttributes.cpp | 11 ++--
.../attributedstring/ParagraphAttributes.h | 11 +++-
.../renderer/attributedstring/conversions.h | 51 +++++++++++++++++++
.../renderer/attributedstring/primitives.h | 19 ++++++-
4 files changed, 87 insertions(+), 5 deletions(-)
diff --git a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
index fe64a462aa3e..cafee3113893 100644
--- a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
+++ b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
@@ -21,13 +21,15 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes &rhs) const {
ellipsizeMode,
textBreakStrategy,
adjustsFontSizeToFit,
- includeFontPadding) ==
+ includeFontPadding,
+ android_hyphenationFrequency) ==
std::tie(
rhs.maximumNumberOfLines,
rhs.ellipsizeMode,
rhs.textBreakStrategy,
rhs.adjustsFontSizeToFit,
- rhs.includeFontPadding) &&
+ rhs.includeFontPadding,
+ rhs.android_hyphenationFrequency) &&
floatEquality(minimumFontSize, rhs.minimumFontSize) &&
floatEquality(maximumFontSize, rhs.maximumFontSize);
}
@@ -47,7 +49,10 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
debugStringConvertibleItem("adjustsFontSizeToFit", adjustsFontSizeToFit),
debugStringConvertibleItem("minimumFontSize", minimumFontSize),
debugStringConvertibleItem("maximumFontSize", maximumFontSize),
- debugStringConvertibleItem("includeFontPadding", includeFontPadding)};
+ debugStringConvertibleItem("includeFontPadding", includeFontPadding),
+ debugStringConvertibleItem(
+ "android_hyphenationFrequency",
+ android_hyphenationFrequency)};
}
#endif
diff --git a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
index a5666035eff6..c4fa4a5944ad 100644
--- a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
+++ b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
@@ -42,6 +42,9 @@ class ParagraphAttributes : public DebugStringConvertible {
*/
EllipsizeMode ellipsizeMode{};
+ /*
+ * (Android only) Break strategy for breaking paragraphs into lines.
+ */
TextBreakStrategy textBreakStrategy{};
/*
@@ -55,6 +58,11 @@ class ParagraphAttributes : public DebugStringConvertible {
*/
bool includeFontPadding{true};
+ /*
+ * (Android only) Frequency of automatic hyphenation to use when determining word breaks.
+ */
+ HyphenationFrequency android_hyphenationFrequency{};
+
/*
* In case of font size adjustment enabled, defines minimum and maximum
* font sizes.
@@ -89,7 +97,8 @@ struct hash {
attributes.adjustsFontSizeToFit,
attributes.minimumFontSize,
attributes.maximumFontSize,
- attributes.includeFontPadding);
+ attributes.includeFontPadding,
+ attributes.android_hyphenationFrequency);
}
};
} // namespace std
diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h
index da688767fcd7..43c449cdde2d 100644
--- a/ReactCommon/react/renderer/attributedstring/conversions.h
+++ b/ReactCommon/react/renderer/attributedstring/conversions.h
@@ -712,6 +712,48 @@ inline void fromRawValue(
result = AccessibilityRole::None;
}
+inline std::string toString(const HyphenationFrequency &hyphenationFrequency) {
+ switch (hyphenationFrequency) {
+ case HyphenationFrequency::None:
+ return "none";
+ case HyphenationFrequency::Normal:
+ return "normal";
+ case HyphenationFrequency::Full:
+ return "full";
+ }
+
+ LOG(ERROR) << "Unsupported HyphenationFrequency value";
+ react_native_assert(false);
+ return "none";
+}
+
+inline void fromRawValue(
+ const PropsParserContext &context,
+ const RawValue &value,
+ HyphenationFrequency &result) {
+ react_native_assert(value.hasType());
+ if (value.hasType()) {
+ auto string = (std::string)value;
+ if (string == "none") {
+ result = HyphenationFrequency::None;
+ } else if (string == "normal") {
+ result = HyphenationFrequency::Normal;
+ } else if (string == "full") {
+ result = HyphenationFrequency::Full;
+ } else {
+ // sane default
+ LOG(ERROR) << "Unsupported HyphenationFrequency value: " << string;
+ react_native_assert(false);
+ result = HyphenationFrequency::None;
+ }
+ return;
+ }
+
+ LOG(ERROR) << "Unsupported HyphenationFrequency type";
+ react_native_assert(false);
+ result = HyphenationFrequency::None;
+}
+
inline ParagraphAttributes convertRawProp(
const PropsParserContext &context,
RawProps const &rawProps,
@@ -761,6 +803,12 @@ inline ParagraphAttributes convertRawProp(
"includeFontPadding",
sourceParagraphAttributes.includeFontPadding,
defaultParagraphAttributes.includeFontPadding);
+ paragraphAttributes.android_hyphenationFrequency = convertRawProp(
+ context,
+ rawProps,
+ "android_hyphenationFrequency",
+ sourceParagraphAttributes.android_hyphenationFrequency,
+ defaultParagraphAttributes.android_hyphenationFrequency);
return paragraphAttributes;
}
@@ -796,6 +844,9 @@ inline folly::dynamic toDynamic(
values("textBreakStrategy", toString(paragraphAttributes.textBreakStrategy));
values("adjustsFontSizeToFit", paragraphAttributes.adjustsFontSizeToFit);
values("includeFontPadding", paragraphAttributes.includeFontPadding);
+ values(
+ "android_hyphenationFrequency",
+ toString(paragraphAttributes.android_hyphenationFrequency));
return values;
}
diff --git a/ReactCommon/react/renderer/attributedstring/primitives.h b/ReactCommon/react/renderer/attributedstring/primitives.h
index cb080f35b83e..49c14ea0637e 100644
--- a/ReactCommon/react/renderer/attributedstring/primitives.h
+++ b/ReactCommon/react/renderer/attributedstring/primitives.h
@@ -53,7 +53,11 @@ enum class EllipsizeMode {
Middle // Truncate middle of line: "ab...yz".
};
-enum class TextBreakStrategy { Simple, Balanced, HighQuality };
+enum class TextBreakStrategy {
+ Simple, // Simple strategy.
+ Balanced, // Balances line lengths.
+ HighQuality // High-quality strategy, including hyphenation.
+};
enum class TextAlignment {
Natural, // Indicates the default alignment for script.
@@ -126,6 +130,12 @@ enum class TextTransform {
Unset,
};
+enum class HyphenationFrequency {
+ None, // No hyphenation.
+ Normal, // Less frequent hyphenation.
+ Full // Standard amount of hyphenation.
+};
+
} // namespace react
} // namespace facebook
@@ -213,4 +223,11 @@ struct hash {
return hash()(static_cast(v));
}
};
+
+template <>
+struct hash {
+ size_t operator()(const facebook::react::HyphenationFrequency &v) const {
+ return hash()(static_cast(v));
+ }
+};
} // namespace std
From 5d6484e0a87c71f89daba007a5782f824c625727 Mon Sep 17 00:00:00 2001
From: Luna Wei
Date: Thu, 26 Aug 2021 18:52:44 -0700
Subject: [PATCH 024/986] Keep repo-config workspace in bump-oss-version
Summary: Changelog: [Internal][Fixed] - Keep repo-config as a workspace for bumping oss release version. Fixes CI jobs not having tooling dependencies
Reviewed By: yungsters
Differential Revision: D30595543
fbshipit-source-id: 1dd2adc6a0363202efb5314b7e8eb44618b50327
---
repo-config/package.json | 2 +-
scripts/bump-oss-version.js | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/repo-config/package.json b/repo-config/package.json
index 9cd9c30b9a59..e092222641ef 100644
--- a/repo-config/package.json
+++ b/repo-config/package.json
@@ -8,7 +8,7 @@
"type": "git",
"url": "git@github.com:facebook/react-native.git"
},
- "dependencies": {
+ "devDependencies": {
"@babel/core": "^7.14.0",
"@babel/generator": "^7.14.0",
"@babel/template": "^7.0.0",
diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js
index d22eb2516714..ef06e4f1e7f0 100755
--- a/scripts/bump-oss-version.js
+++ b/scripts/bump-oss-version.js
@@ -127,8 +127,12 @@ fs.writeFileSync(
);
let packageJson = JSON.parse(cat('package.json'));
+
packageJson.version = version;
-delete packageJson.workspaces;
+
+// Only keep 'repo-config` workspace
+packageJson.workspaces = packageJson.workspaces.filter(w => w === 'repo-config');
+
delete packageJson.private;
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');
From 1acf33461451834097463f43e70d90bae0f67198 Mon Sep 17 00:00:00 2001
From: Valentin Shergin
Date: Thu, 26 Aug 2021 21:45:22 -0700
Subject: [PATCH 025/986] Fixed `alignItems: baseline` for elements on
Android (#31575)
Summary:
This fixes https://github.com/facebook/react-native/issues/20666 and https://github.com/facebook/react-native/issues/21918.
This is pretty much the same as 51b3529f6c2ca354800c0cf6ecb8eb3115eaa36e but implemented for Android.
Now exposes the actual base-line offset value that allows Yoga to position it properly when `alignItems: baseline` is requested.
## Changelog
[Android][Fixed] - Fixed `alignItems: baseline` for elements on Android
Pull Request resolved: https://github.com/facebook/react-native/pull/31575
Test Plan:
The same test case that we have for iOS.
Before:
After:
Reviewed By: JoshuaGross
Differential Revision: D28631468
Pulled By: yungsters
fbshipit-source-id: 7c259e469d19d8344298319f066b8437dfdedad0
---
.../react/views/text/ReactTextShadowNode.java | 16 +++++
.../js/examples/Text/TextExample.android.js | 62 +++++++++++++++++++
2 files changed, 78 insertions(+)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java
index 46bc1e9b5005..26257ebe9388 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java
@@ -32,6 +32,7 @@
import com.facebook.react.uimanager.UIViewOperationQueue;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.facebook.react.uimanager.events.RCTEventEmitter;
+import com.facebook.yoga.YogaBaselineFunction;
import com.facebook.yoga.YogaConstants;
import com.facebook.yoga.YogaDirection;
import com.facebook.yoga.YogaMeasureFunction;
@@ -159,6 +160,20 @@ public long measure(
}
};
+ private final YogaBaselineFunction mTextBaselineFunction =
+ new YogaBaselineFunction() {
+ @Override
+ public float baseline(YogaNode node, float width, float height) {
+ Spannable text =
+ Assertions.assertNotNull(
+ mPreparedSpannableText,
+ "Spannable element has not been prepared in onBeforeLayout");
+
+ Layout layout = measureSpannedText(text, width, YogaMeasureMode.EXACTLY);
+ return layout.getLineBaseline(layout.getLineCount() - 1);
+ }
+ };
+
public ReactTextShadowNode() {
this(null);
}
@@ -171,6 +186,7 @@ public ReactTextShadowNode(@Nullable ReactTextViewManagerCallback reactTextViewM
private void initMeasureFunction() {
if (!isVirtual()) {
setMeasureFunction(mTextMeasureFunction);
+ setBaselineFunction(mTextBaselineFunction);
}
}
diff --git a/packages/rn-tester/js/examples/Text/TextExample.android.js b/packages/rn-tester/js/examples/Text/TextExample.android.js
index d44aff22b429..aacb5fa973d4 100644
--- a/packages/rn-tester/js/examples/Text/TextExample.android.js
+++ b/packages/rn-tester/js/examples/Text/TextExample.android.js
@@ -884,6 +884,62 @@ const styles = StyleSheet.create({
alignSelf: 'center',
},
});
+
+function TextBaseLineLayoutExample(props: {}): React.Node {
+ const texts = [];
+ for (let i = 9; i >= 0; i--) {
+ texts.push(
+
+ {i}
+ ,
+ );
+ }
+
+ const marker = (
+
+ );
+ const subtitleStyle = {fontSize: 16, marginTop: 8, fontWeight: 'bold'};
+
+ return (
+
+ {'Nested s:'}
+
+ {marker}
+ {texts}
+ {marker}
+
+
+ {'Array of s in :'}
+
+ {marker}
+ {texts}
+ {marker}
+
+
+ {'Interleaving and :'}
+
+ {marker}
+
+ Some text.
+
+ {marker}
+ Text inside View.
+ {marker}
+
+
+ {marker}
+
+
+ );
+}
+
exports.title = 'Text';
exports.documentationURL = 'https://reactnative.dev/docs/text';
exports.category = 'Basic';
@@ -895,4 +951,10 @@ exports.examples = [
return ;
},
},
+ {
+ title: "Text `alignItems: 'baseline'` style",
+ render: function(): React.Node {
+ return ;
+ },
+ },
];
From fe5a5dc878158a0a5fb6dff005096fa8fb8f0ab7 Mon Sep 17 00:00:00 2001
From: Phillip Pan
Date: Thu, 26 Aug 2021 22:39:10 -0700
Subject: [PATCH 026/986] virtualize setDisplayMode
Summary:
Changelog:
[internal]
following the recommendation in https://fb.workplace.com/groups/474291069286180/posts/6540719469309946
in order to unit test classes that use SurfaceHandler, we need to be able to mock it somehow - since the class is final we aren't able to do that. in this diff, we convert the function that we need to stub / listen to to a virtual function so we can mock it.
the alternative is to keep this class final, and create another abstract interface that this will extend from. however, this class is quite large and that would have a lot more boilerplate and updation of callsites, so this simpler approach seems better.
Reviewed By: sammy-SC
Differential Revision: D30578928
fbshipit-source-id: 4a63396f049c44753986d15f1ac64332b2a8393a
---
ReactCommon/react/renderer/scheduler/SurfaceHandler.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h
index a606167c3709..c0ae0e60bdc7 100644
--- a/ReactCommon/react/renderer/scheduler/SurfaceHandler.h
+++ b/ReactCommon/react/renderer/scheduler/SurfaceHandler.h
@@ -34,7 +34,7 @@ class UIManager;
* ensure the logical consistency of some methods (e.g. calling `stop` for
* non-running surface will crash).
*/
-class SurfaceHandler final {
+class SurfaceHandler {
public:
/*
* Represents a status of the `SurfaceHandler` instance.
@@ -62,7 +62,7 @@ class SurfaceHandler final {
* Can be constructed anytime with a `moduleName` and a `surfaceId`.
*/
SurfaceHandler(std::string const &moduleName, SurfaceId surfaceId) noexcept;
- ~SurfaceHandler() noexcept;
+ virtual ~SurfaceHandler() noexcept;
/*
* Movable-only.
@@ -95,10 +95,10 @@ class SurfaceHandler final {
void stop() const noexcept;
/*
- * Sets (and gets) the runnnig mode.
+ * Sets (and gets) the running mode.
* The running mode can be changed anytime (even for `Unregistered` surface).
*/
- void setDisplayMode(DisplayMode displayMode) const noexcept;
+ virtual void setDisplayMode(DisplayMode displayMode) const noexcept;
DisplayMode getDisplayMode() const noexcept;
#pragma mark - Accessors
From ec92c85a15468fd00dc0a23b8f69f5f1624f7b45 Mon Sep 17 00:00:00 2001
From: Phillip Pan
Date: Thu, 26 Aug 2021 22:39:10 -0700
Subject: [PATCH 027/986] introduce MockSurfaceHandler
Summary:
Changelog:
[ios][added] - introduce MockSurfaceHandler
following the recommendation in https://fb.workplace.com/groups/474291069286180/posts/6540719469309946
in order to unit test classes that use SurfaceHandler, we need to be able to mock it somehow - since the class is final we aren't able to do that. in this diff, we add the mock class.
Reviewed By: sammy-SC
Differential Revision: D30578927
fbshipit-source-id: 9b39b03ad0b55cecd9b482f9cce9630d7e7d5bda
---
ReactCommon/react/test_utils/BUCK | 3 +++
.../react/test_utils/MockSurfaceHandler.h | 25 +++++++++++++++++++
2 files changed, 28 insertions(+)
create mode 100644 ReactCommon/react/test_utils/MockSurfaceHandler.h
diff --git a/ReactCommon/react/test_utils/BUCK b/ReactCommon/react/test_utils/BUCK
index 52bae03fe6c5..8cd75144aaaa 100644
--- a/ReactCommon/react/test_utils/BUCK
+++ b/ReactCommon/react/test_utils/BUCK
@@ -51,4 +51,7 @@ rn_xplat_cxx_library(
react_native_xplat_target("better:better"),
react_native_xplat_target("react/debug:debug"),
],
+ exported_deps = [
+ "//xplat/third-party/gmock:gmock",
+ ],
)
diff --git a/ReactCommon/react/test_utils/MockSurfaceHandler.h b/ReactCommon/react/test_utils/MockSurfaceHandler.h
new file mode 100644
index 000000000000..c6f678ce4848
--- /dev/null
+++ b/ReactCommon/react/test_utils/MockSurfaceHandler.h
@@ -0,0 +1,25 @@
+/*
+ * 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
+
+namespace facebook {
+namespace react {
+
+class MockSurfaceHandler : public SurfaceHandler {
+ public:
+ MockSurfaceHandler() : SurfaceHandler("moduleName", 0){};
+
+ MOCK_QUALIFIED_METHOD1(setDisplayMode, const noexcept, void(DisplayMode));
+};
+
+} // namespace react
+} // namespace facebook
From 4ac42d88ef60ae3fed7319851d47b93e98ac9afa Mon Sep 17 00:00:00 2001
From: Adlai Holler
Date: Thu, 26 Aug 2021 22:40:03 -0700
Subject: [PATCH 028/986] Optimize font handling on iOS (#31764)
Summary:
Few issues I saw when profiling RNTester:
- Repeatedly calling `-lowercaseString` during `weightOfFont` causes a TON of extra memory traffic, for no reason.
- `NSCache` is thread-safe, so no need for a mutex.
- Using `stringWithFormat:` for the cache key is slow. Use `NSValue` to store the data directly instead.
- Calling `-fontDescriptor` in `isItalicFont` and `isCondensedFont` is overly expensive and unnecessary.
- `+fontNamesForFamilyName:` is insanely expensive. Wrap it in a cache.
Unscientific test on RNTester iPhone 11 Pro, memory & time. Before:
After:
Changelog:
[iOS][Changed] - Optimized font handling
Pull Request resolved: https://github.com/facebook/react-native/pull/31764
Reviewed By: appden
Differential Revision: D30241725
Pulled By: yungsters
fbshipit-source-id: 342e4f6e5492926acd2afc7d645e6878846369fc
---
BUCK | 1 +
React/Views/RCTFont.mm | 92 +++++++++++--------
.../RNTesterUnitTests/RCTFontTests.m | 2 +-
3 files changed, 56 insertions(+), 39 deletions(-)
diff --git a/BUCK b/BUCK
index b315295c974f..8c53560e3330 100644
--- a/BUCK
+++ b/BUCK
@@ -376,6 +376,7 @@ rn_xplat_cxx_library2(
"$SDKROOT/System/Library/Frameworks/CFNetwork.framework",
"$SDKROOT/System/Library/Frameworks/CoreGraphics.framework",
"$SDKROOT/System/Library/Frameworks/CoreLocation.framework",
+ "$SDKROOT/System/Library/Frameworks/CoreText.framework",
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
"$SDKROOT/System/Library/Frameworks/MapKit.framework",
"$SDKROOT/System/Library/Frameworks/QuartzCore.framework",
diff --git a/React/Views/RCTFont.mm b/React/Views/RCTFont.mm
index 93e1a803c7ca..7a8cbbb19abe 100644
--- a/React/Views/RCTFont.mm
+++ b/React/Views/RCTFont.mm
@@ -11,18 +11,16 @@
#import
-#import
-
typedef CGFloat RCTFontWeight;
static RCTFontWeight weightOfFont(UIFont *font)
{
- static NSArray *fontNames;
- static NSArray *fontWeights;
+ static NSArray *weightSuffixes;
+ static NSArray *fontWeights;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// We use two arrays instead of one map because
// the order is important for suffix matching.
- fontNames = @[
+ weightSuffixes = @[
@"normal",
@"ultralight",
@"thin",
@@ -54,28 +52,29 @@ static RCTFontWeight weightOfFont(UIFont *font)
];
});
- for (NSInteger i = 0; i < 0 || i < (unsigned)fontNames.count; i++) {
- if ([font.fontName.lowercaseString hasSuffix:fontNames[i]]) {
- return (RCTFontWeight)[fontWeights[i] doubleValue];
+ NSString *fontName = font.fontName;
+ NSInteger i = 0;
+ for (NSString *suffix in weightSuffixes) {
+ // CFStringFind is much faster than any variant of rangeOfString: because it does not use a locale.
+ auto options = kCFCompareCaseInsensitive | kCFCompareAnchored | kCFCompareBackwards;
+ if (CFStringFind((CFStringRef)fontName, (CFStringRef)suffix, options).location != kCFNotFound) {
+ return (RCTFontWeight)fontWeights[i].doubleValue;
}
+ i++;
}
- NSDictionary *traits = [font.fontDescriptor objectForKey:UIFontDescriptorTraitsAttribute];
+ auto traits = (__bridge_transfer NSDictionary *)CTFontCopyTraits((CTFontRef)font);
return (RCTFontWeight)[traits[UIFontWeightTrait] doubleValue];
}
static BOOL isItalicFont(UIFont *font)
{
- NSDictionary *traits = [font.fontDescriptor objectForKey:UIFontDescriptorTraitsAttribute];
- UIFontDescriptorSymbolicTraits symbolicTraits = [traits[UIFontSymbolicTrait] unsignedIntValue];
- return (symbolicTraits & UIFontDescriptorTraitItalic) != 0;
+ return (CTFontGetSymbolicTraits((CTFontRef)font) & kCTFontTraitItalic) != 0;
}
static BOOL isCondensedFont(UIFont *font)
{
- NSDictionary *traits = [font.fontDescriptor objectForKey:UIFontDescriptorTraitsAttribute];
- UIFontDescriptorSymbolicTraits symbolicTraits = [traits[UIFontSymbolicTrait] unsignedIntValue];
- return (symbolicTraits & UIFontDescriptorTraitCondensed) != 0;
+ return (CTFontGetSymbolicTraits((CTFontRef)font) & kCTFontTraitCondensed) != 0;
}
static RCTFontHandler defaultFontHandler;
@@ -130,18 +129,16 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec
static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
{
- static NSCache *fontCache;
- static std::mutex *fontCacheMutex = new std::mutex;
-
- NSString *cacheKey = [NSString stringWithFormat:@"%.1f/%.2f", size, weight];
- UIFont *font;
- {
- std::lock_guard lock(*fontCacheMutex);
- if (!fontCache) {
- fontCache = [NSCache new];
- }
- font = [fontCache objectForKey:cacheKey];
- }
+ static NSCache *fontCache = [NSCache new];
+
+ struct __attribute__((__packed__)) CacheKey {
+ CGFloat size;
+ RCTFontWeight weight;
+ };
+
+ CacheKey key{size, weight};
+ NSValue *cacheKey = [[NSValue alloc] initWithBytes:&key objCType:@encode(CacheKey)];
+ UIFont *font = [fontCache objectForKey:cacheKey];
if (!font) {
if (defaultFontHandler) {
@@ -151,15 +148,36 @@ static inline BOOL CompareFontWeights(UIFontWeight firstWeight, UIFontWeight sec
font = [UIFont systemFontOfSize:size weight:weight];
}
- {
- std::lock_guard lock(*fontCacheMutex);
- [fontCache setObject:font forKey:cacheKey];
- }
+ [fontCache setObject:font forKey:cacheKey];
}
return font;
}
+// Caching wrapper around expensive +[UIFont fontNamesForFamilyName:]
+static NSArray *fontNamesForFamilyName(NSString *familyName)
+{
+ static NSCache *> *cache;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ cache = [NSCache new];
+ [NSNotificationCenter.defaultCenter
+ addObserverForName:(NSNotificationName)kCTFontManagerRegisteredFontsChangedNotification
+ object:nil
+ queue:nil
+ usingBlock:^(NSNotification *) {
+ [cache removeAllObjects];
+ }];
+ });
+
+ auto names = [cache objectForKey:familyName];
+ if (!names) {
+ names = [UIFont fontNamesForFamilyName:familyName];
+ [cache setObject:names forKey:familyName];
+ }
+ return names;
+}
+
@implementation RCTConvert (RCTFont)
+ (UIFont *)UIFont:(id)json
@@ -315,7 +333,7 @@ + (UIFont *)updateFont:(UIFont *)font
// Gracefully handle being given a font name rather than font family, for
// example: "Helvetica Light Oblique" rather than just "Helvetica".
- if (!didFindFont && [UIFont fontNamesForFamilyName:familyName].count == 0) {
+ if (!didFindFont && fontNamesForFamilyName(familyName).count == 0) {
font = [UIFont fontWithName:familyName size:fontSize];
if (font) {
// It's actually a font name, not a font family name,
@@ -339,7 +357,8 @@ + (UIFont *)updateFont:(UIFont *)font
// Get the closest font that matches the given weight for the fontFamily
CGFloat closestWeight = INFINITY;
- for (NSString *name in [UIFont fontNamesForFamilyName:familyName]) {
+ NSArray *names = fontNamesForFamilyName(familyName);
+ for (NSString *name in names) {
UIFont *match = [UIFont fontWithName:name size:fontSize];
if (isItalic == isItalicFont(match) && isCondensed == isCondensedFont(match)) {
CGFloat testWeight = weightOfFont(match);
@@ -352,11 +371,8 @@ + (UIFont *)updateFont:(UIFont *)font
// If we still don't have a match at least return the first font in the fontFamily
// This is to support built-in font Zapfino and other custom single font families like Impact
- if (!font) {
- NSArray *names = [UIFont fontNamesForFamilyName:familyName];
- if (names.count > 0) {
- font = [UIFont fontWithName:names[0] size:fontSize];
- }
+ if (!font && names.count > 0) {
+ font = [UIFont fontWithName:names[0] size:fontSize];
}
// Apply font variants to font object
diff --git a/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m b/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m
index bb8f19b03835..650b14f51514 100644
--- a/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m
+++ b/packages/rn-tester/RNTesterUnitTests/RCTFontTests.m
@@ -20,7 +20,7 @@ @implementation RCTFontTests
// will be different objects, but the same font, so this macro now explicitly
// checks that fontName (which includes the style) and pointSize are equal.
#define RCTAssertEqualFonts(font1, font2) { \
- XCTAssertTrue([font1.fontName isEqualToString:font2.fontName]); \
+ XCTAssertEqualObjects(font1.fontName, font2.fontName); \
XCTAssertEqual(font1.pointSize,font2.pointSize); \
}
From 3b2d5419899363d84aea4f5cc3a4c75253dd6406 Mon Sep 17 00:00:00 2001
From: Genki Kondo
Date: Fri, 27 Aug 2021 00:16:30 -0700
Subject: [PATCH 029/986] Set textBreakStrategy default to be HighQuality
Summary:
Android TextView's default for breakStrategy is BREAK_STRATEGY_HIGH_QUALITY (https://developer.android.com/reference/android/widget/TextView#setBreakStrategy(int))
RN docs also states that highQuality is default.
However, on Fabric, the default is 'simple'. This diff fixes the default to be 'highQuality'
Changelog:
[Android][Fixed] - Set textBreakStrategy default to be 'highQuality'
Reviewed By: JoshuaGross
Differential Revision: D30597085
fbshipit-source-id: 3bd7531afdaf980b342cc461dd449c3d3df12cb0
---
.../react/renderer/attributedstring/ParagraphAttributes.cpp | 3 +--
.../react/renderer/attributedstring/ParagraphAttributes.h | 5 +++--
ReactCommon/react/renderer/attributedstring/conversions.h | 6 +++---
ReactCommon/react/renderer/attributedstring/primitives.h | 4 ++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
index cafee3113893..d5251fa907b9 100644
--- a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
+++ b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp
@@ -51,8 +51,7 @@ SharedDebugStringConvertibleList ParagraphAttributes::getDebugProps() const {
debugStringConvertibleItem("maximumFontSize", maximumFontSize),
debugStringConvertibleItem("includeFontPadding", includeFontPadding),
debugStringConvertibleItem(
- "android_hyphenationFrequency",
- android_hyphenationFrequency)};
+ "android_hyphenationFrequency", android_hyphenationFrequency)};
}
#endif
diff --git a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
index c4fa4a5944ad..22f65af3ea4d 100644
--- a/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
+++ b/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h
@@ -45,7 +45,7 @@ class ParagraphAttributes : public DebugStringConvertible {
/*
* (Android only) Break strategy for breaking paragraphs into lines.
*/
- TextBreakStrategy textBreakStrategy{};
+ TextBreakStrategy textBreakStrategy{TextBreakStrategy::HighQuality};
/*
* Enables font size adjustment to fit constrained boundaries.
@@ -59,7 +59,8 @@ class ParagraphAttributes : public DebugStringConvertible {
bool includeFontPadding{true};
/*
- * (Android only) Frequency of automatic hyphenation to use when determining word breaks.
+ * (Android only) Frequency of automatic hyphenation to use when determining
+ * word breaks.
*/
HyphenationFrequency android_hyphenationFrequency{};
diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h
index 43c449cdde2d..8e3ed812eef6 100644
--- a/ReactCommon/react/renderer/attributedstring/conversions.h
+++ b/ReactCommon/react/renderer/attributedstring/conversions.h
@@ -96,7 +96,7 @@ inline std::string toString(const TextBreakStrategy &textBreakStrategy) {
LOG(ERROR) << "Unsupported TextBreakStrategy value";
react_native_assert(false);
- return "simple";
+ return "highQuality";
}
inline void fromRawValue(
@@ -116,14 +116,14 @@ inline void fromRawValue(
// sane default
LOG(ERROR) << "Unsupported TextBreakStrategy value: " << string;
react_native_assert(false);
- result = TextBreakStrategy::Simple;
+ result = TextBreakStrategy::HighQuality;
}
return;
}
LOG(ERROR) << "Unsupported TextBreakStrategy type";
react_native_assert(false);
- result = TextBreakStrategy::Simple;
+ result = TextBreakStrategy::HighQuality;
}
inline void fromRawValue(
diff --git a/ReactCommon/react/renderer/attributedstring/primitives.h b/ReactCommon/react/renderer/attributedstring/primitives.h
index 49c14ea0637e..d4be52366132 100644
--- a/ReactCommon/react/renderer/attributedstring/primitives.h
+++ b/ReactCommon/react/renderer/attributedstring/primitives.h
@@ -55,8 +55,8 @@ enum class EllipsizeMode {
enum class TextBreakStrategy {
Simple, // Simple strategy.
- Balanced, // Balances line lengths.
- HighQuality // High-quality strategy, including hyphenation.
+ HighQuality, // High-quality strategy, including hyphenation.
+ Balanced // Balances line lengths.
};
enum class TextAlignment {
From 4c258a64190f375e503281b3ceb93bac8c43196f Mon Sep 17 00:00:00 2001
From: Thibault Malbranche
Date: Fri, 27 Aug 2021 06:40:32 -0700
Subject: [PATCH 030/986] fix(deps): deduplicated metro deps (#31885)
Summary:
Following recent metro bumps, the lockfile got a bit dirty so I cleaned it
Changelog:
[Internal] [Fixed] - Bump metro / cleaned lockfile to 0.66.2
Pull Request resolved: https://github.com/facebook/react-native/pull/31885
Reviewed By: ShikaSD
Differential Revision: D29814753
Pulled By: sshic
fbshipit-source-id: 462bbcb0304b051800bb7a9a79bdb317fe3f3e87
---
repo-config/package.json | 2 +-
yarn.lock | 19 ++++---------------
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/repo-config/package.json b/repo-config/package.json
index e092222641ef..164f952a2f89 100644
--- a/repo-config/package.json
+++ b/repo-config/package.json
@@ -40,7 +40,7 @@
"jest": "^26.6.3",
"jest-junit": "^10.0.0",
"jscodeshift": "^0.11.0",
- "metro-transform-plugins": "^0.66.0",
+ "metro-transform-plugins": "^0.66.2",
"mkdirp": "^0.5.1",
"prettier": "1.19.1",
"react": "17.0.2",
diff --git a/yarn.lock b/yarn.lock
index f0b97204e201..4b2c41b54f09 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -14,7 +14,7 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.14.0.tgz#a901128bce2ad02565df95e6ecbf195cf9465919"
integrity sha512-vu9V3uMM/1o5Hl5OekMUowo3FqXLJSw+s+66nt0fSWVWTtmosdzn45JHOB3cPtZoe6CTBDzvSw0RdOY85Q37+Q==
-"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.14.0", "@babel/core@^7.4.5", "@babel/core@^7.7.5":
+"@babel/core@^7.1.0", "@babel/core@^7.1.6", "@babel/core@^7.14.0", "@babel/core@^7.4.5", "@babel/core@^7.7.5":
version "7.14.0"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.14.0.tgz#47299ff3ec8d111b493f1a9d04bf88c04e728d88"
integrity sha512-8YqpRig5NmIHlMLw09zMlPTvUVMILjqCOtVgu+TVNWEBvy9b5I3RRyhqnrV4hjgEK7n8P9OqvkWJAFmEL6Wwfw==
@@ -35,7 +35,7 @@
semver "^6.3.0"
source-map "^0.5.0"
-"@babel/generator@^7.14.0", "@babel/generator@^7.5.0":
+"@babel/generator@^7.14.0":
version "7.14.1"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.14.1.tgz#1f99331babd65700183628da186f36f63d615c93"
integrity sha512-TMGhsXMXCP/O1WtQmZjpEYDhCYC9vFhayWZPJSZCGkPJgUqX0rF0wwtrYvnzVxIjcF80tkUertXVk5cwqi5cAQ==
@@ -703,7 +703,7 @@
"@babel/parser" "^7.12.13"
"@babel/types" "^7.12.13"
-"@babel/traverse@^7.0.0", "@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.14.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.7.4":
+"@babel/traverse@^7.1.0", "@babel/traverse@^7.13.0", "@babel/traverse@^7.14.0", "@babel/traverse@^7.7.0", "@babel/traverse@^7.7.4":
version "7.14.0"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.14.0.tgz#cea0dc8ae7e2b1dec65f512f39f3483e8cc95aef"
integrity sha512-dZ/a371EE5XNhTHomvtuLTUyx6UEoJmYX+DT5zBCQN3McHemsuIaKKYqsc/fs26BEkHs/lBZy0J571LP5z9kQA==
@@ -4710,7 +4710,7 @@ metro-symbolicate@0.66.2:
through2 "^2.0.1"
vlq "^1.0.0"
-metro-transform-plugins@0.66.2:
+metro-transform-plugins@0.66.2, metro-transform-plugins@^0.66.2:
version "0.66.2"
resolved "https://registry.yarnpkg.com/metro-transform-plugins/-/metro-transform-plugins-0.66.2.tgz#39dd044a23b1343e4f2d2ec34d08128cdf255ed4"
integrity sha512-KTvqplh0ut7oDKovvDG6yzXM02R6X+9b2oVG+qYq8Zd3aCGTi51ASx4ThCNkAHyEvCuJdYg9fxXTL+j+wvhB5w==
@@ -4721,17 +4721,6 @@ metro-transform-plugins@0.66.2:
"@babel/traverse" "^7.14.0"
nullthrows "^1.1.1"
-metro-transform-plugins@^0.66.0:
- version "0.66.0"
- resolved "https://registry.yarnpkg.com/metro-transform-plugins/-/metro-transform-plugins-0.66.0.tgz#d40cb1a88110b0033b5a870c497ce56a38ec5b1f"
- integrity sha512-0jF27jozp4IYuzliM2R7NaXqbPXleiHQWVczECkHg3UjDroCKneCkkgeSeirVZ1TkBqu7KSLMiWdL2OOT+vVxQ==
- dependencies:
- "@babel/core" "^7.0.0"
- "@babel/generator" "^7.5.0"
- "@babel/template" "^7.0.0"
- "@babel/traverse" "^7.0.0"
- nullthrows "^1.1.1"
-
metro-transform-worker@0.66.2:
version "0.66.2"
resolved "https://registry.yarnpkg.com/metro-transform-worker/-/metro-transform-worker-0.66.2.tgz#0a8455992132c479721accd52c9bd47deb77769e"
From f3e8ea9c2910b33db17001e98b96720b07dce0b3 Mon Sep 17 00:00:00 2001
From: Genki Kondo
Date: Fri, 27 Aug 2021 09:02:26 -0700
Subject: [PATCH 031/986] Use hyphenationFrequency for text measurement
Summary:
Implements the calculation of measurement and position of Text attachments in Android
Changelog: [Internal]
Reviewed By: JoshuaGross
Differential Revision: D30586616
fbshipit-source-id: e9ecc002f03477e3465d746855e1dff2e5f0b321
---
.../react/views/text/TextAttributeProps.java | 21 ++++++++++++-
.../react/views/text/TextLayoutManager.java | 31 +++++++++++++++----
.../text/TextLayoutManagerMapBuffer.java | 30 +++++++++++++++---
.../renderer/attributedstring/conversions.h | 4 +++
4 files changed, 74 insertions(+), 12 deletions(-)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java
index 13311fef41bb..6c93d200e857 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java
@@ -68,9 +68,10 @@ public class TextAttributeProps {
private static final int DEFAULT_TEXT_SHADOW_COLOR = 0x55000000;
private static final int DEFAULT_JUSTIFICATION_MODE =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE;
-
private static final int DEFAULT_BREAK_STRATEGY =
(Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY;
+ private static final int DEFAULT_HYPHENATION_FREQUENCY =
+ (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.HYPHENATION_FREQUENCY_NONE;
protected float mLineHeight = Float.NaN;
protected boolean mIsColorSet = false;
@@ -568,4 +569,22 @@ public static int getTextBreakStrategy(@Nullable String textBreakStrategy) {
}
return androidTextBreakStrategy;
}
+
+ public static int getHyphenationFrequency(@Nullable String hyphenationFrequency) {
+ int androidHyphenationFrequency = DEFAULT_HYPHENATION_FREQUENCY;
+ if (hyphenationFrequency != null) {
+ switch (hyphenationFrequency) {
+ case "none":
+ androidHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NONE;
+ break;
+ case "normal":
+ androidHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_NORMAL;
+ break;
+ default:
+ androidHyphenationFrequency = Layout.HYPHENATION_FREQUENCY_FULL;
+ break;
+ }
+ }
+ return androidHyphenationFrequency;
+ }
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java
index b0715e7d6be1..f31eee22e300 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManager.java
@@ -64,6 +64,7 @@ public class TextLayoutManager {
private static final boolean DEFAULT_INCLUDE_FONT_PADDING = true;
private static final String INCLUDE_FONT_PADDING_KEY = "includeFontPadding";
private static final String TEXT_BREAK_STRATEGY_KEY = "textBreakStrategy";
+ private static final String HYPHENATION_FREQUENCY_KEY = "android_hyphenationFrequency";
private static final String MAXIMUM_NUMBER_OF_LINES_KEY = "maximumNumberOfLines";
private static final LruCache sSpannableCache =
new LruCache<>(spannableCacheSize);
@@ -250,7 +251,8 @@ private static Layout createLayout(
float width,
YogaMeasureMode widthYogaMeasureMode,
boolean includeFontPadding,
- int textBreakStrategy) {
+ int textBreakStrategy,
+ int hyphenationFrequency) {
Layout layout;
int spanLength = text.length();
boolean unconstrainedWidth = widthYogaMeasureMode == YogaMeasureMode.UNDEFINED || width < 0;
@@ -281,10 +283,9 @@ private static Layout createLayout(
.setLineSpacing(0.f, 1.f)
.setIncludePad(includeFontPadding)
.setBreakStrategy(textBreakStrategy)
- .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
+ .setHyphenationFrequency(hyphenationFrequency)
.build();
}
-
} else if (boring != null && (unconstrainedWidth || boring.width <= width)) {
int boringLayoutWidth = boring.width;
if (boring.width < 0) {
@@ -325,7 +326,7 @@ private static Layout createLayout(
.setLineSpacing(0.f, 1.f)
.setIncludePad(includeFontPadding)
.setBreakStrategy(textBreakStrategy)
- .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
+ .setHyphenationFrequency(hyphenationFrequency);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
builder.setUseLineSpacingFromFallbacks(true);
@@ -378,6 +379,9 @@ public static long measureText(
paragraphAttributes.hasKey(INCLUDE_FONT_PADDING_KEY)
? paragraphAttributes.getBoolean(INCLUDE_FONT_PADDING_KEY)
: DEFAULT_INCLUDE_FONT_PADDING;
+ int hyphenationFrequency =
+ TextAttributeProps.getHyphenationFrequency(
+ paragraphAttributes.getString(HYPHENATION_FREQUENCY_KEY));
if (text == null) {
throw new IllegalStateException("Spannable element has not been prepared in onBeforeLayout");
@@ -387,7 +391,13 @@ public static long measureText(
Layout layout =
createLayout(
- text, boring, width, widthYogaMeasureMode, includeFontPadding, textBreakStrategy);
+ text,
+ boring,
+ width,
+ widthYogaMeasureMode,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency);
int maximumNumberOfLines =
paragraphAttributes.hasKey(MAXIMUM_NUMBER_OF_LINES_KEY)
@@ -539,10 +549,19 @@ public static WritableArray measureLines(
paragraphAttributes.hasKey(INCLUDE_FONT_PADDING_KEY)
? paragraphAttributes.getBoolean(INCLUDE_FONT_PADDING_KEY)
: DEFAULT_INCLUDE_FONT_PADDING;
+ int hyphenationFrequency =
+ TextAttributeProps.getTextBreakStrategy(
+ paragraphAttributes.getString(HYPHENATION_FREQUENCY_KEY));
Layout layout =
createLayout(
- text, boring, width, YogaMeasureMode.EXACTLY, includeFontPadding, textBreakStrategy);
+ text,
+ boring,
+ width,
+ YogaMeasureMode.EXACTLY,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency);
return FontMetricsUtil.getFontMetrics(text, layout, sTextPaintInstance, context);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java
index 1e5287708a0c..ee86e49d97e4 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextLayoutManagerMapBuffer.java
@@ -61,6 +61,7 @@ public class TextLayoutManagerMapBuffer {
public static final short PA_KEY_TEXT_BREAK_STRATEGY = 2;
public static final short PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3;
public static final short PA_KEY_INCLUDE_FONT_PADDING = 4;
+ public static final short PA_KEY_HYPHENATION_FREQUENCY = 5;
private static final boolean ENABLE_MEASURE_LOGGING = ReactBuildConfig.DEBUG && false;
@@ -264,7 +265,8 @@ private static Layout createLayout(
float width,
YogaMeasureMode widthYogaMeasureMode,
boolean includeFontPadding,
- int textBreakStrategy) {
+ int textBreakStrategy,
+ int hyphenationFrequency) {
Layout layout;
int spanLength = text.length();
boolean unconstrainedWidth = widthYogaMeasureMode == YogaMeasureMode.UNDEFINED || width < 0;
@@ -295,7 +297,7 @@ private static Layout createLayout(
.setLineSpacing(0.f, 1.f)
.setIncludePad(includeFontPadding)
.setBreakStrategy(textBreakStrategy)
- .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
+ .setHyphenationFrequency(hyphenationFrequency)
.build();
}
@@ -338,7 +340,7 @@ private static Layout createLayout(
.setLineSpacing(0.f, 1.f)
.setIncludePad(includeFontPadding)
.setBreakStrategy(textBreakStrategy)
- .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL);
+ .setHyphenationFrequency(hyphenationFrequency);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
builder.setUseLineSpacingFromFallbacks(true);
@@ -391,6 +393,9 @@ public static long measureText(
paragraphAttributes.hasKey(PA_KEY_INCLUDE_FONT_PADDING)
? paragraphAttributes.getBoolean(PA_KEY_INCLUDE_FONT_PADDING)
: DEFAULT_INCLUDE_FONT_PADDING;
+ int hyphenationFrequency =
+ TextAttributeProps.getTextBreakStrategy(
+ paragraphAttributes.getString(PA_KEY_HYPHENATION_FREQUENCY));
if (text == null) {
throw new IllegalStateException("Spannable element has not been prepared in onBeforeLayout");
@@ -404,7 +409,13 @@ public static long measureText(
Layout layout =
createLayout(
- text, boring, width, widthYogaMeasureMode, includeFontPadding, textBreakStrategy);
+ text,
+ boring,
+ width,
+ widthYogaMeasureMode,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency);
int maximumNumberOfLines =
paragraphAttributes.hasKey(PA_KEY_MAX_NUMBER_OF_LINES)
@@ -561,10 +572,19 @@ public static WritableArray measureLines(
paragraphAttributes.hasKey(PA_KEY_INCLUDE_FONT_PADDING)
? paragraphAttributes.getBoolean(PA_KEY_INCLUDE_FONT_PADDING)
: DEFAULT_INCLUDE_FONT_PADDING;
+ int hyphenationFrequency =
+ TextAttributeProps.getTextBreakStrategy(
+ paragraphAttributes.getString(PA_KEY_HYPHENATION_FREQUENCY));
Layout layout =
createLayout(
- text, boring, width, YogaMeasureMode.EXACTLY, includeFontPadding, textBreakStrategy);
+ text,
+ boring,
+ width,
+ YogaMeasureMode.EXACTLY,
+ includeFontPadding,
+ textBreakStrategy,
+ hyphenationFrequency);
return FontMetricsUtil.getFontMetrics(text, layout, sTextPaintInstance, context);
}
diff --git a/ReactCommon/react/renderer/attributedstring/conversions.h b/ReactCommon/react/renderer/attributedstring/conversions.h
index 8e3ed812eef6..56ab6bdef943 100644
--- a/ReactCommon/react/renderer/attributedstring/conversions.h
+++ b/ReactCommon/react/renderer/attributedstring/conversions.h
@@ -1044,6 +1044,7 @@ constexpr static Key PA_KEY_ELLIPSIZE_MODE = 1;
constexpr static Key PA_KEY_TEXT_BREAK_STRATEGY = 2;
constexpr static Key PA_KEY_ADJUST_FONT_SIZE_TO_FIT = 3;
constexpr static Key PA_KEY_INCLUDE_FONT_PADDING = 4;
+constexpr static Key PA_KEY_HYPHENATION_FREQUENCY = 5;
inline MapBuffer toMapBuffer(const ParagraphAttributes ¶graphAttributes) {
auto builder = MapBufferBuilder();
@@ -1058,6 +1059,9 @@ inline MapBuffer toMapBuffer(const ParagraphAttributes ¶graphAttributes) {
PA_KEY_ADJUST_FONT_SIZE_TO_FIT, paragraphAttributes.adjustsFontSizeToFit);
builder.putBool(
PA_KEY_INCLUDE_FONT_PADDING, paragraphAttributes.includeFontPadding);
+ builder.putString(
+ PA_KEY_HYPHENATION_FREQUENCY,
+ toString(paragraphAttributes.android_hyphenationFrequency));
return builder.build();
}
From 1bc885b8b856c7a050f0df68d9a09ca7581d0220 Mon Sep 17 00:00:00 2001
From: Neil Dhar
Date: Fri, 27 Aug 2021 17:15:23 -0700
Subject: [PATCH 032/986] Make JSI a dynamic library
Summary:
Ship libjsi as a standalone dynamic library. This prevents problems
with exception handling caused by duplicate typeinfo across multiple
shared libs, and reduces bundle size by removing duplicate copies of
JSI.
Changelog: [Internal]
Reviewed By: fkgozali
Differential Revision: D30599215
fbshipit-source-id: abad1398342a5328daa825f3f684e0067cad7a96
---
ReactAndroid/Android-prebuilt.mk | 8 +++++++
.../hermes/instrumentation/Android.mk | 4 ++--
.../facebook/hermes/reactexecutor/Android.mk | 8 +++----
.../com/facebook/react/fabric/jni/Android.mk | 2 +-
.../com/facebook/react/jscexecutor/Android.mk | 4 ++--
.../react/modules/blob/jni/Android.mk | 4 ++--
ReactCommon/hermes/executor/Android.mk | 8 +++----
ReactCommon/hermes/inspector/Android.mk | 3 +--
ReactCommon/jsi/Android.mk | 2 +-
ReactCommon/jsiexecutor/Android.mk | 4 ++--
.../react/nativemodule/core/Android.mk | 4 ++--
.../samples/platform/android/Android.mk | 2 +-
.../renderer/components/image/Android.mk | 2 +-
.../renderer/components/scrollview/Android.mk | 2 +-
.../react/renderer/components/text/Android.mk | 2 +-
.../renderer/components/textinput/Android.mk | 2 +-
.../components/unimplementedview/Android.mk | 2 +-
.../react/renderer/components/view/Android.mk | 2 +-
ReactCommon/react/renderer/core/Android.mk | 2 +-
.../react/renderer/mounting/Android.mk | 2 +-
.../renderer/runtimescheduler/Android.mk | 2 +-
.../generators/modules/GenerateModuleJniH.js | 4 +---
.../GenerateModuleJniH-test.js.snap | 24 +++++--------------
yarn.lock | 6 ++---
24 files changed, 49 insertions(+), 56 deletions(-)
diff --git a/ReactAndroid/Android-prebuilt.mk b/ReactAndroid/Android-prebuilt.mk
index fa41a5594e0b..18f8c2662045 100644
--- a/ReactAndroid/Android-prebuilt.mk
+++ b/ReactAndroid/Android-prebuilt.mk
@@ -156,6 +156,14 @@ LOCAL_EXPORT_C_INCLUDES := \
$(REACT_COMMON_DIR)/react/renderer/components/view
include $(PREBUILT_SHARED_LIBRARY)
+# jsi
+include $(CLEAR_VARS)
+LOCAL_MODULE := jsi
+LOCAL_SRC_FILES := $(REACT_NDK_EXPORT_DIR)/$(TARGET_ARCH_ABI)/libjsi.so
+LOCAL_EXPORT_C_INCLUDES := \
+ $(REACT_COMMON_DIR)/jsi
+include $(PREBUILT_SHARED_LIBRARY)
+
# react_codegen_rncore
include $(CLEAR_VARS)
LOCAL_MODULE := react_codegen_rncore
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk
index 3548e86abd3c..651168243ef0 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/Android.mk
@@ -18,8 +18,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
LOCAL_CPP_FEATURES := exceptions
-LOCAL_STATIC_LIBRARIES := libjsireact libjsi
-LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes
+LOCAL_STATIC_LIBRARIES := libjsireact
+LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes libjsi
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk
index ff05e4c14824..7716394c31f7 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk
@@ -17,8 +17,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
LOCAL_CPP_FEATURES := exceptions
-LOCAL_STATIC_LIBRARIES := libjsireact libjsi libhermes-executor-common-release
-LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes
+LOCAL_STATIC_LIBRARIES := libjsireact libhermes-executor-common-release
+LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes libjsi
include $(BUILD_SHARED_LIBRARY)
@@ -34,7 +34,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-no
LOCAL_CPP_FEATURES := exceptions
-LOCAL_STATIC_LIBRARIES := libjsireact libjsi libhermes-executor-common-debug libhermes-inspector
-LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes
+LOCAL_STATIC_LIBRARIES := libjsireact libhermes-executor-common-debug libhermes-inspector
+LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libhermes libjsi
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk
index 827112595cef..2ad53b97cc2c 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk
+++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Android.mk
@@ -11,7 +11,7 @@ LOCAL_MODULE := fabricjni
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
-LOCAL_SHARED_LIBRARIES := libreactconfig librrc_slider librrc_progressbar librrc_switch librrc_modal libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core react_render_componentregistry librrc_view librrc_unimplementedview librrc_root librrc_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libreact_codegen_rncore rrc_text librrc_image librrc_textinput libreact_debug libreact_render_mapbuffer libmapbufferjni libreact_render_telemetry
+LOCAL_SHARED_LIBRARIES := libjsi libreactconfig librrc_slider librrc_progressbar librrc_switch librrc_modal libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures libreact_render_mounting libreactnativeutilsjni libreact_utils libreact_render_debug libreact_render_graphics libreact_render_core react_render_componentregistry librrc_view librrc_unimplementedview librrc_root librrc_scrollview libbetter libreact_render_attributedstring libreact_render_uimanager libreact_render_templateprocessor libreact_render_scheduler libreact_render_animations libreact_render_imagemanager libreact_render_textlayoutmanager libreact_codegen_rncore rrc_text librrc_image librrc_textinput libreact_debug libreact_render_mapbuffer libmapbufferjni libreact_render_telemetry
LOCAL_STATIC_LIBRARIES :=
diff --git a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk
index c521147677c1..19a28eee5af2 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk
+++ b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/Android.mk
@@ -15,7 +15,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti
-LOCAL_STATIC_LIBRARIES := libjsi libjsireact jscruntime
-LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni
+LOCAL_STATIC_LIBRARIES := libjsireact jscruntime
+LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libjsi
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk
index 53fb0c2bf557..6c5a7224c78a 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk
+++ b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/Android.mk
@@ -15,7 +15,7 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS += -fvisibility=hidden -fexceptions -frtti
-LOCAL_STATIC_LIBRARIES := libjsi libjsireact
-LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni
+LOCAL_STATIC_LIBRARIES := libjsireact
+LOCAL_SHARED_LIBRARIES := libfolly_json libfb libfbjni libreactnativejni libjsi
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/hermes/executor/Android.mk b/ReactCommon/hermes/executor/Android.mk
index 491100c33a99..52b4d25085f7 100644
--- a/ReactCommon/hermes/executor/Android.mk
+++ b/ReactCommon/hermes/executor/Android.mk
@@ -16,8 +16,8 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-node-module,$(LOCAL_PATH),hermes-engine)/android/include
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_STATIC_LIBRARIES := libjsi libjsireact
-LOCAL_SHARED_LIBRARIES := libhermes
+LOCAL_STATIC_LIBRARIES := libjsireact
+LOCAL_SHARED_LIBRARIES := libhermes libjsi
include $(BUILD_SHARED_LIBRARY)
@@ -31,7 +31,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(REACT_NATIVE)/ReactCommon/jsi $(call find-node-module,$(LOCAL_PATH),hermes-engine)/android/include
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_STATIC_LIBRARIES := libjsi libjsireact libhermes-inspector
-LOCAL_SHARED_LIBRARIES := libhermes
+LOCAL_STATIC_LIBRARIES := libjsireact libhermes-inspector
+LOCAL_SHARED_LIBRARIES := libhermes libjsi
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/hermes/inspector/Android.mk b/ReactCommon/hermes/inspector/Android.mk
index a6692943e17d..461b10aaac33 100644
--- a/ReactCommon/hermes/inspector/Android.mk
+++ b/ReactCommon/hermes/inspector/Android.mk
@@ -21,7 +21,6 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_ROOT)
LOCAL_CPP_FEATURES := exceptions
-LOCAL_STATIC_LIBRARIES := libjsi
-LOCAL_SHARED_LIBRARIES := jsinspector libfb libfbjni libfolly_futures libfolly_json libhermes
+LOCAL_SHARED_LIBRARIES := jsinspector libfb libfbjni libfolly_futures libfolly_json libhermes libjsi libglog
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/jsi/Android.mk b/ReactCommon/jsi/Android.mk
index 6bc98f1b35fc..3fce2059e2d7 100644
--- a/ReactCommon/jsi/Android.mk
+++ b/ReactCommon/jsi/Android.mk
@@ -17,7 +17,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS := -fexceptions -frtti -O3
LOCAL_SHARED_LIBRARIES := libfolly_json glog
-include $(BUILD_STATIC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
diff --git a/ReactCommon/jsiexecutor/Android.mk b/ReactCommon/jsiexecutor/Android.mk
index 74ae7a65cef2..e0661538e666 100644
--- a/ReactCommon/jsiexecutor/Android.mk
+++ b/ReactCommon/jsiexecutor/Android.mk
@@ -16,7 +16,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_CFLAGS := -fexceptions -frtti -O3
-LOCAL_STATIC_LIBRARIES := libjsi reactnative reactperflogger
-LOCAL_SHARED_LIBRARIES := libfolly_json glog
+LOCAL_STATIC_LIBRARIES := reactnative reactperflogger
+LOCAL_SHARED_LIBRARIES := libfolly_json glog libjsi
include $(BUILD_STATIC_LIBRARY)
diff --git a/ReactCommon/react/nativemodule/core/Android.mk b/ReactCommon/react/nativemodule/core/Android.mk
index 9fbfdb4759d5..bb2a0d79c774 100644
--- a/ReactCommon/react/nativemodule/core/Android.mk
+++ b/ReactCommon/react/nativemodule/core/Android.mk
@@ -15,9 +15,9 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp) $(wildcard $(LOCA
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/platform/android/
-LOCAL_SHARED_LIBRARIES := libfbjni libfolly_json libreactnativejni libreact_debug
+LOCAL_SHARED_LIBRARIES := libfbjni libfolly_json libreactnativejni libreact_debug libjsi
-LOCAL_STATIC_LIBRARIES := libjsi libreactperflogger
+LOCAL_STATIC_LIBRARIES := libreactperflogger
LOCAL_CFLAGS := \
-DLOG_TAG=\"ReactNative\"
diff --git a/ReactCommon/react/nativemodule/samples/platform/android/Android.mk b/ReactCommon/react/nativemodule/samples/platform/android/Android.mk
index 9694d7a07380..a000332e34c3 100644
--- a/ReactCommon/react/nativemodule/samples/platform/android/Android.mk
+++ b/ReactCommon/react/nativemodule/samples/platform/android/Android.mk
@@ -10,7 +10,7 @@ LOCAL_MODULE := sampleturbomodule
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/ReactCommon/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
-LOCAL_SHARED_LIBRARIES := libfbjni libreact_nativemodule_core
+LOCAL_SHARED_LIBRARIES := libfbjni libreact_nativemodule_core libjsi
LOCAL_CFLAGS := \
-DLOG_TAG=\"ReactNative\"
LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
diff --git a/ReactCommon/react/renderer/components/image/Android.mk b/ReactCommon/react/renderer/components/image/Android.mk
index 1d7fdcc85bae..8c3fbcabda9c 100644
--- a/ReactCommon/react/renderer/components/image/Android.mk
+++ b/ReactCommon/react/renderer/components/image/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_render_imagemanager libreact_debug libreact_render_mapbuffer
+LOCAL_SHARED_LIBRARIES := libjsi libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_render_imagemanager libreact_debug libreact_render_mapbuffer
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/components/scrollview/Android.mk b/ReactCommon/react/renderer/components/scrollview/Android.mk
index a0bbbf75425d..9b02ae73f042 100644
--- a/ReactCommon/react/renderer/components/scrollview/Android.mk
+++ b/ReactCommon/react/renderer/components/scrollview/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug libreact_render_mapbuffer
+LOCAL_SHARED_LIBRARIES := libjsi libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug libreact_render_mapbuffer
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/components/text/Android.mk b/ReactCommon/react/renderer/components/text/Android.mk
index 4e082f6dd991..33bfdb78a963 100644
--- a/ReactCommon/react/renderer/components/text/Android.mk
+++ b/ReactCommon/react/renderer/components/text/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_textlayoutmanager libreact_render_attributedstring libreact_render_mounting librrc_view libreact_utils libreact_debug libreact_render_mapbuffer
+LOCAL_SHARED_LIBRARIES := libjsi libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_textlayoutmanager libreact_render_attributedstring libreact_render_mounting librrc_view libreact_utils libreact_debug libreact_render_mapbuffer
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/components/textinput/Android.mk b/ReactCommon/react/renderer/components/textinput/Android.mk
index 70e44891ddfb..c45affab7b9b 100644
--- a/ReactCommon/react/renderer/components/textinput/Android.mk
+++ b/ReactCommon/react/renderer/components/textinput/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_mounting libreact_render_componentregistry libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_imagemanager libreact_render_textlayoutmanager libreact_render_attributedstring librrc_text librrc_image librrc_view libreact_utils libreact_debug libreact_render_mapbuffer
+LOCAL_SHARED_LIBRARIES := libjsi libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_mounting libreact_render_componentregistry libreact_render_debug libreact_render_graphics libreact_render_uimanager libreact_render_imagemanager libreact_render_textlayoutmanager libreact_render_attributedstring librrc_text librrc_image librrc_view libreact_utils libreact_debug libreact_render_mapbuffer
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/components/unimplementedview/Android.mk b/ReactCommon/react/renderer/components/unimplementedview/Android.mk
index f533321b94d2..959500fb70d1 100644
--- a/ReactCommon/react/renderer/components/unimplementedview/Android.mk
+++ b/ReactCommon/react/renderer/components/unimplementedview/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug
+LOCAL_SHARED_LIBRARIES := libjsi libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics librrc_view libreact_debug
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/components/view/Android.mk b/ReactCommon/react/renderer/components/view/Android.mk
index 877f17bd1c84..1e05d18f6b02 100644
--- a/ReactCommon/react/renderer/components/view/Android.mk
+++ b/ReactCommon/react/renderer/components/view/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_debug logger
+LOCAL_SHARED_LIBRARIES := libyoga glog libfolly_json libglog_init libreact_render_core libreact_render_debug libreact_render_graphics libreact_debug logger libjsi
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/core/Android.mk b/ReactCommon/react/renderer/core/Android.mk
index 9ae13e652c01..32a8ddf5efe2 100644
--- a/ReactCommon/react/renderer/core/Android.mk
+++ b/ReactCommon/react/renderer/core/Android.mk
@@ -15,7 +15,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../
-LOCAL_SHARED_LIBRARIES := libfolly_json libjsi libfolly_futures libreact_utils libreact_debug libreact_render_debug libreact_render_graphics
+LOCAL_SHARED_LIBRARIES := libfolly_json libjsi libfolly_futures libreact_utils libreact_debug libreact_render_debug libreact_render_graphics libglog
LOCAL_CFLAGS := \
-DLOG_TAG=\"Fabric\"
diff --git a/ReactCommon/react/renderer/mounting/Android.mk b/ReactCommon/react/renderer/mounting/Android.mk
index d8a4360c17ed..f1383e722e4e 100644
--- a/ReactCommon/react/renderer/mounting/Android.mk
+++ b/ReactCommon/react/renderer/mounting/Android.mk
@@ -21,7 +21,7 @@ LOCAL_CFLAGS += -fexceptions -frtti -std=c++17 -Wall
LOCAL_STATIC_LIBRARIES :=
-LOCAL_SHARED_LIBRARIES := libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug libreact_render_telemetry
+LOCAL_SHARED_LIBRARIES := libjsi libbetter libyoga libfolly_futures glog libfolly_json libglog_init libreact_render_core libreact_render_debug librrc_view librrc_root libreact_utils libreact_debug libreact_render_telemetry
include $(BUILD_SHARED_LIBRARY)
diff --git a/ReactCommon/react/renderer/runtimescheduler/Android.mk b/ReactCommon/react/renderer/runtimescheduler/Android.mk
index 2e81b329eab5..010cced3849e 100644
--- a/ReactCommon/react/renderer/runtimescheduler/Android.mk
+++ b/ReactCommon/react/renderer/runtimescheduler/Android.mk
@@ -15,7 +15,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../../
-LOCAL_SHARED_LIBRARIES := libruntimeexecutor libreact_render_core libreact_debug
+LOCAL_SHARED_LIBRARIES := libruntimeexecutor libreact_render_core libreact_debug libjsi
LOCAL_CFLAGS := \
-DLOG_TAG=\"Fabric\"
diff --git a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js
index 4298a8d16d37..a893fea829f1 100644
--- a/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js
+++ b/packages/react-native-codegen/src/generators/modules/GenerateModuleJniH.js
@@ -80,9 +80,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/${libraryName}
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\
-DLOG_TAG=\\"ReactNative\\"
diff --git a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap
index 6bb1b8b9a948..5f68533849b1 100644
--- a/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap
+++ b/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleJniH-test.js.snap
@@ -52,9 +52,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/complex_objects
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\\\
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
@@ -118,9 +116,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/empty_native_modules
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\\\
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
@@ -184,9 +180,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/native_modules_with_type_aliases
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\\\
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
@@ -258,9 +252,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/real_module_example
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\\\
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
@@ -324,9 +316,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/simple_native_modules
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\\\
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
@@ -398,9 +388,7 @@ LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp) $(wildcard $(LOCAL_PATH)/reac
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/react/renderer/components/two_modules_different_files
-LOCAL_SHARED_LIBRARIES := libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
-
-LOCAL_STATIC_LIBRARIES := libjsi
+LOCAL_SHARED_LIBRARIES := libjsi libglog libfolly_json libyoga libreact_nativemodule_core librrc_view libreact_render_core libreact_render_graphics libreact_debug libreact_render_debug
LOCAL_CFLAGS := \\\\
-DLOG_TAG=\\\\\\"ReactNative\\\\\\"
diff --git a/yarn.lock b/yarn.lock
index 4b2c41b54f09..c19efec0b0be 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3298,9 +3298,9 @@ has@^1.0.3:
function-bind "^1.1.1"
hermes-engine@~0.8.0:
- version "0.8.0"
- resolved "https://registry.yarnpkg.com/hermes-engine/-/hermes-engine-0.8.0.tgz#d8e507fbfda66f6bd604f79503b45fded1163296"
- integrity sha512-bFxAnIjE8M3cco1uh4HlHME8qmOsPcVS75bQoo/fM3wUzMYxZBL0s1IfePUO+R9IUKoO+pfIpjV2I9ay8w7mqw==
+ version "0.8.1"
+ resolved "https://registry.yarnpkg.com/hermes-engine/-/hermes-engine-0.8.1.tgz#b6d0d70508ac5add2d198304502fb968cdecb8b2"
+ integrity sha512-as9Iccj/qrqqtDmfYUHbOIjt5xsQbUB6pjNIW3i1+RVr+pCAdz5S8/Jry778mz3rJWplYzHWdR1u1xQSYfBRYw==
hermes-parser@0.4.7:
version "0.4.7"
From 7dc22116b077fcc4dc0eb1bdb4e6376c47a16d85 Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Sat, 28 Aug 2021 06:58:06 -0700
Subject: [PATCH 033/986] Remove RTTI from LayoutAnimations
Summary:
changelog: [internal]
Remote use of dynamic_cast from LayoutAnimations.
Reviewed By: JoshuaGross, cortinico
Differential Revision: D30602864
fbshipit-source-id: ce23f9b4a8b4e28d17d2297d64d8e460a1e03472
---
.../LayoutAnimationKeyFrameManager.cpp | 48 ++++++++-----------
.../renderer/components/view/ViewShadowNode.h | 2 +-
ReactCommon/react/utils/ContextContainer.h | 27 -----------
3 files changed, 21 insertions(+), 56 deletions(-)
diff --git a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp
index 928cd1ced077..2467b5fa7f77 100644
--- a/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp
+++ b/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp
@@ -1093,13 +1093,11 @@ LayoutAnimationKeyFrameManager::pullTransaction(
getComponentDescriptorForShadowView(baselineShadowView)
.cloneProps(propsParserContext, viewStart.props, {});
- // Dynamic cast, because - we don't know the type of this
- // ShadowNode, it could be Image or Text or something else with
- // different base props.
- const auto viewProps =
- dynamic_cast(props.get());
- if (viewProps != nullptr) {
- const_cast(viewProps)->opacity = 0;
+ if (baselineShadowView.traits.check(
+ ShadowNodeTraits::Trait::ViewKind)) {
+ auto const &viewProps =
+ *std::static_pointer_cast(props);
+ const_cast(viewProps).opacity = 0;
}
react_native_assert(props != nullptr);
@@ -1118,13 +1116,11 @@ LayoutAnimationKeyFrameManager::pullTransaction(
getComponentDescriptorForShadowView(baselineShadowView)
.cloneProps(propsParserContext, viewStart.props, {});
- // Dynamic cast, because - we don't know the type of this
- // ShadowNode, it could be Image or Text or something else with
- // different base props.
- const auto viewProps =
- dynamic_cast(props.get());
- if (viewProps != nullptr) {
- const_cast(viewProps)->transform =
+ if (baselineShadowView.traits.check(
+ ShadowNodeTraits::Trait::ViewKind)) {
+ auto const &viewProps =
+ *std::static_pointer_cast(props);
+ const_cast(viewProps).transform =
Transform::Scale(isScaleX ? 0 : 1, isScaleY ? 0 : 1, 1);
}
@@ -1221,13 +1217,11 @@ LayoutAnimationKeyFrameManager::pullTransaction(
getComponentDescriptorForShadowView(baselineShadowView)
.cloneProps(propsParserContext, viewFinal.props, {});
- // Dynamic cast, because - we don't know the type of this
- // ShadowNode, it could be Image or Text or something else with
- // different base props.
- const auto viewProps =
- dynamic_cast(props.get());
- if (viewProps != nullptr) {
- const_cast(viewProps)->opacity = 0;
+ if (baselineShadowView.traits.check(
+ ShadowNodeTraits::Trait::ViewKind)) {
+ auto const &viewProps =
+ *std::static_pointer_cast(props);
+ const_cast(viewProps).opacity = 0;
}
react_native_assert(props != nullptr);
@@ -1248,13 +1242,11 @@ LayoutAnimationKeyFrameManager::pullTransaction(
getComponentDescriptorForShadowView(baselineShadowView)
.cloneProps(propsParserContext, viewFinal.props, {});
- // Dynamic cast, because - we don't know the type of this
- // ShadowNode, it could be Image or Text or something else with
- // different base props.
- const auto viewProps =
- dynamic_cast(props.get());
- if (viewProps != nullptr) {
- const_cast(viewProps)->transform =
+ if (baselineShadowView.traits.check(
+ ShadowNodeTraits::Trait::ViewKind)) {
+ auto const &viewProps =
+ *std::static_pointer_cast(props);
+ const_cast(viewProps).transform =
Transform::Scale(isScaleX ? 0 : 1, isScaleY ? 0 : 1, 1);
}
diff --git a/ReactCommon/react/renderer/components/view/ViewShadowNode.h b/ReactCommon/react/renderer/components/view/ViewShadowNode.h
index 0ccf2116e447..20ccc04d5f45 100644
--- a/ReactCommon/react/renderer/components/view/ViewShadowNode.h
+++ b/ReactCommon/react/renderer/components/view/ViewShadowNode.h
@@ -24,7 +24,7 @@ class ViewShadowNode final : public ConcreteViewShadowNode<
ViewEventEmitter> {
public:
static ShadowNodeTraits BaseTraits() {
- auto traits = BaseShadowNode::BaseTraits();
+ auto traits = ConcreteViewShadowNode::BaseTraits();
traits.set(ShadowNodeTraits::Trait::View);
return traits;
}
diff --git a/ReactCommon/react/utils/ContextContainer.h b/ReactCommon/react/utils/ContextContainer.h
index f0e2613fdb99..1431fe1af831 100644
--- a/ReactCommon/react/utils/ContextContainer.h
+++ b/ReactCommon/react/utils/ContextContainer.h
@@ -45,10 +45,6 @@ class ContextContainer final {
std::unique_lock lock(mutex_);
instances_.insert({key, std::make_shared(instance)});
-
-#ifdef REACT_NATIVE_DEBUG
- typeNames_.insert({key, typeid(T).name()});
-#endif
}
/*
@@ -59,10 +55,6 @@ class ContextContainer final {
std::unique_lock lock(mutex_);
instances_.erase(key);
-
-#ifdef REACT_NATIVE_DEBUG
- typeNames_.erase(key);
-#endif
}
/*
@@ -76,11 +68,6 @@ class ContextContainer final {
for (auto const &pair : contextContainer.instances_) {
instances_.erase(pair.first);
instances_.insert(pair);
-#ifdef REACT_NATIVE_DEBUG
- typeNames_.erase(pair.first);
- typeNames_.insert(
- {pair.first, contextContainer.typeNames_.at(pair.first)});
-#endif
}
}
@@ -96,11 +83,6 @@ class ContextContainer final {
react_native_assert(
instances_.find(key) != instances_.end() &&
"ContextContainer doesn't have an instance for given key.");
-#ifdef REACT_NATIVE_DEBUG
- react_native_assert(
- typeNames_.at(key) == typeid(T).name() &&
- "ContextContainer stores an instance of different type for given key.");
-#endif
return *std::static_pointer_cast(instances_.at(key));
}
@@ -118,12 +100,6 @@ class ContextContainer final {
return {};
}
-#ifdef REACT_NATIVE_DEBUG
- react_native_assert(
- typeNames_.at(key) == typeid(T).name() &&
- "ContextContainer stores an instance of different type for given key.");
-#endif
-
return *std::static_pointer_cast(iterator->second);
}
@@ -131,9 +107,6 @@ class ContextContainer final {
mutable better::shared_mutex mutex_;
// Protected by mutex_`.
mutable better::map> instances_;
-#ifdef REACT_NATIVE_DEBUG
- mutable better::map typeNames_;
-#endif
};
} // namespace react
From b51a99c73cc4fbcbb03c97f92b7f7f166493538f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A9ctor=20Ramos?=
Date: Sat, 28 Aug 2021 11:30:25 -0700
Subject: [PATCH 034/986] rn-demo-app: Implement getModuleInstanceFromClass:
Summary:
While not strictly necessary for rn-demo-app at this point, we do need to provide the `getModuleInstanceFromClass:` implementation to simplify the TurboModule migration process later on.
Also, removed some issues in the Xcode project that must have been introduced during a recent rebase (duplicate Embed Pods build phases).
Changelog: [Internal]
Reviewed By: fkgozali
Differential Revision: D30618992
fbshipit-source-id: a9b496cfa0cd34fca6389ddf829613aa13ea409d
---
packages/rn-tester/RNTester/AppDelegate.mm | 1 +
1 file changed, 1 insertion(+)
diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm
index dc5d65c1cfad..74a8c35dd831 100644
--- a/packages/rn-tester/RNTester/AppDelegate.mm
+++ b/packages/rn-tester/RNTester/AppDelegate.mm
@@ -206,6 +206,7 @@ - (Class)getModuleClassFromName:(const char *)name
- (id)getModuleInstanceFromClass:(Class)moduleClass
{
+ // Set up the default RCTImageLoader and RCTNetworking modules.
if (moduleClass == RCTImageLoader.class) {
return [[moduleClass alloc] initWithRedirectDelegate:nil
loadersProvider:^NSArray> *(RCTModuleRegistry * moduleRegistry) {
From 53c6494615fcc19e555adf7900cd443b88ce562a Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Sun, 29 Aug 2021 09:30:50 -0700
Subject: [PATCH 035/986] Remount children in scrollView if layout changes
Summary: changelog: [internal]
Reviewed By: hramos
Differential Revision: D30603617
fbshipit-source-id: bc189d4a0a997202e6b2cd5314b997395bcdf7b2
---
.../ScrollView/RCTScrollViewComponentView.mm | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
index 885e8636f180..37468a85b11e 100644
--- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
+++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm
@@ -133,6 +133,15 @@ - (void)dealloc
[self.scrollViewDelegateSplitter removeAllDelegates];
}
+- (void)layoutSubviews
+{
+ [super layoutSubviews];
+
+ if (_subviewClippingEnabled) {
+ [self _remountChildren];
+ }
+}
+
- (RCTGenericDelegateSplitter> *)scrollViewDelegateSplitter
{
return ((RCTEnhancedScrollView *)_scrollView).delegateSplitter;
From 19f8d2f7da13f4524f31acf7aa10cc0aa91b5da4 Mon Sep 17 00:00:00 2001
From: luism3861
Date: Mon, 30 Aug 2021 10:16:34 -0700
Subject: [PATCH 036/986] docs: add new version convenant contribuitor guide
link (#32107)
Summary:
## Summary
this PR update available link version in Contributor Covenant.!
cc: yungsters
Changelog:
[General][Changed] Updated to Contributor Covenant v2.1
Pull Request resolved: https://github.com/facebook/react-native/pull/32107
Reviewed By: lunaleaps
Differential Revision: D30616702
Pulled By: yungsters
fbshipit-source-id: b79b07cfa14154fbe948e7bb4d6698925be2cdd4
---
CODE_OF_CONDUCT.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index d1abc700d28d..3a44dc2513d1 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -67,8 +67,8 @@ members of the project's leadership.
## Attribution
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1,
+available at https://www.contributor-covenant.org/version/2/1/code_of_conduct/
[homepage]: https://www.contributor-covenant.org
From de1a72acaeea45f5ea9c717b64b193879b4bc628 Mon Sep 17 00:00:00 2001
From: Daiki Ihara
Date: Mon, 30 Aug 2021 16:31:04 -0700
Subject: [PATCH 037/986] move prettier to peerDeps in
eslint-config-react-native-community (#28637)
Summary:
In monorepo environment, prettier-plugin in some editor load from nearest `node_modules`. Older version of eslint-config-react-native-community includes prettier v1 in their dependencies. It cause conflict of code style inside the monorepo.
## Changelog
[Internal] [Fixed] - move prettier to peerDependencies in eslint-config-react-native-community
Pull Request resolved: https://github.com/facebook/react-native/pull/28637
Test Plan: I think it would be good with no plan to test.
Reviewed By: yungsters
Differential Revision: D30648134
Pulled By: charlesbdudley
fbshipit-source-id: 6c01226d6e4cc37ddbc86be260563deb093758d0
---
packages/eslint-config-react-native-community/package.json | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/packages/eslint-config-react-native-community/package.json b/packages/eslint-config-react-native-community/package.json
index ef00ef62dff9..5c59f9ead21b 100644
--- a/packages/eslint-config-react-native-community/package.json
+++ b/packages/eslint-config-react-native-community/package.json
@@ -26,9 +26,11 @@
"prettier": "^2.0.2"
},
"peerDependencies": {
- "eslint": ">=7"
+ "eslint": ">=7",
+ "prettier": ">=2"
},
"devDependencies": {
- "eslint": "7.12.0"
+ "eslint": "7.12.0",
+ "prettier": "^2.3.2"
}
}
From 49b3b31d8e706338dac4ced1b372424d7d1d133f Mon Sep 17 00:00:00 2001
From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com>
Date: Mon, 30 Aug 2021 18:02:02 -0700
Subject: [PATCH 038/986] Native component check in deprecatedPropType was
inverted (#31164)
Summary:
While investigating an issue hit on a recent sync of [react-native-windows](https://github.com/microsoft/react-native-windows) I noticed that https://github.com/facebook/react-native/commit/e68cf7cee9d36271a1d3899fecff817304bb8bdc appears to have accidently inverted the logic to avoid checking native components.
`!UIManager.getViewManagerConfig(componentName)`
become
`UIManager.hasViewManagerConfig(componentName)`
losing the !
Also adding a check in PaperUIManager's getViewManagerConfig to avoid trying to call a sync method when using Chrome Debugging.
## Changelog
[Internal] [Fixed] - Restored the previous logic of deprecatedPropType
Pull Request resolved: https://github.com/facebook/react-native/pull/31164
Test Plan:
Change tested and being submitted in react-native-windows:
https://github.com/microsoft/react-native-windows/pull/7397
Reviewed By: hramos
Differential Revision: D30624302
Pulled By: fkgozali
fbshipit-source-id: 0f26e750283a1fa5eb5f44ecd2cf90617b6d931f
---
Libraries/ReactNative/PaperUIManager.js | 1 +
Libraries/Utilities/deprecatedPropType.js | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/Libraries/ReactNative/PaperUIManager.js b/Libraries/ReactNative/PaperUIManager.js
index c468958e5663..87cc101db310 100644
--- a/Libraries/ReactNative/PaperUIManager.js
+++ b/Libraries/ReactNative/PaperUIManager.js
@@ -34,6 +34,7 @@ function getConstants(): Object {
function getViewManagerConfig(viewManagerName: string): any {
if (
viewManagerConfigs[viewManagerName] === undefined &&
+ global.nativeCallSyncHook && // If we're in the Chrome Debugger, let's not even try calling the sync method
NativeUIManager.getConstantsForViewManager
) {
try {
diff --git a/Libraries/Utilities/deprecatedPropType.js b/Libraries/Utilities/deprecatedPropType.js
index 1801f98cb1c2..0a0fc69aab2a 100644
--- a/Libraries/Utilities/deprecatedPropType.js
+++ b/Libraries/Utilities/deprecatedPropType.js
@@ -21,7 +21,7 @@ function deprecatedPropType(
// Don't warn for native components.
if (
global.RN$Bridgeless !== true &&
- UIManager.hasViewManagerConfig(componentName) &&
+ !UIManager.hasViewManagerConfig(componentName) &&
props[propName] !== undefined
) {
console.warn(
From cbe0e6bf27c0dddfdba627f66c4b8db69c534743 Mon Sep 17 00:00:00 2001
From: Joshua Gross
Date: Mon, 30 Aug 2021 20:02:00 -0700
Subject: [PATCH 039/986] Pass nativeTimestamp into
PressabilityPerformanceEvent
Summary:
Pass nativeTimestamp into PressabilityPerformanceEvent as a way to uniquely identify events.
Changelog: [Internal]
Differential Revision: D30648544
fbshipit-source-id: 7cb0146f6ff1655f1312e5094535e59268fb2a22
---
Libraries/Pressability/Pressability.js | 1 +
Libraries/Pressability/PressabilityPerformanceEventEmitter.js | 1 +
2 files changed, 2 insertions(+)
diff --git a/Libraries/Pressability/Pressability.js b/Libraries/Pressability/Pressability.js
index 9ffab69aa01c..2c43fe6cd1fa 100644
--- a/Libraries/Pressability/Pressability.js
+++ b/Libraries/Pressability/Pressability.js
@@ -631,6 +631,7 @@ export default class Pressability {
PressabilityPerformanceEventEmitter.emitEvent(() => {
return {
signal,
+ nativeTimestamp: event.nativeEvent.timestamp,
touchDelayMs: Date.now() - event.nativeEvent.timestamp,
};
});
diff --git a/Libraries/Pressability/PressabilityPerformanceEventEmitter.js b/Libraries/Pressability/PressabilityPerformanceEventEmitter.js
index 832b1ee270e7..302baf5e8744 100644
--- a/Libraries/Pressability/PressabilityPerformanceEventEmitter.js
+++ b/Libraries/Pressability/PressabilityPerformanceEventEmitter.js
@@ -12,6 +12,7 @@ import {type PressabilityTouchSignal as TouchSignal} from './PressabilityTypes.j
export type PressabilityPerformanceEvent = $ReadOnly<{|
signal: TouchSignal,
+ nativeTimestamp: number,
touchDelayMs: number,
|}>;
export type PressabilityPerformanceEventListener = PressabilityPerformanceEvent => void;
From 2e8893fb5be0c877e0818d04264d75fa92ae0f8e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A9ctor=20Ramos?=
Date: Tue, 31 Aug 2021 05:22:01 -0700
Subject: [PATCH 040/986] Replace envvars with required params in codegen
script and add Fabric output overrides
Summary:
The codegen script now takes parameters for any necessary configuration. Now, there are three *required* parameters: JS_SRCS_DIR, LIBRARY_NAME, and OUTPUT_DIR.
By default, all modules and components output will be copied to the OUTPUT_DIR under a single LIBRARY_NAME.
If a fourth argument is provided, this COMPONENT_LIBRARY_NAME will be used for the component library name.
If a fifth argument is provided, this COMPONENT_OUTPUT_DIR will be used as the output directory for the component library.
These last two arguments are used to build the core FBReactNativeSpec modules and rncore components libraries. Eventually, all module and component output will be part of a single library, but for the time being we need to keep these apart for the core modules and components.
The script will output usage instructions if no argument is provided:
```
./scripts/generate-specs.sh
NAME
./scripts/generate-specs.sh -- generate specs
SYNOPSIS
./scripts/generate-specs.sh javascript_sources_directory specs_library_name output_directory
./scripts/generate-specs.sh javascript_sources_directory specs_library_name output_directory component_library_name [component_output_directory]
DESCRIPTION
In the first synopsis form, this script collects native module and native component JavaScript spec definitions in javascript_sources_directory, then uses react-native-codegen to generate the native interface code into a library named specs_library_name, which is copied to the destination output_directory.
In the second synopsis form, the component_library_name will be used as the name of the component native interface code library. If provided, the component output will be copied to the component_output_directory, otherwise it will be copied to the output_directory.
```
With these changes, `codegen.js` became redundant and has been removed.
Changelog:
[Internal] - Codegen script interface changes.
Reviewed By: fkgozali
Differential Revision: D30626294
fbshipit-source-id: 475c29242497db5f93213aa64ca9b7c480140d55
---
.../FBReactNativeSpec.podspec | 14 ++-
scripts/codegen.js | 54 -----------
scripts/generate-specs.sh | 91 +++++++++++++------
scripts/react_native_pods.rb | 58 ++++++------
4 files changed, 103 insertions(+), 114 deletions(-)
delete mode 100644 scripts/codegen.js
diff --git a/React/FBReactNativeSpec/FBReactNativeSpec.podspec b/React/FBReactNativeSpec/FBReactNativeSpec.podspec
index 32a4bf8cb419..bdbf1023319e 100644
--- a/React/FBReactNativeSpec/FBReactNativeSpec.podspec
+++ b/React/FBReactNativeSpec/FBReactNativeSpec.podspec
@@ -4,7 +4,9 @@
# LICENSE file in the root directory of this source tree.
require "json"
-require_relative "../../scripts/react_native_pods.rb"
+
+react_native_path = "../.."
+require_relative "#{react_native_path}/scripts/react_native_pods.rb"
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "package.json")))
version = package['version']
@@ -46,5 +48,13 @@ Pod::Spec.new do |s|
s.dependency "React-jsi", version
s.dependency "ReactCommon/turbomodule/core", version
- use_react_native_codegen! (s)
+ use_react_native_codegen!(s, {
+ :react_native_path => react_native_path,
+ :js_srcs_dir => "#{react_native_path}/Libraries",
+ :library_name => "FBReactNativeSpec",
+ :output_dir => "#{react_native_path}/React/FBReactNativeSpec",
+ :component_library_name => "rncore",
+ # TODO: component_output_dir should be programmatically specified, and may change with use_frameworks! support.
+ :component_output_dir => "#{react_native_path}/ReactCommon/react/renderer/components/"
+ })
end
diff --git a/scripts/codegen.js b/scripts/codegen.js
deleted file mode 100644
index 12ff0917dd66..000000000000
--- a/scripts/codegen.js
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/env node
-/**
- * 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.
- *
- * @format
- */
-
-'use strict';
-
-require('shelljs/global');
-const yargs = require('yargs');
-const execSync = require('child_process').execSync;
-
-let argv = yargs.option('srcs', {
- alias: 'srcs_dir',
- type: 'string',
- description: 'Path to JavaScript sources',
-}).option('modules_library_name', {
- type: 'string',
- description: 'Native modules interfaces library name',
-}).option('modules_output_dir', {
- type: 'string',
- description: 'Native modules interfaces output dir',
-}).option('components_library_name', {
- type: 'string',
- description: 'Native components interfaces library name',
-}).option('components_output_dir', {
- type: 'string',
- description: 'Native components interfaces output dir',
-}).argv;
-
-let env_vars = [];
-const { srcs_dir, modules_library_name, modules_output_dir, components_library_name, components_output_dir } = argv;
-
-if (srcs_dir) {
- env_vars.push(`SRCS_DIR=${srcs_dir}`);
-}
-if (modules_library_name) {
- env_vars.push(`MODULES_LIBRARY_NAME=${modules_library_name}`);
-}
-if (modules_output_dir) {
- env_vars.push(`MODULES_OUTPUT_DIR=${modules_output_dir}`);
-}
-if (components_library_name) {
- env_vars.push(`COMPONENTS_LIBRARY_NAME=${components_library_name}`);
-}
-if (components_output_dir) {
- env_vars.push(`COMPONENTS_OUTPUT_DIR=${components_output_dir}`);
-}
-
-execSync(`${env_vars.join(' ')} ./generate-specs.sh`);
diff --git a/scripts/generate-specs.sh b/scripts/generate-specs.sh
index 4456557dfbb6..d3ea448e1759 100755
--- a/scripts/generate-specs.sh
+++ b/scripts/generate-specs.sh
@@ -4,20 +4,12 @@
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
-# This script collects the JavaScript spec definitions for core
+# This script collects the JavaScript spec definitions for
# native modules and components, then uses react-native-codegen
# to generate native code.
#
-# Optionally, set these envvars to override defaults:
-# - SRCS_DIR: Path to JavaScript sources
-# - MODULES_LIBRARY_NAME: Defaults to FBReactNativeSpec
-# - MODULES_OUTPUT_DIR: Defaults to React/$MODULES_LIBRARY_NAME/$MODULES_LIBRARY_NAME
-# - COMPONENTS_LIBRARY_NAME: Defaults to rncore
-# - COMPONENTS_OUTPUT_DIR: Defaults to ReactCommon/react/renderer/components/$COMPONENTS_LIBRARY_NAME
-#
# Usage:
# ./scripts/generate-specs.sh
-# SRCS_DIR=myapp/js MODULES_LIBRARY_NAME=MySpecs MODULES_OUTPUT_DIR=myapp/MySpecs ./scripts/generate-specs.sh
#
# shellcheck disable=SC2038
@@ -44,27 +36,45 @@ describe () {
printf "\\n\\n>>>>> %s\\n\\n\\n" "$1" >&2
}
+print_usage () {
+ printf "\\nNAME\\n\\t%s -- generate specs\\n" "$1" >&2
+ printf "\\nSYNOPSIS\\n" >&2
+ printf "\\t%s javascript_sources_directory specs_library_name output_directory\\n" "$1" >&2
+ printf "\\t%s javascript_sources_directory specs_library_name output_directory component_library_name [component_output_directory]\\n" "$1" >&2
+ printf "\\n\\nDESCRIPTION\\n\\tIn the first synopsis form, this script collects native module and native component JavaScript spec definitions in javascript_sources_directory, then uses react-native-codegen to generate the native interface code into a library named specs_library_name, which is copied to the destination output_directory.\\n" >&2
+ printf "\\n\\tIn the second synopsis form, the component_library_name will be used as the name of the component native interface code library. If provided, the component output will be copied to the component_output_directory, otherwise it will be copied to the output_directory.\\n" >&2
+}
+
main() {
- SRCS_DIR=${SRCS_DIR:-$(cd "$RN_DIR/Libraries" && pwd)}
- MODULES_LIBRARY_NAME=${MODULES_LIBRARY_NAME:-FBReactNativeSpec}
+ MIN_ARG_NUM=3
+ if [ "$#" -eq 0 ]; then
+ print_usage "$0"
+ exit 1
+ fi
+
+ if [ -z "$NODE_BINARY" ]; then
+ echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
+ exit 1
+ fi
+
+ if [ "$#" -lt "$MIN_ARG_NUM" ]; then
+ echo "Error: Expected $MIN_ARG_NUM arguments, got $# instead. Run $0 with no arguments to learn more." 1>&2
+ exit 1
+ fi
- COMPONENTS_LIBRARY_NAME=${COMPONENTS_LIBRARY_NAME:-rncore}
- MODULES_OUTPUT_DIR=${MODULES_OUTPUT_DIR:-"$RN_DIR/React/$MODULES_LIBRARY_NAME/$MODULES_LIBRARY_NAME"}
- # TODO: $COMPONENTS_PATH should be programmatically specified, and may change with use_frameworks! support.
- COMPONENTS_PATH="ReactCommon/react/renderer/components"
- COMPONENTS_OUTPUT_DIR=${COMPONENTS_OUTPUT_DIR:-"$RN_DIR/$COMPONENTS_PATH/$COMPONENTS_LIBRARY_NAME"}
+ SRCS_DIR=$1
+ LIBRARY_NAME=$2
+ OUTPUT_DIR=$3
+ COMPONENT_LIBRARY_NAME_OVERRIDE=$4
+ COMPONENT_OUTPUT_DIR_OVERRIDE=$5
+ PLATFORM="ios"
TEMP_OUTPUT_DIR="$TEMP_DIR/out"
SCHEMA_FILE="$TEMP_DIR/schema.json"
CODEGEN_REPO_PATH="$RN_DIR/packages/react-native-codegen"
CODEGEN_NPM_PATH="$RN_DIR/../react-native-codegen"
- if [ -z "$NODE_BINARY" ]; then
- echo "Error: Could not find node. Make sure it is in bash PATH or set the NODE_BINARY environment variable." 1>&2
- exit 1
- fi
-
if [ -d "$CODEGEN_REPO_PATH" ]; then
CODEGEN_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
elif [ -d "$CODEGEN_NPM_PATH" ]; then
@@ -82,15 +92,38 @@ main() {
describe "Generating schema from Flow types"
"$NODE_BINARY" "$CODEGEN_PATH/lib/cli/combine/combine-js-to-schema-cli.js" "$SCHEMA_FILE" "$SRCS_DIR"
- describe "Generating native code from schema (iOS)"
- pushd "$RN_DIR" >/dev/null || exit 1
- "$NODE_BINARY" scripts/generate-specs-cli.js ios "$SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$MODULES_LIBRARY_NAME"
- popd >/dev/null || exit 1
+ describe "Generating native code from schema ($PLATFORM)"
+ pushd "$RN_DIR" >/dev/null
+ "$NODE_BINARY" scripts/generate-specs-cli.js "$PLATFORM" "$SCHEMA_FILE" "$TEMP_OUTPUT_DIR" "$LIBRARY_NAME"
+ popd >/dev/null
+
+
+ mkdir -p "$OUTPUT_DIR"
- mkdir -p "$COMPONENTS_OUTPUT_DIR" "$MODULES_OUTPUT_DIR"
- cp -R "$TEMP_OUTPUT_DIR/$MODULES_LIBRARY_NAME.h" "$TEMP_OUTPUT_DIR/$MODULES_LIBRARY_NAME-generated.mm" "$MODULES_OUTPUT_DIR" || exit 1
- find "$TEMP_OUTPUT_DIR" -type f | xargs sed -i.bak "s/$MODULES_LIBRARY_NAME/$COMPONENTS_LIBRARY_NAME/g" || exit 1
- find "$TEMP_OUTPUT_DIR" -type f -not -iname "$MODULES_LIBRARY_NAME*" -exec cp '{}' "$COMPONENTS_OUTPUT_DIR/" ';' || exit 1
+ if [ -z "$COMPONENT_LIBRARY_NAME_OVERRIDE" ]; then
+ # Copy all output to output_dir
+ cp -R "$TEMP_OUTPUT_DIR/" "$OUTPUT_DIR"
+ echo >&2 "$LIBRARY_NAME output has been written to $OUTPUT_DIR:"
+ ls -1 "$OUTPUT_DIR" 2>&1
+ else
+ # Copy modules output to output_dir
+ cp "$TEMP_OUTPUT_DIR/$LIBRARY_NAME.h" "$TEMP_OUTPUT_DIR/$LIBRARY_NAME-generated.mm" "$OUTPUT_DIR"
+ echo >&2 "$LIBRARY_NAME output has been written to $OUTPUT_DIR:"
+ ls -1 "$OUTPUT_DIR" 2>&1
+
+ # Rename library name used in components output files
+ find "$TEMP_OUTPUT_DIR" -type f | xargs sed -i.bak "s/$LIBRARY_NAME/$COMPONENT_LIBRARY_NAME_OVERRIDE/g"
+
+ if [ -n "$COMPONENT_OUTPUT_DIR_OVERRIDE" ]; then
+ # Components codegen output to be moved to separate directory
+ mkdir -p "$COMPONENT_OUTPUT_DIR_OVERRIDE"
+ OUTPUT_DIR="$COMPONENT_OUTPUT_DIR_OVERRIDE"
+ fi
+
+ find "$TEMP_OUTPUT_DIR" -type f -not -iname "$LIBRARY_NAME.h" -not -iname "$LIBRARY_NAME-generated.mm" -not -iname "*.bak" -exec cp '{}' "$OUTPUT_DIR/" ';'
+ echo >&2 "$COMPONENT_LIBRARY_NAME_OVERRIDE output has been written to $OUTPUT_DIR:"
+ ls -1 "$OUTPUT_DIR" 2>&1
+ fi
echo >&2 'Done.'
}
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index a4131f3ec299..02b04e1e4f75 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -161,38 +161,38 @@ def use_react_native_codegen!(spec, options={})
js_srcs = options[:js_srcs_dir] ||= "#{prefix}/Libraries"
# Library name (e.g. FBReactNativeSpec)
- modules_library_name = options[:library_name] ||= spec.name
+ library_name = options[:library_name] ||= "#{spec.name}Spec"
# Output dir, relative to podspec that invoked this method
- modules_output_dir = options[:modules_output_dir] ||= "#{prefix}/React/#{modules_library_name}/#{modules_library_name}"
+ output_dir = options[:output_dir] ||= "#{prefix}/React/#{library_name}"
- generated_dirs = [ modules_output_dir ]
- generated_filenames = [ "#{modules_library_name}.h", "#{modules_library_name}-generated.mm" ]
- generated_files = generated_filenames.map { |filename| "#{modules_output_dir}/#{filename}" }
+ generated_dirs = [ "#{output_dir}/#{library_name}" ]
+ generated_filenames = [ "#{library_name}.h", "#{library_name}-generated.mm" ]
+ generated_files = generated_filenames.map { |filename| "#{output_dir}/#{library_name}/#{filename}" }
# Run the codegen as part of the Xcode build pipeline.
- env_vars = "SRCS_DIR='${PODS_TARGET_SRCROOT}/#{js_srcs}'"
- env_vars += " MODULES_OUTPUT_DIR='${PODS_TARGET_SRCROOT}/#{modules_output_dir}'"
- env_vars += " MODULES_LIBRARY_NAME='#{modules_library_name}'"
-
- if ENV['USE_FABRIC'] == '1'
- # We use a different library name for components, as well as an additional set of files.
- # Eventually, we want these to be part of the same library as #{modules_library_name} above.
- components_output_dir = options[:components_output_dir] ||= "#{prefix}/ReactCommon/react/renderer/components/rncore/"
- generated_dirs.push components_output_dir
- env_vars += " COMPONENTS_OUTPUT_DIR='${PODS_TARGET_SRCROOT}/#{components_output_dir}'"
- 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| "#{components_output_dir}/#{filename}" })
- end
+ codegen_script_args = [ "'${PODS_TARGET_SRCROOT}/#{js_srcs}'" ]
+ codegen_script_args.push "'#{library_name}'"
+ codegen_script_args.push "'${PODS_TARGET_SRCROOT}/#{output_dir}/#{library_name}'"
+
+ # We use a different library name for components, as well as an additional set of files.
+ # Eventually, we want these to be part of the same library as #{library_name} above.
+ component_library_name = options[:component_library_name] ||= library_name
+ component_output_dir = options[:component_output_dir] ||= output_dir
+ generated_dirs.push "#{component_output_dir}/#{component_library_name}"
+ codegen_script_args.push "'#{component_library_name}'"
+ codegen_script_args.push "'${PODS_TARGET_SRCROOT}/#{component_output_dir}/#{component_library_name}'"
+ 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| "#{component_output_dir}/#{component_library_name}/#{filename}" })
# Prepare filesystem by creating empty files that will be picked up as references by CocoaPods.
prepare_command = "mkdir -p #{generated_dirs.join(" ")} && touch -a #{generated_files.join(" ")}"
@@ -202,11 +202,11 @@ def use_react_native_codegen!(spec, options={})
spec.script_phase = {
:name => 'Generate Specs',
:input_files => [ "${PODS_TARGET_SRCROOT}/#{js_srcs}" ], # This also needs to be relative to Xcode
- :output_files => ["${DERIVED_FILE_DIR}/codegen-#{modules_library_name}.log"].concat(generated_files.map { |filename| " ${PODS_TARGET_SRCROOT}/#{filename}"} ),
+ :output_files => ["${DERIVED_FILE_DIR}/codegen-#{library_name}.log"].concat(generated_files.map { |filename| " ${PODS_TARGET_SRCROOT}/#{filename}"} ),
# The final generated files will be created when this script is invoked at Xcode build time.
:script => %{set -o pipefail
-bash -l -c '#{env_vars} $\{PODS_TARGET_SRCROOT\}/#{prefix}/scripts/generate-specs.sh' 2>&1 | tee "${SCRIPT_OUTPUT_FILE_0}"
+bash -l -c '$\{PODS_TARGET_SRCROOT\}/#{prefix}/scripts/generate-specs.sh #{codegen_script_args.join(" ")}' 2>&1 | tee "${SCRIPT_OUTPUT_FILE_0}"
},
:execution_position => :before_compile,
:show_env_vars_in_log => true
From 24a9ef7384b776ff0ab75be043e934591bb8d319 Mon Sep 17 00:00:00 2001
From: Nicola Corti
Date: Tue, 31 Aug 2021 09:51:58 -0700
Subject: [PATCH 041/986] Suppressing bad file descriptor errors on native
builds
Summary:
When running native builds, we experience a lot of
bad file descriptor warnings. This diff is suppressing the issue on local builds (on Mac).
Changelog:
[Internal] [Changed] - Suppressed bad file descriptor on native builds
Reviewed By: ShikaSD
Differential Revision: D30487098
fbshipit-source-id: 8199fb8f2f18d19543d2861f1f2f852fff6ae73b
---
ReactAndroid/build.gradle | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle
index edadad219f3b..8db3196c6bca 100644
--- a/ReactAndroid/build.gradle
+++ b/ReactAndroid/build.gradle
@@ -362,7 +362,8 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
inputs.dir("src/main/java/com/facebook/react/turbomodule/core/jni")
inputs.dir("src/main/java/com/facebook/react/modules/blob")
outputs.dir("$buildDir/react-ndk/all")
- commandLine(getNdkBuildFullPath(),
+ def commandLineArgs = [
+ getNdkBuildFullPath(),
"APP_ABI=${reactNativeArchitectures()}",
"NDK_DEBUG=" + (nativeBuildType.equalsIgnoreCase("debug") ? "1" : "0"),
"NDK_PROJECT_PATH=null",
@@ -375,7 +376,12 @@ def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
"-C", file("src/main/jni/react/jni").absolutePath,
"--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors()
- )
+ ]
+ if (Os.isFamily(Os.FAMILY_MAC)) {
+ // This flag will suppress "fcntl(): Bad file descriptor" warnings on local builds.
+ commandLineArgs.add("--output-sync=none")
+ }
+ commandLine(commandLineArgs)
}
def cleanReactNdkLib = tasks.register("cleanReactNdkLib", Exec) {
From 85249cafe8870ab8f47c38569b106555ce2f8527 Mon Sep 17 00:00:00 2001
From: Nicola Corti
Date: Tue, 31 Aug 2021 12:48:55 -0700
Subject: [PATCH 042/986] Update project to build on Gradle 7.0.2 (#32073)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32073
This Diff bumps the version of Gradle used to build the project to
7.0.2. Ideally we could bump to 7.2.x directly, but I'll do one minor version
at a time to exclude potential build problems.
This diff is addressing all the extra build warnings that got raised by the new version.
Changelog:
[Android][Changed] - Bumped Gradle project version to 7.0.2
Reviewed By: ShikaSD
Differential Revision: D30486612
fbshipit-source-id: 70e0f7d18e547013ca7b1d12f8dd64a633df5870
---
ReactAndroid/build.gradle | 2 +-
gradle/wrapper/gradle-wrapper.properties | 2 +-
gradlew.bat | 178 +++++++++---------
.../gradle/wrapper/gradle-wrapper.properties | 2 +-
.../react-native-codegen/android/gradlew.bat | 178 +++++++++---------
.../react/tasks/BundleJsAndAssetsTask.kt | 7 +-
.../facebook/react/tasks/HermesBinaryTask.kt | 6 +-
packages/rn-tester/android/app/build.gradle | 1 +
8 files changed, 191 insertions(+), 185 deletions(-)
diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle
index 8db3196c6bca..7d2e903790e3 100644
--- a/ReactAndroid/build.gradle
+++ b/ReactAndroid/build.gradle
@@ -56,7 +56,6 @@ task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
- from("src/main/jni/third-party/boost/Android.mk")
from("src/main/jni/third-party/boost")
include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp", "asm/**/*.S")
includeEmptyDirs = false
@@ -171,6 +170,7 @@ task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
// Prepare glog sources to be compiled, this task will perform steps that normally should've been
// executed by automake. This way we can avoid dependencies on make/automake
task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
+ duplicatesStrategy("warn")
from(dependenciesPath ?: tarTree(downloadGlog.dest))
from("src/main/jni/third-party/glog/")
include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 7665b0fa93ae..29e413457635 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-6.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew.bat b/gradlew.bat
index 107acd32c4e6..ac1b06f93825 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/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties b/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties
index 7665b0fa93ae..29e413457635 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-6.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-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 107acd32c4e6..ac1b06f93825 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/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt
index 086f2515f98d..300774a48a0c 100644
--- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt
+++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleJsAndAssetsTask.kt
@@ -11,13 +11,16 @@ import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.file.FileTree
import org.gradle.api.tasks.Input
+import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.InputFiles
+import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
open class BundleJsAndAssetsTask : DefaultTask() {
- internal lateinit var reactRoot: File
+
+ @get:Internal internal lateinit var reactRoot: File
@get:InputFiles
@Suppress("UNUSED") // used to invalidate caches
@@ -25,7 +28,7 @@ open class BundleJsAndAssetsTask : DefaultTask() {
@get:Input internal lateinit var execCommand: List
@get:Input internal lateinit var bundleCommand: String
@get:Input internal var devEnabled: Boolean = true
- @get:Input internal lateinit var entryFile: File
+ @get:InputFile internal lateinit var entryFile: File
@get:Input internal var extraArgs: List = emptyList()
@get:OutputDirectory internal lateinit var jsBundleDir: File
diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt
index 0e641dea7ad8..af3ae0fe5ebd 100644
--- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt
+++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/HermesBinaryTask.kt
@@ -11,18 +11,20 @@ import java.io.File
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
+import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction
open class HermesBinaryTask : DefaultTask() {
- internal lateinit var reactRoot: File
+
+ @get:Internal internal lateinit var reactRoot: File
@get:Input internal lateinit var hermesCommand: String
@get:Input internal var hermesFlags: List = emptyList()
@get:InputFile internal lateinit var jsBundleFile: File
@get:Input internal lateinit var composeSourceMapsCommand: List
- @get:Input internal lateinit var jsPackagerSourceMapFile: File
+ @get:InputFile internal lateinit var jsPackagerSourceMapFile: File
@get:OutputFile internal lateinit var jsCompilerSourceMapFile: File
@get:OutputFile internal lateinit var jsOutputSourceMapFile: File
diff --git a/packages/rn-tester/android/app/build.gradle b/packages/rn-tester/android/app/build.gradle
index 7f04213604bf..503ada4fd87e 100644
--- a/packages/rn-tester/android/app/build.gradle
+++ b/packages/rn-tester/android/app/build.gradle
@@ -288,6 +288,7 @@ if (enableCodegen) {
def packageReactNdkLibs = tasks.register("packageReactNdkLibs", Copy) {
// TODO: handle extracting .so from prebuilt :ReactAndroid.
dependsOn(":ReactAndroid:packageReactNdkLibs")
+ dependsOn("generateCodegenSchemaFromJavaScript")
from("$reactAndroidBuildDir/react-ndk/exported")
into("$buildDir/react-ndk/exported")
}
From 13107fa3d0bcb41d1e91d676f2886c575c599bc2 Mon Sep 17 00:00:00 2001
From: Nicola Corti
Date: Tue, 31 Aug 2021 12:48:55 -0700
Subject: [PATCH 043/986] Import template/android/ as part of the top level
build (#32124)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32124
This Diff adds `template/android/` as part of the top level build as an included
build. This means that the Android template will be loaded inside Android studio and it
will be easier to invoke tasks directly there.
I'm also bumping Gradle to 7.0.2 for the template.
Please note that the template relies on the `template/node_modules` folder to
work correctly, as the Gradle build is loading a file from there.
Therefore I've added a check to verify that we import the build only if `node_modules`
is available.
Changelog:
[Internal] [Changed] - Load template/android/ inside the build.
Reviewed By: ShikaSD
Differential Revision: D30672845
fbshipit-source-id: 7253296b54e1fde7448e0e170d59b244ed9ec8fb
---
.gitignore | 2 +
settings.gradle.kts | 7 +
.../gradle/wrapper/gradle-wrapper.properties | 2 +-
template/android/gradlew.bat | 178 +++++++++---------
4 files changed, 99 insertions(+), 90 deletions(-)
diff --git a/.gitignore b/.gitignore
index de6bcc3d45d9..ecfa96ceaa29 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,8 @@ project.xcworkspace
/ReactAndroid/gradle/
/ReactAndroid/gradlew
/ReactAndroid/gradlew.bat
+/template/android/app/build/
+/template/android/build/
# Buck
.buckd
diff --git a/settings.gradle.kts b/settings.gradle.kts
index 1d838685e259..f804e186f975 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -22,3 +22,10 @@ include(
// Include this to enable codegen Gradle plugin.
includeBuild("packages/react-native-codegen/android")
includeBuild("packages/react-native-gradle-plugin/")
+
+// Include this to build the Android template as well and make sure is not broken.
+if (File("template/node_modules/").exists()) {
+ includeBuild("template/android/") {
+ name = "template-android"
+ }
+}
diff --git a/template/android/gradle/wrapper/gradle-wrapper.properties b/template/android/gradle/wrapper/gradle-wrapper.properties
index 7665b0fa93ae..29e413457635 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-6.9-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/template/android/gradlew.bat b/template/android/gradlew.bat
index 107acd32c4e6..ac1b06f93825 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
From ed20a851522ba88d0f7108bb8516f62cad383839 Mon Sep 17 00:00:00 2001
From: Matt Oakes
Date: Tue, 31 Aug 2021 15:52:20 -0700
Subject: [PATCH 044/986] Bump the version of
@react-native-community/eslint-config (#32117)
Summary:
The version of this package needs to be bumped for me to release the changes from https://github.com/facebook/react-native/issues/28637 to NPM.
## Changelog
[Internal] [Added] - Bump react-native-community/eslint-config version
Pull Request resolved: https://github.com/facebook/react-native/pull/32117
Test Plan: N/A
Reviewed By: cortinico
Differential Revision: D30663708
Pulled By: yungsters
fbshipit-source-id: f433c324f12663d76e55c9395630cd642955b25e
---
packages/eslint-config-react-native-community/package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/packages/eslint-config-react-native-community/package.json b/packages/eslint-config-react-native-community/package.json
index 5c59f9ead21b..bf80d296770f 100644
--- a/packages/eslint-config-react-native-community/package.json
+++ b/packages/eslint-config-react-native-community/package.json
@@ -1,6 +1,6 @@
{
"name": "@react-native-community/eslint-config",
- "version": "3.0.0",
+ "version": "3.0.1",
"description": "ESLint config for React Native",
"main": "index.js",
"license": "MIT",
From 6651d8c34680a0104c31abe65223d55cce237f96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?H=C3=A9ctor=20Ramos?=
Date: Tue, 31 Aug 2021 16:18:41 -0700
Subject: [PATCH 045/986] Enable codegen in RNTester's NativeModuleExample
Summary:
Create a ScreenshotManager.podspec (codegen recipe included) and add ScreenshotManager Pod to the Podfile.
Changelog:
[Internal]
Reviewed By: fkgozali
Differential Revision: D30623054
fbshipit-source-id: be20880a53ba8a08f8b42b8d81c868c8a21960e1
---
.gitignore | 1 +
.../ScreenshotManager.podspec | 39 +++++++++++++++++++
packages/rn-tester/Podfile | 3 ++
packages/rn-tester/Podfile.lock | 9 ++++-
4 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec
diff --git a/.gitignore b/.gitignore
index ecfa96ceaa29..747bb762be95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,6 +105,7 @@ package-lock.json
/React/FBReactNativeSpec/FBReactNativeSpec
/packages/react-native-codegen/lib
/ReactCommon/react/renderer/components/rncore/
+/packages/rn-tester/NativeModuleExample/ScreenshotManagerSpec
# Visual studio
.vscode
diff --git a/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec b/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec
new file mode 100644
index 000000000000..bfa423f63e04
--- /dev/null
+++ b/packages/rn-tester/NativeModuleExample/ScreenshotManager.podspec
@@ -0,0 +1,39 @@
+# 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.
+
+require "json"
+
+package = JSON.parse(File.read(File.join(__dir__, "../package.json")))
+
+folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
+folly_version = '2021.06.28.00'
+
+Pod::Spec.new do |s|
+ s.name = "ScreenshotManager"
+ s.version = package["version"]
+ s.summary = package["description"]
+ s.description = "ScreenshotManager"
+ s.homepage = "https://github.com/facebook/react-native.git"
+ s.license = "MIT"
+ s.platforms = { :ios => "11.0", :tvos => "11.0" }
+ s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness'
+ s.author = "Facebook, Inc. and its affiliates"
+ s.source = { :git => "https://github.com/facebook/react-native.git", :tag => "#{s.version}" }
+
+ s.source_files = "**/*.{h,m,mm,swift}"
+ s.requires_arc = true
+
+ s.dependency "React"
+ s.dependency "RCT-Folly", folly_version
+
+ # s.dependency "..."
+
+ # Enable codegen for this library
+ use_react_native_codegen!(s, {
+ :react_native_path => "../../..",
+ :js_srcs_dir => "./",
+ :output_dir => "./"
+ })
+end
diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile
index ae885b014548..dcc05865ac59 100644
--- a/packages/rn-tester/Podfile
+++ b/packages/rn-tester/Podfile
@@ -37,6 +37,9 @@ def pods()
pod 'React-RCTPushNotification', :path => "#{prefix_path}/Libraries/PushNotificationIOS"
pod 'Yoga', :path => "#{prefix_path}/ReactCommon/yoga", :modular_headers => true
# Additional Pods which are classed as unstable
+
+ # RNTester native modules and components
+ pod 'ScreenshotManager', :path => "NativeModuleExample"
end
target 'RNTester' do
diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock
index 52b05d0344bb..9fb2a10be87c 100644
--- a/packages/rn-tester/Podfile.lock
+++ b/packages/rn-tester/Podfile.lock
@@ -704,6 +704,9 @@ PODS:
- React-logger (= 1000.0.0)
- React-perflogger (= 1000.0.0)
- ReactCommon/turbomodule/core (= 1000.0.0)
+ - ScreenshotManager (0.0.1):
+ - RCT-Folly (= 2021.06.28.00)
+ - React
- Yoga (1.14.0)
- YogaKit (1.18.1):
- Yoga (~> 1.14)
@@ -769,6 +772,7 @@ DEPENDENCIES:
- React-runtimeexecutor (from `../../ReactCommon/runtimeexecutor`)
- ReactCommon/turbomodule/core (from `../../ReactCommon`)
- ReactCommon/turbomodule/samples (from `../../ReactCommon`)
+ - ScreenshotManager (from `NativeModuleExample`)
- Yoga (from `../../ReactCommon/yoga`)
SPEC REPOS:
@@ -857,6 +861,8 @@ EXTERNAL SOURCES:
:path: "../../ReactCommon/runtimeexecutor"
ReactCommon:
:path: "../../ReactCommon"
+ ScreenshotManager:
+ :path: NativeModuleExample
Yoga:
:path: "../../ReactCommon/yoga"
@@ -908,9 +914,10 @@ SPEC CHECKSUMS:
React-RCTVibration: 1a58f6ab1ae5fad004119979b676cb5e912f2e44
React-runtimeexecutor: 4b0c6eb341c7d3ceb5e2385cb0fdb9bf701024f3
ReactCommon: 632474905edd9a20ec4f4084142ff4b4a4f3fd8b
+ ScreenshotManager: a23f618c2a205e3087f29b05154a7c3d6e515d8a
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
-PODFILE CHECKSUM: 6e910a576b7db9347c60dfc58f7852f692200116
+PODFILE CHECKSUM: ae3037f2256663bd77e3b1cffcac23908027fdb1
COCOAPODS: 1.10.1
From 945c5f714d9b3a75f0be02b3a408f865c9021aa7 Mon Sep 17 00:00:00 2001
From: Kevin Gozali
Date: Wed, 1 Sep 2021 00:15:04 -0700
Subject: [PATCH 046/986] OSS: Fix $ENTRY_FILE check for non-Debug Xcode builds
Summary:
The original $ENTRY_FILE check was added in https://github.com/facebook/react-native/pull/29012 to help catch misconfiguration for the entry JS file. That turned out breaking some RNTester builds/tests, so https://github.com/facebook/react-native/pull/29263 was added to accommodate the fact that RNTester .xcodeproj file has its own directory hierarchy.
The 2nd PR had multiple issues:
* It is incorrect to assume that the $ENTRY_FILE always exists in the parent dir of the .xcodeproj location. This caused an issue in RC 0.66: https://github.com/react-native-community/releases/issues/249#issue-983474535
* RNTester has since moved to packages/rn-tester/ (from RNTester/), hence breaking that assumption
It turns out RNTester .xcodeproj has incorrectly misconfigured this JS bundling step (not sure since when). The original script invocation passed in the correct path for `RNTesterApp.ios.js`, but as an arg to the `react-native-xcode.sh` instead of by setting `ENTRY_FILE` env var.
So this diff does 2 things:
* Undid https://github.com/facebook/react-native/pull/29263
* Fix RNTester JS bundling invocation to set the ENTRY_FILE correctly
{F659123377}
Changelog: [iOS][Fixed] Unbreak $ENTRY_FILE handling for JS bundling
Reviewed By: lunaleaps
Differential Revision: D30690900
fbshipit-source-id: 7c5802b3eac56c0456edcd4b7478bfa4af48fc27
---
packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj | 3 +--
scripts/react-native-xcode.sh | 2 +-
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
index d47d63409c25..d526edbc7d63 100644
--- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
+++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
@@ -321,7 +321,6 @@
C38CB0C2095A8FFDE13321E5 /* Pods-RNTesterUnitTests.debug.xcconfig */,
8735BC063632C9712E25C7D9 /* Pods-RNTesterUnitTests.release.xcconfig */,
);
- name = Pods;
path = Pods;
sourceTree = "";
};
@@ -610,7 +609,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "set -e\n\nexport NODE_BINARY=node\nexport PROJECT_ROOT=\"$SRCROOT/../../\"\nexport SOURCEMAP_FILE=../sourcemap.ios.map\n# export FORCE_BUNDLING=true\n\"$SRCROOT/../../scripts/react-native-xcode.sh\" $SRCROOT/../../packages/rn-tester/js/RNTesterApp.ios.js\n";
+ shellScript = "set -e\n\nexport NODE_BINARY=node\nexport PROJECT_ROOT=\"$SRCROOT/../../\"\nexport ENTRY_FILE=\"$SRCROOT/js/RNTesterApp.ios.js\"\nexport SOURCEMAP_FILE=../sourcemap.ios.map\n# export FORCE_BUNDLING=true\n\"$SRCROOT/../../scripts/react-native-xcode.sh\"\n";
};
A2FBDDDD0C26B4EFA3726B6C /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh
index dab1d5cb05b5..b5f7544d3e83 100755
--- a/scripts/react-native-xcode.sh
+++ b/scripts/react-native-xcode.sh
@@ -74,7 +74,7 @@ else
ENTRY_FILE=${1:-index.js}
fi
-if [[ $DEV != true && ! -f "../$ENTRY_FILE" ]]; then
+if [[ $DEV != true && ! -f "$ENTRY_FILE" ]]; then
echo "error: Entry file $ENTRY_FILE does not exist. If you use another file as your entry point, pass ENTRY_FILE=myindex.js" >&2
exit 2
fi
From ac4ddec542febda744de218dae3a3d34edc7da84 Mon Sep 17 00:00:00 2001
From: Kevin Gozali
Date: Wed, 1 Sep 2021 00:15:04 -0700
Subject: [PATCH 047/986] OSS: add Xcode 12.5 + M1 machines CocoaPods
post_install workaround
Summary:
Context: there are multiple issues currently exposed by Xcode 12.5 and/or M1 machine + Flipper. To unblock the new 0.66 release, let's add this workaround in the official react_native_pods.rb recipe and make RNTester and new app Podfile's call it directly.
Changelog: [iOS][Fixed] Added workaround for Xcode 12.5 / M1 machines build issues
Reviewed By: lunaleaps
Differential Revision: D30691291
fbshipit-source-id: 8b24cc60da3d620dbc90f95c77f2345e18c28212
---
packages/rn-tester/Podfile | 1 +
scripts/react_native_pods.rb | 35 +++++++++++++++++++++++++++++++++++
template/ios/Podfile | 1 +
3 files changed, 37 insertions(+)
diff --git a/packages/rn-tester/Podfile b/packages/rn-tester/Podfile
index dcc05865ac59..b7492364d720 100644
--- a/packages/rn-tester/Podfile
+++ b/packages/rn-tester/Podfile
@@ -61,4 +61,5 @@ end
post_install do |installer|
react_native_post_install(installer)
+ __apply_Xcode_12_5_M1_post_install_workaround(installer)
end
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index 02b04e1e4f75..2325ad33c574 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -212,3 +212,38 @@ def use_react_native_codegen!(spec, options={})
:show_env_vars_in_log => true
}
end
+
+# This provides a post_install workaround for build issues related Xcode 12.5 and Apple Silicon (M1) machines.
+# Call this in the app's main Podfile's post_install hook.
+# See https://github.com/facebook/react-native/issues/31480#issuecomment-902912841 for more context.
+# Actual fix was authored by https://github.com/mikehardy.
+# New app template will call this for now until the underlying issue is resolved.
+def __apply_Xcode_12_5_M1_post_install_workaround(installer)
+ # Apple Silicon builds require a library path tweak for Swift library discovery to resolve Swift-related "symbol not found".
+ # Note: this was fixed via https://github.com/facebook/react-native/commit/eb938863063f5535735af2be4e706f70647e5b90
+ # Keeping this logic here but commented out for future reference.
+ #
+ # installer.aggregate_targets.each do |aggregate_target|
+ # aggregate_target.user_project.native_targets.each do |target|
+ # target.build_configurations.each do |config|
+ # config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
+ # end
+ # end
+ # aggregate_target.user_project.save
+ # end
+
+ # Flipper podspecs are still targeting an older iOS deployment target, and may cause an error like:
+ # "error: thread-local storage is not supported for the current target"
+ # The most reliable known workaround is to bump iOS deployment target to match react-native (iOS 11 now).
+ installer.pods_project.targets.each do |target|
+ target.build_configurations.each do |config|
+ config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '11.0'
+ end
+ end
+
+ # But... doing so caused another issue in Flipper:
+ # "Time.h:52:17: error: typedef redefinition with different types"
+ # We need to make a patch to RCT-Folly - set `__IPHONE_10_0` to our iOS target + 1.
+ # See https://github.com/facebook/flipper/issues/834 for more details.
+ `sed -i -e $'s/__IPHONE_10_0/__IPHONE_12_0/' Pods/RCT-Folly/folly/portability/Time.h`
+end
diff --git a/template/ios/Podfile b/template/ios/Podfile
index 65d5ffcbfcf4..9409747f9178 100644
--- a/template/ios/Podfile
+++ b/template/ios/Podfile
@@ -25,5 +25,6 @@ target 'HelloWorld' do
post_install do |installer|
react_native_post_install(installer)
+ __apply_Xcode_12_5_M1_post_install_workaround(installer)
end
end
From b26f2772624c863c91fa1ff627b481c92d7562fb Mon Sep 17 00:00:00 2001
From: Utkarsh
Date: Wed, 1 Sep 2021 00:18:08 -0700
Subject: [PATCH 048/986] Add Linking examples in rn-tester (#30547)
Summary:
Added examples to RNTester for the Linking API.
## Changelog
[General] [Added] - Added example for openSettings() for Linking API.
[General] [Added] - Added [LSApplicationQueriesSchemes](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW14) in info.plist with entries tel, telprompt, http, fb, geo
Pull Request resolved: https://github.com/facebook/react-native/pull/30547
Test Plan: 
Reviewed By: yungsters
Differential Revision: D30559457
Pulled By: lunaleaps
fbshipit-source-id: dba2721a9905ddb9ddd2b14141e5553bdf8880da
---
packages/rn-tester/RNTester/Info.plist | 8 +++++++
.../js/examples/Linking/LinkingExample.js | 23 ++++++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/packages/rn-tester/RNTester/Info.plist b/packages/rn-tester/RNTester/Info.plist
index 13573d49b866..788e4d6193c8 100644
--- a/packages/rn-tester/RNTester/Info.plist
+++ b/packages/rn-tester/RNTester/Info.plist
@@ -2,6 +2,14 @@
+ LSApplicationQueriesSchemes
+
+ tel
+ telprompt
+ http
+ fb
+ geo
+ UIStatusBarStyleUIStatusBarStyleBlackTranslucentCFBundleDevelopmentRegion
diff --git a/packages/rn-tester/js/examples/Linking/LinkingExample.js b/packages/rn-tester/js/examples/Linking/LinkingExample.js
index 02f883a644db..cd0c9eabf8eb 100644
--- a/packages/rn-tester/js/examples/Linking/LinkingExample.js
+++ b/packages/rn-tester/js/examples/Linking/LinkingExample.js
@@ -11,6 +11,7 @@
const React = require('react');
const {
+ Button,
Linking,
Platform,
StyleSheet,
@@ -48,6 +49,16 @@ class OpenURLButton extends React.Component {
}
}
+class OpenSettingsExample extends React.Component {
+ openSettings() {
+ Linking.openSettings();
+ }
+
+ render() {
+ return ;
+ }
+}
+
class SendIntentButton extends React.Component {
handleIntent = async () => {
try {
@@ -72,14 +83,14 @@ class IntentAndroidExample extends React.Component {
render() {
return (
-
+
-
+
{Platform.OS === 'android' && (
@@ -122,9 +133,15 @@ exports.documentationURL = 'https://reactnative.dev/docs/linking';
exports.description = 'Shows how to use Linking to open URLs.';
exports.examples = [
{
- title: 'Simple list of items',
+ title: 'Open external URLs',
render: function(): React.Element {
return ;
},
},
+ {
+ title: 'Open settings app',
+ render: function(): React.Element {
+ return ;
+ },
+ },
];
From 65e58f26e1fbd06b1ae32e2ab3a2616c8eef08e0 Mon Sep 17 00:00:00 2001
From: Tim Yung
Date: Wed, 1 Sep 2021 00:53:41 -0700
Subject: [PATCH 049/986] RN: @react-native/normalize-color support Node.js
Summary:
Changes `react-native/normalize-color` to be useable from Node.js by making the following changes:
1. Rename `base.js` to `index.js` so importing is more convenient.
2. Move Flow definitions into a seprate library definition flow so `index.js` can be consumed directly.
I also made a few improvements to the actual implementation:
1. Avoid allocating `matchers` for non-strings.
2. Avoid allocating an object of all the color keywords. This will reduce memory usage (in exchange for slightly larger compiled bytecode).
Changelog:
[General][Changed] - react-native/normalize-color now supports Node.js
Reviewed By: lunaleaps
Differential Revision: D30595908
fbshipit-source-id: e6279e9ff815d8d1f489811187deabfdf53b8fbf
---
.../__tests__/normalizeColor-test.js | 8 +-
Libraries/StyleSheet/normalizeColor.js | 4 +-
package.json | 2 +-
.../normalize-color/__tests__/base-test.js | 129 ------
.../__tests__/normalizeColor-test.js | 131 ++++++
packages/normalize-color/base.js | 387 ------------------
packages/normalize-color/index.js | 378 +++++++++++++++++
packages/normalize-color/index.js.flow | 10 +
packages/normalize-color/package.json | 4 +-
9 files changed, 527 insertions(+), 526 deletions(-)
delete mode 100644 packages/normalize-color/__tests__/base-test.js
create mode 100644 packages/normalize-color/__tests__/normalizeColor-test.js
delete mode 100644 packages/normalize-color/base.js
create mode 100644 packages/normalize-color/index.js
create mode 100644 packages/normalize-color/index.js.flow
diff --git a/Libraries/StyleSheet/__tests__/normalizeColor-test.js b/Libraries/StyleSheet/__tests__/normalizeColor-test.js
index 5421edccd233..f07498751e28 100644
--- a/Libraries/StyleSheet/__tests__/normalizeColor-test.js
+++ b/Libraries/StyleSheet/__tests__/normalizeColor-test.js
@@ -13,13 +13,11 @@
const {OS} = require('../../Utilities/Platform');
const normalizeColor = require('../normalizeColor');
-it('forwards calls to @react-native/normalize-color/base', () => {
- jest
- .resetModules()
- .mock('@react-native/normalize-color/base', () => jest.fn());
+it('forwards calls to @react-native/normalize-color', () => {
+ jest.resetModules().mock('@react-native/normalize-color', () => jest.fn());
expect(require('../normalizeColor')('#abc')).not.toBe(null);
- expect(require('@react-native/normalize-color/base')).toBeCalled();
+ expect(require('@react-native/normalize-color')).toBeCalled();
});
describe('iOS', () => {
diff --git a/Libraries/StyleSheet/normalizeColor.js b/Libraries/StyleSheet/normalizeColor.js
index 4ba0dae0085f..89a672c4567d 100755
--- a/Libraries/StyleSheet/normalizeColor.js
+++ b/Libraries/StyleSheet/normalizeColor.js
@@ -10,7 +10,7 @@
/* eslint no-bitwise: 0 */
-import normalizeColorBase from '@react-native/normalize-color/base';
+import _normalizeColor from '@react-native/normalize-color';
import type {ColorValue} from './StyleSheet';
import type {ProcessedColorValue} from './processColor';
@@ -27,7 +27,7 @@ function normalizeColor(
}
if (typeof color === 'string' || typeof color === 'number') {
- return normalizeColorBase(color);
+ return _normalizeColor(color);
}
}
diff --git a/package.json b/package.json
index 773a915a7985..f8d1e7729122 100644
--- a/package.json
+++ b/package.json
@@ -94,7 +94,7 @@
"@react-native-community/cli-platform-android": "^6.0.0",
"@react-native-community/cli-platform-ios": "^6.0.0",
"@react-native/assets": "1.0.0",
- "@react-native/normalize-color": "1.0.0",
+ "@react-native/normalize-color": "2.0.0",
"@react-native/polyfills": "2.0.0",
"abort-controller": "^3.0.0",
"anser": "^1.4.9",
diff --git a/packages/normalize-color/__tests__/base-test.js b/packages/normalize-color/__tests__/base-test.js
deleted file mode 100644
index c37c9af5ff0a..000000000000
--- a/packages/normalize-color/__tests__/base-test.js
+++ /dev/null
@@ -1,129 +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.
- *
- * @format
- * @emails oncall+react_native
- */
-
-'use strict';
-
-const normalizeColorBase = require('../base');
-
-it('should accept only spec compliant colors', () => {
- expect(normalizeColorBase('#abc')).not.toBe(null);
- expect(normalizeColorBase('#abcd')).not.toBe(null);
- expect(normalizeColorBase('#abcdef')).not.toBe(null);
- expect(normalizeColorBase('#abcdef01')).not.toBe(null);
- expect(normalizeColorBase('rgb(1,2,3)')).not.toBe(null);
- expect(normalizeColorBase('rgb(1, 2, 3)')).not.toBe(null);
- expect(normalizeColorBase('rgb( 1 , 2 , 3 )')).not.toBe(null);
- expect(normalizeColorBase('rgb(-1, -2, -3)')).not.toBe(null);
- expect(normalizeColorBase('rgba(0, 0, 0, 1)')).not.toBe(null);
- expect(normalizeColorBase(0x01234567 + 0.5)).toBe(null);
- expect(normalizeColorBase(-1)).toBe(null);
- expect(normalizeColorBase(0xffffffff + 1)).toBe(null);
-});
-
-it('should temporarily accept floating point values for rgb', () => {
- expect(normalizeColorBase('rgb(1.1, 2.1, 3.1)')).toBe(0x010203ff);
- expect(normalizeColorBase('rgba(1.1, 2.1, 3.1, 1.0)')).toBe(0x010203ff);
-});
-
-it('should refuse non spec compliant colors', () => {
- expect(normalizeColorBase('#00gg00')).toBe(null);
- expect(normalizeColorBase('rgb(1, 2, 3,)')).toBe(null);
- expect(normalizeColorBase('rgb(1, 2, 3')).toBe(null);
-
- // Used to be accepted by normalizeColorBase
- expect(normalizeColorBase('abc')).toBe(null);
- expect(normalizeColorBase(' #abc ')).toBe(null);
- expect(normalizeColorBase('##abc')).toBe(null);
- expect(normalizeColorBase('rgb 255 0 0')).toBe(null);
- expect(normalizeColorBase('RGBA(0, 1, 2)')).toBe(null);
- expect(normalizeColorBase('rgb (0, 1, 2)')).toBe(null);
- expect(normalizeColorBase('hsv(0, 1, 2)')).toBe(null);
- expect(normalizeColorBase({r: 10, g: 10, b: 10})).toBe(null);
- expect(normalizeColorBase('hsl(1%, 2, 3)')).toBe(null);
- expect(normalizeColorBase('rgb(1%, 2%, 3%)')).toBe(null);
-});
-
-it('should handle hex6 properly', () => {
- expect(normalizeColorBase('#000000')).toBe(0x000000ff);
- expect(normalizeColorBase('#ffffff')).toBe(0xffffffff);
- expect(normalizeColorBase('#ff00ff')).toBe(0xff00ffff);
- expect(normalizeColorBase('#abcdef')).toBe(0xabcdefff);
- expect(normalizeColorBase('#012345')).toBe(0x012345ff);
-});
-
-it('should handle hex3 properly', () => {
- expect(normalizeColorBase('#000')).toBe(0x000000ff);
- expect(normalizeColorBase('#fff')).toBe(0xffffffff);
- expect(normalizeColorBase('#f0f')).toBe(0xff00ffff);
-});
-
-it('should handle hex8 properly', () => {
- expect(normalizeColorBase('#00000000')).toBe(0x00000000);
- expect(normalizeColorBase('#ffffffff')).toBe(0xffffffff);
- expect(normalizeColorBase('#ffff00ff')).toBe(0xffff00ff);
- expect(normalizeColorBase('#abcdef01')).toBe(0xabcdef01);
- expect(normalizeColorBase('#01234567')).toBe(0x01234567);
-});
-
-it('should handle rgb properly', () => {
- expect(normalizeColorBase('rgb(0, 0, 0)')).toBe(0x000000ff);
- expect(normalizeColorBase('rgb(-1, -2, -3)')).toBe(0x000000ff);
- expect(normalizeColorBase('rgb(0, 0, 255)')).toBe(0x0000ffff);
- expect(normalizeColorBase('rgb(100, 15, 69)')).toBe(0x640f45ff);
- expect(normalizeColorBase('rgb(255, 255, 255)')).toBe(0xffffffff);
- expect(normalizeColorBase('rgb(256, 256, 256)')).toBe(0xffffffff);
-});
-
-it('should handle rgba properly', () => {
- expect(normalizeColorBase('rgba(0, 0, 0, 0.0)')).toBe(0x00000000);
- expect(normalizeColorBase('rgba(0, 0, 0, 0)')).toBe(0x00000000);
- expect(normalizeColorBase('rgba(0, 0, 0, -0.5)')).toBe(0x00000000);
- expect(normalizeColorBase('rgba(0, 0, 0, 1.0)')).toBe(0x000000ff);
- expect(normalizeColorBase('rgba(0, 0, 0, 1)')).toBe(0x000000ff);
- expect(normalizeColorBase('rgba(0, 0, 0, 1.5)')).toBe(0x000000ff);
- expect(normalizeColorBase('rgba(100, 15, 69, 0.5)')).toBe(0x640f4580);
-});
-
-it('should handle hsl properly', () => {
- expect(normalizeColorBase('hsl(0, 0%, 0%)')).toBe(0x000000ff);
- expect(normalizeColorBase('hsl(360, 100%, 100%)')).toBe(0xffffffff);
- expect(normalizeColorBase('hsl(180, 50%, 50%)')).toBe(0x40bfbfff);
- expect(normalizeColorBase('hsl(540, 50%, 50%)')).toBe(0x40bfbfff);
- expect(normalizeColorBase('hsl(70, 25%, 75%)')).toBe(0xcacfafff);
- expect(normalizeColorBase('hsl(70, 100%, 75%)')).toBe(0xeaff80ff);
- expect(normalizeColorBase('hsl(70, 110%, 75%)')).toBe(0xeaff80ff);
- expect(normalizeColorBase('hsl(70, 0%, 75%)')).toBe(0xbfbfbfff);
- expect(normalizeColorBase('hsl(70, -10%, 75%)')).toBe(0xbfbfbfff);
-});
-
-it('should handle hsla properly', () => {
- expect(normalizeColorBase('hsla(0, 0%, 0%, 0)')).toBe(0x00000000);
- expect(normalizeColorBase('hsla(360, 100%, 100%, 1)')).toBe(0xffffffff);
- expect(normalizeColorBase('hsla(360, 100%, 100%, 0)')).toBe(0xffffff00);
- expect(normalizeColorBase('hsla(180, 50%, 50%, 0.2)')).toBe(0x40bfbf33);
-});
-
-it('should handle named colors properly', () => {
- expect(normalizeColorBase('red')).toBe(0xff0000ff);
- expect(normalizeColorBase('transparent')).toBe(0x00000000);
- expect(normalizeColorBase('peachpuff')).toBe(0xffdab9ff);
-});
-
-it('should handle number colors properly', () => {
- expect(normalizeColorBase(0x00000000)).toBe(0x00000000);
- expect(normalizeColorBase(0xff0000ff)).toBe(0xff0000ff);
- expect(normalizeColorBase(0xffffffff)).toBe(0xffffffff);
- expect(normalizeColorBase(0x01234567)).toBe(0x01234567);
-});
-
-it("should return the same color when it's already normalized", () => {
- const normalizedColor = normalizeColorBase('red') || 0;
- expect(normalizeColorBase(normalizedColor)).toBe(normalizedColor);
-});
diff --git a/packages/normalize-color/__tests__/normalizeColor-test.js b/packages/normalize-color/__tests__/normalizeColor-test.js
new file mode 100644
index 000000000000..fc68e4c95ba9
--- /dev/null
+++ b/packages/normalize-color/__tests__/normalizeColor-test.js
@@ -0,0 +1,131 @@
+/**
+ * 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.
+ *
+ * @emails oncall+react_native
+ * @flow stroct
+ * @format
+ */
+
+'use strict';
+
+import normalizeColor from '..';
+
+it('accepts only spec compliant colors', () => {
+ expect(normalizeColor('#abc')).not.toBe(null);
+ expect(normalizeColor('#abcd')).not.toBe(null);
+ expect(normalizeColor('#abcdef')).not.toBe(null);
+ expect(normalizeColor('#abcdef01')).not.toBe(null);
+ expect(normalizeColor('rgb(1,2,3)')).not.toBe(null);
+ expect(normalizeColor('rgb(1, 2, 3)')).not.toBe(null);
+ expect(normalizeColor('rgb( 1 , 2 , 3 )')).not.toBe(null);
+ expect(normalizeColor('rgb(-1, -2, -3)')).not.toBe(null);
+ expect(normalizeColor('rgba(0, 0, 0, 1)')).not.toBe(null);
+ expect(normalizeColor(0x01234567 + 0.5)).toBe(null);
+ expect(normalizeColor(-1)).toBe(null);
+ expect(normalizeColor(0xffffffff + 1)).toBe(null);
+});
+
+it('temporarilys accept floating point values for rgb', () => {
+ expect(normalizeColor('rgb(1.1, 2.1, 3.1)')).toBe(0x010203ff);
+ expect(normalizeColor('rgba(1.1, 2.1, 3.1, 1.0)')).toBe(0x010203ff);
+});
+
+it('refuses non-spec compliant colors', () => {
+ expect(normalizeColor('#00gg00')).toBe(null);
+ expect(normalizeColor('rgb(1, 2, 3,)')).toBe(null);
+ expect(normalizeColor('rgb(1, 2, 3')).toBe(null);
+
+ // Used to be accepted by normalizeColor
+ expect(normalizeColor('abc')).toBe(null);
+ expect(normalizeColor(' #abc ')).toBe(null);
+ expect(normalizeColor('##abc')).toBe(null);
+ expect(normalizeColor('rgb 255 0 0')).toBe(null);
+ expect(normalizeColor('RGBA(0, 1, 2)')).toBe(null);
+ expect(normalizeColor('rgb (0, 1, 2)')).toBe(null);
+ expect(normalizeColor('hsv(0, 1, 2)')).toBe(null);
+ // $FlowExpectedError - Intentionally malformed argument.
+ expect(normalizeColor({r: 10, g: 10, b: 10})).toBe(null);
+ expect(normalizeColor('hsl(1%, 2, 3)')).toBe(null);
+ expect(normalizeColor('rgb(1%, 2%, 3%)')).toBe(null);
+});
+
+it('handles hex6 properly', () => {
+ expect(normalizeColor('#000000')).toBe(0x000000ff);
+ expect(normalizeColor('#ffffff')).toBe(0xffffffff);
+ expect(normalizeColor('#ff00ff')).toBe(0xff00ffff);
+ expect(normalizeColor('#abcdef')).toBe(0xabcdefff);
+ expect(normalizeColor('#012345')).toBe(0x012345ff);
+});
+
+it('handles hex3 properly', () => {
+ expect(normalizeColor('#000')).toBe(0x000000ff);
+ expect(normalizeColor('#fff')).toBe(0xffffffff);
+ expect(normalizeColor('#f0f')).toBe(0xff00ffff);
+});
+
+it('handles hex8 properly', () => {
+ expect(normalizeColor('#00000000')).toBe(0x00000000);
+ expect(normalizeColor('#ffffffff')).toBe(0xffffffff);
+ expect(normalizeColor('#ffff00ff')).toBe(0xffff00ff);
+ expect(normalizeColor('#abcdef01')).toBe(0xabcdef01);
+ expect(normalizeColor('#01234567')).toBe(0x01234567);
+});
+
+it('handles rgb properly', () => {
+ expect(normalizeColor('rgb(0, 0, 0)')).toBe(0x000000ff);
+ expect(normalizeColor('rgb(-1, -2, -3)')).toBe(0x000000ff);
+ expect(normalizeColor('rgb(0, 0, 255)')).toBe(0x0000ffff);
+ expect(normalizeColor('rgb(100, 15, 69)')).toBe(0x640f45ff);
+ expect(normalizeColor('rgb(255, 255, 255)')).toBe(0xffffffff);
+ expect(normalizeColor('rgb(256, 256, 256)')).toBe(0xffffffff);
+});
+
+it('handles rgba properly', () => {
+ expect(normalizeColor('rgba(0, 0, 0, 0.0)')).toBe(0x00000000);
+ expect(normalizeColor('rgba(0, 0, 0, 0)')).toBe(0x00000000);
+ expect(normalizeColor('rgba(0, 0, 0, -0.5)')).toBe(0x00000000);
+ expect(normalizeColor('rgba(0, 0, 0, 1.0)')).toBe(0x000000ff);
+ expect(normalizeColor('rgba(0, 0, 0, 1)')).toBe(0x000000ff);
+ expect(normalizeColor('rgba(0, 0, 0, 1.5)')).toBe(0x000000ff);
+ expect(normalizeColor('rgba(100, 15, 69, 0.5)')).toBe(0x640f4580);
+});
+
+it('handles hsl properly', () => {
+ expect(normalizeColor('hsl(0, 0%, 0%)')).toBe(0x000000ff);
+ expect(normalizeColor('hsl(360, 100%, 100%)')).toBe(0xffffffff);
+ expect(normalizeColor('hsl(180, 50%, 50%)')).toBe(0x40bfbfff);
+ expect(normalizeColor('hsl(540, 50%, 50%)')).toBe(0x40bfbfff);
+ expect(normalizeColor('hsl(70, 25%, 75%)')).toBe(0xcacfafff);
+ expect(normalizeColor('hsl(70, 100%, 75%)')).toBe(0xeaff80ff);
+ expect(normalizeColor('hsl(70, 110%, 75%)')).toBe(0xeaff80ff);
+ expect(normalizeColor('hsl(70, 0%, 75%)')).toBe(0xbfbfbfff);
+ expect(normalizeColor('hsl(70, -10%, 75%)')).toBe(0xbfbfbfff);
+});
+
+it('handles hsla properly', () => {
+ expect(normalizeColor('hsla(0, 0%, 0%, 0)')).toBe(0x00000000);
+ expect(normalizeColor('hsla(360, 100%, 100%, 1)')).toBe(0xffffffff);
+ expect(normalizeColor('hsla(360, 100%, 100%, 0)')).toBe(0xffffff00);
+ expect(normalizeColor('hsla(180, 50%, 50%, 0.2)')).toBe(0x40bfbf33);
+});
+
+it('handles named colors properly', () => {
+ expect(normalizeColor('red')).toBe(0xff0000ff);
+ expect(normalizeColor('transparent')).toBe(0x00000000);
+ expect(normalizeColor('peachpuff')).toBe(0xffdab9ff);
+});
+
+it('handles number colors properly', () => {
+ expect(normalizeColor(0x00000000)).toBe(0x00000000);
+ expect(normalizeColor(0xff0000ff)).toBe(0xff0000ff);
+ expect(normalizeColor(0xffffffff)).toBe(0xffffffff);
+ expect(normalizeColor(0x01234567)).toBe(0x01234567);
+});
+
+it('returns the same color when it is already normalized', () => {
+ const normalizedColor = normalizeColor('red') || 0;
+ expect(normalizeColor(normalizedColor)).toBe(normalizedColor);
+});
diff --git a/packages/normalize-color/base.js b/packages/normalize-color/base.js
deleted file mode 100644
index b8e88e942065..000000000000
--- a/packages/normalize-color/base.js
+++ /dev/null
@@ -1,387 +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.
- *
- * @format
- * @flow
- */
-
-/* eslint no-bitwise: 0 */
-
-'use strict';
-
-function normalizeColorBase(color: ?string | number): null | number {
- const matchers = getMatchers();
- let match;
-
- if (typeof color === 'number') {
- if (color >>> 0 === color && color >= 0 && color <= 0xffffffff) {
- return color;
- }
- return null;
- }
-
- if (typeof color !== 'string') {
- return null;
- }
-
- // Ordered based on occurrences on Facebook codebase
- if ((match = matchers.hex6.exec(color))) {
- return parseInt(match[1] + 'ff', 16) >>> 0;
- }
-
- if (names.hasOwnProperty(color)) {
- return names[color];
- }
-
- if ((match = matchers.rgb.exec(color))) {
- return (
- // b
- ((parse255(match[1]) << 24) | // r
- // $FlowFixMe[incompatible-use]
- (parse255(match[2]) << 16) | // g
- // $FlowFixMe[incompatible-use]
- (parse255(match[3]) << 8) |
- 0x000000ff) >>> // a
- 0
- );
- }
-
- if ((match = matchers.rgba.exec(color))) {
- return (
- // b
- ((parse255(match[1]) << 24) | // r
- // $FlowFixMe[incompatible-use]
- (parse255(match[2]) << 16) | // g
- // $FlowFixMe[incompatible-use]
- (parse255(match[3]) << 8) |
- // $FlowFixMe[incompatible-use]
- parse1(match[4])) >>> // a
- 0
- );
- }
-
- if ((match = matchers.hex3.exec(color))) {
- return (
- parseInt(
- match[1] +
- match[1] + // r
- match[2] +
- match[2] + // g
- match[3] +
- match[3] + // b
- 'ff', // a
- 16,
- ) >>> 0
- );
- }
-
- // https://drafts.csswg.org/css-color-4/#hex-notation
- if ((match = matchers.hex8.exec(color))) {
- return parseInt(match[1], 16) >>> 0;
- }
-
- if ((match = matchers.hex4.exec(color))) {
- return (
- parseInt(
- match[1] +
- match[1] + // r
- match[2] +
- match[2] + // g
- match[3] +
- match[3] + // b
- match[4] +
- match[4], // a
- 16,
- ) >>> 0
- );
- }
-
- if ((match = matchers.hsl.exec(color))) {
- return (
- (hslToRgb(
- parse360(match[1]), // h
- // $FlowFixMe[incompatible-use]
- parsePercentage(match[2]), // s
- // $FlowFixMe[incompatible-use]
- parsePercentage(match[3]), // l
- ) |
- 0x000000ff) >>> // a
- 0
- );
- }
-
- if ((match = matchers.hsla.exec(color))) {
- return (
- (hslToRgb(
- parse360(match[1]), // h
- // $FlowFixMe[incompatible-use]
- parsePercentage(match[2]), // s
- // $FlowFixMe[incompatible-use]
- parsePercentage(match[3]), // l
- ) |
- // $FlowFixMe[incompatible-use]
- parse1(match[4])) >>> // a
- 0
- );
- }
-
- return null;
-}
-
-function hue2rgb(p: number, q: number, t: number): number {
- if (t < 0) {
- t += 1;
- }
- if (t > 1) {
- t -= 1;
- }
- if (t < 1 / 6) {
- return p + (q - p) * 6 * t;
- }
- if (t < 1 / 2) {
- return q;
- }
- if (t < 2 / 3) {
- return p + (q - p) * (2 / 3 - t) * 6;
- }
- return p;
-}
-
-function hslToRgb(h: number, s: number, l: number): number {
- const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
- const p = 2 * l - q;
- const r = hue2rgb(p, q, h + 1 / 3);
- const g = hue2rgb(p, q, h);
- const b = hue2rgb(p, q, h - 1 / 3);
-
- return (
- (Math.round(r * 255) << 24) |
- (Math.round(g * 255) << 16) |
- (Math.round(b * 255) << 8)
- );
-}
-
-// var INTEGER = '[-+]?\\d+';
-const NUMBER = '[-+]?\\d*\\.?\\d+';
-const PERCENTAGE = NUMBER + '%';
-
-function call(...args) {
- return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
-}
-
-let cachedMatchers;
-
-function getMatchers() {
- if (cachedMatchers === undefined) {
- cachedMatchers = {
- rgb: new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)),
- rgba: new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)),
- hsl: new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)),
- hsla: new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)),
- hex3: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
- hex4: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
- hex6: /^#([0-9a-fA-F]{6})$/,
- hex8: /^#([0-9a-fA-F]{8})$/,
- };
- }
- return cachedMatchers;
-}
-
-function parse255(str: string): number {
- const int = parseInt(str, 10);
- if (int < 0) {
- return 0;
- }
- if (int > 255) {
- return 255;
- }
- return int;
-}
-
-function parse360(str: string): number {
- const int = parseFloat(str);
- return (((int % 360) + 360) % 360) / 360;
-}
-
-function parse1(str: string): number {
- const num = parseFloat(str);
- if (num < 0) {
- return 0;
- }
- if (num > 1) {
- return 255;
- }
- return Math.round(num * 255);
-}
-
-function parsePercentage(str: string): number {
- // parseFloat conveniently ignores the final %
- const int = parseFloat(str);
- if (int < 0) {
- return 0;
- }
- if (int > 100) {
- return 1;
- }
- return int / 100;
-}
-
-const names = {
- transparent: 0x00000000,
-
- // http://www.w3.org/TR/css3-color/#svg-color
- aliceblue: 0xf0f8ffff,
- antiquewhite: 0xfaebd7ff,
- aqua: 0x00ffffff,
- aquamarine: 0x7fffd4ff,
- azure: 0xf0ffffff,
- beige: 0xf5f5dcff,
- bisque: 0xffe4c4ff,
- black: 0x000000ff,
- blanchedalmond: 0xffebcdff,
- blue: 0x0000ffff,
- blueviolet: 0x8a2be2ff,
- brown: 0xa52a2aff,
- burlywood: 0xdeb887ff,
- burntsienna: 0xea7e5dff,
- cadetblue: 0x5f9ea0ff,
- chartreuse: 0x7fff00ff,
- chocolate: 0xd2691eff,
- coral: 0xff7f50ff,
- cornflowerblue: 0x6495edff,
- cornsilk: 0xfff8dcff,
- crimson: 0xdc143cff,
- cyan: 0x00ffffff,
- darkblue: 0x00008bff,
- darkcyan: 0x008b8bff,
- darkgoldenrod: 0xb8860bff,
- darkgray: 0xa9a9a9ff,
- darkgreen: 0x006400ff,
- darkgrey: 0xa9a9a9ff,
- darkkhaki: 0xbdb76bff,
- darkmagenta: 0x8b008bff,
- darkolivegreen: 0x556b2fff,
- darkorange: 0xff8c00ff,
- darkorchid: 0x9932ccff,
- darkred: 0x8b0000ff,
- darksalmon: 0xe9967aff,
- darkseagreen: 0x8fbc8fff,
- darkslateblue: 0x483d8bff,
- darkslategray: 0x2f4f4fff,
- darkslategrey: 0x2f4f4fff,
- darkturquoise: 0x00ced1ff,
- darkviolet: 0x9400d3ff,
- deeppink: 0xff1493ff,
- deepskyblue: 0x00bfffff,
- dimgray: 0x696969ff,
- dimgrey: 0x696969ff,
- dodgerblue: 0x1e90ffff,
- firebrick: 0xb22222ff,
- floralwhite: 0xfffaf0ff,
- forestgreen: 0x228b22ff,
- fuchsia: 0xff00ffff,
- gainsboro: 0xdcdcdcff,
- ghostwhite: 0xf8f8ffff,
- gold: 0xffd700ff,
- goldenrod: 0xdaa520ff,
- gray: 0x808080ff,
- green: 0x008000ff,
- greenyellow: 0xadff2fff,
- grey: 0x808080ff,
- honeydew: 0xf0fff0ff,
- hotpink: 0xff69b4ff,
- indianred: 0xcd5c5cff,
- indigo: 0x4b0082ff,
- ivory: 0xfffff0ff,
- khaki: 0xf0e68cff,
- lavender: 0xe6e6faff,
- lavenderblush: 0xfff0f5ff,
- lawngreen: 0x7cfc00ff,
- lemonchiffon: 0xfffacdff,
- lightblue: 0xadd8e6ff,
- lightcoral: 0xf08080ff,
- lightcyan: 0xe0ffffff,
- lightgoldenrodyellow: 0xfafad2ff,
- lightgray: 0xd3d3d3ff,
- lightgreen: 0x90ee90ff,
- lightgrey: 0xd3d3d3ff,
- lightpink: 0xffb6c1ff,
- lightsalmon: 0xffa07aff,
- lightseagreen: 0x20b2aaff,
- lightskyblue: 0x87cefaff,
- lightslategray: 0x778899ff,
- lightslategrey: 0x778899ff,
- lightsteelblue: 0xb0c4deff,
- lightyellow: 0xffffe0ff,
- lime: 0x00ff00ff,
- limegreen: 0x32cd32ff,
- linen: 0xfaf0e6ff,
- magenta: 0xff00ffff,
- maroon: 0x800000ff,
- mediumaquamarine: 0x66cdaaff,
- mediumblue: 0x0000cdff,
- mediumorchid: 0xba55d3ff,
- mediumpurple: 0x9370dbff,
- mediumseagreen: 0x3cb371ff,
- mediumslateblue: 0x7b68eeff,
- mediumspringgreen: 0x00fa9aff,
- mediumturquoise: 0x48d1ccff,
- mediumvioletred: 0xc71585ff,
- midnightblue: 0x191970ff,
- mintcream: 0xf5fffaff,
- mistyrose: 0xffe4e1ff,
- moccasin: 0xffe4b5ff,
- navajowhite: 0xffdeadff,
- navy: 0x000080ff,
- oldlace: 0xfdf5e6ff,
- olive: 0x808000ff,
- olivedrab: 0x6b8e23ff,
- orange: 0xffa500ff,
- orangered: 0xff4500ff,
- orchid: 0xda70d6ff,
- palegoldenrod: 0xeee8aaff,
- palegreen: 0x98fb98ff,
- paleturquoise: 0xafeeeeff,
- palevioletred: 0xdb7093ff,
- papayawhip: 0xffefd5ff,
- peachpuff: 0xffdab9ff,
- peru: 0xcd853fff,
- pink: 0xffc0cbff,
- plum: 0xdda0ddff,
- powderblue: 0xb0e0e6ff,
- purple: 0x800080ff,
- rebeccapurple: 0x663399ff,
- red: 0xff0000ff,
- rosybrown: 0xbc8f8fff,
- royalblue: 0x4169e1ff,
- saddlebrown: 0x8b4513ff,
- salmon: 0xfa8072ff,
- sandybrown: 0xf4a460ff,
- seagreen: 0x2e8b57ff,
- seashell: 0xfff5eeff,
- sienna: 0xa0522dff,
- silver: 0xc0c0c0ff,
- skyblue: 0x87ceebff,
- slateblue: 0x6a5acdff,
- slategray: 0x708090ff,
- slategrey: 0x708090ff,
- snow: 0xfffafaff,
- springgreen: 0x00ff7fff,
- steelblue: 0x4682b4ff,
- tan: 0xd2b48cff,
- teal: 0x008080ff,
- thistle: 0xd8bfd8ff,
- tomato: 0xff6347ff,
- turquoise: 0x40e0d0ff,
- violet: 0xee82eeff,
- wheat: 0xf5deb3ff,
- white: 0xffffffff,
- whitesmoke: 0xf5f5f5ff,
- yellow: 0xffff00ff,
- yellowgreen: 0x9acd32ff,
-};
-
-module.exports = normalizeColorBase;
diff --git a/packages/normalize-color/index.js b/packages/normalize-color/index.js
new file mode 100644
index 000000000000..15f50bd788f6
--- /dev/null
+++ b/packages/normalize-color/index.js
@@ -0,0 +1,378 @@
+/**
+ * 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.
+ *
+ * @format
+ * @noflow
+ */
+
+/* eslint no-bitwise: 0 */
+
+'use strict';
+
+function normalizeColor(color) {
+ if (typeof color === 'number') {
+ if (color >>> 0 === color && color >= 0 && color <= 0xffffffff) {
+ return color;
+ }
+ return null;
+ }
+
+ if (typeof color !== 'string') {
+ return null;
+ }
+
+ const matchers = getMatchers();
+ let match;
+
+ // Ordered based on occurrences on Facebook codebase
+ if ((match = matchers.hex6.exec(color))) {
+ return parseInt(match[1] + 'ff', 16) >>> 0;
+ }
+
+ const colorFromKeyword = normalizeKeyword(color);
+ if (colorFromKeyword != null) {
+ return colorFromKeyword;
+ }
+
+ if ((match = matchers.rgb.exec(color))) {
+ return (
+ ((parse255(match[1]) << 24) | // r
+ (parse255(match[2]) << 16) | // g
+ (parse255(match[3]) << 8) | // b
+ 0x000000ff) >>> // a
+ 0
+ );
+ }
+
+ if ((match = matchers.rgba.exec(color))) {
+ return (
+ ((parse255(match[1]) << 24) | // r
+ (parse255(match[2]) << 16) | // g
+ (parse255(match[3]) << 8) | // b
+ parse1(match[4])) >>> // a
+ 0
+ );
+ }
+
+ if ((match = matchers.hex3.exec(color))) {
+ return (
+ parseInt(
+ match[1] +
+ match[1] + // r
+ match[2] +
+ match[2] + // g
+ match[3] +
+ match[3] + // b
+ 'ff', // a
+ 16,
+ ) >>> 0
+ );
+ }
+
+ // https://drafts.csswg.org/css-color-4/#hex-notation
+ if ((match = matchers.hex8.exec(color))) {
+ return parseInt(match[1], 16) >>> 0;
+ }
+
+ if ((match = matchers.hex4.exec(color))) {
+ return (
+ parseInt(
+ match[1] +
+ match[1] + // r
+ match[2] +
+ match[2] + // g
+ match[3] +
+ match[3] + // b
+ match[4] +
+ match[4], // a
+ 16,
+ ) >>> 0
+ );
+ }
+
+ if ((match = matchers.hsl.exec(color))) {
+ return (
+ (hslToRgb(
+ parse360(match[1]), // h
+ parsePercentage(match[2]), // s
+ parsePercentage(match[3]), // l
+ ) |
+ 0x000000ff) >>> // a
+ 0
+ );
+ }
+
+ if ((match = matchers.hsla.exec(color))) {
+ return (
+ (hslToRgb(
+ parse360(match[1]), // h
+ parsePercentage(match[2]), // s
+ parsePercentage(match[3]), // l
+ ) |
+ parse1(match[4])) >>> // a
+ 0
+ );
+ }
+
+ return null;
+}
+
+function hue2rgb(p, q, t) {
+ if (t < 0) {
+ t += 1;
+ }
+ if (t > 1) {
+ t -= 1;
+ }
+ if (t < 1 / 6) {
+ return p + (q - p) * 6 * t;
+ }
+ if (t < 1 / 2) {
+ return q;
+ }
+ if (t < 2 / 3) {
+ return p + (q - p) * (2 / 3 - t) * 6;
+ }
+ return p;
+}
+
+function hslToRgb(h, s, l) {
+ const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ const p = 2 * l - q;
+ const r = hue2rgb(p, q, h + 1 / 3);
+ const g = hue2rgb(p, q, h);
+ const b = hue2rgb(p, q, h - 1 / 3);
+
+ return (
+ (Math.round(r * 255) << 24) |
+ (Math.round(g * 255) << 16) |
+ (Math.round(b * 255) << 8)
+ );
+}
+
+const NUMBER = '[-+]?\\d*\\.?\\d+';
+const PERCENTAGE = NUMBER + '%';
+
+function call(...args) {
+ return '\\(\\s*(' + args.join(')\\s*,\\s*(') + ')\\s*\\)';
+}
+
+let cachedMatchers;
+
+function getMatchers() {
+ if (cachedMatchers === undefined) {
+ cachedMatchers = {
+ rgb: new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER)),
+ rgba: new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER)),
+ hsl: new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE)),
+ hsla: new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER)),
+ hex3: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
+ hex4: /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
+ hex6: /^#([0-9a-fA-F]{6})$/,
+ hex8: /^#([0-9a-fA-F]{8})$/,
+ };
+ }
+ return cachedMatchers;
+}
+
+function parse255(str) {
+ const int = parseInt(str, 10);
+ if (int < 0) {
+ return 0;
+ }
+ if (int > 255) {
+ return 255;
+ }
+ return int;
+}
+
+function parse360(str) {
+ const int = parseFloat(str);
+ return (((int % 360) + 360) % 360) / 360;
+}
+
+function parse1(str) {
+ const num = parseFloat(str);
+ if (num < 0) {
+ return 0;
+ }
+ if (num > 1) {
+ return 255;
+ }
+ return Math.round(num * 255);
+}
+
+function parsePercentage(str) {
+ // parseFloat conveniently ignores the final %
+ const int = parseFloat(str);
+ if (int < 0) {
+ return 0;
+ }
+ if (int > 100) {
+ return 1;
+ }
+ return int / 100;
+}
+
+function normalizeKeyword(name) {
+ // prettier-ignore
+ switch (name) {
+ case 'transparent': return 0x00000000;
+ // http://www.w3.org/TR/css3-color/#svg-color
+ case 'aliceblue': return 0xf0f8ffff;
+ case 'antiquewhite': return 0xfaebd7ff;
+ case 'aqua': return 0x00ffffff;
+ case 'aquamarine': return 0x7fffd4ff;
+ case 'azure': return 0xf0ffffff;
+ case 'beige': return 0xf5f5dcff;
+ case 'bisque': return 0xffe4c4ff;
+ case 'black': return 0x000000ff;
+ case 'blanchedalmond': return 0xffebcdff;
+ case 'blue': return 0x0000ffff;
+ case 'blueviolet': return 0x8a2be2ff;
+ case 'brown': return 0xa52a2aff;
+ case 'burlywood': return 0xdeb887ff;
+ case 'burntsienna': return 0xea7e5dff;
+ case 'cadetblue': return 0x5f9ea0ff;
+ case 'chartreuse': return 0x7fff00ff;
+ case 'chocolate': return 0xd2691eff;
+ case 'coral': return 0xff7f50ff;
+ case 'cornflowerblue': return 0x6495edff;
+ case 'cornsilk': return 0xfff8dcff;
+ case 'crimson': return 0xdc143cff;
+ case 'cyan': return 0x00ffffff;
+ case 'darkblue': return 0x00008bff;
+ case 'darkcyan': return 0x008b8bff;
+ case 'darkgoldenrod': return 0xb8860bff;
+ case 'darkgray': return 0xa9a9a9ff;
+ case 'darkgreen': return 0x006400ff;
+ case 'darkgrey': return 0xa9a9a9ff;
+ case 'darkkhaki': return 0xbdb76bff;
+ case 'darkmagenta': return 0x8b008bff;
+ case 'darkolivegreen': return 0x556b2fff;
+ case 'darkorange': return 0xff8c00ff;
+ case 'darkorchid': return 0x9932ccff;
+ case 'darkred': return 0x8b0000ff;
+ case 'darksalmon': return 0xe9967aff;
+ case 'darkseagreen': return 0x8fbc8fff;
+ case 'darkslateblue': return 0x483d8bff;
+ case 'darkslategray': return 0x2f4f4fff;
+ case 'darkslategrey': return 0x2f4f4fff;
+ case 'darkturquoise': return 0x00ced1ff;
+ case 'darkviolet': return 0x9400d3ff;
+ case 'deeppink': return 0xff1493ff;
+ case 'deepskyblue': return 0x00bfffff;
+ case 'dimgray': return 0x696969ff;
+ case 'dimgrey': return 0x696969ff;
+ case 'dodgerblue': return 0x1e90ffff;
+ case 'firebrick': return 0xb22222ff;
+ case 'floralwhite': return 0xfffaf0ff;
+ case 'forestgreen': return 0x228b22ff;
+ case 'fuchsia': return 0xff00ffff;
+ case 'gainsboro': return 0xdcdcdcff;
+ case 'ghostwhite': return 0xf8f8ffff;
+ case 'gold': return 0xffd700ff;
+ case 'goldenrod': return 0xdaa520ff;
+ case 'gray': return 0x808080ff;
+ case 'green': return 0x008000ff;
+ case 'greenyellow': return 0xadff2fff;
+ case 'grey': return 0x808080ff;
+ case 'honeydew': return 0xf0fff0ff;
+ case 'hotpink': return 0xff69b4ff;
+ case 'indianred': return 0xcd5c5cff;
+ case 'indigo': return 0x4b0082ff;
+ case 'ivory': return 0xfffff0ff;
+ case 'khaki': return 0xf0e68cff;
+ case 'lavender': return 0xe6e6faff;
+ case 'lavenderblush': return 0xfff0f5ff;
+ case 'lawngreen': return 0x7cfc00ff;
+ case 'lemonchiffon': return 0xfffacdff;
+ case 'lightblue': return 0xadd8e6ff;
+ case 'lightcoral': return 0xf08080ff;
+ case 'lightcyan': return 0xe0ffffff;
+ case 'lightgoldenrodyellow': return 0xfafad2ff;
+ case 'lightgray': return 0xd3d3d3ff;
+ case 'lightgreen': return 0x90ee90ff;
+ case 'lightgrey': return 0xd3d3d3ff;
+ case 'lightpink': return 0xffb6c1ff;
+ case 'lightsalmon': return 0xffa07aff;
+ case 'lightseagreen': return 0x20b2aaff;
+ case 'lightskyblue': return 0x87cefaff;
+ case 'lightslategray': return 0x778899ff;
+ case 'lightslategrey': return 0x778899ff;
+ case 'lightsteelblue': return 0xb0c4deff;
+ case 'lightyellow': return 0xffffe0ff;
+ case 'lime': return 0x00ff00ff;
+ case 'limegreen': return 0x32cd32ff;
+ case 'linen': return 0xfaf0e6ff;
+ case 'magenta': return 0xff00ffff;
+ case 'maroon': return 0x800000ff;
+ case 'mediumaquamarine': return 0x66cdaaff;
+ case 'mediumblue': return 0x0000cdff;
+ case 'mediumorchid': return 0xba55d3ff;
+ case 'mediumpurple': return 0x9370dbff;
+ case 'mediumseagreen': return 0x3cb371ff;
+ case 'mediumslateblue': return 0x7b68eeff;
+ case 'mediumspringgreen': return 0x00fa9aff;
+ case 'mediumturquoise': return 0x48d1ccff;
+ case 'mediumvioletred': return 0xc71585ff;
+ case 'midnightblue': return 0x191970ff;
+ case 'mintcream': return 0xf5fffaff;
+ case 'mistyrose': return 0xffe4e1ff;
+ case 'moccasin': return 0xffe4b5ff;
+ case 'navajowhite': return 0xffdeadff;
+ case 'navy': return 0x000080ff;
+ case 'oldlace': return 0xfdf5e6ff;
+ case 'olive': return 0x808000ff;
+ case 'olivedrab': return 0x6b8e23ff;
+ case 'orange': return 0xffa500ff;
+ case 'orangered': return 0xff4500ff;
+ case 'orchid': return 0xda70d6ff;
+ case 'palegoldenrod': return 0xeee8aaff;
+ case 'palegreen': return 0x98fb98ff;
+ case 'paleturquoise': return 0xafeeeeff;
+ case 'palevioletred': return 0xdb7093ff;
+ case 'papayawhip': return 0xffefd5ff;
+ case 'peachpuff': return 0xffdab9ff;
+ case 'peru': return 0xcd853fff;
+ case 'pink': return 0xffc0cbff;
+ case 'plum': return 0xdda0ddff;
+ case 'powderblue': return 0xb0e0e6ff;
+ case 'purple': return 0x800080ff;
+ case 'rebeccapurple': return 0x663399ff;
+ case 'red': return 0xff0000ff;
+ case 'rosybrown': return 0xbc8f8fff;
+ case 'royalblue': return 0x4169e1ff;
+ case 'saddlebrown': return 0x8b4513ff;
+ case 'salmon': return 0xfa8072ff;
+ case 'sandybrown': return 0xf4a460ff;
+ case 'seagreen': return 0x2e8b57ff;
+ case 'seashell': return 0xfff5eeff;
+ case 'sienna': return 0xa0522dff;
+ case 'silver': return 0xc0c0c0ff;
+ case 'skyblue': return 0x87ceebff;
+ case 'slateblue': return 0x6a5acdff;
+ case 'slategray': return 0x708090ff;
+ case 'slategrey': return 0x708090ff;
+ case 'snow': return 0xfffafaff;
+ case 'springgreen': return 0x00ff7fff;
+ case 'steelblue': return 0x4682b4ff;
+ case 'tan': return 0xd2b48cff;
+ case 'teal': return 0x008080ff;
+ case 'thistle': return 0xd8bfd8ff;
+ case 'tomato': return 0xff6347ff;
+ case 'turquoise': return 0x40e0d0ff;
+ case 'violet': return 0xee82eeff;
+ case 'wheat': return 0xf5deb3ff;
+ case 'white': return 0xffffffff;
+ case 'whitesmoke': return 0xf5f5f5ff;
+ case 'yellow': return 0xffff00ff;
+ case 'yellowgreen': return 0x9acd32ff;
+ }
+ return null;
+}
+
+module.exports = normalizeColor;
diff --git a/packages/normalize-color/index.js.flow b/packages/normalize-color/index.js.flow
new file mode 100644
index 000000000000..c6199ff6deeb
--- /dev/null
+++ b/packages/normalize-color/index.js.flow
@@ -0,0 +1,10 @@
+/**
+ * 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.
+ *
+ * @flow strict
+ */
+
+declare module.exports: (color: ?(string | number)) => null | number;
diff --git a/packages/normalize-color/package.json b/packages/normalize-color/package.json
index 9ff2e8a0733d..7ecb89c6b89c 100644
--- a/packages/normalize-color/package.json
+++ b/packages/normalize-color/package.json
@@ -1,7 +1,7 @@
{
"name": "@react-native/normalize-color",
- "version": "1.0.0",
- "description": "Color normalization code for React Native.",
+ "version": "2.0.0",
+ "description": "Color normalization for React Native.",
"repository": {
"type": "git",
"url": "git@github.com:facebook/react-native.git",
From 963254e2ec31fd5897d46e51862feba5d65a7e5b Mon Sep 17 00:00:00 2001
From: Luna Wei
Date: Wed, 1 Sep 2021 01:40:01 -0700
Subject: [PATCH 050/986] Copy repo-config dependencies for bumping release
version
Summary:
Changelog: [Internal[Fixed] - Revert, yarn workspaces only used in private packages. Copy dependencies over from repo-config instead
Original commit changeset: 1dd2adc6a036
Reviewed By: fkgozali
Differential Revision: D30599065
fbshipit-source-id: 0efffaaf38bc23bac339e6e1d917736243e1750e
---
repo-config/package.json | 2 +-
scripts/bump-oss-version.js | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/repo-config/package.json b/repo-config/package.json
index 164f952a2f89..bc6712214e06 100644
--- a/repo-config/package.json
+++ b/repo-config/package.json
@@ -8,7 +8,7 @@
"type": "git",
"url": "git@github.com:facebook/react-native.git"
},
- "devDependencies": {
+ "dependencies": {
"@babel/core": "^7.14.0",
"@babel/generator": "^7.14.0",
"@babel/template": "^7.0.0",
diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js
index ef06e4f1e7f0..ab582e3666dd 100755
--- a/scripts/bump-oss-version.js
+++ b/scripts/bump-oss-version.js
@@ -127,13 +127,13 @@ fs.writeFileSync(
);
let packageJson = JSON.parse(cat('package.json'));
-
packageJson.version = version;
-
-// Only keep 'repo-config` workspace
-packageJson.workspaces = packageJson.workspaces.filter(w => w === 'repo-config');
-
+delete packageJson.workspaces;
delete packageJson.private;
+
+// Copy dependencies over from repo-config/package.json
+const repoConfigJson = JSON.parse(cat('repo-config/package.json'));
+packageJson.devDependencies = {...packageJson.devDependencies, ...repoConfigJson.dependencies};
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2), 'utf-8');
// Change ReactAndroid/gradle.properties
From 8b4f5073a18d919a39c64c428f58b11059d1b47a Mon Sep 17 00:00:00 2001
From: Andrei Shikov
Date: Wed, 1 Sep 2021 07:29:32 -0700
Subject: [PATCH 051/986] Log created views with mounting errors
Summary:
Displays views from the surface mounting manager after we hit a crash during mounting.
This change should help with debugging mounting crashes (e.g. when view is added before removal)
Changelog: [Internal]
Reviewed By: cortinico
Differential Revision: D30681339
fbshipit-source-id: f83cecaf8e418a2fa5aa0713513c51bb1be77013
---
.../fabric/mounting/MountItemDispatcher.java | 10 +++++++++-
.../mounting/SurfaceMountingManager.java | 19 +++++++++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
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 2370e84ba2fa..ca2c7df44f14 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.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 @@ private boolean dispatchMountItems() {
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 1f05f824c8f6..f93d1c20dcad 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 View getView(int reactTag) {
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.
From 329b026f3a48a4228a89696540ba459276f9a2c2 Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Wed, 1 Sep 2021 08:03:06 -0700
Subject: [PATCH 052/986] Switch order of search libraries to fix M1 build
error
Summary: changelog: Resolve Xcode 13 build error on M1 Macs for projects created from RN template
Reviewed By: fkgozali
Differential Revision: D30693466
fbshipit-source-id: f0b4fd471de38119d636c8e337831aa4d4599c4e
---
packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj | 4 ++--
template/ios/HelloWorld.xcodeproj/project.pbxproj | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
index d526edbc7d63..51a0c03e36c0 100644
--- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
+++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
@@ -783,10 +783,10 @@
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
+ "\"$(SDKROOT)/usr/lib/swift\"",
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",
- "\"$(SDKROOT)/usr/lib/swift\"",
);
"LIBRARY_SEARCH_PATHS[arch=*]" = "$(inherited)";
OTHER_LDFLAGS = (
@@ -818,10 +818,10 @@
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
+ "\"$(SDKROOT)/usr/lib/swift\"",
"$(inherited)",
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",
- "\"$(SDKROOT)/usr/lib/swift\"",
);
OTHER_LDFLAGS = (
"$(inherited)",
diff --git a/template/ios/HelloWorld.xcodeproj/project.pbxproj b/template/ios/HelloWorld.xcodeproj/project.pbxproj
index b05416f4193c..fbe9f29272fa 100644
--- a/template/ios/HelloWorld.xcodeproj/project.pbxproj
+++ b/template/ios/HelloWorld.xcodeproj/project.pbxproj
@@ -435,10 +435,10 @@
"$(inherited)",
);
LIBRARY_SEARCH_PATHS = (
+ "\"$(SDKROOT)/usr/lib/swift\"",
"\"$(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;
@@ -493,10 +493,10 @@
"$(inherited)",
);
LIBRARY_SEARCH_PATHS = (
+ "\"$(SDKROOT)/usr/lib/swift\"",
"\"$(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;
From 3e6eedaedb75f736aea170ed4a3544ecc7c33c4d Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Wed, 1 Sep 2021 10:08:25 -0700
Subject: [PATCH 053/986] Use surfaceId type instead of int in
PropsParserContext
Summary:
changelog: [internal]
Use surfaceId type instead of raw int type in PropsParserContext
Reviewed By: RSNara
Differential Revision: D30667540
fbshipit-source-id: 2bf890b892851e785318e3566692ac72ec782b91
---
.../react/renderer/attributedstring/AttributedString.h | 1 -
ReactCommon/react/renderer/attributedstring/TextAttributes.h | 2 +-
ReactCommon/react/renderer/core/ConcreteShadowNode.h | 1 +
ReactCommon/react/renderer/core/Props.h | 1 +
ReactCommon/react/renderer/core/PropsParserContext.h | 5 +++--
ReactCommon/react/renderer/core/ReactPrimitives.h | 2 --
ReactCommon/react/renderer/core/ShadowNodeFamily.h | 1 +
7 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/ReactCommon/react/renderer/attributedstring/AttributedString.h b/ReactCommon/react/renderer/attributedstring/AttributedString.h
index f3ed79223837..a1058c510bb2 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 87bbffc30e26..b7f07b962dae 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 d441f326a0b2..8ad8820f59e4 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 3321310b433f..5d99a0139a1e 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 9b9d10d2dcb2..df4b16d70a59 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 4954fcfff9b2..28738394bf9e 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 2f57666c1794..07746e35501b 100644
--- a/ReactCommon/react/renderer/core/ShadowNodeFamily.h
+++ b/ReactCommon/react/renderer/core/ShadowNodeFamily.h
@@ -10,6 +10,7 @@
#include
#include
+#include
#include
#include
From 66deb8a9c074007a5a0a5ac495853b1246f7047a Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Wed, 1 Sep 2021 10:08:25 -0700
Subject: [PATCH 054/986] Pass surfaceId to PropsParserContext when created
though native animated
Summary:
changelog: [internal]
Pass surfaceId to PropsParserContext instead of placeholder -1.
Reviewed By: RSNara
Differential Revision: D30667846
fbshipit-source-id: bed98ad6c829c1346d8eb9e68d7beeb6696d6c4a
---
React/Fabric/Mounting/RCTMountingManager.mm | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/React/Fabric/Mounting/RCTMountingManager.mm b/React/Fabric/Mounting/RCTMountingManager.mm
index beb1ed2b660e..f09ae72ce41a 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 @@ - (void)synchronouslyUpdateViewOnUIThread:(ReactTag)reactTag
{
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];
From 569c1cdce9848ad9d2fb03e0ef2edd901723d844 Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Wed, 1 Sep 2021 10:08:25 -0700
Subject: [PATCH 055/986] Remove unused property _rootTag RCTPropsAnimatedNode
Summary:
changelog: [internal]
`_rootTag` is never assigned to and never read, let's remove it.
Reviewed By: RSNara
Differential Revision: D30667860
fbshipit-source-id: f4b89ebe6b6d26559188b0e19682f5ac765d40b6
---
Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m | 3 ---
1 file changed, 3 deletions(-)
diff --git a/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m b/Libraries/NativeAnimation/Nodes/RCTPropsAnimatedNode.m
index 102234798bbc..91acd7dcbaed 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 @@ - (void)connectToView:(NSNumber *)viewTag
_connectedViewTag = viewTag;
_connectedViewName = viewName;
_managedByFabric = RCTUIManagerTypeForTagIsFabric(viewTag);
- _rootTag = nil;
}
- (void)disconnectFromView:(NSNumber *)viewTag
@@ -58,7 +56,6 @@ - (void)disconnectFromView:(NSNumber *)viewTag
_connectedViewTag = nil;
_connectedViewName = nil;
_managedByFabric = NO;
- _rootTag = nil;
}
- (void)updateView
From dbda1917cc10a2bb304bc65b3f54ac1c07243a30 Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Wed, 1 Sep 2021 11:17:41 -0700
Subject: [PATCH 056/986] Make RuntimeScheduler module compile in C++ 14
Summary:
changelog: [internal]
Don't use C++ 17 features in RuntimeScheduler module as it needs to be imported into C++14 module.
Also removes redundant dependency.
Reviewed By: ShikaSD
Differential Revision: D30485642
fbshipit-source-id: 0a20f85c596eebe193affc815c8ca851fc72e46d
---
ReactCommon/react/renderer/runtimescheduler/BUCK | 1 -
.../react/renderer/runtimescheduler/RuntimeScheduler.cpp | 6 ++++--
.../react/renderer/runtimescheduler/RuntimeScheduler.h | 6 ++++--
.../renderer/runtimescheduler/RuntimeSchedulerBinding.cpp | 7 ++++---
.../renderer/runtimescheduler/RuntimeSchedulerBinding.h | 6 ++++--
.../renderer/runtimescheduler/RuntimeSchedulerClock.h | 6 ++++--
.../react/renderer/runtimescheduler/SchedulerPriority.h | 7 ++++---
ReactCommon/react/renderer/runtimescheduler/Task.cpp | 6 ++++--
ReactCommon/react/renderer/runtimescheduler/Task.h | 6 ++++--
ReactCommon/react/renderer/runtimescheduler/primitives.h | 6 ++++--
10 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/ReactCommon/react/renderer/runtimescheduler/BUCK b/ReactCommon/react/renderer/runtimescheduler/BUCK
index 7cdf02a76375..83037289820e 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 d1550bc85b1a..fd47ab43033f 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 b5dad38ae2ad..5d18a7d9ea8a 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 05a3d3395a4c..92525118e282 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 cc4544d6a8f1..27c1ad9f31df 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 25e8b327db8f..51652ee0a070 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 4b5a1b7eab2f..329fe252aa38 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 b44d9719a10d..bd87944afa37 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 74c387636e78..87676d5db737 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 76794941452e..2283b4cad271 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
From e2e39808d35d87b8d828062f53cb980d26e4a78c Mon Sep 17 00:00:00 2001
From: Samuel Susla
Date: Wed, 1 Sep 2021 11:17:41 -0700
Subject: [PATCH 057/986] Remove RuntimeSchedulerManager
Summary:
Changelog: [internal]
Remove RuntimeSchedulerManager on Android in favor of different way to initialise RuntimeScheduler.
Reviewed By: ShikaSD
Differential Revision: D30486975
fbshipit-source-id: 9fe38de12be452bd9d2c92bb54cf5933ce7555b5
---
.../src/main/java/com/facebook/react/BUCK | 1 -
.../facebook/react/ReactInstanceManager.java | 6 ---
.../com/facebook/react/runtimescheduler/BUCK | 20 --------
.../RuntimeSchedulerManager.java | 39 ----------------
.../react/runtimescheduler/jni/Android.mk | 34 --------------
.../facebook/react/runtimescheduler/jni/BUCK | 35 --------------
.../react/runtimescheduler/jni/OnLoad.cpp | 15 ------
.../jni/RuntimeSchedulerManager.cpp | 46 -------------------
.../jni/RuntimeSchedulerManager.h | 40 ----------------
9 files changed, 236 deletions(-)
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/BUCK
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/RuntimeSchedulerManager.java
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/Android.mk
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/BUCK
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/OnLoad.cpp
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.cpp
delete mode 100644 ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/jni/RuntimeSchedulerManager.h
diff --git a/ReactAndroid/src/main/java/com/facebook/react/BUCK b/ReactAndroid/src/main/java/com/facebook/react/BUCK
index b550756ae1ba..a32feeb61c98 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 d73c8f7e1eca..4c8a8f97977f 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.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 interface ReactInstanceEventListener {
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 void destroy() {
mViewManagerNames = null;
}
mComponentNameResolverManager = null;
- mRuntimeSchedulerManager = null;
FLog.d(ReactConstants.TAG, "ReactInstanceManager has been destroyed");
}
@@ -1394,9 +1391,6 @@ public String[] getComponentNames() {
});
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/runtimescheduler/BUCK b/ReactAndroid/src/main/java/com/facebook/react/runtimescheduler/BUCK
deleted file mode 100644
index a68079db767f..000000000000
--- 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 d7846b568c40..000000000000
--- 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 bb4e32011288..000000000000
--- 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 426b06a13911..000000000000
--- 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 189de80dfce8..000000000000
--- 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 2b0d89337035..000000000000
--- 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 6456c7176fab..000000000000
--- 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
From c360b1d92b69e1d298b390ec88c4d29c1023945a Mon Sep 17 00:00:00 2001
From: fabriziobertoglio1987
Date: Wed, 1 Sep 2021 14:50:38 -0700
Subject: [PATCH 058/986] Fix non selectable Text in FlatList (#28952)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/26264 fixes https://github.com/facebook/react-native/issues/27107
Text is not selectable inside a FlatList on Android. The solution is to invalidate the ReactTextView after a change of the selectable prop. If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future and make the Text selectable.
## Changelog
[Android] [Fixed] - Fix non selectable Text in FlatList
Pull Request resolved: https://github.com/facebook/react-native/pull/28952
Test Plan:
**CLICK TO OPEN TESTS RESULTS**
The issue was demonstrated in the following [snack](https://snack.expo.io/fabrizio.bertoglio/selectable-bug-in-flatlist) (more info in issue https://github.com/facebook/react-native/issues/26264).
The solution is:
1) Calling `invalidate()` from [setSelectableText][1] after changing the `selectable` prop and `mSelectableText` value. [`invalidate()`](https://developer.android.com/reference/android/view/View#invalidate()) triggers the `onDraw` callback.
[1]: https://github.com/fabriziobertoglio1987/react-native/blob/8027524947cafd5cbdc492e4ef9c92b346fe23fc/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java#L427-L430
2) calling `setTextIsSelectable(mSelectableText);` from the [`onDraw`][2] callback
[2]: https://github.com/fabriziobertoglio1987/react-native/blob/8027524947cafd5cbdc492e4ef9c92b346fe23fc/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java#L456-L460
The example below is availabe in RNTester FlatList example. Two options (`onPressDisabled` and `textSelectable`) have been added to test the functionality inside a FlatList.
Reviewed By: ShikaSD
Differential Revision: D30000870
Pulled By: lunaleaps
fbshipit-source-id: 4851a294960df0af057d006793aa9ba97c51e3f9
---
.../react/views/text/ReactTextView.java | 8 +++++++
.../js/components/ListExampleShared.js | 4 +++-
.../js/examples/FlatList/FlatListExample.js | 23 ++++++++++++++++++-
3 files changed, 33 insertions(+), 2 deletions(-)
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 7ce861de7bfd..64135eda4f5e 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 void onStartTemporaryDetach() {
}
}
+ @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/packages/rn-tester/js/components/ListExampleShared.js b/packages/rn-tester/js/components/ListExampleShared.js
index 2312ee69c22f..158590e4ad3e 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 4606d68090c6..93d7eb2de4be 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}
/>
);
},
From 4384c32aad6a6b815504da710d19288954af190e Mon Sep 17 00:00:00 2001
From: "Aaron (Li Bo) Tao"
Date: Thu, 2 Sep 2021 02:38:21 -0700
Subject: [PATCH 059/986] revert to class component of ScrollViewStickyHeader
Summary:
Changelog:
[Internal][Changed] - revert to class component of ScrollViewStickyHeader. There is a redbox error during unmount in the functional version
Reviewed By: lunaleaps
Differential Revision: D30705974
fbshipit-source-id: b564c522b0026db0b334cc834a80bbbe9cd261e2
---
.../ScrollView/ScrollViewStickyHeader.js | 520 +++++++++---------
1 file changed, 268 insertions(+), 252 deletions(-)
diff --git a/Libraries/Components/ScrollView/ScrollViewStickyHeader.js b/Libraries/Components/ScrollView/ScrollViewStickyHeader.js
index f530be611602..ea21ce221b75 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 AnimatedImplementation from '../../Animated/AnimatedImplementation';
+import AnimatedAddition from '../../Animated/nodes/AnimatedAddition';
+import AnimatedDiffClamp from '../../Animated/nodes/AnimatedDiffClamp';
+import AnimatedNode from '../../Animated/nodes/AnimatedNode';
+
import * as React from 'react';
-import {useEffect, useMemo, useRef, useCallback} 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 = Animated.View;
+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);
+ }
+ if (this._timer) {
+ clearTimeout(this._timer);
}
- return initialTranslateY;
- });
+ }
- const _haveReceivedInitialZeroTranslateY = useRef(true);
- const _timer = useRef(null);
+ UNSAFE_componentWillReceiveProps(nextProps: Props) {
+ if (
+ nextProps.scrollViewHeight !== this.props.scrollViewHeight ||
+ nextProps.scrollAnimatedValue !== this.props.scrollAnimatedValue ||
+ nextProps.inverted !== this.props.inverted
+ ) {
+ this._shouldRecreateTranslateY = true;
+ }
+ }
- useEffect(() => {
- if (translateY !== 0 && translateY != null) {
- _haveReceivedInitialZeroTranslateY.current = false;
+ updateTranslateListener(
+ translateY: AnimatedImplementation.Interpolation,
+ isFabric: boolean,
+ offset: AnimatedDiffClamp | null,
+ ) {
+ if (this._translateY != null && this._animatedValueListenerId != null) {
+ this._translateY.removeListener(this._animatedValueListenerId);
}
- }, [translateY]);
+ offset
+ ? (this._translateY = new AnimatedAddition(translateY, offset))
+ : (this._translateY = 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);
- }
- }, _debounceTimeout);
- },
- [translateY],
- );
+ this._shouldRecreateTranslateY = false;
- useEffect(() => {
- const inputRange: Array = [-1, 0];
- const outputRange: Array = [0, 0];
+ if (!isFabric) {
+ return;
+ }
- 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._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;
}
- } 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);
+ if (this._timer) {
+ clearTimeout(this._timer);
}
- }
- }
-
- let newAnimatedTranslateY: Animated.Node = scrollAnimatedValue.interpolate({
- inputRange,
- outputRange,
- });
-
- if (offset != null) {
- newAnimatedTranslateY = Animated.add(newAnimatedTranslateY, offset);
+ this._timer = setTimeout(() => {
+ if (value !== this.state.translateY) {
+ this.setState({
+ translateY: value,
+ });
+ }
+ }, this._debounceTimeout);
+ };
}
-
- // add the event listener
- let animatedListenerId;
- if (isFabric) {
- animatedListenerId = newAnimatedTranslateY.addListener(
- animatedValueListener,
- );
+ if (this.state.translateY !== 0 && this.state.translateY != null) {
+ this._haveReceivedInitialZeroTranslateY = false;
}
+ this._animatedValueListenerId = translateY.addListener(
+ this._animatedValueListener,
+ );
+ }
- setAnimatedTranslateY(newAnimatedTranslateY);
+ _onLayout = event => {
+ const layoutY = event.nativeEvent.layout.y;
+ const layoutHeight = event.nativeEvent.layout.height;
+ const measured = true;
- // 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]);
+ if (
+ layoutY !== this.state.layoutY ||
+ layoutHeight !== this.state.layoutHeight ||
+ measured !== this.state.measured
+ ) {
+ this._shouldRecreateTranslateY = true;
+ }
- const _onLayout = (event: LayoutEvent) => {
- setLayoutY(event.nativeEvent.layout.y);
- setLayoutHeight(event.nativeEvent.layout.height);
- setMeasured(true);
+ this.setState({
+ measured,
+ layoutY,
+ layoutHeight,
+ });
- 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;
+ };
+
+ 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];
- // TODO T68319535: remove this if NativeAnimated is rewritten for Fabric
- const passthroughAnimatedPropExplicitValues =
- isFabric && translateY != null
- ? {
- style: {transform: [{translateY: translateY}]},
+ 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;
From 6a2b6c2f3ef63cf0ff733daf75005ee32eebdd00 Mon Sep 17 00:00:00 2001
From: Nicola Corti
Date: Thu, 2 Sep 2021 04:30:01 -0700
Subject: [PATCH 060/986] Bump Kotlin to 1.4.32 (#32137)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32137
Bumping the minor version of Kotlin. I don't expect any major breakage.
Changelog:
[Android] [Changed] - Bumped Kotlin to 1.4.32
Reviewed By: ShikaSD
Differential Revision: D30698315
fbshipit-source-id: e1de6251c1c17c490700298540dea5b48d034e3c
---
gradle.properties | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gradle.properties b/gradle.properties
index e785ec12c912..223dcfb79c24 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
From b1120c6a6513ec24568abc6bbe60dd57ef1dec96 Mon Sep 17 00:00:00 2001
From: Nicola Corti
Date: Thu, 2 Sep 2021 04:30:01 -0700
Subject: [PATCH 061/986] Bump Gradle to 7.1.1 (#32138)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32138
This is a follow up to the Gradle bump: D30486612 (https://github.com/facebook/react-native/commit/85249cafe8870ab8f47c38569b106555ce2f8527)
Changelog:
[Android] [Changed] - Bumped Gradle to 7.1.1
Reviewed By: ShikaSD
Differential Revision: D30698411
fbshipit-source-id: ae51499c36380dca6763abeaf04ab3d6ca37456d
---
gradle/wrapper/gradle-wrapper.properties | 2 +-
.../android/gradle/wrapper/gradle-wrapper.properties | 2 +-
template/android/gradle/wrapper/gradle-wrapper.properties | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 29e413457635..af7be50b1015 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/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties b/packages/react-native-codegen/android/gradle/wrapper/gradle-wrapper.properties
index 29e413457635..af7be50b1015 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/template/android/gradle/wrapper/gradle-wrapper.properties b/template/android/gradle/wrapper/gradle-wrapper.properties
index 29e413457635..af7be50b1015 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
From 99f3a6a56e04a73744dfff004613307d6b5aa8d0 Mon Sep 17 00:00:00 2001
From: Pieter Vanderwerff
Date: Thu, 2 Sep 2021 11:38:52 -0700
Subject: [PATCH 062/986] Deploy 0.159.0 to xplat
Summary: Changelog: [Internal]
Reviewed By: mroch
Differential Revision: D30712727
fbshipit-source-id: 21db45b834cf902619743871e7f076fceff46053
---
.flowconfig | 2 +-
.flowconfig.android | 2 +-
package.json | 2 +-
repo-config/package.json | 2 +-
template/_flowconfig | 2 +-
yarn.lock | 8 ++++----
6 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/.flowconfig b/.flowconfig
index c7aa3f075c7e..e6ad16c7bcc1 100644
--- a/.flowconfig
+++ b/.flowconfig
@@ -71,4 +71,4 @@ untyped-import
untyped-type-import
[version]
-^0.158.0
+^0.159.0
diff --git a/.flowconfig.android b/.flowconfig.android
index 96b27477635f..53110b81ff77 100644
--- a/.flowconfig.android
+++ b/.flowconfig.android
@@ -71,4 +71,4 @@ untyped-import
untyped-type-import
[version]
-^0.158.0
+^0.159.0
diff --git a/package.json b/package.json
index f8d1e7729122..5c651a3d53b2 100644
--- a/package.json
+++ b/package.json
@@ -121,7 +121,7 @@
"ws": "^6.1.4"
},
"devDependencies": {
- "flow-bin": "^0.158.0",
+ "flow-bin": "^0.159.0",
"react": "17.0.2"
},
"detox": {
diff --git a/repo-config/package.json b/repo-config/package.json
index bc6712214e06..c09bf529a56b 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.10.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/template/_flowconfig b/template/_flowconfig
index 4320b7070ea6..cb5247b72a82 100644
--- a/template/_flowconfig
+++ b/template/_flowconfig
@@ -62,4 +62,4 @@ untyped-import
untyped-type-import
[version]
-^0.158.0
+^0.159.0
diff --git a/yarn.lock b/yarn.lock
index c19efec0b0be..5f5e62cfb958 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3028,10 +3028,10 @@ flatted@^2.0.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138"
integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA==
-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.*, flow-parser@^0.121.0:
version "0.121.0"
From c13eb781fec49ada04ba3a2d691a029842785e3c Mon Sep 17 00:00:00 2001
From: Janic Duplessis
Date: Thu, 2 Sep 2021 12:02:44 -0700
Subject: [PATCH 063/986] Exclude OpenSSL-Universal flipper dependency from
release builds (#31938)
Summary:
Use the same technique as other flipper transitive deps to make sure it is excluded from release builds.
## Changelog
[iOS][Fixed] - Exclude OpenSSL-Universal flipper dependency from release builds
Pull Request resolved: https://github.com/facebook/react-native/pull/31938
Test Plan: Tested in an app that it still builds and works.
Reviewed By: mweststrate
Differential Revision: D30674216
Pulled By: yungsters
fbshipit-source-id: f2ab5154c80036e6df90d1a98882cc4b85734485
---
scripts/react_native_pods.rb | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index 2325ad33c574..dd3d60ca256c 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -79,6 +79,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
@@ -102,6 +103,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)
From a40f973f58609ca717fac63bc501d5cf93b748ad Mon Sep 17 00:00:00 2001
From: Ashoat Tevosyan
Date: Thu, 2 Sep 2021 12:15:04 -0700
Subject: [PATCH 064/986] Remove custom Hermes config for Android (#31900)
Summary:
Right now, `react-native` on Android passes in an explicit Hermes config when initializes Hermes. The upcoming version of Hermes shipping with React Native 0.66 will handle this default config itself, so there's no need to override it from Android anymore.
Changelog:
[Android][Changed] - Hermes initialization will no longer need an explicit configuration.
Pull Request resolved: https://github.com/facebook/react-native/pull/31900
Test Plan: I compiled and ran a React Native app using the Android build, making sure to build `ReactAndroid` from source. I confirmed that the config was actually being applied by testing how much memory an application could eat before being killed.
Reviewed By: sshic
Differential Revision: D30675510
Pulled By: yungsters
fbshipit-source-id: 5eef056893b72ddd433ee808eb08d0eb56f22f72
---
.../com/facebook/hermes/reactexecutor/BUCK | 16 --------
.../hermes/reactexecutor/HermesExecutor.java | 9 ++---
.../reactexecutor/HermesExecutorFactory.java | 12 +-----
.../facebook/hermes/reactexecutor/OnLoad.cpp | 40 +------------------
.../hermes/reactexecutor/RuntimeConfig.java | 19 ---------
5 files changed, 5 insertions(+), 91 deletions(-)
delete mode 100644 ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
index fca40c1027f7..f305aa4fe0ed 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
@@ -17,22 +17,6 @@ rn_android_library(
react_native_target("java/com/facebook/hermes/instrumentation:hermes_samplingprofiler"),
react_native_target("java/com/facebook/react/bridge:bridge"),
":jni",
- ":runtimeconfig",
- ],
-)
-
-rn_android_library(
- name = "runtimeconfig",
- srcs = [
- "RuntimeConfig.java",
- ],
- autoglob = False,
- visibility = [
- "PUBLIC",
- ],
- deps = [
- react_native_dep("third-party/java/jsr-305:jsr-305"),
- react_native_target("java/com/facebook/hermes/instrumentation:instrumentation"),
],
)
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java
index 7519f2146faf..cdee2c9ef80d 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java
@@ -10,7 +10,6 @@
import com.facebook.jni.HybridData;
import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.soloader.SoLoader;
-import javax.annotation.Nullable;
public class HermesExecutor extends JavaScriptExecutor {
private static String mode_;
@@ -27,8 +26,8 @@ public class HermesExecutor extends JavaScriptExecutor {
}
}
- HermesExecutor(@Nullable RuntimeConfig config) {
- super(config == null ? initHybridDefaultConfig() : initHybrid(config.heapSizeMB));
+ HermesExecutor() {
+ super(initHybrid());
}
@Override
@@ -45,7 +44,5 @@ public String getName() {
*/
public static native boolean canLoadFile(String path);
- private static native HybridData initHybridDefaultConfig();
-
- private static native HybridData initHybrid(long heapSizeMB);
+ private static native HybridData initHybrid();
}
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
index 976af80b1eeb..a2686dba3a95 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
@@ -14,19 +14,9 @@
public class HermesExecutorFactory implements JavaScriptExecutorFactory {
private static final String TAG = "Hermes";
- private final RuntimeConfig mConfig;
-
- public HermesExecutorFactory() {
- this(new RuntimeConfig(1024));
- }
-
- public HermesExecutorFactory(RuntimeConfig config) {
- mConfig = config;
- }
-
@Override
public JavaScriptExecutor create() {
- return new HermesExecutor(mConfig);
+ return new HermesExecutor();
}
@Override
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp
index 56a9f589490f..f02a1b190687 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp
@@ -10,8 +10,6 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
@@ -30,26 +28,6 @@ static void hermesFatalHandler(const std::string &reason) {
static std::once_flag flag;
-static ::hermes::vm::RuntimeConfig makeRuntimeConfig(jlong heapSizeMB) {
- namespace vm = ::hermes::vm;
- auto gcConfigBuilder =
- vm::GCConfig::Builder()
- .withName("RN")
- // For the next two arguments: avoid GC before TTI by initializing the
- // runtime to allocate directly in the old generation, but revert to
- // normal operation when we reach the (first) TTI point.
- .withAllocInYoung(false)
- .withRevertToYGAtTTI(true);
-
- if (heapSizeMB > 0) {
- gcConfigBuilder.withMaxHeapSize(heapSizeMB << 20);
- }
-
- return vm::RuntimeConfig::Builder()
- .withGCConfig(gcConfigBuilder.build())
- .build();
-}
-
static void installBindings(jsi::Runtime &runtime) {
react::Logger androidLogger =
static_cast(
@@ -67,8 +45,7 @@ class HermesExecutorHolder
static constexpr auto kJavaDescriptor =
"Lcom/facebook/hermes/reactexecutor/HermesExecutor;";
- static jni::local_ref initHybridDefaultConfig(
- jni::alias_ref) {
+ static jni::local_ref initHybrid(jni::alias_ref) {
JReactMarker::setLogPerfMarkerIfNeeded();
std::call_once(flag, []() {
@@ -78,18 +55,6 @@ class HermesExecutorHolder
std::make_unique(installBindings));
}
- static jni::local_ref initHybrid(
- jni::alias_ref,
- jlong heapSizeMB) {
- JReactMarker::setLogPerfMarkerIfNeeded();
- auto runtimeConfig = makeRuntimeConfig(heapSizeMB);
- std::call_once(flag, []() {
- facebook::hermes::HermesRuntime::setFatalHandler(hermesFatalHandler);
- });
- return makeCxxInstance(std::make_unique(
- installBindings, JSIExecutor::defaultTimeoutInvoker, runtimeConfig));
- }
-
static bool canLoadFile(jni::alias_ref, const std::string &path) {
return true;
}
@@ -97,9 +62,6 @@ class HermesExecutorHolder
static void registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", HermesExecutorHolder::initHybrid),
- makeNativeMethod(
- "initHybridDefaultConfig",
- HermesExecutorHolder::initHybridDefaultConfig),
makeNativeMethod("canLoadFile", HermesExecutorHolder::canLoadFile)});
}
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
deleted file mode 100644
index fec7c457bc8b..000000000000
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
+++ /dev/null
@@ -1,19 +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.hermes.reactexecutor;
-
-/** Holds runtime configuration for a Hermes VM instance (master or snapshot). */
-public final class RuntimeConfig {
- public long heapSizeMB;
-
- RuntimeConfig() {}
-
- RuntimeConfig(long heapSizeMB) {
- this.heapSizeMB = heapSizeMB;
- }
-}
From 7edf9274cf6d3398075c19cd1cb020a5d6a346a2 Mon Sep 17 00:00:00 2001
From: Janic Duplessis
Date: Thu, 2 Sep 2021 12:36:17 -0700
Subject: [PATCH 065/986] Fix keyboardDismissMode="on-drag" on Android (#31943)
Summary:
Fixes https://github.com/facebook/react-native/issues/23364
The current logic using `_isTouching` does not work because `_handleTouchCancel` is always called before scroll events begin. This means `_isTouching` is always false. To fix it I moved the logic to `_handleScrollBeginDrag` which is only called once when scroll drag beings. This accomplishes the expected behavior and is better than keeping it in onScroll where it would be called for each scroll event.
## Changelog
[Android] [Fixed] - Fix keyboardDismissMode="on-drag" on Android
Pull Request resolved: https://github.com/facebook/react-native/pull/31943
Test Plan: Tested in an app that on-drag does not work before and works after this patch.
Reviewed By: sshic
Differential Revision: D30674276
Pulled By: yungsters
fbshipit-source-id: aa0bd605809fa01518f70fbf323c06e32c76ed1d
---
Libraries/Components/ScrollView/ScrollView.js | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js
index e497288b1b7d..696781ffbe3d 100644
--- a/Libraries/Components/ScrollView/ScrollView.js
+++ b/Libraries/Components/ScrollView/ScrollView.js
@@ -1178,11 +1178,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);
};
@@ -1299,6 +1294,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);
};
From 455433f481bf5f743a3330a9a46edda5fc69da69 Mon Sep 17 00:00:00 2001
From: Tim Yung
Date: Thu, 2 Sep 2021 13:17:53 -0700
Subject: [PATCH 066/986] Revert D30675510: Remove custom Hermes config for
Android
Differential Revision:
D30675510 (https://github.com/facebook/react-native/commit/a40f973f58609ca717fac63bc501d5cf93b748ad)
Original commit changeset: 5eef056893b7
fbshipit-source-id: 25db31c4fbe938d92bba8b0bfe6523bced1524f0
---
.../com/facebook/hermes/reactexecutor/BUCK | 16 ++++++++
.../hermes/reactexecutor/HermesExecutor.java | 9 +++--
.../reactexecutor/HermesExecutorFactory.java | 12 +++++-
.../facebook/hermes/reactexecutor/OnLoad.cpp | 40 ++++++++++++++++++-
.../hermes/reactexecutor/RuntimeConfig.java | 19 +++++++++
5 files changed, 91 insertions(+), 5 deletions(-)
create mode 100644 ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
index f305aa4fe0ed..fca40c1027f7 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/BUCK
@@ -17,6 +17,22 @@ rn_android_library(
react_native_target("java/com/facebook/hermes/instrumentation:hermes_samplingprofiler"),
react_native_target("java/com/facebook/react/bridge:bridge"),
":jni",
+ ":runtimeconfig",
+ ],
+)
+
+rn_android_library(
+ name = "runtimeconfig",
+ srcs = [
+ "RuntimeConfig.java",
+ ],
+ autoglob = False,
+ visibility = [
+ "PUBLIC",
+ ],
+ deps = [
+ react_native_dep("third-party/java/jsr-305:jsr-305"),
+ react_native_target("java/com/facebook/hermes/instrumentation:instrumentation"),
],
)
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java
index cdee2c9ef80d..7519f2146faf 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutor.java
@@ -10,6 +10,7 @@
import com.facebook.jni.HybridData;
import com.facebook.react.bridge.JavaScriptExecutor;
import com.facebook.soloader.SoLoader;
+import javax.annotation.Nullable;
public class HermesExecutor extends JavaScriptExecutor {
private static String mode_;
@@ -26,8 +27,8 @@ public class HermesExecutor extends JavaScriptExecutor {
}
}
- HermesExecutor() {
- super(initHybrid());
+ HermesExecutor(@Nullable RuntimeConfig config) {
+ super(config == null ? initHybridDefaultConfig() : initHybrid(config.heapSizeMB));
}
@Override
@@ -44,5 +45,7 @@ public String getName() {
*/
public static native boolean canLoadFile(String path);
- private static native HybridData initHybrid();
+ private static native HybridData initHybridDefaultConfig();
+
+ private static native HybridData initHybrid(long heapSizeMB);
}
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
index a2686dba3a95..976af80b1eeb 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
@@ -14,9 +14,19 @@
public class HermesExecutorFactory implements JavaScriptExecutorFactory {
private static final String TAG = "Hermes";
+ private final RuntimeConfig mConfig;
+
+ public HermesExecutorFactory() {
+ this(new RuntimeConfig(1024));
+ }
+
+ public HermesExecutorFactory(RuntimeConfig config) {
+ mConfig = config;
+ }
+
@Override
public JavaScriptExecutor create() {
- return new HermesExecutor();
+ return new HermesExecutor(mConfig);
}
@Override
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp
index f02a1b190687..56a9f589490f 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/OnLoad.cpp
@@ -10,6 +10,8 @@
#include
#include
#include
+#include
+#include
#include
#include
#include
@@ -28,6 +30,26 @@ static void hermesFatalHandler(const std::string &reason) {
static std::once_flag flag;
+static ::hermes::vm::RuntimeConfig makeRuntimeConfig(jlong heapSizeMB) {
+ namespace vm = ::hermes::vm;
+ auto gcConfigBuilder =
+ vm::GCConfig::Builder()
+ .withName("RN")
+ // For the next two arguments: avoid GC before TTI by initializing the
+ // runtime to allocate directly in the old generation, but revert to
+ // normal operation when we reach the (first) TTI point.
+ .withAllocInYoung(false)
+ .withRevertToYGAtTTI(true);
+
+ if (heapSizeMB > 0) {
+ gcConfigBuilder.withMaxHeapSize(heapSizeMB << 20);
+ }
+
+ return vm::RuntimeConfig::Builder()
+ .withGCConfig(gcConfigBuilder.build())
+ .build();
+}
+
static void installBindings(jsi::Runtime &runtime) {
react::Logger androidLogger =
static_cast(
@@ -45,7 +67,8 @@ class HermesExecutorHolder
static constexpr auto kJavaDescriptor =
"Lcom/facebook/hermes/reactexecutor/HermesExecutor;";
- static jni::local_ref initHybrid(jni::alias_ref) {
+ static jni::local_ref initHybridDefaultConfig(
+ jni::alias_ref) {
JReactMarker::setLogPerfMarkerIfNeeded();
std::call_once(flag, []() {
@@ -55,6 +78,18 @@ class HermesExecutorHolder
std::make_unique(installBindings));
}
+ static jni::local_ref initHybrid(
+ jni::alias_ref,
+ jlong heapSizeMB) {
+ JReactMarker::setLogPerfMarkerIfNeeded();
+ auto runtimeConfig = makeRuntimeConfig(heapSizeMB);
+ std::call_once(flag, []() {
+ facebook::hermes::HermesRuntime::setFatalHandler(hermesFatalHandler);
+ });
+ return makeCxxInstance(std::make_unique(
+ installBindings, JSIExecutor::defaultTimeoutInvoker, runtimeConfig));
+ }
+
static bool canLoadFile(jni::alias_ref, const std::string &path) {
return true;
}
@@ -62,6 +97,9 @@ class HermesExecutorHolder
static void registerNatives() {
registerHybrid(
{makeNativeMethod("initHybrid", HermesExecutorHolder::initHybrid),
+ makeNativeMethod(
+ "initHybridDefaultConfig",
+ HermesExecutorHolder::initHybridDefaultConfig),
makeNativeMethod("canLoadFile", HermesExecutorHolder::canLoadFile)});
}
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
new file mode 100644
index 000000000000..fec7c457bc8b
--- /dev/null
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
@@ -0,0 +1,19 @@
+/*
+ * 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.hermes.reactexecutor;
+
+/** Holds runtime configuration for a Hermes VM instance (master or snapshot). */
+public final class RuntimeConfig {
+ public long heapSizeMB;
+
+ RuntimeConfig() {}
+
+ RuntimeConfig(long heapSizeMB) {
+ this.heapSizeMB = heapSizeMB;
+ }
+}
From a909ba20db84480c3ac699f0689d5757509b1668 Mon Sep 17 00:00:00 2001
From: Ramanpreet Nara
Date: Thu, 2 Sep 2021 16:48:53 -0700
Subject: [PATCH 067/986] Remove !RCTRootView.bridge check from
FBReactRootViewController
Summary:
Users of RCTRootView access the bridge from it, to see if it's nil or not.
## Changes
- Instead of exposing the bridge from RCTRootView for this use-case, we're now exposing a property on RCTRootView: hasBridge. This will be false in bridgeless mode, and true in bridge mode.
## Benefits
This takes us one step closer towards removing RCTBridge leakage through RCTRootView.
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D30434885
fbshipit-source-id: 02f50e16831852b5049a626e8b08d59a90b2059a
---
React/Base/RCTRootView.h | 5 +++++
React/Base/RCTRootView.m | 5 +++++
.../SurfaceHostingView/RCTSurfaceHostingProxyRootView.h | 1 +
.../SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm | 5 +++++
4 files changed, 16 insertions(+)
diff --git a/React/Base/RCTRootView.h b/React/Base/RCTRootView.h
index f555e234c713..5074c54bda6c 100644
--- a/React/Base/RCTRootView.h
+++ b/React/Base/RCTRootView.h
@@ -75,6 +75,11 @@ 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;
+
/**
* 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 7e8a3804d1db..c5c5881739ca 100644
--- a/React/Base/RCTRootView.m
+++ b/React/Base/RCTRootView.m
@@ -116,6 +116,11 @@ - (instancetype)initWithBundleURL:(NSURL *)bundleURL
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
+- (BOOL)hasBridge
+{
+ return _bridge != nil;
+}
+
#pragma mark - passThroughTouches
- (BOOL)passThroughTouches
diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
index 8e34cd7583c2..3d9037196537 100644
--- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
+++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
@@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy, readonly) NSString *moduleName;
@property (nonatomic, strong, readonly) RCTBridge *bridge;
+@property (nonatomic, readonly) BOOL hasBridge;
@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 50f4e745fb16..2f69e6d49322 100644
--- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm
+++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm
@@ -93,6 +93,11 @@ - (instancetype)initWithBundleURL:(NSURL *)bundleURL
return [self initWithBridge:bridge moduleName:moduleName initialProperties:initialProperties];
}
+- (BOOL)hasBridge
+{
+ return _bridge != nil;
+}
+
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
From bfead74e69f69fac6ae87110737e8935d293922e Mon Sep 17 00:00:00 2001
From: Ramanpreet Nara
Date: Thu, 2 Sep 2021 16:48:53 -0700
Subject: [PATCH 068/986] Allow RCTRootView users to require NativeModules
without the bridge
Summary:
RCTRootVeiw exports the bridge. One reason why is to allow users of RCTRootView users to access NativeModules.
## Changes
- RCTBridge now exports the RCTModuleRegistry
- RCTRootView now exports the RCTModuleRegistry exported by the bridge
- Users of RCTRootView use the RCTModuleRegistry exported by RCTRootView to access NativeModules
## Benefits
Down the line, we'll change how RCTRootView gets the RCTModuleRegistry (i.e: it won't use the bridge in bridgeless mode).
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D30434886
fbshipit-source-id: 875fce24d2fd9ee6350f128c8612e613e61e390e
---
React/Base/RCTBridge+Private.h | 8 ++++++++
React/Base/RCTBridge.m | 5 +++++
React/Base/RCTRootView.h | 8 ++++++++
React/Base/RCTRootView.m | 5 +++++
.../SurfaceHostingView/RCTSurfaceHostingProxyRootView.h | 1 +
.../SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm | 6 ++++++
React/CxxBridge/RCTCxxBridge.mm | 5 +++++
7 files changed, 38 insertions(+)
diff --git a/React/Base/RCTBridge+Private.h b/React/Base/RCTBridge+Private.h
index 70a20f0b00f6..9dd96a5cd140 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 850c78c135ad..10503261d72b 100644
--- a/React/Base/RCTBridge.m
+++ b/React/Base/RCTBridge.m
@@ -257,6 +257,11 @@ - (void)didReceiveReloadCommand
});
}
+- (RCTModuleRegistry *)moduleRegistry
+{
+ return self.batchedBridge.moduleRegistry;
+}
+
- (NSArray *)moduleClasses
{
return self.batchedBridge.moduleClasses;
diff --git a/React/Base/RCTRootView.h b/React/Base/RCTRootView.h
index 5074c54bda6c..27eec8bf3dff 100644
--- a/React/Base/RCTRootView.h
+++ b/React/Base/RCTRootView.h
@@ -8,6 +8,8 @@
#import
#import
+#import
+#import
@protocol RCTRootViewDelegate;
@@ -80,6 +82,12 @@ extern
*/
@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;
+
/**
* 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 c5c5881739ca..a8a8c2ccfa24 100644
--- a/React/Base/RCTRootView.m
+++ b/React/Base/RCTRootView.m
@@ -121,6 +121,11 @@ - (BOOL)hasBridge
return _bridge != nil;
}
+- (RCTModuleRegistry *)moduleRegistry
+{
+ return _bridge.moduleRegistry;
+}
+
#pragma mark - passThroughTouches
- (BOOL)passThroughTouches
diff --git a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
index 3d9037196537..110b6e4f23bc 100644
--- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
+++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
@@ -27,6 +27,7 @@ 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, 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 2f69e6d49322..6ca24ae80bbd 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"
@@ -98,6 +99,11 @@ - (BOOL)hasBridge
return _bridge != nil;
}
+- (RCTModuleRegistry *)moduleRegistry
+{
+ return _bridge.moduleRegistry;
+}
+
RCT_NOT_IMPLEMENTED(-(instancetype)initWithFrame : (CGRect)frame)
RCT_NOT_IMPLEMENTED(-(instancetype)initWithCoder : (NSCoder *)aDecoder)
diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm
index 0f1a601f4a6e..a33b656d9cfb 100644
--- a/React/CxxBridge/RCTCxxBridge.mm
+++ b/React/CxxBridge/RCTCxxBridge.mm
@@ -244,6 +244,11 @@ @implementation RCTCxxBridge {
@synthesize performanceLogger = _performanceLogger;
@synthesize valid = _valid;
+- (RCTModuleRegistry *)moduleRegistry
+{
+ return _objCModuleRegistry;
+}
+
- (void)setRCTTurboModuleRegistry:(id)turboModuleRegistry
{
_turboModuleRegistry = turboModuleRegistry;
From 9f69c922cbfcd08bbdfa16c36bd57153d77b9b1b Mon Sep 17 00:00:00 2001
From: Ramanpreet Nara
Date: Thu, 2 Sep 2021 16:48:53 -0700
Subject: [PATCH 069/986] Remove RCTRootView.bridge usage from
RCTBaseViewController
Summary:
RCTBaseViewController uses RCTRootView.bridge to call RCTViewEventEmitter.emit.
## Changes
- RCTEventDispatcher now exposes a method to dispatch RCTViewEventEmitter events.
- RCTRootView (for paper), and RCTSurfaceHostingProxyRootView (for fabric and bridgeless mode) now exports the RCTEventDispatcher by grabbing it from the bridge
- RCTBaseViewController now uses the event dispatcher exported from RCTRootView to dispatch the RCTViewEventEmitter event.
## Benefits
- RCTBaseViewController no longer uses the bridge to dispatch RCTViewEventEmitter events
- In the future, we'll make RCTSurfaceHostingProxyRootView work with bridgeless mode, which'll allow us to remove the bridge/bridgeless fork in RCTBaseViewController.
Changelog: [Internal]
Reviewed By: sammy-SC
Differential Revision: D30434884
fbshipit-source-id: d961a56ac2abc08a661f8fe7c37926f219b731d0
---
React/Base/RCTEventDispatcherProtocol.h | 2 ++
React/Base/RCTRootView.h | 2 ++
React/Base/RCTRootView.m | 5 +++++
.../SurfaceHostingView/RCTSurfaceHostingProxyRootView.h | 1 +
.../SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm | 5 +++++
React/CoreModules/RCTEventDispatcher.mm | 5 +++++
6 files changed, 20 insertions(+)
diff --git a/React/Base/RCTEventDispatcherProtocol.h b/React/Base/RCTEventDispatcherProtocol.h
index 9e54ccbf187e..913cf8522835 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 27eec8bf3dff..dd5634531531 100644
--- a/React/Base/RCTRootView.h
+++ b/React/Base/RCTRootView.h
@@ -88,6 +88,8 @@ extern
*/
@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 a8a8c2ccfa24..4da26ee42b10 100644
--- a/React/Base/RCTRootView.m
+++ b/React/Base/RCTRootView.m
@@ -126,6 +126,11 @@ - (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 110b6e4f23bc..7a42041d0fdc 100644
--- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
+++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.h
@@ -28,6 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
@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 6ca24ae80bbd..ad12ace6ddc5 100644
--- a/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm
+++ b/React/Base/Surface/SurfaceHostingView/RCTSurfaceHostingProxyRootView.mm
@@ -104,6 +104,11 @@ - (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 d9c690538967..5b2dad2d61ba 100644
--- a/React/CoreModules/RCTEventDispatcher.mm
+++ b/React/CoreModules/RCTEventDispatcher.mm
@@ -56,6 +56,11 @@ - (void)initialize
_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"
From a8ac5ea32676dedb17b63069a0c83ddf71746888 Mon Sep 17 00:00:00 2001
From: Xuan Huang
Date: Thu, 2 Sep 2021 17:02:48 -0700
Subject: [PATCH 070/986] Revert the Android specific max heap size GCConfig
Summary:
Changelog:
[Category][Internal]
This diff reverts the [Androids-specific heap size overrides](github.com/facebook/react-native/commit/63d20d3b1ef35cb4398d63d62f631f7f5d2935c7#diff-4c59ddca85e294a90a0e1bd15ed323ff4e130911d9642680dde44aacbcd7d32c) after
[Hermes has changed its default max heap size to 3GiB](https://github.com/facebook/hermes/commit/5f2b47d0be6281fd2605d24efc0b43af42b4033d).
You can read about more context there.
Reviewed By: yungsters
Differential Revision: D30726067
fbshipit-source-id: 1bcc93fdf4da817f3b3d60bd09c6a5a64166eb7e
---
.../hermes/reactexecutor/HermesExecutorFactory.java | 2 +-
.../com/facebook/hermes/reactexecutor/RuntimeConfig.java | 6 ------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
index 976af80b1eeb..ce09abba9611 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/HermesExecutorFactory.java
@@ -17,7 +17,7 @@ public class HermesExecutorFactory implements JavaScriptExecutorFactory {
private final RuntimeConfig mConfig;
public HermesExecutorFactory() {
- this(new RuntimeConfig(1024));
+ this(null);
}
public HermesExecutorFactory(RuntimeConfig config) {
diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
index fec7c457bc8b..a3e91b8cce6f 100644
--- a/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
+++ b/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/RuntimeConfig.java
@@ -10,10 +10,4 @@
/** Holds runtime configuration for a Hermes VM instance (master or snapshot). */
public final class RuntimeConfig {
public long heapSizeMB;
-
- RuntimeConfig() {}
-
- RuntimeConfig(long heapSizeMB) {
- this.heapSizeMB = heapSizeMB;
- }
}
From 66bd1e9c2c5c12d8652847b068ea149e790259cf Mon Sep 17 00:00:00 2001
From: Xuan Huang
Date: Thu, 2 Sep 2021 17:55:31 -0700
Subject: [PATCH 071/986] Bump Hermes npm to 0.9.0
Summary:
Changelog:
[General][Changed] - Bump Hermes to 0.9.0
allow-large-files
Reviewed By: lunaleaps
Differential Revision: D30726474
fbshipit-source-id: 742cf68b046d8768e83e00d754e8efcc97586c00
---
package.json | 2 +-
yarn.lock | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json
index 5c651a3d53b2..97747f06de0c 100644
--- a/package.json
+++ b/package.json
@@ -100,7 +100,7 @@
"anser": "^1.4.9",
"base64-js": "^1.1.2",
"event-target-shim": "^5.0.1",
- "hermes-engine": "~0.8.0",
+ "hermes-engine": "~0.9.0",
"invariant": "^2.2.4",
"jsc-android": "^250230.2.1",
"metro-babel-register": "0.66.2",
diff --git a/yarn.lock b/yarn.lock
index 5f5e62cfb958..59cfe9134a14 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3297,10 +3297,10 @@ has@^1.0.3:
dependencies:
function-bind "^1.1.1"
-hermes-engine@~0.8.0:
- version "0.8.1"
- resolved "https://registry.yarnpkg.com/hermes-engine/-/hermes-engine-0.8.1.tgz#b6d0d70508ac5add2d198304502fb968cdecb8b2"
- integrity sha512-as9Iccj/qrqqtDmfYUHbOIjt5xsQbUB6pjNIW3i1+RVr+pCAdz5S8/Jry778mz3rJWplYzHWdR1u1xQSYfBRYw==
+hermes-engine@~0.9.0:
+ version "0.9.0"
+ resolved "https://registry.yarnpkg.com/hermes-engine/-/hermes-engine-0.9.0.tgz#84d9cfe84e8f6b1b2020d6e71b350cec84ed982f"
+ integrity sha512-r7U+Y4P2Qg/igFVZN+DpT7JFfXUn1MM4dFne8aW+cCrF6RRymof+VqrUHs1kl07j8h8V2CNesU19RKgWbr3qPw==
hermes-parser@0.4.7:
version "0.4.7"
From 8e66f0b35b5ec1054994f7048ef3e66002544197 Mon Sep 17 00:00:00 2001
From: Xuan Huang
Date: Thu, 2 Sep 2021 18:41:29 -0700
Subject: [PATCH 072/986] Bump Hermes pod to 0.9.0
Summary:
Changelog:
[General][Changed] - Bump Hermes to 0.9.0
(Note: this ignores all push blocking failures!)
Reviewed By: lunaleaps
Differential Revision: D30726473
fbshipit-source-id: add4149454b3f0333f3c1cb8b5d632371fd1bd80
---
packages/rn-tester/Podfile.lock | 3 ++-
scripts/react_native_pods.rb | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock
index 9fb2a10be87c..265d84a18552 100644
--- a/packages/rn-tester/Podfile.lock
+++ b/packages/rn-tester/Podfile.lock
@@ -738,6 +738,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`)
- RCT-Folly/Fabric (from `../../third-party-podspecs/RCT-Folly.podspec`)
- RCTRequired (from `../../Libraries/RCTRequired`)
@@ -918,6 +919,6 @@ SPEC CHECKSUMS:
Yoga: c0d06f5380d34e939f55420669a60fe08b79bd75
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a
-PODFILE CHECKSUM: ae3037f2256663bd77e3b1cffcac23908027fdb1
+PODFILE CHECKSUM: 5cc47caddf8a8bf3fe9ea873886352846aee027a
COCOAPODS: 1.10.1
diff --git a/scripts/react_native_pods.rb b/scripts/react_native_pods.rb
index dd3d60ca256c..0853df7e45bf 100644
--- a/scripts/react_native_pods.rb
+++ b/scripts/react_native_pods.rb
@@ -65,7 +65,7 @@ def use_react_native! (options={})
if hermes_enabled
pod 'React-hermes', :path => "#{prefix}/ReactCommon/hermes"
- pod 'hermes-engine'
+ pod 'hermes-engine', '~> 0.9.0'
pod 'libevent', '~> 2.1.12'
end
end
From 040f548ba008c02ace3ee3d600cabe45addcb0d7 Mon Sep 17 00:00:00 2001
From: Nicola Corti
Date: Mon, 6 Sep 2021 02:41:19 -0700
Subject: [PATCH 073/986] Setup Gradle Wrapper inside
packages/react-native-gradle-plugin/ (#32140)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32140
This diff is setting up the Gradle wrapper inside packages/react-native-gradle-plugin/.
Currently the `./gradlew` file is missing so it's not possible to `cd` inside the project and build it from
there (also opening that folder inside the IDE will trigger the creation of the files I added here).
This diff is fixing. The files have been generated with the command:
```
gw -p packages/react-native-gradle-plugin wrapper --gradle-version 7.0.2 --distribution-type=all
```
Changelog:
[Internal] [Added] - Setup Gradle Wrapper inside packages/react-native-gradle-plugin/
Reviewed By: yungsters
Differential Revision: D30730145
fbshipit-source-id: a0bd6be0ac062e089b2b90a55b47987c0f4b6644
---
.../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59536 bytes
.../gradle/wrapper/gradle-wrapper.properties | 5 +
packages/react-native-gradle-plugin/gradlew | 185 ++++++++++++++++++
.../react-native-gradle-plugin/gradlew.bat | 89 +++++++++
4 files changed, 279 insertions(+)
create mode 100644 packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar
create mode 100644 packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties
create mode 100755 packages/react-native-gradle-plugin/gradlew
create mode 100644 packages/react-native-gradle-plugin/gradlew.bat
diff --git a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000000000000000000000000000000000000..7454180f2ae8848c63b8b4dea2cb829da983f2fa
GIT binary patch
literal 59536
zcma&NbC71ylI~qywr$(CZQJHswz}-9F59+k+g;UV+cs{`J?GrGXYR~=-ydruB3JCa
zB64N^cILAcWk5iofq)<(fq;O7{th4@;QxID0)qN`mJ?GIqLY#rX8-|G{5M0pdVW5^
zzXk$-2kQTAC?_N@B`&6-N-rmVFE=$QD?>*=4<|!MJu@}isLc4AW#{m2if&A5T5g&~
ziuMQeS*U5sL6J698wOd)K@oK@1{peP5&Esut<#VH^u)gp`9H4)`uE!2$>RTctN+^u
z=ASkePDZA-X8)rp%D;p*~P?*a_=*Kwc<^>QSH|^<0>o37lt^+Mj1;4YvJ(JR-Y+?%Nu}JAYj5
z_Qc5%Ao#F?q32i?ZaN2OSNhWL;2oDEw_({7ZbgUjna!Fqn3NzLM@-EWFPZVmc>(fZ
z0&bF-Ch#p9C{YJT9Rcr3+Y_uR^At1^BxZ#eo>$PLJF3=;t_$2|t+_6gg5(j{TmjYU
zK12c&lE?Eh+2u2&6Gf*IdKS&6?rYbSEKBN!rv{YCm|Rt=UlPcW9j`0o6{66#y5t9C
zruFA2iKd=H%jHf%ypOkxLnO8#H}#Zt{8p!oi6)7#NqoF({t6|J^?1e*oxqng9Q2Cc
zg%5Vu!em)}Yuj?kaP!D?b?(C*w!1;>R=j90+RTkyEXz+9CufZ$C^umX^+4|JYaO<5
zmIM3#dv`DGM;@F6;(t!WngZSYzHx?9&$xEF70D1BvfVj<%+b#)vz)2iLCrTeYzUcL
z(OBnNoG6Le%M+@2oo)&jdOg=iCszzv59e
zDRCeaX8l1hC=8LbBt|k5?CXgep=3r9BXx1uR8!p%Z|0+4Xro=xi0G!e{c4U~1j6!)
zH6adq0}#l{%*1U(Cb%4AJ}VLWKBPi0MoKFaQH6x?^hQ!6em@993xdtS%_dmevzeNl
z(o?YlOI=jl(`L9^
z0O+H9k$_@`6L13eTT8ci-V0ljDMD|0ifUw|Q-Hep$xYj0hTO@0%IS^TD4b4n6EKDG
z??uM;MEx`s98KYN(K0>c!C3HZdZ{+_53DO%9k5W%pr6yJusQAv_;IA}925Y%;+!tY
z%2k!YQmLLOr{rF~!s<3-WEUs)`ix_mSU|cNRBIWxOox_Yb7Z=~Q45ZNe*u|m^|)d*
zog=i>`=bTe!|;8F+#H>EjIMcgWcG2ORD`w0WD;YZAy5#s{65~qfI6o$+Ty&-hyMyJ
z3Ra~t>R!p=5ZpxA;QkDAoPi4sYOP6>LT+}{xp}tk+<0k^CKCFdNYG(Es>p0gqD)jP
zWOeX5G;9(m@?GOG7g;e74i_|SmE?`B2i;sLYwRWKLy0RLW!Hx`=!LH3&k=FuCsM=9M4|GqzA)anEHfxkB
z?2iK-u(DC_T1};KaUT@3nP~LEcENT^UgPvp!QC@Dw&PVAhaEYrPey{nkcn(ro|r7XUz
z%#(=$7D8uP_uU-oPHhd>>^adbCSQetgSG`e$U|7mr!`|bU0aHl_cmL)na-5x1#OsVE#m*+k84Y^+UMeSAa
zbrVZHU=mFwXEaGHtXQq`2ZtjfS!B2H{5A<3(nb-6ARVV8kEmOkx6D2x7~-6hl;*-*}2Xz;J#a8Wn;_B5=m
zl3dY;%krf?i-Ok^Pal-}4F`{F@TYPTwTEhxpZK5WCpfD^UmM_iYPe}wpE!Djai6_{
z*pGO=WB47#Xjb7!n2Ma)s^yeR*1rTxp`Mt4sfA+`HwZf%!7ZqGosPkw69`Ix5Ku6G
z@Pa;pjzV&dn{M=QDx89t?p?d9gna*}jBly*#1!6}5K<*xDPJ{wv4&
zM$17DFd~L*Te3A%yD;Dp9UGWTjRxAvMu!j^Tbc}2v~q^59d4bz
zvu#!IJCy(BcWTc`;v$9tH;J%oiSJ_i7s;2`JXZF+qd4C)vY!hyCtl)sJIC{ebI*0>
z@x>;EzyBv>AI-~{D6l6{ST=em*U(
z(r$nuXY-#CCi^8Z2#v#UXOt`dbYN1z5jzNF2
z411?w)whZrfA20;nl&C1Gi+gk<`JSm+{|*2o<<
zqM#@z_D`Cn|0H^9$|Tah)0M_X4c37|KQ*PmoT@%xHc3L1ZY6(p(sNXHa&49Frzto&
zR`c~ClHpE~4Z=uKa5S(-?M8EJ$zt0&fJk~p$M#fGN1-y$7!37hld`Uw>Urri(DxLa;=#rK0g4J)pXMC
zxzraOVw1+kNWpi#P=6(qxf`zSdUC?D$i`8ZI@F>k6k
zz21?d+dw7b&i*>Kv5L(LH-?J%@WnqT7j#qZ9B>|Zl+=>
z^U-pV@1y_ptHo4hl^cPRWewbLQ#g6XYQ@EkiP
z;(=SU!yhjHp%1&MsU`FV1Z_#K1&(|5n(7IHbx&gG28HNT)*~-BQi372@|->2Aw5It
z0CBpUcMA*QvsPy)#lr!lIdCi@1k4V2m!NH)%Px(vu-r(Q)HYc!p
zJ^$|)j^E#q#QOgcb^pd74^JUi7fUmMiNP_o*lvx*q%_odv49Dsv$NV;6J
z9GOXKomA{2Pb{w}&+yHtH?IkJJu~}Z?{Uk++2mB8zyvh*xhHKE``99>y#TdD
z&(MH^^JHf;g(Tbb^&8P*;_i*2&fS$7${3WJtV7K&&(MBV2~)2KB3%cWg#1!VE~k#C
z!;A;?p$s{ihyojEZz+$I1)L}&G~ml=udD9qh>Tu(ylv)?YcJT3ihapi!zgPtWb*CP
zlLLJSRCj-^w?@;RU9aL2zDZY1`I3d<&OMuW=c3$o0#STpv_p3b9Wtbql>w^bBi~u4
z3D8KyF?YE?=HcKk!xcp@Cigvzy=lnFgc^9c%(^F22BWYNAYRSho@~*~S)4%AhEttv
zvq>7X!!EWKG?mOd9&n>vvH1p4VzE?HCuxT-u+F&mnsfDI^}*-d00-KAauEaXqg3k@
zy#)MGX!X;&3&0s}F3q40ZmVM$(H3CLfpdL?hB6nVqMxX)q=1b}o_PG%r~hZ4gUfSp
zOH4qlEOW4OMUc)_m)fMR_rl^pCfXc{$fQbI*E&mV77}kRF
z&{<06AJyJ!e863o-V>FA1a9Eemx6>^F$~9ppt()ZbPGfg_NdRXBWoZnDy2;#ODgf!
zgl?iOcF7Meo|{AF>KDwTgYrJLb$L2%%BEtO>T$C?|9bAB&}s;gI?lY#^tttY&hfr#
zKhC+&b-rpg_?~uVK%S@mQleU#_xCsvIPK*<`E0fHE1&!J7!xD#IB|SSPW6-PyuqGn3^M^Rz%WT{e?OI^svARX&SAdU77V(C~
zM$H{Kg59op{<|8ry9ecfP%=kFm(-!W&?U0@<