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

26965 Коммитов

Автор SHA1 Сообщение Дата
Ruslan Lesiutin dacb1593de RN: add @react-native/tester as a workspace to xplat/js/public (#36531)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36531

Changelog: [Internal]

In order to make `react-native/tester` imports work, adding this package to `xplat/js/public`

Also moving devDependecies from `react-native/tester/package.json` to root package json to avoid checking in dev dependencies in `xplat/js/public/node_modules`

Reviewed By: cortinico

Differential Revision: D44030539

fbshipit-source-id: b06e49869cdad6e511b1675d1063a1ceac56e3e6
2023-03-20 07:05:52 -07:00
Saad Najmi 65e61f3c88 Enable Address and Undefined Behavior Sanitizers (#36443)
Summary:
This change does two things:

1) Moves RNTester on iOS to use an `.xctestplan` to configure its tests. This moves the test configuration out of the `.xcscheme` file, and into a new json file that Xcode likes. It also allows you to run the same tests multiple times with different configurations. This was done by clicking the focused button below.

![image](https://user-images.githubusercontent.com/6722175/224447314-49d460e9-d2d6-4ec9-9767-64c2a1c449c0.png)

Note: this is partially me upstreaming a change from React Native macOS (https://github.com/microsoft/react-native-macos/pull/190/), though at some point our Xcode project got messed up and we were no longer referencing them ��.

2) Enables Address Sanitizer and Udefined Behavior Sanitizer through the xctestplan

This should help catch some extra vulnerabilities should they ever show up while our tests run.

Notably, I did not _also_ add a configuration to run Thread Sanitizer, because tests start failing with that enabled 😅.

## Changelog:

[IOS] [SECURITY] - Enable Address and Undefined Behavior Sanitizers on RNTester

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

Test Plan: CI should pass

Reviewed By: cortinico

Differential Revision: D44213517

Pulled By: cipolleschi

fbshipit-source-id: 0646174c4b416413a563e8178aa2cfca230b5e66
2023-03-20 06:03:51 -07:00
Rubén Norte cd65a324fe Add skeletons for ReadOnlyNode, ReadOnlyElement and ReactNativeElement
Summary:
This just creates the class structure for `ReadOnlyNode`, `ReadOnlyElement` and `ReactNativeElement`, with all methods throwing as unimplemented.

These classes will be gated behind a feature flag, so merging incomplete work is ok.

This doesn't add the future setters that will log warnings / throw errors when used.

See: https://github.com/react-native-community/discussions-and-proposals/pull/607
Changelog: [internal]

Reviewed By: rickhanlonii, yungsters

Differential Revision: D44060539

fbshipit-source-id: e489532fd365d9aa2bb8308847a35eb715d675e7
2023-03-20 06:01:25 -07:00
Rubén Norte a8b5ff8646 Implement basic version of DOMRectList
Summary:
This implements a basic version of DOMRectList that's close to the spec but diverges in some things (e.g.: methods could be called with an instance created through `Object.create`, etc.).

This will be used soon to implement `ReadOnlyelement.getClientRects()` (behind a flag).

See: https://github.com/react-native-community/discussions-and-proposals/pull/607

Changelog: [internal]

Reviewed By: yungsters

Differential Revision: D44060540

fbshipit-source-id: ad29b5c41f2778864e7dd7ece9223dcf73cd5d6c
2023-03-20 06:01:25 -07:00
Rubén Norte c4b84baf00 Implement basic version of NodeList
Summary:
This implements a basic version of NodeList that's close to the spec but diverges in some things (e.g.: methods could be called with an instance created through `Object.create`, etc.).

This will be used soon to implement `ReadOnlyNode.childNodes` (behind a flag).

See: https://github.com/react-native-community/discussions-and-proposals/pull/607

Changelog: [internal]

Reviewed By: yungsters

Differential Revision: D44055911

fbshipit-source-id: 10b435b06ea6f75eaead85f01c2703e05bb3bd37
2023-03-20 06:01:25 -07:00
Rubén Norte e4d83a14f5 Implement basic version of HTMLCollection
Summary:
This implements a basic version of HTMLCollection that's close to the spec but diverges in some things (e.g.: methods could be called with an instance created through `Object.create`, etc.).

This will be used soon to implement `ReadOnlyElement.children` (behind a flag).

See: https://github.com/react-native-community/discussions-and-proposals/pull/607

Changelog: [internal]

Reviewed By: yungsters

Differential Revision: D44055912

fbshipit-source-id: 37bcd7c12916b95a258e6b2e5717a642f478abdf
2023-03-20 06:01:25 -07:00
Rubén Norte 4ad5fe3c21 Define types for missing methods in nativeFabricUIManager
Summary:
These 3 methods are defined in the binding in native, but not in the type definition in JS.

Changelog: [internal]

Reviewed By: yungsters

Differential Revision: D44139730

fbshipit-source-id: 5ce74c61a424ece8091046425b9cd5598f14bbf1
2023-03-20 06:01:25 -07:00
Rob Hogan a0fa3c736e Move Jest preprocessor up to workspace root, remove public metro-react-native-babel-transformer dep (#36523)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36523

`jest/private/preprocessor.js` is only used to run tests on the workspace itself, it's not part of our exported Jest preset and is specifically excluded from publication in the `react-native` package.

Now that we have the monorepo setup, this belongs at the workspace root.

 - `metro-react-native-babel-transformer` moved from RN `dependencies` to root `devDependencies` because it's only used by the preprocessor
 - `jest/create-cache-key-function` added to `devDependencies` - it's also used by the `assetTransformer` in the public preset.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D44197879

fbshipit-source-id: 0bbd9e2f500f53fa4f16562f05374dc601b67df6
2023-03-20 05:44:34 -07:00
Jerry 0c5c07fc9b fix: add missing lineBreakStrategyIOS types for Text, TextInput (#36526)
Summary:
I added missing type `lineBreakStrategyIOS` for Text and TextInput. ([Text docs](https://reactnative.dev/docs/text))

## Changelog

[GENERAL] [FIXED] - add `lineBreakStrategyIOS` prop type for Text and TextInput

<!-- 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/36526

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

Reviewed By: jacdebug

Differential Revision: D44213791

Pulled By: javache

fbshipit-source-id: 8d0d44e2cdd1fa362c54935326e86dde88c5ba0b
2023-03-20 05:16:20 -07:00
Rob Hogan 0eff8d66c9 Support PNPM and workspace setups with pod install (#36485)
Summary:
With Metro symlink support coming soon, users will expect isolated `node_modules` resolution and hoisted `react-native` to work. Currently, we make some fragile assumptions in Ruby scripts about the location of `node_modules` packages - in particular `react-native` and `react-native-community/cli-platform-ios`.

This change invokes `node` to resolve those paths, which should allow these scripts to work in any Node JS-compliant setup.

There's a small (sub-second) performance penalty involved in invoking node, but two of these in the context of `pod install` seems reasonable. Also, these scripts [already invoke `node`](fb78fe8ea2/packages/cli-platform-ios/native_modules.rb (L26)), so this isn't an additional dependency or point of failure.

*This is probably the first Ruby I've written in >10 years, review suggestions welcome!*

Changelog:
[iOS][Added] - Support workspace and isolated setups with `pod install`

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

Test Plan: `pod install` succeeds on a PNPM workspace setup where `react-native-community/cli` was not at the path previously expected by this script.

Reviewed By: cipolleschi

Differential Revision: D44097440

Pulled By: robhogan

fbshipit-source-id: 8300144888d8da019451b3f792b30eabc3a568cf
2023-03-20 03:27:55 -07:00
Ruslan Shestopalyuk b9c64f3651 Bulk detect/correct (most of the) typos and misspells in RN core code
Summary:
## Changelog:
[Internal] -

While merging a Contributor PR in D43816768, I got curious whether such things as detecting/fixing typos could be automated.

There is a tool called [typos](https://github.com/crate-ci/typos), which, as it turns out, works very well on source code files.

The amount of false positives was minimal, most of the suggestions were valid ones.

And the total amount of typos found and fixed was **more than 300**, which is... quite a bit :)

### Methodology

* Run `typos` separately on `ReactCommon`, `Libraries`, `React`, `ReactAndroid` and `scripts` folders inside `packages/react-native`, e.g.:
```
$ typos -w --config ~/tmp/_typos.toml ~/fbsource/xplat/js/react-native-github/packages/react-native/ReactAndroid
```

Contents of the `_typos.toml` config file:
```
[default.extend-words]
collapsable = "collapsable"
NDK = "NDK"
inout = "inout"
```

(yeah, it really didn't like the "collapsable" word, for some reason ;))
* Inspect all the changes manually and revert false positives (as mentioned, their amount was minimal)

Note that most of the changes are inside things like comments and error messages, however there are a few among identifier name fixes (`typos` is actually quite smart at understanding naming conventions in code) - I kept the suggestions in cases that are local and not part of a public API. There are also misspelled file name changes in a couple of cases.

Reviewed By: NickGerleman

Differential Revision: D44172494

fbshipit-source-id: 86e27edbbb99e09135e3cdd5d7cea8ffeb8307f4
2023-03-20 02:05:38 -07:00
Rob Hogan 96789004b6 Fix reference to old `template/package.json` path
Summary:
Nightly builds are broken at the moment - at least in the first instance this looks to be because a reference to `template/package.json` was missed in the monorepo PR. This repairs it.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D44205810

fbshipit-source-id: c810b7a211db7162569a67fca26771fce79d4f9d
2023-03-19 18:06:33 -07:00
Genki Kondo 0ae5e50e37 Support mixed props for components
Summary:
Changelog:
[Changed][General] - Support mixed props for components in codegen

Reviewed By: rickhanlonii

Differential Revision: D43894460

fbshipit-source-id: e5faf2f83e6829170cdce550e923c3c09ddff0b0
2023-03-19 16:47:22 -07:00
Rob Hogan e5b97f0f13 Don't register Babel in Jest preprocessor (#36522)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36522

We don't need to register Babel for internal tests, Jest takes care of hooking require. This resolves an internal require-clobbering issue.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D44197281

fbshipit-source-id: ee076d431b0c49ae4a2da609d964cdd66bca27f8
2023-03-18 13:46:58 -07:00
Intl Scheduler 4a05f680e1 translation auto-update for i18n/anna.config.json on master
Summary:
Chronos Job Instance ID: 1125907824975914
Sandcastle Job Instance ID: 22517999042723056
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D44193886

fbshipit-source-id: 0c093d45a198c9b4db628369520a07bcd3e8b9b9
2023-03-18 00:30:05 -07:00
Intl Scheduler 3116bfd427 translation auto-update for i18n/adsmanager.config.json on master
Summary:
Chronos Job Instance ID: 1125907824975914
Sandcastle Job Instance ID: 22517999042723056
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D44193882

fbshipit-source-id: d07f3fef9e54b2c92a0dde7ce3de9502ce91fda3
2023-03-18 00:30:05 -07:00
Intl Scheduler d4a0f606b1 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907824975914
Sandcastle Job Instance ID: 22517999042723056
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D44193881

fbshipit-source-id: 60ae352367124e6a05b84c24b7c622dd9a7eafd1
2023-03-18 00:30:05 -07:00
Intl Scheduler c19b1673ec translation auto-update for i18n/twilight.config.json on master
Summary:
Chronos Job Instance ID: 1125907824975914
Sandcastle Job Instance ID: 22517999042723056
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D44193891

fbshipit-source-id: 9a57e04fa2c275096bf56470cc9f2e3cbac86a81
2023-03-18 00:30:05 -07:00
Intl Scheduler ccaa3a6091 translation auto-update for i18n/instagram-sandbox.config.json on master
Summary:
Chronos Job Instance ID: 1125907824975914
Sandcastle Job Instance ID: 22517999042723056
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D44193889

fbshipit-source-id: 8e59dcb6237d2d3763650850666aeef8ef16b825
2023-03-18 00:30:05 -07:00
Evan Yeung cd048d4abf Deploy 0.202.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D44155581

fbshipit-source-id: 358df8c40395812216afef1c99f93c576a425b11
2023-03-17 15:46:25 -07:00
Vincent Riemer 728e8a0177 Ensure that pointercancel events have a zeroed location
Summary:
Changelog: [Internal] - Ensure pointercancel events have zeroed location properties

When looking at the pointercancel test the remaining assertion failures were from the expectation that pointercancel events should be reported at [0, 0]. This diff ensures this occurs.

Reviewed By: NickGerleman

Differential Revision: D43886424

fbshipit-source-id: dda37153bd077500599f35db99f114c1a0823120
2023-03-17 15:38:22 -07:00
Vincent Riemer bfee3d9d8d Ensure trailing leave/out events are fired after a cancel event
Summary:
Changelog: [Internal] - Ensure trailing leave/out pointer events are fired after a cancel event

The pointercancel test checks that pointerleave/pointerout events are fired after a pointercancel which preivously wasn't occuring so this added call ensures so.

Reviewed By: NickGerleman

Differential Revision: D43886121

fbshipit-source-id: 9ea801e8f5fcd5855832cfac973bda6ba905998d
2023-03-17 15:38:22 -07:00
Nicola Corti 346de2d16a Compile the GTest suite with CMake (#36477)
Summary:
That's a first step to make sure our C++ tests can effectively run.
Here I'm setting up the pipeline to at least compile those tests and make sure they can be executed on a Android Emulator

Changelog:
[Internal] [Changed] - Setup CMake to run the GTest suite

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

Test Plan: CI needs to be green.

Reviewed By: rshest

Differential Revision: D44066754

Pulled By: cortinico

fbshipit-source-id: f963e0d7d4d9473eada53d7feecfabc21f3c3196
2023-03-17 13:40:57 -07:00
baranga 790df10fa9 Fix check of "reduce motion" setting on android (#36508)
Summary:
On Android `AccessibilityInfo.isReduceMotionEnabled()` returns false even when "Disable Animations" is enabled. This fixes https://github.com/facebook/react-native/issues/31221.

## Changelog

<!-- 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
-->
[ANDROID] [FIXED] - Fix check of "reduce motion" setting on android

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

Test Plan: Have some code logging the value of `AccessibilityInfo.isReduceMotionEnabled()` or using it to change the UI. Run that code on Android without and with "Disable Animations" enabled. See the value is always `false` without the fix, but changes to `true` when  "Disable Animations" is enabled with the fix.

Reviewed By: cortinico, rshest

Differential Revision: D44163583

Pulled By: javache

fbshipit-source-id: ad239454ea68b381e0c7f024df797b3646aeefd7
2023-03-17 11:42:54 -07:00
Nicola Corti b0c30ada21 Fix test_buck by using RuntimeEnvironment.application (#36515)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36515

Buck is using a older version of Robolectric which doens't have
`RuntimeEnvironment.getApplication()`. Reverting to the older
accessor.

Changelog:
[Internal] [Changed] - Fix test_buck by using RuntimeEnvironment.application

Reviewed By: cipolleschi

Differential Revision: D44171240

fbshipit-source-id: d2b49e3b08ffd737bc70ea3e0cb6b291cc36425f
2023-03-17 10:26:34 -07:00
Nicola Corti d904164434 Make robolectric tests run in offline mode (#36510)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36510

This sets up a small offline mirror for Robolectric tests
and allows to run them both on CircleCI and on the internal CI.

allow-large-files

Changelog:
[Internal] [Changed] - Make robolectric tests run in offline mode

Reviewed By: cipolleschi

Differential Revision: D44066692

fbshipit-source-id: 3974d92169ed5c8947f72c953e83a7bf6fadca54
2023-03-17 10:26:34 -07:00
Nicola Corti 5cbabe30d3 Use the default `build` task rather than `buildAll`
Summary:
We can now use the `build` lifecycle task rather than a custom buildAll.
This task will also run linters and other checks on our builds.

Speficially I realized we were missing some permission in the manifest of RN-Tester
which were missed once we bumped to SDK 33.

Changelog:
[Internal] [Changed] - Use the default `build` task rather than `buildAll`

Reviewed By: cipolleschi

Differential Revision: D44055845

fbshipit-source-id: c9adbbeaaaf7ab8a8000fc1dce84ec39427fb26e
2023-03-17 10:26:34 -07:00
Nicola Corti a389373442 Enable JVM Unit Tests for Gradle
Summary:
This makes sure all the tests are executed inside the `ReactAndroid/src/test` folder.
Currently, we're not executing those tests as they're broken. In this diff I took care of:
- Re-enabling them as much as I could
- Ignoring the ones that are ignored also on BUCK

Those tests will have to be entirely re-written as they're using PowerMock which is
unmaintained and not working well with JDK 17+ (that's also why I had to add
the `--illegal-access=permit` and the `--add-opens` directing to allow mocking).

In general, I believe this is a net positive change as it allows us to add new JUnit tests
that are effectively executed, while the current status is ignoring all of them.

Changelog:
[Internal] [Changed] - Enable JVM Unit Tests for Gradle

Reviewed By: cipolleschi

Differential Revision: D41523697

fbshipit-source-id: dc9f2c4c93d0e6b231e8240a583ca31220152d3f
2023-03-17 10:26:34 -07:00
Tim Gates 342c0beafa docs: Fix a few typos (#36372)
Summary:
##Changelog:
[Internal] -

There are small typos in:
- Libraries/Core/setUpTimers.js
- Libraries/LogBox/Data/LogBoxData.js
- Libraries/Pressability/Pressability.js
- Libraries/Renderer/implementations/ReactFabric-dev.js
- Libraries/Renderer/implementations/ReactNativeRenderer-dev.js
- ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h

Fixes:
- Should read `snapshot` rather than `snapsho`.
- Should read `symbolication` rather than `sybolication`.
- Should read `polyfilled` rather than `polyfiled`.
- Should read `instance` rather than `instace`.
- Should read `gesture` rather than `gestute`.

Semi-automated pull request generated by
https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

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

Reviewed By: cortinico, cipolleschi

Differential Revision: D43816768

Pulled By: rshest

fbshipit-source-id: 1346cb3a26748c41d72a3c388d81713ddf2272ed
2023-03-17 09:35:21 -07:00
Ian Jones 3b8459d66b xplat RN: fix flow for useSyncExternalStore
Summary:
They flow type for useSyncExternalStore is incorrect and in consistent with www.

v1.0.0 of use-sync-external-store has the third parameter:
4997515b96/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js (L37)
This revision is 1.0.0:
4997515b96/packages/use-sync-external-store/package.json

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D44163470

fbshipit-source-id: 6582b20ba09f5840b444a1ca3d8fc12d6c783a00
2023-03-17 06:20:15 -07:00
Ruslan Lesiutin 714b502b0c | RN Monorepo | Migrate to package (#36434)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36434

Changelog: [Internal]

This is a squashed stack of 18 commits, starting from D43202126

allow-large-files

Reviewed By: cortinico

Differential Revision: D43977381

fbshipit-source-id: 0da552ddb85f2f61a0be0ef071915b35f3f8555c
2023-03-17 05:03:25 -07:00
Carlos Mesquita 1c1dfab5bc fix(eslint-plugin-specs): removes unnecessary `ENOENT` error check (#36448)
Summary:
```javascript
      // workaround https://github.com/nodejs/node/issues/31481
      // todo: remove the ENOENT error check when we drop node.js 13 support
      case 'ENOENT':
      case 'EACCES':
```

Well, there was a TODO comment asking to remove `ENOENT` error check when react native drop nodejs 13 support since nodejs 14 has fixed the bug that motivated this check. Now react native minimum nodejs version supported is nodejs 14, so this check is not needed anymore.

## Changelog

[Internal] [Fixed] - Removes `ENOENT` error check

<!-- 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/36448

Reviewed By: NickGerleman

Differential Revision: D44025087

Pulled By: cortinico

fbshipit-source-id: f42cb7105a088e2eea207da12d4e63c6d26f3c77
2023-03-17 04:26:36 -07:00
Vincent Riemer 379d9d4918 Refactor PointerEvent emitting into its own gesture recognizer
Summary:
Changelog: [iOS][Internal] - Refactor PointerEvent emitting into its own gesture recognizer

In doing some exploration of a full e2e implementation of the click event I found pretty early on the necessity of addressing the pointerCancel on scroll functionality which, to implement properly without degrading the existing touch gesture handler — involves extracting all the pointer event handling code written so far into its own gesture handler so it can "fail" (when a scroll view wants to take priority) without affecting the existing touch handlers.

This diff is only a refactor and doesn't add/change any new functionality.

allow-large-files

Reviewed By: sammy-SC

Differential Revision: D43372806

fbshipit-source-id: e16f75121fd121d3f82ab43cfc6fab0629654f26
2023-03-16 16:31:36 -07:00
Vincent Riemer b2fda3eca7 Add platform test for pointercancel events caused by touch scrolling
Summary:
Changelog: [Internal] - Add platform test for pointercancel events caused by touch scrolling

This diff adds a new ported Web Platform Test which [verifies that pointercancel events are properly emitted once a touch causes scrolling](https://github.com/web-platform-tests/wpt/blob/master/pointerevents/pointerevent_pointercancel_touch.html).

Reviewed By: lunaleaps

Differential Revision: D43855277

fbshipit-source-id: 94a106058ba2c5e5fe4c1980519ceceddb2bb389
2023-03-16 12:23:25 -07:00
jiggag 93c1fbd2d8 Fix typos (RCTCustomRefreshControlProtocol) (#36363)
Summary:
Fix typo `RCTCustomRefreshContolProtocol` > `RCTCustomRefreshControlProtocol`

## Changelog

[INTERNAL] [FIXED] - Fixed typo RCTCustomRefreshControlProtocol

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

Test Plan: none

Reviewed By: cortinico

Differential Revision: D44024938

Pulled By: cipolleschi

fbshipit-source-id: 1fbc4e75361334586e46e14ee746cbb94d230a92
2023-03-16 09:47:31 -07:00
Pranav Yadav c0a46c696b Merge `defaultExports.forEach(statement => ...` (Flow, TS) to `findNativeComponentType` fn in `parser-commons.js` (#36466)
Summary:
>[Codegen 95] Extract the `defaultExports.forEach(statement =>` (Flow, TS) function in `parser-commons`, so that it accept a Parser parameter to unify the behaviors between flow and typescript. The Parser object needs to be enriched with all the methods to extract the required information from the Node, if they are not there yet.

### Changes

- merged TS & Flow parsers' logic for `defaultExports.forEach(statement =>` of `/components/index.js:findComponentConfig()` into;
- `findNativeComponentType` fn to `parsers-commons.js`
- add `getTypeArgumentParamsFromDeclaration` & `getNativeComponentType` fn's
- add **_tests_** for getTypeArgumentParamsFromDeclaration & `getNativeComponentType` fn's

## Changelog

[INTERNAL] [CHANGED] - Merge `defaultExports.forEach(statement => ...` (Flow, TS) to `findNativeComponentType` fn in `parser-commons.js`

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

Test Plan: - `yarn lint && yarn run flow && yarn jest react-native` ⇒ �

Reviewed By: rshest

Differential Revision: D44088862

Pulled By: cipolleschi

fbshipit-source-id: 91bf0edcd53b2e054160af34d7c128355c178b26
2023-03-16 09:47:31 -07:00
yux-m 94f505ba2b Extract inner switch case 'TSTypereference' to function translateTypeReferenceAnnotation() (#36463)
Summary:
> [Codegen 91] Extract the inner switch in typescript/modules/index.js at line to parse the case TSTypereference ([lines](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L194-L275))into a function translateTypeReferenceAnnotation() (the goal is to try and get a simpler switch statement and to spot structural similiarities between the flow and typescript index.js files)

Part of Issue https://github.com/facebook/react-native/issues/34872

## Changelog

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

Pick one each for the category and type tags:

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

[INTERNAL] [CHANGED] - Extract inner switch case 'TSTypereference' to function translateTypeReferenceAnnotation().

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

Test Plan:
- yarn lint
- yarn run flow
- yarn test react-native-codegen

Reviewed By: cortinico

Differential Revision: D44027755

Pulled By: cipolleschi

fbshipit-source-id: b32d6adc56fcd0e1b42c255b16828b2306941d57
2023-03-16 09:47:31 -07:00
Luna Wei c0abff11b6 Precedent textContentType when set
Summary: Changelog: [iOS][Changed] - Give precedence to `textContentType` property for backwards compat as mentioned in https://github.com/facebook/react-native/issues/36229#issuecomment-1470468374

Reviewed By: necolas

Differential Revision: D44106291

fbshipit-source-id: 5702d7f171735d1abe6cfbc9ca1ad8f21751d51e
2023-03-16 08:26:53 -07:00
Gabriel Tomitsuka dc2cbed07c Improve error messages for invalid function types in react-native-codegen (#36498)
Summary:
The supported `CodegenTypes` aren't provided in the docs, which leads to many issues for developers working to transition native components to support Fabric.
However, explicit error messages are provided in many cases (e.g., to use specific numeric types instead of `number` attributes or to remove nested optionals in arrays).
This isn't the case for the common use case of TypeScript functions, which are very commonly used for event handlers in native components (such as `onChange`), forcing devs to search their way through the `react-native` codebase until they find [this file](681d7f8113/Libraries/Types/CodegenTypes.js (L18)).

By providing an explicit error message, we can significantly improve developer experience for those working to transition libraries/components, leading to higher Fabric adoption.

## Changelog

<!-- 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
-->
[GENERAL] [ADDED] - Create explicit error message for TypeScript functions used as props in Codegen components, redirecting devs to the supported function types `BubblingEventHandler` and `DirectEventHandler`.

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

Test Plan:
* `yarn run lint` shows no errors
* no impact on `yarn && yarn jest react-native-codegen`, which failed 362 tests before and after my changes.

Reviewed By: cipolleschi, sshic

Differential Revision: D44132960

Pulled By: dmytrorykun

fbshipit-source-id: d805ec8403613bf4e070cbd2904ff5a2648ec5fc
2023-03-16 08:17:45 -07:00
Helena Ford 4acef8e4a4 fix: EventEmitter ts definition file (#36462)
Summary:
There's an error in the `d.ts` file for EventEmitter which causes the following error:

```
This expression is not constructable.
  Type 'typeof import(".../vendor/emitter/EventEmitter")' has no construct signatures.
const emitter = new EventEmitter();
                      ~~~~~~~~~~~~
```

See dce9d8d5de/Libraries/vendor/emitter/EventEmitter.js (L63)

## Changelog

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

Pick one each for the category and type tags:

[GENERAL] [FIXED] -Fixes an issue with the EventEmitter type definition file

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

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

Reviewed By: cipolleschi

Differential Revision: D44130846

Pulled By: javache

fbshipit-source-id: 64cecdf55e58b99b243392811226e5095d5dc006
2023-03-16 06:04:51 -07:00
Alex Hunt 681d7f8113 Hotfix for Jest preset changes in 0a3c555 (#36495)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36495

It looks like Jest is not running `babel/transform-modules-commonjs` on all files, and therefore when including `"import"` as a Package Exports condition in Jest, this misbehaved (0a3c55562b).

This is a hotfix to restore CI stability.

Changelog:
[Fix][Internal] Hotfix adjusting Jest changes added in 0a3c55562b

Reviewed By: cipolleschi, hoxyq

Differential Revision: D44130442

fbshipit-source-id: 6407519d0d5459ef422afe21be26a2e3141bedf3
2023-03-16 04:57:16 -07:00
Jerry 419b41f06d fix: fix animated components ref types (#36472)
Summary:
I found Animated components like `View`, `Text`, `ScrollView`, `Image` ref type inferred as `any` when ref callback used.

![Screen Shot 2023-03-14 at 7 32 53 PM](https://user-images.githubusercontent.com/64301935/224975295-21047dab-7bd1-4023-93d4-a6ee5c47f1e5.png)

this is happening because of `unknown` type is included as union type as below.

![Screen Shot 2023-03-14 at 7 33 01 PM](https://user-images.githubusercontent.com/64301935/224975937-6ee49f7e-55f7-4391-a752-c52c5171ec02.png)

So I excluded `unknown` type inferring via fixing `TAugmentRef` utility type.

Result below!

![Screen Shot 2023-03-14 at 7 33 36 PM](https://user-images.githubusercontent.com/64301935/224976685-da66e5ec-3ef0-41dd-9e1f-2bb8bfcdf598.png)

## Changelog

[GENERAL] [FIXED] - fix animated components ref type inferred `any`

<!-- 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/36472

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

Reviewed By: cipolleschi

Differential Revision: D44055510

Pulled By: dmytrorykun

fbshipit-source-id: 0d380a2c2198c84d586889e912dec5d2304c213a
2023-03-16 04:23:15 -07:00
Zihan Chen (MSFT) ac5aec3f5c Add minimum necessary .d.ts files to react-native-codegen (2) (#36397)
Summary:
- Add .d.ts files for generators
- export each generators because `react-native-windows` need its own selection of generators.

## Changelog

[GENERAL] [CHANGED] - Add minimum necessary .d.ts files to react-native-codegen (2)

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

Test Plan:
`npm run build` in `packages/react-native-codegen` and see all .d.ts files appear in `lib`.
Checked .d.ts file in typescript playground.

Reviewed By: rshest

Differential Revision: D43941811

Pulled By: cipolleschi

fbshipit-source-id: 28f5bd56f27531ecf25223620a580358018b779d
2023-03-16 03:32:27 -07:00
Alex Hunt 0a3c55562b Update custom "exports" conditions in Jest environment
Summary:
Updates the default set of `"exports"` condition names in our `ReactNativeEnv` for Jest, so that it aligns with the defaults in React Native CLI (https://github.com/react-native-community/cli/pull/1862).

Also includes a subtle update to how this is accomplished. Instead of overriding `exportConditions()`, we assign to the underlying class property — this allows users (once https://github.com/facebook/jest/pull/13989 is merged) to override `customExportConditions` via [`testEnvironmentOptions`](https://jestjs.io/docs/configuration#testenvironmentoptions-object).

```js
  preset: 'react-native',
  testEnvironmentOptions: {
    customExportConditions: ['test', 'react-native'],
  },
```

Changelog: [Internal]

Reviewed By: jacdebug

Differential Revision: D43879056

fbshipit-source-id: 86fffe2b5fdf9d8492d25b8b12a78be75b5fa3be
2023-03-15 17:18:08 -07:00
David Vacca b1b6673796 Refactor usages of TextLayoutManager.sTextPaintInstance
Summary:
Refactor usages of TextLayoutManager.sTextPaintInstance

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D43888689

fbshipit-source-id: 64a198f3ca07e32666701204d94e6e75b3ab53ad
2023-03-15 16:03:39 -07:00
David Vacca 8c3cb4e6db Refactor TextLayoutManager.isRTL() method
Summary:
Quick refactor of refactor TextLayoutManager.isRTL() method to cleanup the method and remove lint warning

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D43888197

fbshipit-source-id: 779fb84527f95b3c04504eaa4302be55ab328634
2023-03-15 16:03:39 -07:00
Adam Gleitman 9ee0e1c78e Use SocketRocket for web socket library (#36471)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36471

The previous native web socket API, `RCTSRWebSocket`, appears to be an older version of the one provided as part of [SocketRocket](https://github.com/facebookincubator/SocketRocket). The latter has several improvements, such as the ability to respect proxy settings, which has been requested by a user of a React Native app.

Everything translates over pretty easily, and considering that SocketRocket is already a dependency of Flipper, there doesn't seem to be much additional cost to swapping out the libraries. If we wanted to make things even slimmer, it may even be possible to make the WebSocket library be optional for release builds.

## Changelog

[IOS] [CHANGED] - Use SocketRocket for web socket library

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

Test Plan:
Validated the following:
* The WebSocket test page in RNTester
* Live reloading

Reviewed By: cortinico

Differential Revision: D43768835

Pulled By: javache

fbshipit-source-id: 11e1ac2700bc92991897c594622e6687339bfcbf
2023-03-15 13:32:59 -07:00
George Zahariev 7fee407564 Update React Native codegen to support `Partial` as alias of `$Partial`
Summary:
`Partial` is the new name of `$Partial`

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D43993220

fbshipit-source-id: 38e8a6bcfa559857b2ab88efee6b904b387bdc0d
2023-03-15 12:13:36 -07:00
Rubén Norte 06b97ca28e Back out "React Native sync for revisions fccf3a9...47cf4e5"
Summary:
There's some problem in the last sync that changes the memoization behavior in some product code. We'll revert and investigate.

Changelog: [internal]

Reviewed By: bvanderhoof

Differential Revision: D44100907

fbshipit-source-id: 233b478dd6f2f29121ac05323047ab6099b6b56c
2023-03-15 11:38:15 -07:00
Pieter De Baets 01e7ff5513 Fix incorrect hyphenation frequency in TextLayoutManagerMapBuffer
Summary: Changelog: [Android][Fixed] Fixed text measurement issue related to hyphenation frequency

Reviewed By: makovkastar

Differential Revision: D44093758

fbshipit-source-id: 71b7b6cd862586b673a49f5e6efaf9aeeb25c6e1
2023-03-15 11:35:51 -07:00