Commit Graph

7495 Commits

Author SHA1 Message Date
Ruslan Shestopalyuk ea354d4e22 Unit tests/fixes for PerformanceEntryObserver::get/clearEntries (#36384)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36384

## Changelog:
[Internal] - Adds more test coverage to PerformanceEntryObserver functionality related to buffering of the marks/measures, as well as making fixes for certain corner cases handled incorrectly (which are now covered by tests).

Reviewed By: rubennorte

Differential Revision: D43835928

fbshipit-source-id: fc8adbd6c2a2b6b201f1f14bdf51245268c5eabd
2023-03-06 15:23:02 -08:00
Mikhail Mikhaylov 0ecb4e64f0 Fixes JSDoc in Clipboard setString (#36381)
Summary:
There was a JSDoc mismatch in `Clipboard.setString` method, `the` was considered as a parameter name, not `content`. Added correct param name and kept the same description as before, separated with a hyphen.

## Changelog

[GENERAL] [FIXED] - Fixes JSDoc in Cliapboard setString

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

Test Plan: No tests needed

Reviewed By: yungsters

Differential Revision: D43839086

Pulled By: cortinico

fbshipit-source-id: 126035d9796e66938402704eaf9bc8646ee9b78b
2023-03-06 10:25:32 -08:00
Ruslan Shestopalyuk 350c055e3d Set up C++ unit tests for WebPerformance
Summary:
## Changelog:
[Internal] - Add unit tests for the WebPerformance library (PerformanceEntryReporter)

This sets up a C++ unit test suite for `PerformanceEntryReporter` (the core part of the native side of WebPerformance) and adds test coverage for its core functionality.

Reviewed By: sammy-SC

Differential Revision: D43771370

fbshipit-source-id: ad3e0f3f206701c2ea6a5c9386458a76699e7c80
2023-03-06 03:53:16 -08:00
Marshall Roch 947751fbe4 Upgrade to Flow 0.201.0
Summary: Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D43772813

fbshipit-source-id: 563c6f3dfb00bc9247ac0505d7f841afad1eb43e
2023-03-03 17:06:58 -08:00
Riccardo Cipolleschi e4257a4dfb Attach a script to React-RCTAppDelegate to register Legacy Components in the interop layer (#36335)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36335

This change depends on [this PR](https://github.com/react-native-community/cli/pull/1849) of the CLI that introduces the `unstable_reactLegacyComponent` field in the `react-native.config.js` file.

This change introduce a JS script that reads that fields and generated a method in an object to return a list of components to be registered. The `RCTAppDelegate` has been updated to read those components and to automatically register them into the interop layer.

Notice that a user can just update the `react-native.config.js` and rebuild the app to integrate these changes, there is no need to reinstall the pods.

The idea behind this logic is to let the user know which components they are using with the interop layer, rather than rely on some black magic that could leave them blind to the need of actually migrate their apps.

## Changelog:
[iOS][Changed] - Implement mechanism to register legacy components in the iOS Fabric interop layer

Reviewed By: cortinico, dmytrorykun

Differential Revision: D43665973

fbshipit-source-id: b4e8d71fa1bbed7a6130ee4f83a6221394d5306e
2023-03-03 14:44:57 -08:00
Ruslan Shestopalyuk eb2f86a46a Fix typing for TS AnimatableStringValue (#36366)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36366

## Changelog:

[General][Fixed] -

https://github.com/facebook/react-native/pull/36346 added some typing improvements, however there was a typo in `AnimatableStringValue` type definition, that broke tests on CI.

Reviewed By: cortinico, cipolleschi, hoxyq

Differential Revision: D43770412

fbshipit-source-id: 7b4f234b5cf04df9271e0c98cf51655c87e3bebb
2023-03-03 07:09:02 -08:00
Nick Gerleman 02e29abead Improve handling of invalid DimensionValue usage (#36346)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36346

1. Remove Paper native assertions for converting DimensionValue string to Yoga unit, and fix a case where Fabric could throw on invalid value.
2. Move DimensionValue types in TypeScript to use template literal types, to show malformed strings in-editor, during typechecking. Update min TS version to allow this (in conformance with the min TS version used by DefinitelyTyped).

Changelog:
[General][Added] - Improve handling of invalid DimensionValue usage

Reviewed By: javache

Differential Revision: D43153075

fbshipit-source-id: db4e813df6e81cbd3158edad7c07c7a90c009803
2023-03-02 20:23:08 -08:00
Xin Chen c1023c73b0 Add performance.reactNativeStartupTiming API
Summary:
This diff adds the `performance.reactNativeStartupTiming` API to the performance global object for RN. This property does not exist in web, and we are free to make up our own list of properties in the startup metrics to track RN app startup process. In our case, we have the following six properties to begin with (we may extend and add more to this list in the future):

```
- `(start|end)Time`: The time ‘zero’ for the startup timing and the end of app startup. RN has no knowledge of app start time, which will be provided by the platform. The `endTime` will be the time when the first JS bundle finishes executing (Note that RN supports multiple JS bundles, which can be loaded async)
  - `executeJavaScriptBundleEntryPoint(Start|End)`: The time for RN to execute the JS entry point (and finish all sync job)

```

Changelog:
[General][Added] - Add new JS performance API to support getting RN app startup timings

Reviewed By: rshest

Differential Revision: D43326564

fbshipit-source-id: 7b4c7cae70ff64ba1714a1630cd5e183df6c06b0
2023-03-02 20:04:42 -08:00
Genki Kondo ba9327dc98 Add unit tests for proper order of create and connect operations for native animated
Summary:
Adds unit tests to test multiple animated values that connect to either transform, style, or props, to verify that the create operations are queued before connect operations. See D43717819 (https://github.com/facebook/react-native/commit/c72c592ecd9d31ec1661958d4e5f77f8dfb37cac) for context.

Changelog:
[Internal] - Add unit tests for proper order of create and connect operations for native animated

Reviewed By: mdvacca

Differential Revision: D43741191

fbshipit-source-id: 9143ba1fce86b546bc5a5a781c08ef0ca2d946d6
2023-03-02 16:20:03 -08:00
Genki Kondo c72c592ecd Fix order of operations when creating native DAG
Summary:
## Issue

You will run into an exception like:
  Animated node with tag (child) [8] does not exist
when attempting to convert an Animated node (or starting a native animation) to native when there are multiple non-style props that have AnimatedValues (this should be a very rare case, unless you have a custom native component, as most animated props are in style).

## Root cause

Due to how __makeNative is recursively called up and down the node graph, in a specific case where multiple AnimatedValues have an AnimatedProps as their child, the "connect" operation will occur before the "create" operation for the AnimatedProps node. For example:

- When a native animation is fired via Animated.timing().start(), __makeNative is called on the AnimatedValue (call this node AnimatedValueA) that is being animated. This results in the following sequence of events:
  - AnimatedValueA iterates through its children (in this case, AnimatedProps) and calls child.__makeNative
  - AnimatedProps iterates through all props with AnimatedValue values and calls __makeNative on them (call these nodes AnimatedValueB and AnimatedValueC).
  - AnimatedValueA.__makeNative is called again, but this time, the call early exits and does not do anything.
  - AnimatedValueB.__makeNative is called. This in turn calls AnimatedProps.__makeNative, which early exits (ROOT CAUSE OF BUG).
    - connectAnimatedNodes is queued (undesired)

## Fix

Short of completely refactoring of how we handle converting the DAG to native (which we should do at some point - the current implementation is error prone and suboptimal. Tracking in T146991336), for now we can make AnimatedProps.__makeNative behavior consistent with AnimatedTransform and AnimatedStyle by just avoiding the early exit, so that the connectAnimatedNodes calls all occur after all native nodes have been created

Changelog:
[General][Fixed] - Fixed error during native DAG creation when there are multiple AnimatedValue props

Reviewed By: rshest

Differential Revision: D43717819

fbshipit-source-id: 258682300a2be65935646b499591acf41eabc56e
2023-03-02 10:28:30 -08:00
Marshall Roch b044ece594 presuppress Flow v0.201 errors
Summary: Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D43720099

fbshipit-source-id: 6931548c90deb82cfc7e3d8173ccfc6aa7f0e1c8
2023-03-02 08:43:56 -08:00
Tim Yung 2780ba38ff EventEmitter: Enforce Function Type of Listener
Summary:
Currently, `EventEmitter#addListener` defines the type (via TypeScript and Flow) of its second argument as a non-nullable function, and the implementation of `EventEmitter#emit` depends on this.

However, not everyone may be using a static type system. We're seeing some people encounter a poor developer experience when they supply non-function values to `EventEmitter#addListener`, because the type mismatch is not surfaced as an error until `EventEmitter#emit` throws later on.

This changes `EventEmitter#addListener` so that it throws when the second argument is not a function. This will make it easier for developers to identify the problematic call site because the stack trace will include the source of the non-function `listener` parameter.

Changelog:
[General][Changed] - `EventEmitter#addListener` now throws if the 2nd argument is not a function.

Reviewed By: rshest

Differential Revision: D43705465

fbshipit-source-id: 34ca91ac92862b31435bd12b7c9cb6da870a2a32
2023-03-02 02:52:20 -08:00
Nick Gerleman cbc279c877 Fix Jest failure on console.error()
Summary:
The version using `jest.spyOn()` stopped working at some point. Couldn't find any relevant setup changes, but this form seems to work.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D43669469

fbshipit-source-id: 89d207117e9a56ae3374aed47a8a75fdf2e644fd
2023-03-01 06:34:57 -08:00
Ruslan Shestopalyuk bc56f66b8d Implement Performance.getEntries* W3C extension for Performance Timeline API (#36314)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36314

## Changelog:

[Internal] - Added support for W3C Performance API extension (Performance,getEntries*)

See [here for the details](https://www.w3.org/TR/performance-timeline/#extensions-to-the-performance-interface).

This only supports `mark` and `measure` performance entry types (not `events`, as those are not supported by browsers either, they recommend using the `PerformanceObserver` API instead).

From the implementation perspective, we already maintained persistent buffer for `mark` entry types, which was required in order to look up measures.

The buffer is circular, limited to 1K entries by default.

I basically mimic the same behavior for `measure` entry types as well, since it's the simplest way of doing it at this point,

If we happen to want adding some other entry types that would be available via `Performance.getEntries*` API in the future, we may want to iterate on the internal data structures representation inside `PerformanceEntryReporter`, but for now I believe this approach should work just fine, and whatever changes we may want to do will be purely internal implementation detail.

Reviewed By: rubennorte

Differential Revision: D43625488

fbshipit-source-id: dd315b3f8488e910749a8e2a4158246e94d76f99
2023-03-01 04:14:51 -08:00
Ruslan Shestopalyuk 3997fc1c66 Lazy init for event name mapping registry
Summary:
## Changelog:

[Internal] -

Noticed this when setting up C++ unit tests for WebPerformance - the change in this diff both makes sure there is no "global constructor" warning generated when `-Wglobal-constructors` is enabled, and also makes this bit potentially a little bit more efficient, as we don't pay for the registry construction if we don't use the WebPerformance API.

Reviewed By: christophpurrer

Differential Revision: D43663521

fbshipit-source-id: 59952f2415f49bb455a3443b3bfd8971108ac72b
2023-03-01 00:36:07 -08:00
fabriziobertoglio1987 a0adf57e50 Add TYPE_VIEW_HOVER_ENTER to AccessibilityNodeInfo sendAccessibilityEvent (#34969)
Summary:
- Adds `AccessibilityEvent.TYPE_VIEW_HOVER_ENTER` to AccessibilityNodeInfo sendAccessibilityEvent
- Adds an example implementation.

fixes https://github.com/facebook/react-native/issues/30860 fixes https://github.com/facebook/react-native/issues/30097
Related Documentation https://github.com/facebook/react-native-website/pull/3438

## Changelog

[Android] [Added] - Add TYPE_VIEW_HOVER_ENTER to AccessibilityNodeInfo sendAccessibilityEvent

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

Test Plan:
Android: https://github.com/facebook/react-native/pull/34969#issuecomment-1320225358 https://github.com/facebook/react-native/pull/34969#issuecomment-1329779921
iOS: https://github.com/facebook/react-native/pull/34969#issuecomment-1329780545 https://github.com/facebook/react-native/pull/34969#issuecomment-1330984202

Reviewed By: christophpurrer

Differential Revision: D42613990

Pulled By: lunaleaps

fbshipit-source-id: 8c8950610799dcc74067d2b47b44d4ff030f66e5
2023-02-28 20:57:35 -08:00
fabriziobertoglio1987 cbe934bcff 1/2 TextInput accessibilityErrorMessage (Talkback, Android) (#33468)
Summary:
**Android**: The functionality consists of calling the [AccessibilityNodeInfo#setError][10] and [#setContentInvalid][13] method to display the error message in the TextInput.

**Fixes [https://github.com/facebook/react-native/issues/30848][51] - Adding an accessibilityErrorMessage prop to the TextInput Component**:
**Android**: The prop accessibilityErrorMessage triggers the AccessibilityNodeInfo method [setError][10] which automatically sets the correct properties on the AccessibilityNodeInfo that will inform screen readers of this state. The method calls setContentInvalid(true) and setError(youErrorString) on the AccessibilityNodeInfo.

**Fixes [https://github.com/facebook/react-native/issues/30859][52] -  Detecting changes in the Error state (text inputs)**
**Fabric - Android** - Adding accessibilityErrorMessage to field AndroidTextInputState.
ReactTextInputManager and ReactEditText receive state updates both from [Javascript][32] and [cpp (fabric)][34].
- accessibilityErrorMessage is added to the fabric AndroidTextInputState field
- The updates are received in the ReactAndroid API with method updateState from ReactTextInputManager
- After updating the TextInput text with onChangeText, the update of the accessibilityErrorMessage is triggered with method maybeSetAccessibilityError which triggers [setError][10].

More info:
- An explanation of [state updates between fabric and ReactAndroid for the TextInput component][34]
- [ReactNative renderer state updates][35]

**Paper - Android** - Adding accessibilityErrorMessage to ReactTextInputShadowNode to trigger updates in Paper renderer when accessibilityErrorMessage is changed within the onChange callback.

Related Links (Android):
- [In this diff I'm shipping and deleting mapBufferSerialization for Text measurement][101]
- [This diff implement and integrates Mapbuffer into Fabric text measure system][39]
- [Refactor ViewPropsMapBuffer -> general MapBuffer props mechanism][100]
- [TextInput: support modifying TextInputs with multiple Fragments (Cxx side)][24]
- [TextInput: keep C++ state in-sync with updated AttributedStrings in Java][23]
- [AccessibilityNodeInfo#setError][11]
- [Explanation on how TextInput calls SET_TEXT_AND_SELECTION in Java API][32]
- [Fabric: convertRawProp was extended to accept an optional default value][27]
- [understanding onChangeText callback][31]
- [Editable method replace()][12]
- [Change of error state from onChangeText show/hides a TextInput error][30]
- [AndroidTextInput: support using commands instead of setNativeProps (native change)][25]
- [TextInput: support editing completely empty TextInputs][26]
- [[Android] Fix letters duplication when using autoCapitalize https://github.com/facebook/react-native/issues/29070][40]
- [Support optional types for C++ TurboModules][28]
- [discussion on using announceForAccessibility in ReactEditText][36]
- [ fix annoucement delayed to next character][61]
- [Announce accessibility state changes happening in the background][29]
- [Refactor MountingManager into MountingManager + SurfaceMountingManager][37]

iOS Functionalities are included in separate PR https://github.com/facebook/react-native/pull/35908
Documentation PR https://github.com/facebook/react-native-website/pull/3010

Next PR [2/2 TextInput accessibilityErrorMessage (VoiceOver, iOS) https://github.com/facebook/react-native/issues/35908](https://github.com/facebook/react-native/pull/35908)
Related https://github.com/facebook/react-native-deprecated-modules/pull/18

## Changelog

[Android] [Added] - Adding TextInput prop accessibilityErrorMessage to announce with TalkBack screenreaders

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

Test Plan:
**Android - 20 Jan 2023**
https://github.com/facebook/react-native/pull/33468#issuecomment-1398228674

**iOS - 20 Jan 2023**
https://github.com/facebook/react-native/pull/33468#issuecomment-1398249006

<details><summary>CLICK TO OPEN OLD VIDEO TEST CASES</summary>
<p>

**PR Branch - Android and iOS 24th June**
[88]: Android - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event (Fabric) ([link][88])

**PR Branch - Android**
[1]. Test Cases of the functionality (Fabric) ([link][1])
[2]. Test Cases of the functionality (Paper) ([link][2])

**Main Branch**
[6]. Android - Runtime Error in main branch when passing value of 1 to TextInput  placeholder prop ([link][6])

**Issues Solved**
[7]. TalkBack error does not clear error on the next typed character when using onChangeText ([link][7])
**Other Tests**
[8]. Setting the TextInput errorMessage state with setTextAndSelection Java API from JavaScript ([link][8])
[9]. Setting the TextInput errorMessage state from fabric TextInput internal state to Java ReactTextUpdate API ([link][9])

</p>
</details>

[1]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1072101477 "Test Cases of the functionality (Android - Fabric)"
[2]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1105964322 "Test Cases of the functionality (Android - Paper)"
[3]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1116329282 "Test Cases of the functionality (iOS - Fabric)"
[6]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1087020844 "Runtime Error in main branch when passing value of 1 to TextInput  placeholder prop"
[7]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1096086753 "TalkBack error announcement done on next typed character with onChangeText"
[8]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1082594363 "setting the TextInput errorMessage state with setTextAndSelection Java API from JavaScript"
[9]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1082598745 "Setting the TextInput errorMessage state from fabric TextInput internal state to Java ReactTextUpdate API"

[10]: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setError(java.lang.CharSequence) "AOSP setError"
[11]: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setError(java.lang.CharSequence) "AccessibilityNodeInfo#setError"
[12]: https://github.com/aosp-mirror/platform_frameworks_base/blob/1ac46f932ef88a8f96d652580d8105e361ffc842/core/java/android/text/Editable.java#L28-L52 "Editable method replace"
[13]: https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setContentInvalid(boolean) "setContentInvalid"

[20]: https://github.com/facebook/react-native/commit/60b6c9be8e811241039a6db5dc906a0e88e6ba82 "draft implementation of android_errorMessage "
[21]: https://github.com/facebook/react-native/commit/012d92d0b7e5de2436f186cdbff32ba128e537d5 "add errorMessage to ReactTextUpdate and maybeSetAccessibilityError"
[22]: https://github.com/fabriziobertoglio1987/react-native/commit/cad239bded5748753cee2266c27809e24c6199fb "rename android_errorMessage to errorMessageAndroid"
[23]: https://github.com/fabriziobertoglio1987/react-native/commit/0bae47434ef79eb606c453c5be8105b8df00783a "TextInput: keep C++ state in-sync with updated AttributedStrings in Java"
[24]: https://github.com/fabriziobertoglio1987/react-native/commit/0556e86d09404105dc7ff695686b8b7c01911c5c "TextInput: support modifying TextInputs with multiple Fragments (Cxx side)"
[25]: https://github.com/fabriziobertoglio1987/react-native/commit/7ab5eb4cafdea695c4c53ce2a737f6302afd6380 "AndroidTextInput: support using commands instead of setNativeProps (native change)"
[26]: https://github.com/fabriziobertoglio1987/react-native/commit/b9491b7c5104066b2714045cd7710f995458c9e9 "TextInput: support editing completely empty TextInputs"
[27]: https://github.com/fabriziobertoglio1987/react-native/commit/7f1ed6848f89bdccc7f7a5cc76019eec67e76b2f "Fabric: convertRawProp was extended to accept an optional default value"
[28]: https://github.com/facebook/react-native/commit/6e0fa5f15eef71abcfb47750eb3669065ba2ab7d "Support optional types for C++ TurboModules"
[29]: https://github.com/fabriziobertoglio1987/react-native/commit/baa66f63d8af2b772dea8ff8eda50eba264c3faf "Announce accessibility state changes happening in the background"

[30]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1071989570 "Change of error state from onChangeText show/hides a TextInput error"
[31]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1074827746 "understanding onChangeText callback"
[32]: https://github.com/facebook/react-native/issues/29063#issuecomment-658189938 "Explanation on how TextInput calls SET_TEXT_AND_SELECTION in Java API"
[33]: https://github.com/facebook/react-native/pull/33468#discussion_r835036889 "Explanation of TextInput state management with fabric C++ and JAVA API"
[34]: https://github.com/facebook/react-native/pull/33468#discussion_r835036889 "state updates between fabric and ReactAndroid for the TextInput component"
[35]: https://reactnative.dev/architecture/render-pipeline#react-native-renderer-state-updates "ReactNative renderer state updates"
[35]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1080144483 "Analysis on how AndroidTextInputState.cpp sends updates to ReactTextInputManager"
[36]: https://github.com/facebook/react-native/pull/33468#discussion_r848162849 "discussion on using announceForAccessibility in ReactEditText"
[37]: https://github.com/fabriziobertoglio1987/react-native/commit/29eb632f1cb2ef5459253783eac43e5d7e999742 "Refactor MountingManager into MountingManager + SurfaceMountingManager"
[38]: https://github.com/fabriziobertoglio1987/react-native/commit/733f2285067de401b925195266f4cec84c3f7fef "Diff C++ props for Android consumption"
[39]: https://github.com/fabriziobertoglio1987/react-native/commit/91b3f5d48aa1322046b8c5335f8e2e1a5e702b67 "This diff implement and integrates Mapbuffer into Fabric text measure system"

[40]: https://github.com/facebook/react-native/pull/29070 "[Android] Fix letters duplication when using autoCapitalize https://github.com/facebook/react-native/issues/29070"

[50]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12  "Notes from work on iOS/Android: Text input error for screenreaders https://github.com/facebook/react-native/issues/12"
[51]: https://github.com/facebook/react-native/issues/30848 "iOS/Android: Text input error for screenreaders https://github.com/facebook/react-native/issues/30848"
[52]: https://github.com/facebook/react-native/issues/30859 "Android: Error state change (text inputs) https://github.com/facebook/react-native/issues/30859"

[61]: https://github.com/facebook/react-native/pull/33468/commits/eb33c933c8bcb9a8421a6acdb7a51f261121be45 "fix annoucement delayed to next character"

[70]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1116966512 "iOS - Paper renderer does not update the accessibilityValue"
[71]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1124631221 "Test Cases of the functionality (Fabric) after removing changes to .cpp libs"
[72]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1124892802 "Test Cases of the functionality (Paper) after removing changes to .cpp libs"
[73]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1132830758 "iOS - announcing error onChangeText and screenreader focus"
[74]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1150657065 "iOS - The screenreader announces the TextInput value after the errorMessage is cleared"
[75]: https://github.com/fabriziobertoglio1987/react-native-notes/issues/12#issuecomment-1152285978 "iOS - Exception thrown while executing UI block: - [RCTTextView setOnAccessibiltyAction:]: unrecognized selector sent to instance (Paper) (main branch)"
[76]: https://github.com/facebook/react-native/issues/30859#issuecomment-1158790381 "iOS - announce lastChar (not entire text) onChangeText and avoid multiple announcements (Fabric)"
[77]: https://github.com/facebook/react-native/issues/30859#issuecomment-1158794863 "iOS - announces or does not announce the accessibilityError through Button onPress (not onChangeText) (Fabric)"
[78]: https://github.com/facebook/react-native/issues/30859#issuecomment-1158797801 "iOS - the error is announced with accessibilityInvalid true and does not clear after typing text (onChangeText) (Fabric)"
[79]: https://github.com/facebook/react-native/issues/30848#issuecomment-1162799299 "iOS - Exception thrown while executing UI block: - RCTUITextView setAccessibilityErrorMessage:]: unrecognized selector sent to instance (iOS - Paper on main branch)"

[80]: https://github.com/fabriziobertoglio1987/react-native/commit/e13b9c6e49480e8262df06b7c1e99caab74e801f "RCTTextField was spliited into two classes"
[81]: https://github.com/fabriziobertoglio1987/react-native/commit/ee9697e5155aa972564d5aac90ceeb9db100750d "Introducing RCTBackedTextInputDelegate"
[82]: https://github.com/fabriziobertoglio1987/react-native/commit/2dd2529b3ab3ace39136a6e24c09f80ae421a17e "Add option to hide context menu for TextInput"
[83]: https://github.com/fabriziobertoglio1987/react-native/blob/343eea1e3150cf54d6f7727cd01d13eb7247c7f7/React/Fabric/Mounting/ComponentViews/Text/RCTParagraphComponentAccessibilityProvider.mm#L48-L72 "RCTParagraphComponentAccessibilityProvider accessibilityElements"
[84]: https://github.com/fabriziobertoglio1987/react-native/blob/c8790a114f6f21774c43f0e9b9210e7b35d1c243/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L613 "RCTTextInputComponentView method _setAttributedString"
[85]: https://github.com/fabriziobertoglio1987/react-native/blob/c8790a114f6f21774c43f0e9b9210e7b35d1c243/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm#L146 "RCTTextInputComponentView method updateProps"
[86]: https://github.com/fabriziobertoglio1987/react-native/blob/c8790a114f6f21774c43f0e9b9210e7b35d1c243/Libraries/Text/TextInput/RCTBaseTextInputView.m#L150 "RCTBaseTextInputView setAttributedText"
[87]: https://github.com/facebook/react-native/issues/30859#issuecomment-1165395361 "iOS - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event"
[88]: https://github.com/facebook/react-native/issues/30859#issuecomment-1165398153 "Android - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event"
[89]: https://github.com/facebook/react-native/issues/30859#issuecomment-1165413245 "iOS - accessibilityValue announces correctly with/out errorMessage set with onChangeText or with outside event (Fabric)"

[100]: https://github.com/fabriziobertoglio1987/react-native/commit/110b191b14e3cb692bb6a33f0f129b4f0215f9a6 "Refactor ViewPropsMapBuffer -> general MapBuffer props mechanism"
[101]: https://github.com/fabriziobertoglio1987/react-native/commit/22b6e1c8ec0e69700e9142cf5c9c1ab1e6a84b78 "In this diff I'm shipping and deleting mapBufferSerialization for Text measurement"

Reviewed By: blavalla

Differential Revision: D38410635

Pulled By: lunaleaps

fbshipit-source-id: cd80e9a1be8f5ca017c979d7907974cf72ca4777
2023-02-28 16:05:57 -08:00
Jerry ed39d639ea Fix/animated lists types (#36292)
Summary:
I was working on `Animated.FlatList` and found some types missing as below

![Screen Shot 2023-02-25 at 4 32 43 PM](https://user-images.githubusercontent.com/64301935/221345457-74252131-5207-4e17-ad96-92221a915305.png)

also `Animated.SectionList`

![Screen Shot 2023-02-25 at 4 31 34 PM](https://user-images.githubusercontent.com/64301935/221345679-07ba862b-708e-400e-ac14-7d2156fcc1e8.png)

So I refactored type definition for `Animated.FlatList` and `Animated.SectionList` using `abstract class`.

## Changelog

[GENERAL] [FIXED] - add missing FlatList types for Animated FlatList
[GENERAL] [FIXED] - add missing SectionList types for Animated SectionList

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Test Plan: Ran `yarn test-typescript` and `yarn test-typescript-offline` with no errors.

Reviewed By: lunaleaps

Differential Revision: D43673884

Pulled By: NickGerleman

fbshipit-source-id: 7ccab5997fa2f22226fb0e106672cee98e568ba4
2023-02-28 15:17:21 -08:00
Steve Alves-Blyt 32d03c250c Add missing type objectFit prop in image style type definition (#36249)
Summary:
Following the [`initial commit`](https://github.com/facebook/react-native/commit/b2452ab216e28e004dc625dd8e1ad32351a79be9), the `objectFit` property have been implemented. However, it is not declared in the Typescript type files, making it unknown to the typescript compiler. Thus, when using this property in Typescript, we have the following issue:

![Capture d’écran 2023-02-22 à 14 52 04](https://user-images.githubusercontent.com/29439916/220639885-947dddb1-5e6f-4f60-b423-882ade29ac5a.png)

Then, the purpose of this PR is to fix that by adding the missing property to the `ImageStyle` interface defined in the`StyleSheetTypes.d.ts` file.

## Changelog

[GENERAL][FIXED] Add objectFit to the ImageStyle interface located in the StyleSheetTypes.d.ts file

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

Test Plan:
To test it, create/use a typescript file and call the `Image` component with a `style` property. Then, check if the autocompletion provides you the right properties with the right type. For example:

![Capture d’écran 2023-02-22 à 14 34 58](https://user-images.githubusercontent.com/29439916/220636819-4c0d80dc-bc3a-468d-bcfc-782e038918ca.png)
![Capture d’écran 2023-02-22 à 14 35 46](https://user-images.githubusercontent.com/29439916/220636863-76a84122-0cdb-4d5d-8edf-309ed7c876f7.png)

Reviewed By: NickGerleman, rshest

Differential Revision: D43665291

Pulled By: motiz88

fbshipit-source-id: bf136b8aeb9dd25ff0e696b747ef5805acf8028c
2023-02-28 12:03:08 -08:00
Luna Wei d504fb4145 Revert ESM imports
Summary:
Changelog: [Internal] - Remove all imports back to CJS for changelog in 0.72

We are reverting these imports as it may regress perf as we don't have a recommended inlining solution for ES modules at the current time.

Reviewed By: NickGerleman

Differential Revision: D43630911

fbshipit-source-id: ff3bb80009f327c4d51dad21f2cd287ce46d5964
2023-02-28 10:23:36 -08:00
Birkir Gudjonsson c18566ffdb Appearance.setColorScheme support (revisited) (#36122)
Summary:
Both Android and iOS allow you to set application specific user interface style, which is useful for applications that support both light and dark mode.

With the newly added `Appearance.setColorScheme`, you can natively manage the application's user interface style rather than keeping that preference in JavaScript. The benefit is that native dialogs like alert, keyboard, action sheets and more will also be affected by this change.

Implemented using Android X [AppCompatDelegate.setDefaultNightMode](https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#setDefaultNightMode(int)) and iOS 13+ [overrideUserInterfaceStyle](https://developer.apple.com/documentation/uikit/uiview/3238086-overrideuserinterfacestyle?language=objc)

```tsx
// Lets assume a given device is set to **dark** mode.

Appearance.getColorScheme(); // `dark`

// Set the app's user interface to `light`
Appearance.setColorScheme('light');

Appearance.getColorScheme(); // `light`

// Set the app's user interface to `unspecified`
Appearance.setColorScheme(null);

Appearance.getColorScheme() // `dark`
 ```

## Changelog

[GENERAL] [ADDED] - Added `setColorScheme` to `Appearance` module

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

Test Plan:
Added a RNTester for the feature in the Appearance section.

Three buttons for toggling all set of modes.

Reviewed By: lunaleaps

Differential Revision: D43331405

Pulled By: NickGerleman

fbshipit-source-id: 3b15f1ed0626d1ad7a8266ec026e903cd3ec46aa
2023-02-28 05:28:38 -08:00
Ruslan Shestopalyuk 14ab76ac30 Hoist responsibility for clearMarks/Measures to NativePerformanceObserver (#36312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36312

## Changelog:

[Internal] -

`clearMarks` and `clearMeasures` methods are incidental to the `NativePerformance` TurboModule functionality, as in reality this responsibility belongs more on the `NativePerformanceObserver` and `PerformanceEntryReporter` side.

This is something that [the standard indirectly suggests](https://www.w3.org/TR/user-timing/#clearmarks-method) as well (referencing [performance entry buffer](https://www.w3.org/TR/performance-timeline/#dfn-performance-entry-buffer)).

The new implementation should be also a little bit more efficient, as it avoids calling the predicate for each entry.

Finally (and frankly, the main reason for this change, from my perspective), it will simplify mocking/testing the JS part of the PerfAPI code.

Reviewed By: rubennorte

Differential Revision: D43621174

fbshipit-source-id: c4217a0da1d8ecbce797240627f7b4f057d85b97
2023-02-28 04:10:32 -08:00
Ruslan Shestopalyuk 4fd15c4ae7 Fix various JS linter warnings (#36307)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36307

[Changelog][Internal]

Noticed some JS linter warnings during CircleCI tests being run, this disturbed my OCD, so here's a fix for them.

Reviewed By: cipolleschi

Differential Revision: D43619403

fbshipit-source-id: 779a1d2e197298275d06a2597cfef7554017016f
2023-02-27 07:38:43 -08:00
Nick Gerleman febf6b7f33 Constrain data type in getItemLayout callback (#36237)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36237

This changes the data parameter type for `getItemLayout` from a mutable array (too lenient, even before), to `ArrayLike`, which is now the most constrained subset of data which may be passed to a FlatList.

We could do something more exact by adding another generic parameter to FlatList, but that would be likely be noticeably more breaking, since during testing I couldn't manage a pattern that both kept the same minimum number of generic arguments while keeping inference working.

Changelog:
[General][Breaking] - Constrain data type in `getItemLayout` callback

Reviewed By: javache

Differential Revision: D43466967

fbshipit-source-id: 7a1ce717e7d5cc96a58b8d3ad9def6cf6250871f
2023-02-24 16:19:14 -08:00
Nick Gerleman c03de97fb4 Make FlatList permissive of ArrayLike data (#36236)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36236

D38198351 (https://github.com/facebook/react-native/commit/d574ea3526e713eae2c6e20c7a68fa66ff4ad7d2) addedd a guard to FlatList, to no-op if passed `data` that was not an array. This broke functionality where Realm had documented using `Realm.Results` with FlatList. `Real.Results` is an array-like JSI object, but not actually an array, and fails any `Array.isArray()` checks.

This change loosens the FlatList contract, to explicitly allow array-like non-array entities. The requirement align to Flow `ArrayLike`, which allows both arrays, and objects which provide a length and indexer. Flow `$ArrayLike` currently also requires an iterator, but this is seemingly a mistake in the type definition, and not enforced.

Though `Realm.Results` has all the methods of TS `ReadonlyArray`, RN has generally assumes its array inputs will pass `Array.isArray()`. This includes any array props still being checked [via prop-types](https://github.com/facebook/prop-types/blob/044efd7a108556c7660f6b62092756666e39d74b/factoryWithTypeCheckers.js#L548).

This change intentionally does not yet change the parameter type of `getItemLayout()`, which is already too loose (allowing mutable arrays). Changing this is a breaking change, that would be disruptive to backport, so we separate it into a different commit that will be landed as part of 0.72 (see next diff in the stack).

Changelog:
[General][Changed] - Make FlatList permissive of ArrayLike data

Reviewed By: yungsters

Differential Revision: D43465654

fbshipit-source-id: 3ed8c76c15da680560d7639b7cc43272f3e46ac3
2023-02-24 16:19:14 -08:00
Harshika faba66b4b2 Fix: Remove extra slash in import path in requireNativeComponent.d.ts (#36244)
Summary:
Fixes: https://github.com/facebook/react-native/issues/36206

## Changelog

[GENERAL] [FIXED] - Remove extra slash in import path

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

Test Plan: CI should pass.

Reviewed By: cipolleschi

Differential Revision: D43573391

Pulled By: cortinico

fbshipit-source-id: a17b8ed260e06e3ec848e8246a20091394b0634e
2023-02-24 10:51:32 -08:00
Samuel Susla 4672b5844f Move init of _contextContainer to init function
Summary:
changelog: [internal]

Move initialisation to `init` function. This allows subclasses of `RCTAppDelegate` to use new architecture when overriding `didFinishLaunchingWithOptions`

Reviewed By: cipolleschi

Differential Revision: D43535602

fbshipit-source-id: 32adb5416e67a63ad168f0ed2480287bf178a6a6
2023-02-23 09:04:25 -08:00
Steve Alves-Blyt 74cb6073f3 Missing src, srcSet, referrerPolicy, tintColor on Image.d.ts (#36214)
Summary:
After reviewing the doc [`Image`](https://reactnative.dev/docs/image), the typescript compiler doesn't know the following properties:
- src
- srcSet
- referrerPolicy
- tintColor
- objectFit

But after reviewing the source code and this [`commit`](https://github.com/facebook/react-native/commit/b2452ab216e28e004dc625dd8e1ad32351a79be9), the `objectFit` property isn't one related to the Image component but to the `style` props, making the official doc outdated. So, an [`issue in the react-native-website repo`](https://github.com/facebook/react-native-website/issues/3579) have been created and I decided to not include the objectFit prop in this PR.

So, this PR includes those properties: sec, secSet, referrerPolicy and tintColor

## Changelog

[GENERAL][FIXED] Add src, srcSet, referrerPolicy, tintColor to Image.d.ts declaration file

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

Reviewed By: NickGerleman

Differential Revision: D43437894

Pulled By: rshest

fbshipit-source-id: 497426490134aba0a474c49bf8bab9131f2e5845
2023-02-22 16:14:39 -08:00
Xin Chen a2f155fdf3 Enable TraceUpdateOverlay for android RN apps
Summary:
This diff is a retry of shipping D43180893 (https://github.com/facebook/react-native/commit/89ef5bd6f9064298dfe55b0b18be4a770ee0872c), which got backed out in D43350025 (https://github.com/facebook/react-native/commit/1f151e0d2ff4995d296ad09ed8b96c79d2304387) due to issues in iOS RN apps.

I've exclude iOS apps in this diff. I am planning to have the iOS implementation for the TraceUpdateOverlay native component to fill the gap with lower priority.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D43409501

fbshipit-source-id: fe8bb5654862f0b5e9054a97ae1f4cde573bb3e0
2023-02-22 13:36:05 -08:00
Ruslan Shestopalyuk 407fb5c238 Implement ability to emit device events from C++ TurboModules
Summary:
[Changelog][Internal]

This adds a method, `emitDeviceEvent` to the C++ API of TurboModules, which allows to make calls to JS's `RCTDeviceEventEmitter.emit` from a C++ TurboModules.

This is a very common pattern, specifically for the VR apps, but not only for them - e.g. Desktop fork also has a [custom implementation for this](https://www.internalfb.com/code/fbsource/third-party/microsoft-fork-of-react-native/react-native-utils/RCTEventEmitter.cpp).

Note that my original intent was to actually backport the latter, however there are some complications with wiring things in a robust way, without exposing too much stuff and relying on singletons or folly::dynamic.

So I ended up adding it to the TurboModule API itself and use the scheduler/JSI facilities instead.

This approach is arguably well self-contained, uses high level APIs, and shouldn't be abusable much.

Since I was trying to avoid usage of folly::dynamic in this case, I used a kind of "value factory" pattern instead in order to send the arguments to the JS thread in a thread safe way (see [the discussion here](https://fb.workplace.com/groups/rn.fabric/permalink/1398711453593610/)).

Reviewed By: christophpurrer

Differential Revision: D43466326

fbshipit-source-id: a3cb8359d08a46421559edd0f854772863cb5c39
2023-02-21 15:15:31 -08:00
Riccardo Cipolleschi 3e88fd01ce Install the RuntimeScheduler when the New Architecture is enabled (#36209)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36209

ThisChange automatically enable the RuntimeScheduler when the new architecture is enabled, both on RNester and in the Template app.

Note that no migration steps are required.

## Changelog
[iOS][Changed] - Automatically install the RuntimeScheduler

Reviewed By: sammy-SC

Differential Revision: D43392059

fbshipit-source-id: 609ded9bdc3db13a0d54ff44d0d4687dfc8617a5
2023-02-21 04:17:26 -08:00
Riccardo Cipolleschi e7becb06c1 Update RCTFabric to generate headers in the React folder when using Frameworks
Summary:
By leveraging the `PUBLIC_HEADERS_FOLDER_PATH` build settings of Xcode, we can instruct cocoapods to generate the frameworks Headers in a specific folder, for example the `React` folder.
This allows us to maintain the `#include`/`#import` structure, even if the framework has a different name.
However, we need to update the search paths to take into account this extra folder.

## Changelog:
[iOS][Changed] - Generate RCTFabric framework's headers in the React folder

Reviewed By: sammy-SC, dmytrorykun

Differential Revision: D43425677

fbshipit-source-id: 94a4f3a3c7de86341b3ce3457704e6b8fb9a588e
2023-02-20 11:50:10 -08:00
Riccardo Cipolleschi b1b2b8baaf Update podspecs with the right search paths
Summary:
Update podspecs with the right search paths to include the required framework by every module.

## Changelog:
[iOS][Changed] - Update search paths to support `use_frameworks!` with Fabric

Reviewed By: sammy-SC, dmytrorykun

Differential Revision: D43089372

fbshipit-source-id: 4bbfc4b98bd289d66ce4015429d581856d9c05b3
2023-02-20 11:50:10 -08:00
Riccardo Cipolleschi 36a64dc2bd Move the RCTAppsetuUtils to AppDelegate
Summary:
This change solve a Circular Dependency where
- `React-Core` depends on `ReactCommon` because `RCTAppSetupUtils.h` (in Core) imports the `RCTTurboModuleManager` (from ReactCommon)
- `RCTTurboModuleManager` in `ReactCommon` depends on `React-Core` because it imports several classes from it (e.g. the `RCTBridge` class)

## Changelog:
[iOS][Breaking] - Moved the RCTAppSetupUtils to the AppDelegate library to break a dependency cycle

Reviewed By: sammy-SC, dmytrorykun

Differential Revision: D43089183

fbshipit-source-id: d7fc36a50811962caf7cff77bb45d42b8cdd4575
2023-02-20 11:50:10 -08:00
Riccardo Cipolleschi 5d6f21d744 Make sure not to override user background color (#36215)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36215

When we introduced the RCTAppDelegate library, we prepared some template methods for the user to customise their views.

However, after they customized their view, we were chaing the background color to match the system background. This would actually override the background color they set in their own customisation step.

This change make sure that we set the background color before they apply their customisations. In this way, we set the background color and, if they want, they can change it and that changw would be honoured.

This change also fixes [this issue](https://github.com/facebook/react-native/issues/35937)

## Changelog
[iOS][Fixed] - Honour background color customisation in RCTAppDelegate

Reviewed By: cortinico

Differential Revision: D43435946

fbshipit-source-id: cdbdbd5b07082ae7843a4dab352dd1195c69e036
2023-02-20 07:14:20 -08:00
Ruslan Shestopalyuk 1629b9f0a1 Refactor BUCK file for WebPerformance (use TurboModule plugins) (#36197)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36197

[Changelog][Internal]

This turns NativePerformance* module dependencies into "TurboModule plugins", which allows for more streamlined client integration (as it makes them register automatically once the dependency is there).

Reviewed By: rubennorte

Differential Revision: D43353204

fbshipit-source-id: 01d0089750a4873088dc4aefe34fd48693ee9791
2023-02-17 19:10:41 -08:00
Steve Alves-Blyt bcf493f346 fix: add width, height and crossOrigin props on Image type declaration file (#36196)
Summary:
According this Issue [`https://github.com/facebook/react-native/issues/36182`](https://github.com/facebook/react-native/issues/36182), the typescript compiler doesn't know the `width`, `height` and `crossOrigin` props for the `Image` component although they are taken in account in the code, [docs](https://reactnative.dev/docs/image#crossorigin) and the flow types.

## Changelog

[GENERAL] [FIXED] - Fix missing `height`, `width`, `crossOrigin` props on Typescript Image.d.ts file

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

Reviewed By: christophpurrer

Differential Revision: D43406094

Pulled By: rshest

fbshipit-source-id: 547ed142d7c39c361d195275b79b0885ef829ba1
2023-02-17 18:32:18 -08:00
Pieter Vanderwerff 260aab74ce Deploy presuppressions for v0.200.0 to xplat
Reviewed By: mroch

Differential Revision: D43377746

fbshipit-source-id: 288fe8639420931ccc2f1b50a5f35090a2f023c3
2023-02-17 13:36:03 -08:00
Samuel Susla 1f151e0d2f Back out "Add TraceUpdateOverlay to RN AppContainer"
Summary:
changelog: backout

Original commit changeset: a1530cc6e2a9

Original Phabricator Diff: D43180893 (https://github.com/facebook/react-native/commit/89ef5bd6f9064298dfe55b0b18be4a770ee0872c)

Reviewed By: Andjeliko, javache

Differential Revision: D43350025

fbshipit-source-id: 896057e16c2f466b2ecf2da6b38c56963dc51020
2023-02-16 11:46:36 -08:00
Ruslan Shestopalyuk cf194aebfe Implement durationThreshold option for PerformanceObserver (#36152)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36152

[Changelog][Internal]

By [the W3C standard](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver/observe), `PerformanceObserver.observer` can optionally take a `durationThreshold` option, so that only entries with duration larger than the threshold are reported.

This diff adds support for this on the RN side, as well as unit tests for this feature on the JS side.

NOTE: The standard suggests that default value for this is 104s. I left it at 0 for now, as for the RN use cases t may be to too high (needs discussion).

Reviewed By: rubennorte

Differential Revision: D43154319

fbshipit-source-id: 0f9d435506f48d8e8521e408211347e8391d22fc
2023-02-16 06:21:43 -08:00
Ruslan Shestopalyuk 581357bc9b Implement EventCounts Web Performance API for React Native (#36181)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36181

[Changelog][Internal]

Implements EventCounts API (`Performance.eventCounts`) for Web Performance, according to the W3C standard, see the specs here: https://www.w3.org/TR/event-timing/#eventcounts

The rationale for why we need it is to support some advanced metrics computations, such as a ratio of "slow events" to total event count, per event type.

Reviewed By: rubennorte

Differential Revision: D43285073

fbshipit-source-id: 2c53d04d9a57c1301e37f2a5879072c8d33efbbf
2023-02-16 06:21:43 -08:00
Xin Chen 70fb2dce45 Add performance.memory API
Summary:
This diff adds new performance API `memory`, which is a read-only property that gets the current JS heap size from native side.

Note that the JSI API returns an unordered map with unknown list of memory information, which is different from the [web spec](https://fburl.com/p0vpbt33). We may enforce specific memory info type on the JSI API so that it can be properly translate to the web spec.

- Update the JS spec
- Update Native implementation and return memory information with JSI API `jsi::instrumentation()::getHeapInfo()`
- Add native performance module to catalyst package

Changelog:
[General][Added] - Add performance memory API with native memory Info

Reviewed By: rubennorte

Differential Revision: D43137071

fbshipit-source-id: 319f1a6ba78fce61e665b00849ecf2579094af83
2023-02-15 20:52:48 -08:00
Samuel Susla 8299cdcdea React Native sync for revisions 48b687f...fccf3a9
Summary:
This sync includes the following changes:
- **[86c8c8db7](https://github.com/facebook/react/commit/86c8c8db7 )**: test: Don't retry flushActWork if flushUntilNextPaint threw ([#26121](https://github.com/facebook/react/pull/26121)) //<Sebastian Silbermann>//
- **[64acd3918](https://github.com/facebook/react/commit/64acd3918 )**: remove unguarded getRootNode call ([#26152](https://github.com/facebook/react/pull/26152)) //<Josh Story>//
- **[71cace4d3](https://github.com/facebook/react/commit/71cace4d3 )**: Migrate testRunner from jasmine2 to jest-circus ([#26144](https://github.com/facebook/react/pull/26144)) //<Ming Ye>//
- **[c8510227c](https://github.com/facebook/react/commit/c8510227c )**: Treat displayName as undefined ([#26148](https://github.com/facebook/react/pull/26148)) //<Sebastian Markbåge>//
- **[55542bc73](https://github.com/facebook/react/commit/55542bc73 )**: Update jest printBasicPrototype config ([#26142](https://github.com/facebook/react/pull/26142)) //<Ming Ye>//
- **[6396b6641](https://github.com/facebook/react/commit/6396b6641 )**: Model Float on Hoistables semantics ([#26106](https://github.com/facebook/react/pull/26106)) //<Josh Story>//
- **[ef9f6e77b](https://github.com/facebook/react/commit/ef9f6e77b )**: Enable passing Server References from Server to Client ([#26124](https://github.com/facebook/react/pull/26124)) //<Sebastian Markbåge>//
- **[35698311d](https://github.com/facebook/react/commit/35698311d )**: Update jest escapeString config ([#26140](https://github.com/facebook/react/pull/26140)) //<Ming Ye>//
- **[6ddcbd4f9](https://github.com/facebook/react/commit/6ddcbd4f9 )**: [flow] enable LTI inference mode ([#26104](https://github.com/facebook/react/pull/26104)) //<Jan Kassens>//
- **[53b1f69ba](https://github.com/facebook/react/commit/53b1f69ba )**: Implement unstable_getBoundingClientRect in RN Fabric refs ([#26137](https://github.com/facebook/react/pull/26137)) //<Rubén Norte>//
- **[594093496](https://github.com/facebook/react/commit/594093496 )**: Update to Jest 29 ([#26088](https://github.com/facebook/react/pull/26088)) //<Ming Ye>//
- **[28fcae062](https://github.com/facebook/react/commit/28fcae062 )**: Add support for SVG `transformOrigin` prop ([#26130](https://github.com/facebook/react/pull/26130)) //<Aravind D>//
- **[3ff1540e9](https://github.com/facebook/react/commit/3ff1540e9 )**: Prefer JSX in ReactNoop assertions (to combat out-of-memory test runs) ([#26127](https://github.com/facebook/react/pull/26127)) //<Sebastian Silbermann>//
- **[01a0c4e12](https://github.com/facebook/react/commit/01a0c4e12 )**: Add Edge Server Builds for workerd / edge-light ([#26116](https://github.com/facebook/react/pull/26116)) //<Sebastian Markbåge>//
- **[f0cf832e1](https://github.com/facebook/react/commit/f0cf832e1 )**: Update Flight Fixture to "use client" instead of .client.js ([#26118](https://github.com/facebook/react/pull/26118)) //<Sebastian Markbåge>//
- **[03a216070](https://github.com/facebook/react/commit/03a216070 )**: Rename "dom" fork to "dom-node" and "bun" fork to "dom-bun" ([#26117](https://github.com/facebook/react/pull/26117)) //<Sebastian Markbåge>//
- **[4bf2113a1](https://github.com/facebook/react/commit/4bf2113a1 )**: Revert "Move the Webpack manifest config to one level deeper ([#26083](https://github.com/facebook/react/pull/26083))"  ([#26111](https://github.com/facebook/react/pull/26111)) //<Sebastian Markbåge>//
- **[2ef24145e](https://github.com/facebook/react/commit/2ef24145e )**: [flow] upgrade to 0.199.0 ([#26096](https://github.com/facebook/react/pull/26096)) //<Jan Kassens>//
- **[922dd7ba5](https://github.com/facebook/react/commit/922dd7ba5 )**: Revert the outer module object to an object ([#26093](https://github.com/facebook/react/pull/26093)) //<Sebastian Markbåge>//
- **[9d111ffdf](https://github.com/facebook/react/commit/9d111ffdf )**: Serialize Promises through Flight ([#26086](https://github.com/facebook/react/pull/26086)) //<Sebastian Markbåge>//
- **[0ba4698c7](https://github.com/facebook/react/commit/0ba4698c7 )**: Fix async test in React reconciler ([#26087](https://github.com/facebook/react/pull/26087)) //<Ming Ye>//
- **[8c234c0de](https://github.com/facebook/react/commit/8c234c0de )**: Move the Webpack manifest config to one level deeper ([#26083](https://github.com/facebook/react/pull/26083)) //<Sebastian Markbåge>//
- **[977bccd24](https://github.com/facebook/react/commit/977bccd24 )**: Refactor Flight Encoding ([#26082](https://github.com/facebook/react/pull/26082)) //<Sebastian Markbåge>//
- **[d7bb524ad](https://github.com/facebook/react/commit/d7bb524ad )**: [cleanup] Remove unused package jest-mock-scheduler ([#26084](https://github.com/facebook/react/pull/26084)) //<Ming Ye>//
- **[6b3083266](https://github.com/facebook/react/commit/6b3083266 )**: Upgrade prettier ([#26081](https://github.com/facebook/react/pull/26081)) //<Jan Kassens>//
- **[1f5ce59dd](https://github.com/facebook/react/commit/1f5ce59dd )**: [cleanup] fully roll out warnAboutSpreadingKeyToJSX ([#26080](https://github.com/facebook/react/pull/26080)) //<Jan Kassens>//

Changelog:
[General][Changed] - React Native sync for revisions 48b687f...fccf3a9

jest_e2e[run_all_tests]

Reviewed By: rubennorte

Differential Revision: D43305607

fbshipit-source-id: 8da7567ca2a182f4be27788935c2da30a731f83b
2023-02-15 08:03:07 -08:00
Ruslan Shestopalyuk f76d4dee6f Reference implementation (mock) for NativePerformanceObserver (#36116)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36116

[Changelog][Internal]

Add a minimal/reference JavaScript implementation for NativePerformanceObserver - the purpose is both unit testing (JS and native sides separately) and potentially shimming the part of functionality that is not dependent on native side.

This is both a setup for adding general unit tests for the Performance* APIs, but also to be able to do non-trivial changes on JS side for WebPerformance (such as in (D43154319).

Reviewed By: rubennorte

Differential Revision: D43167392

fbshipit-source-id: 213d9534d810dece1dd464f910e92e08dbf39508
2023-02-15 06:03:12 -08:00
Xin Chen 89ef5bd6f9 Add TraceUpdateOverlay to RN AppContainer
Summary:
This diff adds `TraceUpdateOverlay` native component to RN `AppContainer.js`. This will enable the overlay when the build is in DEV environment and the DevTools global hook exists. It also closed gap between the JS dev mode and native dev support flag, so that the native component will be available when used by JS.

## Update (2/13/2023)
Instead of the original approach where I put a default value to the devsupport manager flag, I did ui manager check from JS and make sure the native component exists before using it. This is cleaner.

## Problem
Since the `AppContainer` is being used by all RN apps, we need to make sure the native component is registered in UI Manager of the RN app when it's used. Currently, the native component lives in the `DebugCorePackage.java`, which is added to the RN app [when the `DevSupportManager` is used](https://fburl.com/code/muqmqbsa). However, there's no way to tell if an app is using dev support manager in JS, hence there are gaps when the JS code uses `TraceUpdateOverlay`, vs when the native code registered the native component. This issue caused test error in [ReactNativePerfTest](https://fburl.com/testinfra/j24wzh46) from the [previous diff](https://fburl.com/diff/bv9ckhm7), and it actually prevents Flipper from running this properly as shown in this video:

https://pxl.cl/2sqKf

The errors shown in Flipper indicates the RN surface from the plugin is also missing `TraceUpdateOverlay` in its UI Manager:

{F869168865}

## Solution
To fix this issue, we should find a way to expose if the app is using dev support manager in JS. Or we should set to use DevSupportManager whenever it's a dev build as claimed in JS. I will try to find some way to achieve either one of this. I am open to suggestions here for where I should add the native component to. Given that it's used in the AppContainer, and any app could be built in development mode, I don't want to make people to manually add this native component themselves.

## Alternatives
There are some other approaches that could mitigate the issue, but less ideal:

For the test issue
1) Add `setUseDeveloperSupport(true)` to [ReactNativeTestRule.java](https://fburl.com/code/7jaoamdp). That will make the related test pass by using the DevSupportPackages, which has the native component. However, it only fixes tests using that class.

2) Override the package for [ReactNativeTestRule.java](https://fburl.com/code/b4em32fa), or `addPackage` with more packages including the native component. Again this only fixes this test.

3) Add the native component to the [`MainReactPackage`](https://fburl.com/code/nlayho86), which is what I did here in this diff. This would fix more cases as this package is [recommended to be used](https://fburl.com/code/53eweuoh) for all RN app. However, it may not fix all the cases if the RN app didn't manually use it.

4) Add the native component in the [`CoreModulesPackage`](https://fburl.com/code/lfeklztl), which will make all RN apps work, but at the cost of increase package size when this feature is not needed. Or, we could argue that we want to have highlights on trace updates for production build as well?

Changelog:
[Internal] - Enable TraceUpdateOverlay to RN AppContainer

Reviewed By: rubennorte

Differential Revision: D43180893

fbshipit-source-id: a1530cc6e2a9d8c905bdfe5d622d85c4712266f8
2023-02-14 22:32:55 -08:00
Xin Chen 6ac88a4378 Add TraceUpdateOverlay native component to render highlights on trace updates
Summary:
This diff adds `TraceUpdateOverlay` native component to render highlights when trace update is detected from React JS. This allows a highlight border to be rendered outside of the component with re-renders.

- Created `TraceUpdateOverlay` native component and added to the `DebugCorePackage`
- Added to C++ registry so it's compatible with Fabric
- Added to `AppContainer` for all RN apps when global devtools hook is available

Changelog:
[Android][Internal] - Add trace update overlay to show re-render highlights

Reviewed By: javache

Differential Revision: D42831719

fbshipit-source-id: 30c2e24859a316c27700270087a0d7779d7ad8ed
2023-02-13 21:55:33 -08:00
Ruslan Shestopalyuk aef7194996 API symmetry when passing PerformanceEntryType to/from native module
Summary:
[Changelog][Internal]

`NativePerformanceObserver` TurboModule API would get the type for performance entries as strings in one direction (`start/stopReporting`) and as integers in another direction (inside `RawPerformanceEntry`, for optimization on the native side).

This makes is symmetrical and consistent, all the conversions are now handled on the JS side.

Reviewed By: christophpurrer

Differential Revision: D43236466

fbshipit-source-id: 08e1b62df90e6d26a11577d6b6b1d91a6bce8339
2023-02-13 10:44:06 -08:00
Adam Gleitman 5308fcc9ea Fix typo in Dynamic Type docs (#36113)
Summary:
When working on Dynamic Type, I accidentally referred to it as "Dynamic Text" in some of the documentation. This is just a minor cleanup bit.

## Changelog

[IOS] [FIXED] - Fix typo in documentation

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

Test Plan: Non-functional change, no testing should be needed :-)

Reviewed By: javache

Differential Revision: D43184999

Pulled By: cortinico

fbshipit-source-id: ed057e48289ae6037637bacecb20b8dd58c1d8b5
2023-02-10 06:05:50 -08:00
Xin Chen 6faddc3870 Fix string key issue with constexpr StrKey in Performance C++ native module
Summary:
I encountered build error when using performance API in catalyst android mobile app. The error message P617433618 points at using non-const `std::strlen` API in a `constexpr`.

```
$ buck install catalyst-android
...
stderr: xplat/js/react-native-github/Libraries/WebPerformance/PerformanceEntryReporter.cpp:208:13: error: constexpr constructor never produces a constant expression [-Winvalid-constexpr]
  constexpr StrKey(const char *s)
            ^
xplat/js/react-native-github/Libraries/WebPerformance/PerformanceEntryReporter.cpp:209:39: note: non-constexpr function 'strlen' cannot be used in a constant expression
      : key(folly::hash::fnv32_buf(s, std::strlen(s))) {}
```

Changelog:
[General][Fixed] - Fixed string key calculation in constexpr from Performance C++ native module.

Reviewed By: javache

Differential Revision: D43136624

fbshipit-source-id: c691671b157b507745c67a505c91f75cf6b878d1
2023-02-09 11:23:11 -08:00
Rubén Norte 673c7617bc Implement DOMRect and DOMRectReadOnly matching Web
Summary:
This adds the `DOMRect` and `DOMRectReadOnly` classes to React Native, mostly following the Web spec.

This is a requirement for `node.getBoundingClientRect()`, which we'll implement in React (in https://github.com/facebook/react/blob/main/packages/react-native-renderer/src/ReactFabricHostConfig.js#L134-L323).

Changelog: [General][Added] - Added Web-compatible `DOMRect` and `DOMRectReadOnly` classes to the global scope.

Reviewed By: ryancat

Differential Revision: D42963222

fbshipit-source-id: bf2ed15bfbfd71822cb6f969f8cc0a67c7834333
2023-02-09 09:36:08 -08:00