Граф коммитов

23735 Коммитов

Автор SHA1 Сообщение Дата
Ramanpreet Nara 8f3e188426 Fix Static View Config for RCTView
Summary:
- Fix the StaticViewConfig violations for RCTView

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D32187835

fbshipit-source-id: c8c926817a9245b1e8671e5a2e8965ab7ffecace
2021-12-10 23:19:52 -08:00
Sota Ogo 552af5d85d Add packages/babel-plugin-codegen to react-native (#32737)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32737

Changelog: [Internal] Adding packages/babel-plugin-codegen to react-native. This will add a missing piece to enable the new architecture in nightly build.

Reviewed By: ShikaSD

Differential Revision: D33034294

fbshipit-source-id: 766b97ddaddeaf0813ed9cf9b08a81eac93052ac
2021-12-10 20:57:22 -08:00
Amy Huyen 9b0ed920ef Export flow type for ScrollView Deceleration Rate
Summary:
## Changelog:
[General] [Changed] Export Flow type for deceleration rate for use in other files to keep deceleration rate prop values consistently typed

Reviewed By: lunaleaps

Differential Revision: D32989199

fbshipit-source-id: 2e2fef0721de0d0eb60aaefdbb635788bfc8c1f1
2021-12-10 11:43:08 -08:00
Lorenzo Sciandra 896a5c9230 add 0.66.4 changelog (#32733)
Summary:
lunaleaps did [0.66.4](https://github.com/facebook/react-native/releases/tag/v0.66.4) yesterday - this PR adds the entries for it in the changelog.md file.

## Changelog

[Internal] [Changed] - add changelog entry for 0.66.4

Pull Request resolved: https://github.com/facebook/react-native/pull/32733

Test Plan: N/A

Reviewed By: lunaleaps

Differential Revision: D33017547

Pulled By: cortinico

fbshipit-source-id: 2ffad5d65c7b308686f29395fb6fc54b85804bf0
2021-12-10 10:18:52 -08:00
Eric Rozell fe53cae954 Deduct offset from `getValue` result when detaching
Summary:
The NativeAnimated `getValue` API returns `value + offset`:
Android:
iOS: https://github.com/facebook/react-native/blob/main/Libraries/NativeAnimation/Nodes/RCTValueAnimatedNode.m#L44
Android: https://github.com/facebook/react-native/blob/main/ReactAndroid/src/main/java/com/facebook/react/animated/ValueAnimatedNode.java#L36

When we store the value after detaching the NativeAnimated node, it stores the result of the NativeAnimated `getValue` call to the `_value` property, so if we call `__getValue` at some later point on the `AnimatedValue`, we will count the offset twice.

This change deducts the offset value from the result returned from `getValue` when storing the latest value.

Changelog:
[General][Fixed] - AnimatedValue.__detach should store getValue result with offset deducted

Reviewed By: yungsters

Differential Revision: D32987003

fbshipit-source-id: 488d1fe512f886c7a9de1e5a4de8f19441ebd81e
2021-12-10 08:07:38 -08:00
Luna Wei c034b7e7e1 Bump dependency on eslint-plugin-specs to minimum 0.0.2
Summary: Changelog: [Internal] - Update our release package.json to reference the react-native/eslint-plugin-specs module and a version > 0.0.2

Reviewed By: sota000

Differential Revision: D32973565

fbshipit-source-id: 49bfdb94f5dfdd9617e5849010241e4dda9dc9db
2021-12-09 15:57:20 -08:00
Alex Koller 2e3bcdfda5 Update prop generator to allow `value` prop name
Summary:
So I was adding a new HTTPCookie prop to our WebView native component and found that my build was [failing](https://www.internalfb.com/diff/D32602297?dst_version_fbid=338931330931416) due to "redefinition of `value`". Looks like we use the name of the prop as a variable name during codegen, and this can conflict with some other hardcoded variable names. Rather than try and come up with a better prop name, I figured we can just append some string to our codegen name to reduce the chance for conflicts.

Changelog:
[Internal][Changed] - Change codegen variable naming to prevent conflicts to prop names

Reviewed By: JoshuaGross

Differential Revision: D32967807

fbshipit-source-id: 1b3631ec783b229eddfd3c801ffbb397910fc882
2021-12-09 12:02:29 -08:00
Eric Rozell 8ba771c3dd Fire `AnimatedValue.stopAnimation` callback with correct native value
Summary:
AnimatedValue fires a callback with the current value (raw value + offset) after calling it's `stopAnimation` method. The `_value` field on the `AnimatedValue` node is not necessarily kept in sync with the NativeAnimated value node, so the value provided to the callback may be out of sync.

This change checks if the `AnimatedValue` is a native node and passes the callback to the `NativeAnimatedAPI.getValue` callback, defaulting to the previous current JS node state if the node is not native.

Changelog:
[General][Fixed] - AnimatedValue.stopAnimation callback with correct value for NativeAnimated

Reviewed By: yungsters

Differential Revision: D32968572

fbshipit-source-id: b83f86eabe5456f762a15bc29cacb43f84513f6c
2021-12-09 11:40:13 -08:00
Andrei Shikov 1d4e7f6d40 Use reference for command args
Summary:
The IDE warning suggests that passing folly::dynamic by value will create a copy on each call.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D32978154

fbshipit-source-id: a47a60c332a9d299eb2110d3537dfab0bc2398b6
2021-12-09 09:47:38 -08:00
Phillip Pan 891a1c12f1 introduce get_rn_ios_target_sdk_version()
Summary:
feels like this should be shared across oss

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D32940936

fbshipit-source-id: 76fa8fdac5a768586f7f3e916af2c57685a70e12
2021-12-09 04:08:41 -08:00
Sota Ogo d7768a5e94 Unbreak analyze_pr (#32724)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32724

Changelog: [internal] Fix analyze_pr which was getting stuck at apt-get install openssl ca-certificates

Added -y so that it will install openssl without asking Y/n question.

```
The following packages will be upgraded:
  openssl
1 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
Need to get 620 kB of archives.
After this operation, 1024 B disk space will be freed.
Do you want to continue? [Y/n]
```

Reviewed By: TheSavior

Differential Revision: D32977991

fbshipit-source-id: 6a2e88f7fe61061fd5c18fc8cb28a3b9bfeedaf0
2021-12-08 22:15:13 -08:00
Sota Ogo 6ece1a92b1 Only add fabric example component when using codegen discovery (#32723)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32723

D32128979 (baded0f9e3) added a fabric example to RNTester, and that broke the circle CI test because of a build issue introduced by an build ordering issue (codegen for the example component didn't happen in time). Using codegen discovery the issue wouldn't happen, so I made it only install when use_codegen_discovery == 1.

Caveat is that this would make opening the New Architecture Example throw an error since the native module doesn't exist when running pod install without USE_CODEGEN_DISCOVERY flag. Therefore, I added a message that codegen discovery needs to be enabled in order to try out the example.

Changelog: [internal] Fix rn-tester build

Reviewed By: mdvacca

Differential Revision: D32974821

fbshipit-source-id: b0318ebf122ba00c0121c17a819a730133ab67be
2021-12-08 21:46:12 -08:00
Sota Ogo 74f3913128 Version bump
Summary:
I added some functionalities to react-native-codegen to support the new architecture. Publishing the new version so that those are available to use.

Changelog: [internal] Updated react-native-codegen version

Reviewed By: cortinico

Differential Revision: D32941951

fbshipit-source-id: f1ab3d72c76ac153939c634655a4725b4f49d48d
2021-12-08 20:56:35 -08:00
Luna Wei 2d06e6a4c9 eslint-plugin-specs prepublish step
Summary:
#Changelog: [Internal] - This is an attempt to fix public publishing of eslint-plugin-specs. Currently, internal consumption of this package assumes access to `react-native-codegen/src` but for external usage, we leverage the published `react-native-codegen` which transforms files out to the `lib` folder vs. `src`.

For a similar-ish suit, this change is adding a prepublish step that will very basically update the references.

Reviewed By: mdvacca

Differential Revision: D32910080

fbshipit-source-id: f5e508090cbbf5097a848ddef3b721002a6c6277
2021-12-08 20:28:17 -08:00
Paige Sun 60e60a9b3d Refactor: Assign string label to each case in RCTPLTag enum for startup performance logging
Summary:
`_labelsForTags` is an array with string labels used only for local profiling, that we had to manually keep it in sync with `RCTPLTag`. Refactor so labels are assigned with switch instead.

Changelog: [iOS] Refactor: Assign string label to each case in RCTPLTag enum for startup performance logging

Reviewed By: fkgozali

Differential Revision: D32889043

fbshipit-source-id: 81da592a160a31b91e78289be0990cc2ff960f29
2021-12-08 14:51:04 -08:00
Genki Kondo d393e9490e Stop using RoundedCornerPostProcessor
Summary:
Originally introduced in D2022018

Tried to make the processor optional when no rounding is required, but found even that was not strictly necessary.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D32675492

fbshipit-source-id: 8dfdbf0e4347155045f77b1fba00a59086fe7a33
2021-12-07 16:09:54 -08:00
Sota Ogo baded0f9e3 Add the example fabric component to RN Tester for iOS
Summary:
This diff adds a new architecture example to RN Tester for the iOS App

Changelog: [internal]

Reviewed By: hramos

Differential Revision: D32128979

fbshipit-source-id: b008671553065f4965ba332ac06e01f54d70b331
2021-12-07 16:09:54 -08:00
Samuel Susla f5f6fd70f2 Introduce TextInput.onKeyPressSync
Summary:
changelog: [internal]

Introduce a way to execute `onKeyPress` synchronously. This feature is experimental and will be changed in the future. It is not decided if marking native events as "sync" is going to be path forward with synchronous access.

NOTE: This is experimental API.

Reviewed By: ShikaSD

Differential Revision: D32882092

fbshipit-source-id: 68c66a9bb7c97758219e085c88a77f3c475c1eb3
2021-12-07 13:42:18 -08:00
Samuel Susla 69acb9569e Remove unused method from TextInputEventEmitter
Summary:
changelog: [internal]

Event `onChangeText` does not exist in TextInput. Let's remove this method to avoid confusion.

Reviewed By: philIip

Differential Revision: D32882056

fbshipit-source-id: 37eb260b84dd7d6cce412ce1bc39c0cbf9cab112
2021-12-07 13:42:18 -08:00
Sota Ogo 09b69036c0 Fallback to use lib when src doesn't exist.
Summary:
Changelog: [Internal] babel-plugin-codegen.js to fallback to use lib instead of src.

The bubel plugin uses react-native-codegen/src but it's not compatible when react-native-codegen is installed as a separate dependency (which is the case for OSS).

Reviewed By: cortinico

Differential Revision: D32908846

fbshipit-source-id: 1d3e3a3485e94e2f051e220d76dd2dbcdd8070a8
2021-12-07 12:34:50 -08:00
Samuel Susla fcda1ac514 Add support for synchronous completeRoot
Summary:
changelog: [internal]

Exposes a new flag on RuntimeScheduler: `unstable_getIsSynchronous`. Flag indicates if the current code is run synchronously and therefore commit phase should be synchronous.

Unit tests will be added later, to keep this diff short. This code path is not executed yet.

Reviewed By: mdvacca, ShikaSD

Differential Revision: D32677814

fbshipit-source-id: e01d4fff7e716d627ff99fe104965851138c3aef
2021-12-07 12:11:24 -08:00
Andrei Shikov c0710244b3 Clean up AndroidTextInputEventEmitter
Summary:
This class is not used and can be safely deleted

Changelog: [Internal] Delete unused Android event emitter

Reviewed By: mdvacca

Differential Revision: D32916706

fbshipit-source-id: 6dceb6b6ed9d201d96454bf0d646853c5c893d59
2021-12-07 11:09:22 -08:00
Sota Ogo b174ccffad Fix output path for the fabric provider
Summary:
Changelog: [internal] Fixes the output path for the fabric provider.

The old path wouldn't work when the pod installation path is not the same as the app dir.

Reviewed By: cortinico

Differential Revision: D32911493

fbshipit-source-id: 74a8481a2e8397024645d7daff2897e4b0b5454e
2021-12-07 11:02:29 -08:00
Sota Ogo bc153a651a Add newly added scripts to package.json
Summary: Changelog: [internal] We added generate-artifacts.js and generate-provider.js for codegen, and this diff adds that to the package.json so that it gets included.

Reviewed By: cortinico

Differential Revision: D32910033

fbshipit-source-id: 4982704fd3dac12b9cb64c4b3facb496abef4343
2021-12-07 10:22:59 -08:00
Xin Chen fe6277a30d Support override predict final scroll position with custom fling animator
Summary:
This diff add custom prediction for fling distance support. This is needed for customize fling animator to calculate predicted fling distance, instead of using the overscroller that may not be used by the animator.

More context on this -- when fling happens, our code will first predict the final fling position `p`, apply the snapping logic to decide the expected snapping position `pSnapping` given `p`,  scroll velocity and children layout, then trigger the overscroller (existing) or custom fling animator to finish the fling.

Currently, the prediction logic is done with overscroller, and custom fling animator has no control over how the predicted fling distance should be. Changes in this diff allow the animator to override `getExtrapolatedDistance` method and provide that information.

Changelog:
[Android][Added] - Add new API for custom fling animator to provide predicted travel distance for its fling animation.

Reviewed By: mdvacca

Differential Revision: D32571734

fbshipit-source-id: d34b969206f8b6cb5c68d2f50a18749bfebbc97e
2021-12-06 19:48:23 -08:00
Ramanpreet Nara 39a35feff7 Fix uiViewClassName for TextInlineImageNativeComponent
Summary:
See title.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D32811821

fbshipit-source-id: 2c6fad21cd1e094162a12a4056ddeab948231c57
2021-12-06 15:44:23 -08:00
Ian Grayson 35bcf934b1 fix: find-node.sh now respects .nvmrc (#32712)
Summary:
React-native Xcode build steps (such as "Build JS Bundle") rely on `find.node-sh` to find the correct node binary, using nvm if present. We do this because Xcode may run build steps in a fresh shell environment, presumably for repeatable builds.

This PR fixes `find-node.sh`, to respect any `.nvmrc` file that may be present in the build environment.

Today: `find-node.sh` will set the shell environment to the system node version, and ignores any `.nvmrc` the project may provide to pin node for repeatable builds. By ignoring `.nvmrc`, node versions may differ depending on system environment — between developer laptops, or between developer and CI environments. 😞

This problem has been been noticed before in https://github.com/facebook/react-native/issues/8887

### Should this fix happen upstream?

Unfortunately this nvm behavior [is intended](https://github.com/nvm-sh/nvm/issues/2053),  for backwards compatibility

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - find-node.sh now respects .nvmrc

Pull Request resolved: https://github.com/facebook/react-native/pull/32712

Test Plan:
Before:
```bash
# nvm isn't loaded
$ which nvm

# we're on default system node
$ which node && node --version
/usr/local/bin/node
v17.0.1

$ echo v16.13.0 > .nvmrc
$ source ./scripts/find-node.sh

# Expected: v16.13.0
$ node --version
v17.0.1
```

After:
```bash
# we're on default system node
$ which node && node --version
/usr/local/bin/node
v17.0.1

$ echo v16.13.0 > .nvmrc
$ source ./scripts/find-node.sh

# Expected: v16.13.0
$ node --version
v16.13.0
```

After (no .nvmrc, should preserve previous behavior):
```bash
# we're on default system node
$ which node && node --version
/usr/local/bin/node
v17.0.1

$ source ./scripts/find-node.sh

$  nvm ls|grep default
default -> v14.17.1

# Expected: v14.17.1
$ node --version
v14.17.1
```

Reviewed By: sota000

Differential Revision: D32889629

Pulled By: ShikaSD

fbshipit-source-id: 527384055e303a87bad43413fb66a7fd117d1a63
2021-12-06 14:03:54 -08:00
Marc Rousavy 49a1460a37 Feature: ScrollView `automaticallyAdjustKeyboardInsets` (#31402)
Summary:
Retrying D30015799 (6e903b07fa) with a fix where ScrollViewNativeComponent was missing the automaticallyAdjustKeyboardInsets prop.
----- Original Summary
Currently, ScrollViews provide the prop `keyboardDismissMode` which lets you choose `"interactive"`. However when the keyboard is shown, it will be rendered above the ScrollView, potentially blocking content.

With the `automaticallyAdjustKeyboardInsets` prop the ScrollView will automatically adjust it's `contentInset`, `scrollIndicatorInsets` and `contentOffset` (scroll Y) props to push the content up so nothing gets blocked.

* The animation curve and duration of the Keyboard is exactly matched.
* The absolute position of the ScrollView is respected, so if the Keyboard only overlaps 10 pixels of the ScrollView, it will only get inset by 10 pixels.
* By respecting the absolute position on screen, this automatically makes it fully compatible with phones with notches (custom safe areas)
* By using the keyboard frame, this also works for different sized keyboards and even `<InputAccessoryView>`s
* This also supports `maintainVisibleContentPosition` and `autoscrollToTopThreshold`.
* I also fixed an issue with the `maintainVisibleContentPosition` (`autoscrollToTopThreshold`) prop(s), so they behave more reliably when `contentInset`s are applied. (This makes automatically scrolling to new items fully compatible with `automaticallyAdjustKeyboardInsets`)

## Changelog

* [iOS] [Added] - ScrollView: `automaticallyAdjustKeyboardInsets` prop: Automatically animate `contentInset`, `scrollIndicatorInsets` and `contentOffset` (scroll Y) to avoid the Keyboard. (respecting absolute position on screen and safe-areas)
* [iOS] [Fixed] - ScrollView: Respect `contentInset` when animating new items with `autoscrollToTopThreshold`, make `automaticallyAdjustKeyboardInsets` work with `autoscrollToTopThreshold` (includes vertical, vertical-inverted, horizontal and horizontal-inverted ScrollViews)

Pull Request resolved: https://github.com/facebook/react-native/pull/31402

Test Plan:
<table>
<tr>
<th>Before</th>
<th>After</th>
</tr>
<tr>
<td>

https://user-images.githubusercontent.com/15199031/115708680-9700aa80-a370-11eb-8016-e75d81a92cd7.MP4

</td>

<td>

https://user-images.githubusercontent.com/15199031/115708699-9b2cc800-a370-11eb-976f-c4010cd96d55.MP4

</td>
</table>

### "Why not just use `<KeyboardAvoidingView>`?"

<table>
<tr>
<th>Before (with <code>&lt;KeyboardAvoidingView&gt;</code>)</th>
<th>After (with <code>automaticallyAdjustKeyboardInsets</code>)</th>
</tr>
<tr>
<td>

https://user-images.githubusercontent.com/15199031/115708749-abdd3e00-a370-11eb-8e09-a27ffaef12b8.MP4

</td>

<td>

https://user-images.githubusercontent.com/15199031/115708777-b3044c00-a370-11eb-9b7a-e040ccb3ef8c.MP4

</td>
</table>

> Also notice how the `<KeyboardAvoidingView>` does not match the animation curve of the Keyboard

### Usage

```jsx
export const ChatPage = ({
  flatListProps,
  textInputProps
}: Props): React.ReactElement => (
  <>
    <FlatList
      {...flatListProps}
      keyboardDismissMode="interactive"
      automaticallyAdjustContentInsets={false}
      contentInsetAdjustmentBehavior="never"
      maintainVisibleContentPosition={{ minIndexForVisible: 0, autoscrollToTopThreshold: 100 }}
      automaticallyAdjustKeyboardInsets={true}
    />
    <InputAccessoryView backgroundColor={colors.white}>
      <ChatInput {...textInputProps} />
    </InputAccessoryView>
  </>
);
```

## Related Issues

* Fixes https://github.com/facebook/react-native/issues/31394
* Fixes https://github.com/facebook/react-native/issues/13073

Reviewed By: yungsters

Differential Revision: D32578661

Pulled By: sota000

fbshipit-source-id: 45985e2844275fe96304eccfd1901907dc4f9279
2021-12-06 13:31:13 -08:00
Juan Tejada bba5e6b341 Upgrade OSS react-devtools to v4.21.0
Summary:
Update `react-devtools-core` and `react-devtools` dependencies for RN, VSCode, Sonar, etc.

`js1 upgrade react-devtools -v 4.21.0`

# Changelog:

[General][Changed] - Upgraded react-devtools-core dependency to 4.19.1

Reviewed By: lunaruan

Differential Revision: D32889680

fbshipit-source-id: 25230927c3fb9d3e82db8e842d7bd7fbb4008e5e
2021-12-06 13:14:01 -08:00
Sota Ogo ba70ca4c58 Add an option to use a custom name for codegen components
Summary:
Changelog: [Internal] Adding an option to change the component name for react native codegen.

This will help some use cases where the target name and the actual component names are different.

Reviewed By: fkgozali

Differential Revision: D32852437

fbshipit-source-id: 054a62214cf8bcfea5662b8fba6582d9d7209f90
2021-12-06 13:09:10 -08:00
Xin Chen 66243271a7 Refactor predictFinalScrollPosition method to the helper class
Summary:
This diff refactors method `predictFinalScrollPosition` in `ReactScrollView` and `ReactHorizontalScrollView` to the helper class. This will make future changes to the prediction logic easier.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D32571735

fbshipit-source-id: 7e7e21ac51f929a017cd43de094ed39478fe4032
2021-12-06 09:40:57 -08:00
Xin Chen 1c1945569f Fix mis-use of the post animated value when predict fling distance
Summary:
This diff fixes an edge case where scroll to the end of the list may trigger a bounce back effect.

This issue is a regression from D32487846 (f70018b375) (See [this comment](https://www.internalfb.com/diff/D32487846 (f70018b375)?dst_version_fbid=263960175698224&transaction_fbid=566201141113715)) that zero velocity fling at the end of the scroll view makes the next fling animator use previous post animation position. This is due to cached `postAnimationValue` is applied mistakenly.

- Pass velocity instead of velocity sign to the helper class
- Update helper class logic to decide if we need to use post animated value from last fling animation

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D32566010

fbshipit-source-id: 1c61659030151f8f2c7648ca901b8b4158835538
2021-12-06 09:40:57 -08:00
Xin Chen ead7b97944 Fix fling and snap in recycler viewgroup where children views not fill up all the scrollable space
Summary:
This diff fixes an edge case where fling and snap failed to find the correct target position when children views not fill up all the scrollable space. In this case, the target position would be calculated as the end of the scrollable space, which case the snap logic to go to the end of the scrollable area, instead of stop at the expected snapping position.

Changelog:
[Android][Fixed] - Fix fling and snap with recycler viewgroup where fling to the end of scrollable distance when it goes over current rendered children views.

Reviewed By: mdvacca

Differential Revision: D32565459

fbshipit-source-id: 319ef6e2d4e1c4deb9e45ed02c1bff7d807575c3
2021-12-06 09:40:57 -08:00
Luna Wei 583471bc48 Fix workflow for automating version bumps
Summary: Changelog: [Internal] - Fix bugs in automate workflow

Reviewed By: cortinico, sota000

Differential Revision: D32810597

fbshipit-source-id: 13503fea871043224f673f2c5301804e1f4cf614
2021-12-03 13:17:31 -08:00
Luna Wei 8cc80a843a isTaggedVersion checks if the commit has a version tag on it
Summary: Changelog: [Internal] Add a `isTaggedVersion` function to filter out commits from release automation.

Reviewed By: sota000

Differential Revision: D32842035

fbshipit-source-id: 14bb262a1d2a96ffda87c759a3202c4f9a356141
2021-12-03 13:17:31 -08:00
Chiara Mooney badd30885f Bump deprecated-react-native-prop-types Dependency (#32700)
Summary:
Bump deprecated-react-native-prop-types dependency to ^2.3.0. This version contains a  .windows.js fork of some deprecated props. Current version has missing information for Windows, breaking CI for react-native-windows repository.

## Changelog
[General] [Changed] - Upgrade deprecated-react-native-prop-types dependency

Pull Request resolved: https://github.com/facebook/react-native/pull/32700

Reviewed By: lyahdav, rozele

Differential Revision: D32816801

Pulled By: yungsters

fbshipit-source-id: f6a8507637075b1a936d91c264bbd8a462505f48
2021-12-03 12:43:15 -08:00
Liron Yahdav 771ca921b5 Add TextInput.setSelection method
Summary:
Adds a `setSelection` imperative method to `TextInput`.

Changelog:
[General][Added] - Adds a setSelection imperative method to TextInput

Reviewed By: JoshuaGross

Differential Revision: D32186514

fbshipit-source-id: 549a7d93b1c55363cf01d804b1e3d735e55c4481
2021-12-03 11:54:01 -08:00
zpd106 0aee7330ff mMainComponentName Keep in line with above in ReactActivityDelegate (#32685)
Summary:
```
public String getMainComponentName() {
    return mMainComponentName;
}

protected void onCreate(Bundle savedInstanceState) {
    String mainComponentName = getMainComponentName();
    mReactDelegate =
        new ReactDelegate(
            getPlainActivity(), getReactNativeHost(), mainComponentName, getLaunchOptions()) {
          Override
          protected ReactRootView createRootView() {
            return ReactActivityDelegate.this.createRootView();
          }
        };
    // mMainComponentName rename is mainComponentName
    if (mainComponentName != null) {
      loadApp(mainComponentName);
    }
  }
```

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[CATEGORY] [TYPE] - Message

Pull Request resolved: https://github.com/facebook/react-native/pull/32685

Reviewed By: ShikaSD

Differential Revision: D32754475

Pulled By: cortinico

fbshipit-source-id: 46c395a5d6c6508c14eaa163a1e824f0c3cb8b80
2021-12-03 11:50:29 -08:00
Luna Wei bfc6392e1a Rename eslint-plugin-codegen to eslint-plugin-specs (#32698)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32698

Changelog: [Internal] - Renaming the eslint-plugin-codegen to eslint-plugin-specs as a better descriptor for this package. Part of the plan is to publish as a public npm package

Reviewed By: RSNara

Differential Revision: D32777702

fbshipit-source-id: 7776c481871031dba1280d87fb76b777ecc23339
2021-12-02 20:47:12 -08:00
Yuan Dai 8e49658096 Revert D32778338: Add a dependency to the native component example added to RNTester
Differential Revision:
D32778338 (173d3a4abc)

Original commit changeset: d4703903c222

fbshipit-source-id: 7319c272b93584709a69a2b72173aac916c2f093
2021-12-02 20:27:05 -08:00
Sota Ogo 173d3a4abc Add a dependency to the native component example added to RNTester (#32693)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32693

Changelog: [Internal] this diff adds dependecies to the buck files so that an internal app that referes RNtester will work as intended.

Reviewed By: cortinico

Differential Revision: D32778338

fbshipit-source-id: d4703903c2227283fe9c70f02bb7da420d936fbb
2021-12-02 19:18:16 -08:00
Samuel Susla 387e79f8aa Remove background_executor flag
Summary:
changelog: [internal]

Background executor has been shipped on both platforms for a long time.
I've kept the flag around because I wanted to run tests and compare Concurrent Mode vs Background Executor. The intention was to see if we can get rid of Background Executor to simplify the threading model.

Since then, React team has moved away from Concurrent Mode towards more gradual rollout of concurrent rendering and it no longer makes sense to do this comparison. Right now, we don't have a concern with concurrent rendering and Background Executor. If we ever want to run the an experiment, this gating will need to be added again.

Reviewed By: javache

Differential Revision: D32674798

fbshipit-source-id: a1e51c9c5b8e48efa4cb0f25379d58e7eb80ccd9
2021-12-02 15:32:28 -08:00
Tom Spencer ae67c5ac45 Disable ESLint `no-undef` for TypeScript files (#32655)
Summary:
The `typescript-eslint` project [recommends that `no-undef` is disabled for TypeScript files](6c3816b383/docs/linting/TROUBLESHOOTING.md (i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors)), since TypeScript itself will perform this check. Disabling this config property has two benefits:

- Undefined variables and types will only be reported once, by the TypeScript compiler. Currently they are reported twice: once by TypeScript, and once by ESLint:

<img width="506" alt="Screenshot 2021-11-24 at 12 38 22" src="https://user-images.githubusercontent.com/820863/143239961-eb8ed709-60f9-490a-bda3-fc581673d56c.png">

- Types that are declared globally by React Native will no longer be erroneously reported as undefined - this is currently the case for some types, e.g. `Blob`:

<img width="419" alt="Screenshot 2021-11-24 at 12 40 04" src="https://user-images.githubusercontent.com/820863/143240213-06428b24-09c8-4f95-8e77-7f4fd160eed1.png">

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - ESLint no-undef rule clashing with TypeScript compiler for TS files

Pull Request resolved: https://github.com/facebook/react-native/pull/32655

Test Plan:
- Before: ESLint reporting on undefined variables in TypeScript files
- After: ESLint no longer reporting on undefined variables in TypeScript files

Reviewed By: GijsWeterings

Differential Revision: D32647147

Pulled By: yungsters

fbshipit-source-id: 070c734ac7a075b556492726c8fecf4fdab65898
2021-12-02 14:43:36 -08:00
Sota Ogo 81a431bbbe Add an option to enable USE_CODEGEN_DISCOVERY
Summary: Changelog: [Internal] Adding an option in RN Tester to enable the new codegen discovery option where it uses generate-artifacts.js to codegen native files. It also updates generate-artifacts.js to support the case where react-native is not within node_modules. It also updates the option name for rn-demo-app.

Reviewed By: cortinico

Differential Revision: D32777912

fbshipit-source-id: f2b76fa61573e3d4507a9f16f8243ac7ca006900
2021-12-02 14:26:58 -08:00
Marc Rousavy 1721efb54f fix: Use same implementation for `performance.now()` on iOS and Android (#32695)
Summary:
I've noticed that the `performance.now()` implementations differ on iOS and Android.

iOS:
```objc
PerformanceNow iosPerformanceNowBinder = []() {
  // CACurrentMediaTime() returns the current absolute time, in seconds
  return CACurrentMediaTime() * 1000;
};
```
Android:
```c++
double reactAndroidNativePerformanceNowHook() {
  auto time = std::chrono::steady_clock::now();
  auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>(
                      time.time_since_epoch())
                      .count();

  constexpr double NANOSECONDS_IN_MILLISECOND = 1000000.0;

  return duration / NANOSECONDS_IN_MILLISECOND;
}
```

For consistency, I thought why not just use the same implementation on both iOS and Android.

It also seems more logical to use Chrono on iOS, since it has nanosecond precision and we just multiply it to milliseconds, whereas `CACurrentMediaTime` multiplies to seconds, and we divide it down to milliseconds again.

## Changelog

(internal change only)

Pull Request resolved: https://github.com/facebook/react-native/pull/32695

Test Plan:
Run on iOS and Android:

```ts
const now = global.performance.now()
console.log(`${Platform.OS}: ${now}`)
```

Reviewed By: feedthejim

Differential Revision: D32793838

Pulled By: ShikaSD

fbshipit-source-id: e7967780be95956a75a3a3757311af0077976d23
2021-12-02 12:32:29 -08:00
Luna Wei 90f0de99ad Remove warning against PR for release branch
Summary:
Changelog: [Internal] Remove warning about creating a pull request to a release branch

We want to support this use case as we want pick requesters to land the cherry-picks themselves and rely on CircleCI automation to test

Reviewed By: cortinico

Differential Revision: D32780819

fbshipit-source-id: 882625a016653dbf480da33fd499d3718b2b5524
2021-12-02 12:11:52 -08:00
Samuel Susla 9e2ec4d3dd Make UIManager::animationTick const
Summary:
changelog: [internal]

UIManager::animationTick is thread safe. Let's make it obvious by marking the method const.

Reviewed By: javache

Differential Revision: D32669102

fbshipit-source-id: 49e35d0f0a5c5d1b03baa1cbf9cdece082909e85
2021-12-02 07:54:09 -08:00
David Ashinsky 5da4872775 Restore react native override preference when live shopping ends.
Summary:
The current implementation of the prelive composer is setting the RN override preference to nil when live shopping ends. However, if the user had a previously set appearance override, this would clear it out.

To resolve this, I cache the user's override preference before we override it, and restore it when live shopping ends.

Additionally, I'm adding a missing callback to restore the override pref when live shopping is dismissed, but not cancelled.

Changelog:
[ReactiveNative][Appearance] - Add function to retrieve overridden RN appearance

Differential Revision: D32564739

fbshipit-source-id: d0b4e06d2bbadad68f172d951609cba3e4587e5d
2021-12-02 07:20:05 -08:00
Peter Carpenter 4d1357918a feat: support queuing accessibility announcements on ios (#32637)
Summary:
The current implementation of `AccessibilityInfo.announceForAccessibility` will immediately interrupt any existing in progress speech with the announcement. Sometimes this is desirable behaviour, but often you will want to wait until existing speech is finished before reading the new announcement. This change gives us that option.

My personal use case for this feature is a custom text input. When typing on iOS with voiceover enabled, each character is read out after being selected. I wanted to add some additional information after each character to help with the context of what has changed in the input, but I didn't want to override the reading of the character itself.

This feature is supported natively on iOS by constructing an `NSAttributedString` with the property [`accessibilitySpeechQueueAnnouncement`](https://developer.apple.com/documentation/foundation/nsattributedstring/key/2865770-accessibilityspeechqueueannounce), so this change just adds an extra parameter to `AccessibilityInfo.announceForAccessibility` which controls the value of that property on the native side. Adding this as an extra optional parameter with false as the default ensures that existing uses of the function won't be affected.

Unfortunately, this feature doesn't appear to be supported on Android, so the new second property will be iOS only.

## Changelog

[iOS] [Added] - add new argument to announceForAccessibility to allow queueing on iOS

Pull Request resolved: https://github.com/facebook/react-native/pull/32637

Test Plan:
I've updated the `announceForAccessibility` section in RNTester with multiple buttons to demonstrate the difference between `queue: false` (default) and `queue: true` and show they work as intended.

Here's the expectation for each button:

- "Announce for Accessibility Immediately": on press, should start reading the button label, then be interrupted by the announcement
- "Announce for Accessibility Queued": on press, should read the button label then read the announcement afterwards
- "Announce for Accessibility Queue Multiple": on press, should read the button label, then read three announcements sequentially, no interruptions

You can see the realisation of those expectations in the following video recorded on an iPhone 12 running iOS 15.0.2:

https://user-images.githubusercontent.com/14826539/142770536-d57bfd69-eba5-444d-9c89-4bf4851ea062.mov

I've also tested the same way on an iPhone 8 running iOS 13.4 and it works exactly the same.

Reviewed By: yungsters

Differential Revision: D32637989

Pulled By: philIip

fbshipit-source-id: 3e90add523f11eb0eb34ea623211249263f257e2
2021-12-02 00:34:05 -08:00
Luna Wei 2bb91ae0e9 Consolidate upgrade forms
Summary:
Changelog:
[Internal] - Consolidate issue forms instead of separating into to 2.

Reviewed By: sota000

Differential Revision: D32736198

fbshipit-source-id: 73f858ae7dae4fea6c0e5d5a3af7b110b34c6226
2021-12-01 16:57:18 -08:00