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

6935 Коммитов

Автор SHA1 Сообщение Дата
Blair Vanderhoof 82b268f884 Revert D36468390: Fix negative zoomScale in RTL
Differential Revision:
D36468390 (2f491bfa9f)

Original commit changeset: f18244f1421f

Original Phabricator Diff: D36468390 (2f491bfa9f)

fbshipit-source-id: 925a7b811aaeefb0cda20493365c1e12cab66ee0
2022-05-18 14:44:46 -07:00
Pieter De Baets a4690d054f Disable early return in NativeAnimatedHelper.flushQueue
Summary:
This is the same issue as https://www.internalfb.com/diff/D36298399 (55ee8ce0c4) which was reverted earlier this week.

Changelog: [Internal]

Differential Revision: D36479089

fbshipit-source-id: 2bce05882a558db0c3464ec4a2b05eee36a3048a
2022-05-18 10:36:03 -07:00
Blair Vanderhoof 2f491bfa9f Fix negative zoomScale in RTL
Summary:
Changelog:
[iOS][Fixed] - When in an RTL locale on iOS, e.nativeEvent.zoomScale is -1. This seems to cause erratic blank spaces that don't recover as you scroll. Taking Math.abs of the value fixes it. Blame: D36169686 (13a72e0ccc)

Differential Revision: D36468390

fbshipit-source-id: f18244f1421fc1ccbb0d1035df8a7c6de10ccf62
2022-05-17 21:50:25 -07:00
Joshua Gross 35e2a63b8d Batch Animated calls into one JSI call per frame
Summary:
We introduce a few optimizations:

(1) Previous diff: We defer calling any NativeAnimatedModule methods by waiting 1ms before flushing the queue, and debouncing until no flush is requested. Practically, this just means that we'll call NativeAnimatedModule methods N times at once, at the end of a render loop, instead of N times smeared throughout the render loop.
(2) Additionally, instead of calling N methods, we create multi-operation argument buffer and call a single NativeAnimatedModule API, which should essentially throttle NativeAnimatedModule API calls to once-ish per frame. On the native side, this also reduces a lot of overhead associated with scheduling work on the UI thread (we schedule 1 function to run on the UI thread and perform N operations, as opposed to scheduling N functions to run on the UI thread).

TODO:
- implement stubs for iOS
- write gating code so this can be properly tested in VR and in fb4a

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36338606

fbshipit-source-id: 29ac949b53b874683128a76525586c22def3143b
2022-05-17 16:42:41 -07:00
Joshua Gross 29a91babd4 Delay Animated operations by at most 1ms (one render loop) to batch all operations and execute at once
Summary:
Because of the disconnect between the ReactJS render loop and Animated nodes, we don't know when a render loop begins or ends. Historically we haven't cared about that much,
but now for perf reasons we're attempting to batch them. Scheduling a function to execute at the end of the runloop and canceling until nothing interrupts it achieves that.

Impact seems fairly minimal and this should work everywhere (android, ios, etc) but we may want to gate the behavior as it *could* change things in surprising ways.

Changelog: [Internal]

Reviewed By: genkikondo

Differential Revision: D36338621

fbshipit-source-id: 48e52a1b2e2bcfb3ef13d3abd38d735967356de7
2022-05-17 16:42:41 -07:00
Nicola Corti 7c82cc3095 Add a note about React/React-Native versioning
Summary:
I'm adding a readme inside the ./Libraries/Renderer folder
to explain how React and React Native are aligned.

Changelog:
[Internal] [Changed] - Add a note about React/React-Native versioning

Reviewed By: cipolleschi

Differential Revision: D36445819

fbshipit-source-id: cf1b071b9996bcc8222deab2e9458f014766f2a9
2022-05-17 14:49:00 -07:00
Hetan Thakkar 2fb107c9a6 Fixed Textinput not properly handling padding and paddingVertical in style props (#33564)
Summary:
Fixes https://github.com/facebook/react-native/issues/33562 #21720. Earlier this [`paddingTop`](d5da70e17e/Libraries/Components/TextInput/TextInput.js (L1367)) used to override the  `paddingTop` of `padding` and `paddingVertical` of the style props. Using `Stylesheet.flatten` will solve this problem.

## 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] - Fixed paddingTop not being applied when using padding and paddingVertical in multiline textinput

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

Reviewed By: christophpurrer, cortinico

Differential Revision: D36018667

Pulled By: kacieb

fbshipit-source-id: 0af0ed8ea536ec4e813325b1cf93c7cb2481eb07
2022-05-17 03:26:34 -07:00
Genki Kondo 57d3b9e2ca Modify VirtualizeUtils.elementsThatOverlapOffsets to use binary search
Summary:
elementsThatOverlapOffsets was quite inefficient as it was doing a linear scan over all items without an early out for each input offset.

The number of items can be large, so we'd want to use binary search here.
Before: O(MN), where M is the # offsets and N is the # items
After: O(MlogN)

As a utility method, elementsThatOverlapOffsets should not be responsible for checking that the offsets are in increasing order

'binary-search' dep added via https://www.internalfb.com/intern/wiki/React_Native/Building_Product_Experiences/Third_Party_Packages_(npm)/

Changelog:
[Internal] - Modify VirtualizeUtils.elementsThatOverlapOffsets to use binary search

Reviewed By: javache

Differential Revision: D36292326

fbshipit-source-id: 5f22eb5533b69e2ebe5c1cb34e4f82605838f0a7
2022-05-16 13:14:35 -07:00
Ken Tominaga c73e021a4b Remove iOS 11 deprecation warnings around SafeArea (#32851)
Summary:
We don't have to check or emulate the safe area for iOS 11 above. I deleted the unnecessary check for the safe area.

This is a continuation pull request of these iOS 11 availability check.
* [Remove iOS 11 version check by ken0nek · Pull Request https://github.com/facebook/react-native/issues/32151 · facebook/react-native](https://github.com/facebook/react-native/pull/32151)
* [Remove iOS 11 availability check by ken0nek · Pull Request https://github.com/facebook/react-native/issues/32488 · facebook/react-native](https://github.com/facebook/react-native/pull/32488)

-----

- Stop using layout guide (`topLayoutGuide`, `bottomLayoutGuide`)
- Refactor `RCTSafeAreaView`
- Delete `emulateUnlessSupported` property

Docs PR: https://github.com/facebook/react-native-website/pull/2919

## 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] [Removed] - Remove `emulateUnlessSupported`

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

Reviewed By: philIip, sammy-SC

Differential Revision: D33586023

Pulled By: cortinico

fbshipit-source-id: 75fc1037141f71d9340c7b875a6bf86f9cfd6a02
2022-05-16 09:27:43 -07:00
Joshua Gross bd2d0b28bd Patch loophole that caused some Animated instructions to be executed out of order
Summary:
This patches a loophole in the logic that caused some operations to execute immediately and some to be deferred, even within the same render loop. This caused the non-queued operations to be executed out of order. Instead, if an operation is created and a queued exists, we just push the operation to the end of the queue so ordering is preserved.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D36379125

fbshipit-source-id: d9f63f4d47d8453d51add61763b7b9c74ffe9d88
2022-05-13 13:32:02 -07:00
Tommy Nguyen 494b73cb33 fix: remove unactionable warning when on 'Paper' (#33830)
Summary:
We are currently seeing warning `Native Component 'X' that calls codegenNativeComponent was not code generated at build time. Please check its definition.` even though we have not opted into Fabric. This warning is not actionable and is just noisy.

See also discussion: https://github.com/reactwg/react-native-releases/discussions/21#discussioncomment-2657180

## Changelog

[General] [Fixed] - Remove unactionable warning about `codegenNativeComponent` when on 'Paper'

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

Test Plan: n/a

Reviewed By: dmitryrykun

Differential Revision: D36377844

Pulled By: cortinico

fbshipit-source-id: 23c9f9dbf0ce1cea60c5dc8caa02d0dc53bd635d
2022-05-13 11:23:21 -07:00
Pieter De Baets 75fb346e74 Revert D36298399: Check queue size before starting Animated batch
Differential Revision:
D36298399 (55ee8ce0c4)

Original commit changeset: b43c07994ba2

Original Phabricator Diff: D36298399 (55ee8ce0c4)

fbshipit-source-id: 20989b3e22beb6f991aad44b89d96c2946d3e39b
2022-05-13 09:19:24 -07:00
Marshall Roch 309d705e6a Deploy 0.178.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D36356453

fbshipit-source-id: e56e4694d4e0811f760a3994a889b48f2ba8cffb
2022-05-12 20:06:24 -07:00
Pieter De Baets 55ee8ce0c4 Check queue size before starting Animated batch
Summary:
Small win: if the queue is empty we shouldn't start/stop the batch.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D36298399

fbshipit-source-id: b43c07994ba28b4c890fe52af4e81c265a3b8ac7
2022-05-12 05:49:01 -07:00
Deepak Jacob 2c5a966054 Remove babel plugins from jest preprocessor which are part of preset
Summary:
Changelog:
[Internal][Changed] - Remove babel plugins from jest preprocessor which are part of preset metro-react-native-babel-preset

Transformer metro-react-native-babel-transformer has preset metro-react-native-babel-preset which has necessary plugins to transpile the source. So we don’t need to pass it again in the preprocessor.

As part of the change, updated one test to use strict mode since metro-react-native-babel-preset has strictMode is set to false.

Reviewed By: motiz88

Differential Revision: D34868961

fbshipit-source-id: 71678f1ee6f1b5ebf9a0c6fd2d6444a61d7583ac
2022-05-12 03:48:24 -07:00
Genki Kondo 73ad6514cc Fix bounds calculation with initialScrollIndex
Summary:
Sometimes this._scrollMetrics.offset is 0 even after initial scroll is triggered, because the offset is updated only upon _onScroll, which may not have been called in time for the next computation of the render limits. Thus, there is a window of time where computeWindowedRenderLimits calculates undesired render limits as it uses the offset. This results in 2 extra rerenders of the VirtualizedList if an initial scroll offset is applied, as the render limits shifts from the expected bounds (calculated using initialScrollIndex), to the 0 offset bounds (calculated using computeWindowedRenderLimits due to offset = 0), back to the expected bounds (onScroll triggers recalculation of render limits via _updateCellsToRender).

This issue was introduced in https://www.internalfb.com/diff/D35503114 (c5c17985da)

We cannot rely on this._hasDoneInitialScroll to indicate that scrolling *actually* finished (specifically, that _onScroll was called). Instead, we want to recalculate the windowed render limits if any of the following hold:
- initialScrollIndex is undefined or is 0
- initialScrollIndex > 0 AND scrolling is complete
- initialScrollIndex > 0 AND the end of the list is visible (this handles the case where the list is shorter than the visible area) <- this is the case that https://www.internalfb.com/diff/D35503114 (c5c17985da) attempted to address

Changelog:
[Internal][Fixed] - Fix issue where VirtualizedList rerenders multiple times and flickers when initialScrollIndex is set

Reviewed By: JoshuaGross

Differential Revision: D36328891

fbshipit-source-id: aba26aa06b24f6976657dd1e9f95bb666f60d9a6
2022-05-12 00:47:11 -07:00
Christian Ruink f2e23215ca Adding missing prop for RN Android TextInput behavior
Summary:
An issue that popped up working on:
D36140890
There is already behavior implemented to set the TextInput caret/cursor color independently from the selection box color in Android.
However this handy prop, was not documented or added as one of the available props for the TextInput component.

Associated behavior can be found here:
https://www.internalfb.com/code/fbsource/[f116d651b2e8]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java?lines=512

## **Changelog**
[Android] - Add android-only prop documentation at the TextInput js level.

Reviewed By: genkikondo

Differential Revision: D36208656

fbshipit-source-id: a54a2646351d897e0d598d5e1979f2a0c443e9d6
2022-05-10 16:48:20 -07:00
Genki Kondo 92cf74cd50 Fix render limit calculations by setting default zoomScale to 1
Summary:
During debugging of undesired behavior using VirtualizedList with initialScrollIndex, it was found that zoomScale was sometimes undefined, which resulted in elementsThatOverlapOffsets returning not being able to find the frame at the given offsets.

This does not cause any unexpected behavior when scrolling from the top, as the first item index in VirtualizedList is always calculated to be 0; however, when we set initialScrollIndex, the frame calculations are incorrect, resulting in wasteful re-renders of the VirtualizedList as it renders every frame (row) from the top.

Changelog:
[Internal][Fixed] - Default zoomScale to 1 for computeWindowedRenderLimits and elementsThatOverlapOffsets in order to fix render limit calculation.

Differential Revision: D36294426

fbshipit-source-id: 1e1abec1c95f58a1913bafa2c9680e51e2dc26fa
2022-05-10 16:21:59 -07:00
Genki Kondo 7c581f3d30 Move ScrollView's contentOffset to common props
Summary:
ScrollView's contentOffset prop was assumed to be iOS only, but in reality it is supported on Android as well: https://fburl.com/code/nuxpjpth

Changelog:
[General] - Move ScrollView's contentOffset to common props

Reviewed By: yungsters

Differential Revision: D36219604

fbshipit-source-id: f41679fd2ce7971a30129e0d91ae9f32b9cf756e
2022-05-09 13:05:16 -07:00
Sam Zhou 23a160ebf6 Lock down constrain writes in some directories
Summary: Changelog: [internal]

Reviewed By: gkz

Differential Revision: D36214426

fbshipit-source-id: 8498ef0f646d8a38e5d523f4fd2deacf1b649fd2
2022-05-06 15:53:13 -07:00
Evan Yeung 73a43901b4 Deploy 0.177.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D36141544

fbshipit-source-id: 7e322faa6f902547bb68997d02a50352c525d543
2022-05-06 10:51:36 -07:00
islandryu 13a72e0ccc Fix items disappear when zooming VirtualizedList (#33765)
Summary:
fix https://github.com/facebook/react-native/issues/33705
Fixed the disappearance of items when scrolling after zooming VirtualizedList.
example https://github.com/islandryu/zoomVirtualizedList

Before modification

https://user-images.githubusercontent.com/65934663/166849127-9fc3ba84-5172-4ae1-bd44-dd6312f283ec.mov

After modification

https://user-images.githubusercontent.com/65934663/166868632-2f78e118-f705-442d-b94e-ff165bed26c7.mov

## 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] - Fixed the disappearance of items when scrolling after zooming VirtualizedList.

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

Test Plan:
Make the VirtualizedList zoomable with a prop such as maximumZoomScale.
Apply the patch and make sure that items in the VirtualizedList do not disappear when you scroll after zooming the VirtualizedList.

Or apply the patch from this repository and check it.
https://github.com/islandryu/zoomVirtualizedList

Reviewed By: javache

Differential Revision: D36169686

Pulled By: yungsters

fbshipit-source-id: 0f86255c2864be13f6d2dc5a58af1d11c9eedac3
2022-05-06 09:30:15 -07:00
Rick Hanlon 93b50be8c2 Replace use-subscripton with use-sync-external-store (#33770)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33770

React has replaced use-subscription with the React 18 compatible use-sync-external-store.

Changelog:
[General][Changed] - Replace use-subscripton with use-sync-external-store

Reviewed By: ryancat

Differential Revision: D35592432

fbshipit-source-id: cc2016f66940e53f3614e110bafb02240bae1ae4
2022-05-05 19:58:19 -07:00
Tim Yung 870755fa7e RN: Delete `EventEmitter#removeSubscription`
Summary:
Deletes `EventEmitter#removeSubscription`, which has been deprecated since D27704279 (cb6cbd12f8).

Relatedly, the `removeListener` family of methods (which were deprecated ad the same time) were recently removed by D35549719 (2596b2f695).

Changelog:
[General][Removed] - Removed `EventEmitter.prototype.removeSubscription` method.

Reviewed By: christophpurrer

Differential Revision: D36171048

fbshipit-source-id: 2409d235d43049cddfe0a54bcc60e1f47d4185c5
2022-05-05 12:55:00 -07:00
Moti Zilberman 018d5cf985 Remove nonstandard Promise.prototype.done implementation
Summary:
Changelog:
[General][Breaking] - Remove nonstandard Promise.prototype.done

`Promise.prototype.done` has been deprecated since D34222667 (35800962c1). Here we remove it from React Native's default Promise polyfill. Users should switch to using standard Promise features like `.then()`, or install their own custom polyfills for advanced use cases.

Reviewed By: kodafb

Differential Revision: D36001688

fbshipit-source-id: 37f452000c16279280ef6a50b2ce616776377c4e
2022-05-05 03:55:10 -07:00
George Zahariev 20d9d3aa6a Fixes to non-product code (e.g React Native)
Summary:
We are working on making the empty object literal `{}` have the type `{}` - i.e. exact empty object - rather than being unsealed.

Some manual fixes, in particular to React Native code, which is used and can be synced to other repos (e.g. WWW).

With these changes, error diff in Xplat is down to ~1990 errors

Note that after I roll out `exact_empty_objects`, I'll codemod all the `{...null}` (the only way to get an exact empty object currently) back to `{}`

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D36142838

fbshipit-source-id: 054caf370db230f42a4c5f5706c88979ef246537
2022-05-04 16:13:07 -07:00
Matin Zadeh Dolatabad 2596b2f695 fix: remove deprecated removeListener methods (#33580)
Summary:
Remove old deprecated modules that cause annoying warnings. This can be a breaking change for some third-party modules.

## Changelog

[General] [Removed] - Remove deprecated removeListener methods

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

Test Plan: See `flow-check` and `build-arvr-js-flow` succeed in Sandcastle.

Reviewed By: cortinico

Differential Revision: D35549719

Pulled By: yungsters

fbshipit-source-id: 0495e36de19db434362d5de56463d9c1ad6edd73
2022-05-04 11:32:51 -07:00
George Zahariev e7d9e4dbb5 Collapse object initialization in Xplat
Summary:
Collapse multiline object initialization into one single object literal (as much as possible).

Run codemod (requires temporary xplat task runner config changes), then manual fixes.

```
./scripts/typedjs/flow/runner codemod lti/collapseObjectInitialization ~/fbsource/xplat/js/
```

- Announcement: [post](https://fb.workplace.com/groups/flowlang/posts/903386663600331)
- Support group: [Flow Support](https://fb.workplace.com/groups/flow)

drop-conflicts

Format:
```
arc f
```
Sort imports
```
hg l -n | xargs js1 lint --fix --rule 'fb-tools/sort-requires'
```

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D36112168

fbshipit-source-id: 23db87c3bd8ffe693019ffeb5ac8300ec46c8532
2022-05-03 21:55:01 -07:00
George Zahariev 0337a2981d Add annotations to empty objects that look like indexers in Xplat
Summary:
We are working on making the empty object literal `{}` have the type `{}` - i.e. exact empty object - rather than being unsealed.
Making this change exposes a variety of errors. We can prevent these errors by annotating what we want the type of the empty object to be.

Reduces Xplat error diff to 2.3k

- Announcement: [post](https://fb.workplace.com/groups/flowlang/posts/903386663600331)
- Support group: [Flow Support](https://fb.workplace.com/groups/flow)

drop-conflicts

Format:
```
arc f
```
Sort imports
```
hg l -n | xargs js1 lint --fix --rule 'fb-tools/sort-requires'
```

Changelog: [Internal]

Reviewed By: samwgoldman

Differential Revision: D36086696

fbshipit-source-id: 90447279f2e6e38f44189b74ec0297719f7adf58
2022-05-03 19:59:28 -07:00
Kevin Gozali ab43358da7 iOS: Introduced ReactNativeRuntimeDiagnostics for various runtime validation mechanism
Summary:
With the new architecture, this diagnostic utility will be helpful to ensure stronger validation of various corner cases at runtime, like handling an early JavaScript exception when loading React Native.

If `global.RN$DiagnosticFlags` is set to a string of comma-separated flags, the util functions will be able to perform additional diagnostics. For now, the accepted flags are:
- `early_js_errors`
- `all`

This is still experimental and may change frequently.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D36088407

fbshipit-source-id: 9059d2d081b0f41d049310fb09650416b333ff57
2022-05-03 18:11:35 -07:00
Sam Zhou c8550bb5fa Add annotations to unannotated variable declarations [manually-modified]
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D36085338

fbshipit-source-id: 34d421ad3fd4595c13e7a45256666112f8607fbe
2022-05-03 13:50:45 -07:00
Moti Zilberman 598c2e02fd Use Flow type inference for interpolation outputRange
Summary:
Changelog:
[Internal]

Cleans up unnecessary type casts / suppressions throughout the codebase following D35869725.

Reviewed By: javache

Differential Revision: D35870027

fbshipit-source-id: eefcb544b19ba93587011cdfd4046d18dddb246e
2022-05-03 12:04:02 -07:00
Moti Zilberman 7b86fa2b79 Distinguish between string/number-valued interpolation nodes at the type level
Summary:
Changelog:
[General][Fixed] - Improved Flow type inference in Animated `.interpolate()`

Improves the ergonomics of `.interpolate()` by allowing Flow to infer the correct type for `outputRange`. This is achieved by adding a new type parameter `OutputT` to `interpolate()` (and `Animated.Interpolation` and `InterpolationConfigType`), which Flow infers as either `number` or `string` based on usage.

Admittedly, at the call site, this is not that much safer compared to something like `outputRange: $ReadOnlyArray<number | string>`, but it does document the intent of the API a bit better and provide some downstream type safety. For example, we can now express `Animated.Number` (D35869375) more precisely by excluding string-valued interpolation nodes.

Reviewed By: javache

Differential Revision: D35869725

fbshipit-source-id: e03ec22e9b3368ee196b392af011062ac99d8bb9
2022-05-03 12:04:02 -07:00
Moti Zilberman 9eb7629ac6 Add Animated.Numeric Flow type
Summary:
Changelog: [General][Added] - Add `Animated.Numeric` Flow type

Adds a Flow type to represent the various Animated node types that evaluate to numeric values and can be `interpolate()`d.

I'm including `AnimatedInterpolation` as "numeric" here even though it can technically evaluate either to a number or to a string, depending on its config. Note that calling `interpolate()` on a string-valued `AnimatedInterpolation` is a runtime error.

In a future diff, I'm planning to add a type argument to `AnimatedInterpolation` (and its config type), at which point we can refine `Animated.Numeric` to correctly include only `AnimatedInterpolation<number>`.

Reviewed By: javache

Differential Revision: D35869375

fbshipit-source-id: 2ff6754f1a5abc68c9da2c6836872c2022b25676
2022-05-03 12:04:02 -07:00
Paige Sun a0a45dcaba Minor comment on how to migrate UIManager.sendAccessibilityEvent
Summary: Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D36086114

fbshipit-source-id: 70a05adffea0576731ccf62154a00785e8aceecd
2022-05-02 20:31:31 -07:00
George Zahariev d992ae0448 Codemod `Object.assign` with object literal first argument to object spread in Xplat
Summary:
Codemod `Object.assign` with object literal first argument (e.g. `Object.assign({}, foo)`) to object spread.

This adds several suppressions for exposed errors. The codemod produces errors as `Object.assign` is more unsafe than object spread. For example, `Object.assign` doesn't handle indexers, nor does it handle inexact objects properly, and when the (currently unsealed) empty object is supplied as the first argument, it also leads to unsafe behaviour:
https://flow.org/try/#0FAehAIGJwSQOwCYFMAeSBOBnYyDGAbAQ3SXADdjwBbQgBwC5wBvAbUwBd0BLOAcwF1GHbnwC+AbmDAAFAHkARgCskudgDpCmTF15xpTQowCMogDTU6ASkbyA9rfxJCcS+PBhwAfm8ymwcAGG4Eam-gFqETS0oaKu7hAAyrQkhAjgGOi2WOCa6Si0KuxICFIe0PCohKo5AGZF6HlV7DgqRCTklDyVqowGQpw8vOYRahJSCsqqGlo6en3gAEQAFlwL5vLGZuBdKE1xHjtN4Li2AK74abZkGVzI4AAG8vfgUvphOYzLq6EB4BvBP3CEUOqhi+0SyScaQyWUwOThqAKqmKpQg0AAqnBME5HGkalwsOwcuheDIJoVptpdPotvMTNZmDV7Iw4KcqPIMLE3B5vN4gA

The codemod is safe to do, despite some Flow errors, as `Object.assign` and object spread are equivalent at runtime, with the exception that `Object.assign` triggers setters on the target object. However the codemod [does not run](938dbdd6c3/lib/rules/prefer-object-spread.js (L283-L285)) if the first argument (object literal) has getters/setters, so we are fine.

```
ag -l 'Object.assign\(' | xargs ag -l 'flow' | xargs js1 lint --rule '{"prefer-object-spread":2}' --fix
```
Some manual fixes
```
arc f
```

Reviewed By: SamChou19815

Differential Revision: D36023786

fbshipit-source-id: b682562e670410acf4175ba59ab285c7bdcfe052
2022-04-28 19:40:55 -07:00
Sam Zhou 0c4c6ca319 Add annotations to unannotated variable declarations [manually-modified]
Reviewed By: panagosg7

Differential Revision: D35948108

fbshipit-source-id: 7d286c9dd66dbd25281e2d831691f8bb34504b5d
2022-04-27 19:15:55 -07:00
Rick Hanlon 1a3eaa5dbf React Native sync for revisions 60e63b9...bd4784c
Summary:
This sync includes the following changes:
- **[bd4784c8f](https://github.com/facebook/react/commit/bd4784c8f )**: Revert #24236 (Don't recreate the same fallback on the client if hydrating suspends) ([#24434](https://github.com/facebook/react/pull/24434)) //<dan>//
- **[6d3b6d0f4](https://github.com/facebook/react/commit/6d3b6d0f4 )**: forwardRef et al shouldn't affect if props reused ([#24421](https://github.com/facebook/react/pull/24421)) //<Andrew Clark>//
- **[bd0813766](https://github.com/facebook/react/commit/bd0813766 )**: Fix: useDeferredValue should reuse previous value ([#24413](https://github.com/facebook/react/pull/24413)) //<Andrew Clark>//
- **[9ae80d6a2](https://github.com/facebook/react/commit/9ae80d6a2 )**: Suppress hydration warnings when a preceding sibling suspends ([#24404](https://github.com/facebook/react/pull/24404)) //<Josh Story>//
- **[0dc4e6663](https://github.com/facebook/react/commit/0dc4e6663 )**: Land enableClientRenderFallbackOnHydrationMismatch ([#24410](https://github.com/facebook/react/pull/24410)) //<Andrew Clark>//
- **[354772952](https://github.com/facebook/react/commit/354772952 )**: Land enableSelectiveHydration flag ([#24406](https://github.com/facebook/react/pull/24406)) //<Andrew Clark>//
- **[392808a1f](https://github.com/facebook/react/commit/392808a1f )**: Land enableClientRenderFallbackOnTextMismatch flag ([#24405](https://github.com/facebook/react/pull/24405)) //<Andrew Clark>//
- **[1e748b452](https://github.com/facebook/react/commit/1e748b452 )**: Land enableLazyElements flag ([#24407](https://github.com/facebook/react/pull/24407)) //<Andrew Clark>//
- **[4175f0593](https://github.com/facebook/react/commit/4175f0593 )**: Temporarily feature flag numeric fallback for symbols ([#24401](https://github.com/facebook/react/pull/24401)) //<Ricky>//
- **[a6d53f346](https://github.com/facebook/react/commit/a6d53f346 )**: Revert "Clean up Selective Hydration / Event Replay flag ([#24156](https://github.com/facebook/react/pull/24156))" ([#24402](https://github.com/facebook/react/pull/24402)) //<Ricky>//
- **[ab9cdd34f](https://github.com/facebook/react/commit/ab9cdd34f )**: Bugfix: In legacy mode, call suspended tree's unmount effects when it is deleted ([#24400](https://github.com/facebook/react/pull/24400)) //<Andrew Clark>//
- **[168da8d55](https://github.com/facebook/react/commit/168da8d55 )**: Fix typo that happened during rebasing //<Andrew Clark>//
- **[8bc527a4c](https://github.com/facebook/react/commit/8bc527a4c )**: Bugfix: Fix race condition between interleaved and non-interleaved updates ([#24353](https://github.com/facebook/react/pull/24353)) //<Andrew Clark>//
- **[f7cf077cc](https://github.com/facebook/react/commit/f7cf077cc )**: [Transition Tracing] Add Offscreen Queue ([#24341](https://github.com/facebook/react/pull/24341)) //<Luna Ruan>//
- **[4fc394bbe](https://github.com/facebook/react/commit/4fc394bbe )**: Fix suspense fallback throttling ([#24253](https://github.com/facebook/react/pull/24253)) //<sunderls>//
- **[80170a068](https://github.com/facebook/react/commit/80170a068 )**: Match bundle.name and match upper case entry points ([#24346](https://github.com/facebook/react/pull/24346)) //<Sebastian Markbåge>//
- **[fea6f8da6](https://github.com/facebook/react/commit/fea6f8da6 )**: [Transition Tracing] Add transition to OffscreenState and pendingSuspenseBoundaries to RootState ([#24340](https://github.com/facebook/react/pull/24340)) //<Luna Ruan>//
- **[8e2f9b086](https://github.com/facebook/react/commit/8e2f9b086 )**: move passive flag ([#24339](https://github.com/facebook/react/pull/24339)) //<Luna Ruan>//
- **[55a21ef7e](https://github.com/facebook/react/commit/55a21ef7e )**: fix pushTransition for transition tracing ([#24338](https://github.com/facebook/react/pull/24338)) //<Luna Ruan>//
- **[069d23bb7](https://github.com/facebook/react/commit/069d23bb7 )**:  [eslint-plugin-exhaustive-deps] Fix exhaustive deps check for unstable vars ([#24343](https://github.com/facebook/react/pull/24343)) //<Afzal Sayed>//
- **[4997515b9](https://github.com/facebook/react/commit/4997515b9 )**: Point useSubscription to useSyncExternalStore shim ([#24289](https://github.com/facebook/react/pull/24289)) //<dan>//
- **[01e2bff1d](https://github.com/facebook/react/commit/01e2bff1d )**: Remove unnecessary check ([#24332](https://github.com/facebook/react/pull/24332)) //<zhoulixiang>//
- **[d9a0f9e20](https://github.com/facebook/react/commit/d9a0f9e20 )**: Delete create-subscription folder ([#24288](https://github.com/facebook/react/pull/24288)) //<dan>//
- **[f993ffc51](https://github.com/facebook/react/commit/f993ffc51 )**: Fix infinite update loop that happens when an unmemoized value is passed to useDeferredValue ([#24247](https://github.com/facebook/react/pull/24247)) //<Andrew Clark>//
- **[fa5800226](https://github.com/facebook/react/commit/fa5800226 )**: [Fizz] Pipeable Stream Perf ([#24291](https://github.com/facebook/react/pull/24291)) //<Josh Story>//
- **[0568c0f8c](https://github.com/facebook/react/commit/0568c0f8c )**: Replace zero with NoLanes for consistency in FiberLane ([#24327](https://github.com/facebook/react/pull/24327)) //<Leo>//
- **[e0160d50c](https://github.com/facebook/react/commit/e0160d50c )**: add transition tracing transitions stack ([#24321](https://github.com/facebook/react/pull/24321)) //<Luna Ruan>//
- **[b0f13e5d3](https://github.com/facebook/react/commit/b0f13e5d3 )**: add pendingPassiveTransitions ([#24320](https://github.com/facebook/react/pull/24320)) //<Luna Ruan>//

Changelog:
[General][Changed] - React Native sync for revisions 60e63b9...bd4784c

jest_e2e[run_all_tests]

Reviewed By: kacieb

Differential Revision: D35899012

fbshipit-source-id: 86a885e336fca9f0efa80cd2b8ca040f2cb53853
2022-04-26 13:29:43 -07:00
Pieter De Baets ceb0a54608 Memoize VirtualizedListCellContextProvider
Summary:
When a FlatList is nested inside another FlatList, it may be re-rendered whenever the outer FlatList renders. Apply the same optimization we already had in `VirtualizedListContextProvider` to avoid changing the context object if no values have changed.

Changelog: [General][Changed] - Optimized VirtualizedList context when used with nested lists

Reviewed By: genkikondo

Differential Revision: D35905952

fbshipit-source-id: 695253c85db2043d22e208ad94ecc7daa1455055
2022-04-26 04:04:45 -07:00
Chaoshuai Lu d70d7fd0b3 Adopt UIGraphicsImageRenderer API
Summary:
Apple suggested to this new API on iOS 10+.

> // Any new bitmap drawing code is encouraged to use UIGraphicsImageRenderer in lieu of this API.

WWDC18 Reference: https://developer.apple.com/videos/play/wwdc2018/219/
> Use UIGraphicsImageRenderer to create and draw to an image buffer
Supports Wide Color, unlike UIGraphicsBeginImageContext()
Combine with UIImageView for efficient offscreen rendering

Per https://nshipster.com/image-resizing/#performance-benchmarks, the new API runs even faster than the C version, probably due to more smart context reuses/management.

Changelog:
[iOS][Changed] - Adopt UIGraphicsImageRenderer API

Reviewed By: philIip

Differential Revision: D35699584

fbshipit-source-id: 7a1e2109d5e121fb396c1014f4ed0a892211b0cc
2022-04-22 17:02:51 -07:00
Luna Wei 6958bbb28c Fix up lint errors under react-native-github (#33622)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33622

Changelog: [Internal] Clean up eslint errors

Reviewed By: yungsters

Differential Revision: D35599445

fbshipit-source-id: bbb9061a3cf9df32daacad9a9b44eba94d3ce48c
2022-04-22 16:25:25 -07:00
Antoine Doubovetzky c5c17985da Fix VirtualizedList with initialScrollIndex not rendering all elements when data is updated (#33558)
Summary:
Fixes https://github.com/facebook/react-native/issues/33529 (note that I reproduced the bug on iOS too).

The bug comes from the fact that we were using `this._scrollMetrics.offset` to determine if the initial scroll was done. But sometimes it equals 0 even after the initial scroll is done, for example when the content does not fill the list. So I replaced it with `this._hasDoneInitialScroll`.
I believe that `this._hasDoneInitialScroll` was not used in the first place because it was introduced later (3 years ago vs 5 years ago for the original code).

The replacement correctly fixes the broken test case and the example given in the issue.

Then I had to update two test cases (rename the first and remove the second), that shows explicitly the broken behavior:
we have to simulate the initial scroll for the content to be adjusted, so when the content does not fill the view and the scroll cannot be executed, the content is not adjusted.

## Changelog

[General] [Fix] - Fix VirtualizedList with initialScrollIndex not rendering all elements when data is updated

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

Test Plan:
- I added a broken test case based on the issue
- I tested with the RNTesterApp using the code example given in the issue

Reviewed By: ryancat

Differential Revision: D35503114

Pulled By: yungsters

fbshipit-source-id: 67bb75d7cf1ebac0d59127d0d45afbaa3167dcf3
2022-04-20 10:26:50 -07:00
Moti Zilberman a12959546a Revert D34518929: TalkBack support for ScrollView accessibility announcements (list and grid)
Differential Revision:
D34518929 (dd6325bafe)

Original commit changeset: 410a05263a56

Original Phabricator Diff: D34518929 (dd6325bafe)

fbshipit-source-id: 114d0910970c5f5caefb98c378722faba283f2a1
2022-04-20 06:48:19 -07:00
fabriziobertoglio1987 dd6325bafe TalkBack support for ScrollView accessibility announcements (list and grid) (#33180)
Summary:
This issue fixes [30977][17] . The Pull Request was previously published by [intergalacticspacehighway][13] with [31666][19].
The solution consists of:
1. Adding Javascript logic in the [FlatList][14], SectionList, VirtualizedList components to provide accessibility information (row and column position) for each cell in the method [renderItem][20] as a fourth parameter [accessibilityCollectionItem][21]. The information is saved on the native side in the AccessibilityNodeInfo and announced by TalkBack when changing row, column, or page ([video example][12]). The prop accessibilityCollectionItem is available in the View component which wraps each FlatList cell.
2. Adding Java logic in [ReactScrollView.java][16] and HorizontalScrollView to announce pages with TalkBack when scrolling up/down. The missing AOSP logic in [ScrollView.java][10] (see also the [GridView][11] example) is responsible for announcing Page Scrolling with TalkBack.

Relevant Links:
x [Additional notes on this PR][18]
x [discussion on the additional container View around each FlatList cell][22]
x [commit adding prop getCellsInItemCount to VirtualizedList][23]

## Changelog

[Android] [Added] - Accessibility announcement for list and grid in FlatList

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

Test Plan:
[1]. TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer ([link][1])
[2]. TalkBack announces pages and cells with Vertical Flatlist in the Paper Renderer ([link][2])
[3]. `FlatList numColumns={undefined}` Should not trigger Runtime Error NoSuchKey exception columnCount when enabling TalkBack. ([link][3])
[4]. TalkBack announces pages and cells with Nested Horizontal Flatlist in the rn-tester app ([link][4])

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050452894
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050462465
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1032340879
[4]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050618308
[10]:1ac46f932e/core/java/android/widget/AdapterView.java (L1027-L1029) "GridView.java method responsible for calling setFromIndex and setToIndex"
[11]:https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1042518901 "test case on Android GridView"
[12]:https://github.com/fabriziobertoglio1987/react-native-notes/issues/6#issuecomment-1050452894 "TalkBack announces pages and cells with Horizontal Flatlist in the Paper Renderer"
[13]:https://github.com/intergalacticspacehighway "github intergalacticspacehighway"
[14]:80acf523a4/Libraries/Lists/FlatList.js (L617-L636) "FlatList accessibilityCollectionItem"
[16]:5706bd7d3e/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java (L183-L184) "logic added to ReactScrollView.java"
[17]: https://github.com/facebook/react-native/issues/30977
[18]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/6
[19]: https://github.com/facebook/react-native/pull/31666
[20]: https://reactnative.dev/docs/next/flatlist#required-renderitem "FlatList renderItem documentation"
[21]: 75147359c5 "commit that introduces fourth param accessibilityCollectionItem in callback renderItem"
[22]: https://github.com/facebook/react-native/pull/33180#discussion_r826748664 "discussion on the additional container View around each FlatList cell"
[23]: d50fd1a681 "commit adding prop getCellsInItemCount to VirtualizedList"

Reviewed By: kacieb

Differential Revision: D34518929

Pulled By: blavalla

fbshipit-source-id: 410a05263a56162bf505a4cad957b24005ed65ed
2022-04-19 19:45:10 -07:00
Vincent Riemer 32c704c30f Add gated option to use w3c pointer events for Pressibility's hover callbacks
Summary: Changelog: [Internal] - Add gated option to use w3c pointer events for Pressibility's hover callbacks

Reviewed By: p-sun

Differential Revision: D35596600

fbshipit-source-id: f9e4b71497efd0dbb09dbc1872694fc93a6e1f2e
2022-04-18 15:47:55 -07:00
Vincent Riemer 64034f3976 Put W3C PointerEvents RNTester examples behind a feature flag
Summary: Changelog: [Internal] - Put W3C PointerEvents RNTester examples behind a feature flag

Reviewed By: lunaleaps, p-sun

Differential Revision: D35684411

fbshipit-source-id: c69c12c5ed7ee7acc925d4ca8932e8bd8b6d4eee
2022-04-18 15:47:55 -07:00
Vincent Riemer a40747e2d8 Add experimental disclaimers to pointer event APIs
Summary: Changelog: [Internal] - Add experimental disclaimers to pointer event APIs

Reviewed By: lunaleaps, p-sun

Differential Revision: D35682318

fbshipit-source-id: e85a37a2eb9568df636352e170bd42a3bb30a2f6
2022-04-18 15:47:55 -07:00
Richard Howell 7d4f6840f6 add casts for implicit int to float
Summary: Apply //fbobjc/Tools/cAST:implicit_conversion to existing warnings

Reviewed By: adamjernst

Differential Revision: D35692786

fbshipit-source-id: 13fb4f8a6b6e701c324b00c682943a4b3d80de72
2022-04-18 11:51:50 -07:00
Rick Hanlon 1369eb57ec React Native sync for revisions 8dcedba...60e63b9
Summary:
This sync includes the following changes:
- **[60e63b960](https://github.com/facebook/react/commit/60e63b960 )**: remove console.error in ReactFiberLane ([#24319](https://github.com/facebook/react/pull/24319)) //<Luna Ruan>//
- **[ec52a5698](https://github.com/facebook/react/commit/ec52a5698 )**: Fix: Don't call cWU if already unmounted //<Andrew Clark>//
- **[46db4e996](https://github.com/facebook/react/commit/46db4e996 )**: Combine deletion phase into single recursive function //<Andrew Clark>//
- **[481dece58](https://github.com/facebook/react/commit/481dece58 )**: Use recursion to traverse during mutation phase //<Andrew Clark>//
- **[f9e6aef82](https://github.com/facebook/react/commit/f9e6aef82 )**: Wrap try-catch directly around each user function //<Andrew Clark>//
- **[bcc1b3121](https://github.com/facebook/react/commit/bcc1b3121 )**: Move reportUncaughtErrorInDev to captureCommitPhaseError //<Andrew Clark>//
- **[c99c5f1df](https://github.com/facebook/react/commit/c99c5f1df )**: Move ad hoc flag checks into main switch statement //<Andrew Clark>//
- **[54b5b32d5](https://github.com/facebook/react/commit/54b5b32d5 )**: Move Update flag check into each switch case //<Andrew Clark>//
- **[e66e7a0fb](https://github.com/facebook/react/commit/e66e7a0fb )**: Inline commitWork into commitMutationOnFiber //<Andrew Clark>//
- **[12d7a9ad7](https://github.com/facebook/react/commit/12d7a9ad7 )**: Combine commitWork into single switch statement //<Andrew Clark>//
- **[ea7b2ec28](https://github.com/facebook/react/commit/ea7b2ec28 )**: Remove wrong return pointer warning //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 8dcedba...60e63b9

jest_e2e[run_all_tests]

Reviewed By: kacieb

Differential Revision: D35581192

fbshipit-source-id: d8674d2871612d2f27eaf8d75ff05e54ab91271d
2022-04-14 10:50:23 -07:00
Paige Sun 033ad83b29 Refactor the JS base StaticViewConfig to be easier to understand
Summary:
Changelog: [Internal][SVC][JS] Refactor the JS base SVC StaticViewConfig to be easier to understand

This diff is a refactor that doesn't change any logic.

# Context
NativeViewConfigs are generated from RCTViewManager in iOS and ViewManager in Android.
StaticViewConfigs are partially generated from JS, and partially handwritten in JS.

We've noticed in at least 2 instances that engineers who add new props to NativeViewConfigs sometimes don't put props in the correct place for StaticViewConfigs, and thus they accidentally break the landblocking jest e2e test that validates the StaticViewConfigs matches the NativeViewConfigs.

The human error is mostly because PlatformBaseViewConfig.js was too nested to be easily understood. This diff refactors PlatformBaseViewConfig.js and adds clarifying comments.

Reviewed By: RSNara

Differential Revision: D35623775

fbshipit-source-id: 498a3daa812fa314821a2e7cb7d6f809900dbe3a
2022-04-14 10:34:55 -07:00