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

1793 Коммитов

Автор SHA1 Сообщение Дата
Riccardo Cipolleschi 05438c3387 Update Offline mirror and legocastle script
Summary:
This change updates the Offline mirrors so that the `react-native-oss-ios` jobs pass.

It also updates the legocastle script so that it won't check for a specific version of Ruby as right now we decided to support multiple versions.

allow-large-files

## Changelog
[internal] - update iOS mirrors and legocastle

Reviewed By: cortinico, rshest

Differential Revision: D43619512

fbshipit-source-id: dcd95318de72e0dca159da98ead0ef0f375197c1
2023-02-27 04:35:10 -08:00
gabrieldonadel 5ff8895c27 chore: Create Codegen throwIfPartialWithMoreParameter function (#36300)
Summary:
This PR creates a Codegen `throwIfPartialWithMoreParameter` function and extracts the error-emitting code from [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L165-L169) and [Typescript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L246-L250) index files as requested on https://github.com/facebook/react-native/issues/34872. This also adds unit tests to the new function.

## Changelog

[Internal] [Changed]  - Create codegen `throwIfPartialWithMoreParameter` function and extract the `error-emitting` code from Flow and Typescript index files.

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

Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green
![image](https://user-images.githubusercontent.com/11707729/221445922-b2c21ad2-012e-4266-9456-6c781b0de7f0.png)

Reviewed By: cipolleschi

Differential Revision: D43616254

Pulled By: rshest

fbshipit-source-id: 4742aec56598be6bac895809b96d0879c37fcfe1
2023-02-27 03:24:55 -08:00
Tarun Chauhan 371e263847 create throwIfPartialNotAnnotatingTypeParameter and add extractAnnotatedElement method in parsers (#36272)
Summary:
> Create a throwIfPartialNotAnnotatingTypeParameter function in the error-utils.js file and extract the error-emitting code from [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L174-L178) and [Typescript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L252-L259) index files. Notice that the way in which the annotatedElement is computed is different, therefore we should add an extractAnnotatedElement function to the Flow and TypeScript parsers.

Part of the Codegen ☂️ 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:

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

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - create throwIfPartialNotAnnotatingTypeParameter and add extractAnnotatedElement method in parsers

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

Test Plan: `yarn jest react-native-codegen`

Reviewed By: cipolleschi

Differential Revision: D43564134

Pulled By: rshest

fbshipit-source-id: 89a6567340a560d7b6c353cfff8a43e2dd0f76cc
2023-02-24 08:00:20 -08:00
Ruslan Shestopalyuk e106a62b1a Add device event emit test for the sample C++ TurboModule (#36278)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36278

[Changelog][Internal]

The diff creates a test clause for [TurboModule::emitDeviceEvent C++ API for TurboModules](https://www.internalfb.com/code/fbsource/[929870c905c8fe68cb330ce96bda7eb703bb6ae6]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h?lines=90), which can be seen in either Catalyst or RNTester.

Reviewed By: cipolleschi

Differential Revision: D43466327

fbshipit-source-id: ff4c111b4beaab72b13d2bd89ed03023c9c7b3cf
2023-02-24 06:49:14 -08:00
Riccardo Cipolleschi bf03e86bc7 Use RNTester init also in the old arch when Fabric is enabled (#36283)
Summary:
This PR fixes the initialization path of RNTester when it is run with the Old Arch and Fabric enabled

## Changelog

[iOS][Fixed] - Make sure to initialize the contextContainer in the Old Arch with Fabric enabled

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

Test Plan:
Tested manually on RNTester
CircleCI is green

Reviewed By: sammy-SC

Differential Revision: D43568205

Pulled By: cipolleschi

fbshipit-source-id: cddba97629b542a044191da14221f3300a9d879f
2023-02-24 05:21:11 -08:00
Riccardo Cipolleschi a7f962c469 Update offline mirrors
Summary:
Update offline mirrors for iOS

allow-large-files

## Changelog: [internal]

Reviewed By: cortinico

Differential Revision: D43567454

fbshipit-source-id: 7711e6062d960d05d1ecd9fe77b3b4c1ea5f3070
2023-02-24 03:50:05 -08:00
Pranav Yadav 13628203ab Merge `Flow` and `TS` Parsers' `IncorrectModuleRegistryCallArgumentTypeParserError` error-emitting code (#36252)
Summary:
> [Codegen 83 - assigned to Pranav-yadav] Create a function throwIfIncorrectModuleRegistryCallArgumnent function in the errors.js file and factor together the code from [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L407-L415) and [TypeScript](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L513-L521). Update the Parsers to return the right Literl type

Merged `Flow` and `TS` Parsers' `IncorrectModuleRegistryCallArgumentTypeParserError` error-emitting code

- into `throwIfIncorrectModuleRegistryCallArgument` fun in `error-utils.js`

## Changelog

[INTERNAL] [CHANGED] -  Merge `Flow` and `TS` Parsers' `IncorrectModuleRegistryCallArgumentTypeParserError` error-emitting code

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

Test Plan: - `yarn test`

Reviewed By: rshest

Differential Revision: D43502843

Pulled By: cipolleschi

fbshipit-source-id: eb63b40d433f90134a80c02c8f750257c82104a3
2023-02-24 02:56:34 -08:00
Kyaw Thura 85245af880 Move isModuleInterface function (Flow, TypeScript) to the Flow and TypeScript parsers. (#36268)
Summary:
Task from https://github.com/facebook/react-native/issues/34872

> [Codegen 82] Move isModuleInterface function (Flow, TypeScript) to the Flow and TypeScript parsers.

## Changelog

[INTERNAL] [CHANGED] - Moved isModuleInterface function to to the Flow and TypeScript parsers.

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

Test Plan: ` yarn test react-native-codegen`

Reviewed By: christophpurrer

Differential Revision: D43535948

Pulled By: rshest

fbshipit-source-id: 7a2db05008783499168b0ce3fa58fedbac2b4e79
2023-02-23 13:20:05 -08:00
Xin Chen d528fe28a6 Add performance.memory API example to RNTester
Summary:
Add performance API example to RN tester, start with the `performance.memory` API.

- Update `RNTesterList` file for both android and ios

Changelog:
[General][Internal] - Add `performance.memory` API example to RNTester

Reviewed By: rshest

Differential Revision: D43326565

fbshipit-source-id: adeb18ce9f1f90d9e9ecf66b533307028bc02df8
2023-02-23 09:14:10 -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
Mitch Powell 96b2ca4412 Opt out RNTesterIntegrationTests from Buck2 runs
Summary:
Opts `fbsource//xplat/js/react-native-github/packages/rn-tester:RNTesterIntegrationTests` out of Buck2 runs as the target fails in the analysis stage due to some flavor issues.

I did experiment with just resolving the flavor issues but several more nontrivial issues show up in the build graph the deeper you go and I think this target is going to require a bit more of a deep dive, so just disabling it to unblock buck2 CI rollout for now.

Reviewed By: bujar

Differential Revision: D43505883

fbshipit-source-id: 672dc6aea345a8c0396f6a0e3d549016fe1f7c45
2023-02-22 14:48:24 -08:00
Riccardo Cipolleschi 8cc733b732 Update generator plugin for internal component
Summary:
When developing the changes to support `use_frameworks!`, I may have forgotten to update the script that generate the `FabricComponentProvider` for the open source (and I may have changed directly that file manually to make everything work).

This change restore the generator, using the right `#import statement`

allow-large-files

## Changelog
[internal] - Update  plugin generator

Reviewed By: arushikesarwani94

Differential Revision: D43504184

fbshipit-source-id: a89455b62115f6dc2054f804241fd3834056f1b3
2023-02-22 13:01:53 -08:00
Nicola Corti 2f81bb88a4 Gradle 8.x prep - specify task dependency between mergeNativeLibs and external native builds (#36253)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36253

Another build warning that got converted into a failure in Gradle 8.x
Specifically here as we're running 4 native builds in parallel for RN Tester, but they all originate
from 2 CMake intermediates files (one set for Debug and one for Release), Gradle raises a warning.

Here I'm fixing this warning by specifying an explicit ordering between those tasks.

Changelog:
[Internal] [Changed] - Gradle 8.x prep - specify task dependency between mergeNativeLibs and external native builds

Reviewed By: cipolleschi

Differential Revision: D43501128

fbshipit-source-id: bb40ae902157ce97683f42124ec65f2bc0d73405
2023-02-22 10:06:05 -08:00
Nicola Corti 323d8b1432 RNGP - GenerateCodegenSchemaTask should exclude all of `**/build/[generated|intermediate]**`
Summary:
I'm widening the exclude for GenerateCodegenSchemaTask input files.

This is needed before we can migrate to Gradle 8.x as one of the build warning we have is
now converted to a build failure.

The reason why this is needed is because GenerateCodegenSchemaTask ends up picking up a file that
gets generated by `react-native bundle`. While the file is ignored by the Codegen, Gradle
detects a clash between the two tasks.

This solves the issue completely.

Changelog:
[Internal] [Changed] - RNGP - GenerateCodegenSchemaTask should exclude all of `**/build/[generated|intermediate]**`

Reviewed By: cipolleschi

Differential Revision: D43501129

fbshipit-source-id: 49311b833d6b59d4e67e87c535a424a1db1321e6
2023-02-22 10:06:05 -08:00
Saad Najmi 62faa797dd Remove more tvos remnants (#36240)
Summary:
I noticed this stale directory and snapshot tests for RN-Tester. We might as well just remove them.

## Changelog

[INTERNAL] [REMOVED] - Remove more tvos remnants

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

Test Plan: CI should pass.

Reviewed By: cipolleschi

Differential Revision: D43495264

Pulled By: cortinico

fbshipit-source-id: 7286cf6805e12249db5d71bcaa9a91bc947102ca
2023-02-22 08:49:37 -08:00
Nicola Corti 270584ac79 Kotlin to 1.7.22 for Gradle (#36227)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36227

This is needed for the next Gradle major (8.x) and re-aligns us with the
Kotlin version in fbsource

Changelog:
[Android] [Changed] - Kotlin to 1.7.22 for Gradle

allow-large-files

Reviewed By: rybalkinsd

Differential Revision: D43445999

fbshipit-source-id: 85be1bbb4b5ac1664b5090688b688a4e50c3d80a
2023-02-22 07:13:47 -08:00
Nick Gerleman 817948e0aa Add "Text Styles" TextInput Example
Summary:
This adds a series of examples for TextInput styles to screenshot test, specifically the ones which are projected to Android as spans. This will be used in refactoring to verify we do not change visual output.

Changelog:
[Internal][Added] - Add "Text Styles" TextInput Example

Reviewed By: cortinico

Differential Revision: D43158004

fbshipit-source-id: adaecf0e37941e66e280db282e2631a95b08b27a
2023-02-21 15:03:14 -08:00
Riccardo Cipolleschi dba8cb71bd Bump Flipper to 0.182.0
Summary:
This change bumps Flipper to 0.182.0, mirroring the [Android Commit](8fae37eaea)

allow-large-files

## Changelog:
[iOS][Changed] - Bump Flipper to 0.182.0

Reviewed By: dmytrorykun

Differential Revision: D43454236

fbshipit-source-id: c852520d1e7f3a386a2fac11318a9fb6e868b520
2023-02-21 09:46:02 -08:00
Nicola Corti 39e1a3c3a6 RNGP - Fix RNTester crashing for JSC and safeguard against fetching JSC from Maven Central (#36232)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36232

Seems like RN Tester is crashing for JSC debug/release.

This happens because RN Tester ends up fetching JSC from Maven Central which contains older versions
of the artifacts (r17) which are not compatible with our setup AND are missing `libjsc.so`.

This is happening as our file layout is a bit different than a regular NPM project so
the repository declaration for JSC, being `../jsc-android/dist` from React Native root ends
in the wrong folder.

In this specifically I:
- Add an excludeModule for "org.webkit:android-jsc" on Maven Central inside RNGP
- Remove the allproject{repositories{}} block which was overriding RNGP configuration
- Add a specific repository declaration inside RN Tester to point to where JSC effectively lives

Changelog:
[Internal] [Changed] - RNGP - Fix RNTester crashing for JSC and safeguard against fetching JSC from Maven Central

Reviewed By: sshic

Differential Revision: D43462015

fbshipit-source-id: db830d7567bbf7dd91412df417418aa61a0ca8fe
2023-02-21 09:22:09 -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
Tarun Chauhan 8be9dbfcc1 consolidate parsers component schema to common root (#36219)
Summary:
> [Codegen 85] The parses/flow/components/schema.js and parses/typescript/components/schema.js are the same. Move the schema.js from the one of the two folders to the parsers common root. Delete the other. Update the references to use the shared file.

Part of the Codegen ☂️ 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:

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

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Consolidated the schema.js files for parses/flow/components and parses/typescript/components to a common root.

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

Test Plan: Run ```yarn jest react-native-codegen```

Reviewed By: christophpurrer

Differential Revision: D43444666

Pulled By: cipolleschi

fbshipit-source-id: 24d791fd3a8110730d3f6054497ea3a31549a5a5
2023-02-21 03:46:38 -08:00
Nicola Corti 8fae37eaea Flipper to 0.182.0 (#36221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36221

As the title says.

allow-large-files

Changelog:
[Android] [Changed] - Flipper to 0.182.0

Reviewed By: lblasa

Differential Revision: D43444516

fbshipit-source-id: 33c2cd4bdf98dc3f7037774003bfdfde2123d8cd
2023-02-21 00:30:16 -08:00
Riccardo Cipolleschi 5d175c6775 Break Circular Dependency between React-Codegen and React-Fabric (#36210)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36210

One of the circular dependencies we have in OSS was between React-Codegen and React-Fabric.

React-Codegen generates component which has to depends on React-Fabric because they need to use the files contained in the `react/renderer/view` folder.

React-Fabric contains some components that depends on RNCore, which was generated inside the React-Codegen folder.

This change generates the RNCore components inside the `ReactCommon/react/renderer/components/rncore` folder, breaking the dependency as `rncore` folder is now contained by React-Fabric itself.

**Fun Fact:** That's how it always should have been. There was already a line in the `.gitignore` to exclude the content of `ReactCommon/react/renderer/components/rncore` folder. I guess that with some of the refactoring/previous projects on Codegen, this requirements has slipped.

## Changelog:
[iOS][Breaking] -  generates RNCore components inside the ReactCommon folder and create a new pod for platform-specific ImageManager classes

Reviewed By: sammy-SC, dmytrorykun

Differential Revision: D43304641

fbshipit-source-id: ebb5033ce73dbcd03f880c3e204511fdce04b816
2023-02-20 11:50:10 -08:00
Nicola Corti 1cb46ea6c1 bump package versions (#36218)
Summary:
Bumping RNGP as build from source on nightlies is broken

## Changelog

[INTERNAL] - bump package versions

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

Test Plan: n/a

Reviewed By: hoxyq

Differential Revision: D43438374

Pulled By: cortinico

fbshipit-source-id: 871b56eaba5bc35286882e459136703778dea514
2023-02-20 09:53:56 -08:00
Nicola Corti f8d8764e8f RNGP - Fix defaults for PrivateReactExtension
Summary:
When building from source, the PrivateReactExtension is getting no defaults (or missing defaults).
Specifically root should point to ../../ (as the build from source will originate
from `./node_modules/react-native`).

Without that root specified, all the subsequent paths are broken,
specifically, the default being `../` causes the codegen to be searched inside:
```
project/node_modules/node_modules/react-native/codegen
```
which is broken

Changelog:
[Internal] [Changed] - RNGP - Fix defaults for PrivateReactExtension

Reviewed By: cipolleschi

Differential Revision: D43435590

fbshipit-source-id: 2ed5e26c1d63fd808fc2d559ea83d6d39d106ff6
2023-02-20 05:52:20 -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
Nicola Corti 6dde1dc7cb RNGP - ENTRY_FILE should resolve relative paths from root (#36193)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36193

Fixes #36186

Changelog:
[Android] [Fixed] - ENTRY_FILE should resolve relative paths from root

Reviewed By: cipolleschi

Differential Revision: D43392121

fbshipit-source-id: ddf302d333c5fc5f822e0635a73e5b52470140ee
2023-02-17 07:40:09 -08:00
Nicola Corti e42dd1593d bump package versions (#36184)
Summary:
We do have a lot of changes on `main` to ship to nightlies. This change bump all the packages with pending changes.

## Changelog

[INTERNAL] [CHANGED] - [ci][monorepo] bump package versions

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

Test Plan: Will rely on CI run.

Reviewed By: hoxyq

Differential Revision: D43363981

Pulled By: cortinico

fbshipit-source-id: eba5152dbe007eb3fad43f9088d145b3741fd94e
2023-02-17 06:19:37 -08:00
Moti Zilberman 21a0fb597a Add invalid props example to RNTester (#36162)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36162

Changelog: [Internal]

Adds a dedicated screen to RNTester to help manually test the handling of various invalid prop values.

Reviewed By: huntie

Differential Revision: D43270626

fbshipit-source-id: 3fbf452955b2caace7a09fbb9c83960703fd974f
2023-02-17 05:43:24 -08:00
Ana Margarida Silva 1d51032278 fix: border rendering problem in Android (#36129)
Summary:
Fixes https://github.com/facebook/react-native/issues/36036

The problem was in `ReactViewBackgroundDrawable.java` that was not accounting for adjacent borders that add width set to 0.

## Changelog

[Android] [Fixed] - Fix border rendering issue when bottom borders has no width

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

Test Plan:
| Previously | Now with the fix  |
| --------------- | --------------- |
| <img width="417" alt="image" src="https://user-images.githubusercontent.com/25725586/218149384-00e2145c-3c84-4590-87be-3258574489e5.png"> | <img width="414" alt="image" src="https://user-images.githubusercontent.com/25725586/218148215-a8d37158-0feb-47ae-874b-cba2f422d792.png">  |

Reviewed By: cipolleschi

Differential Revision: D43303228

Pulled By: javache

fbshipit-source-id: cf9d30fe12a5740d9ee8974a66904fd0850e7606
2023-02-16 08:09:22 -08:00
Moti Zilberman d16c1a04d8 Reduce use of assertions in prop parsing (#36164)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36164

Changelog:
[General][Fixed] - Invalid prop values no longer trigger assertion failures in Fabric

## Context

Fabric has historically been very strict about prop parsing. It originally `abort()`ed on any prop value that failed to parse according to the expected type; this was replaced with dev-only assertions in D27540903 (cb37562f83). We've received feedback that C++ assertions (and other similar mechanisms in the legacy renderer) are still too aggressive and disruptive as a diagnostic for developers working on JS code.

We are changing React Native to behave more like a browser in this regard, reflecting a new principle that **bad style values are not runtime errors**. (See e.g. D43159284 (d6e9891577).) The recommended way for developers to ensure they are passing correct style values is to use a typechecker (TypeScript or Flow) in conjunction with E2E tests and manual spot checks.

More broadly, values passed from JS product code should not be able to crash the app, which is why we're not strictly limiting this change to style props. From now on, if a JS developer can trigger an internal assertion in React Native simply by writing normal application code, that is a bug.

## This diff

This diff introduces a new macro called `react_native_expect` which serves as a drop-in replacement for `react_native_assert`, but logs (to glog / logcat / stdout) instead of asserting. This way we don't need to fully delete the existing call sites. This will be helpful if we decide that we want to repurpose these checks for a new, more visible diagnostic.

I'm *intentionally* opting for the simplest possible improvement here, which is to silence the assertions - not to print them to the JS console, not to convert them to LogBox warnings, etc. The hypothesis is that this is already strictly an improvement over the previous behaviour, will help us get to feature parity between renderers faster, and allow us to design improved diagnostics that are consistent and helpful.

## Next steps

1. There are still places where Fabric can hit an unguarded assertion in prop conversion code (e.g. unchecked casts from `RawValue` with no fallback code path). I will fix those in a separate diff.
2. Paper on iOS needs a similar treatment as it calls `RCTLogError` liberally during prop parsing (resulting in a native redbox experience that is nearly as bad as an outright crash). I will fix that in a separate diff.
3. I'll add some manual test cases to RNTester to cover these scenarios.
4. We will eventually need to take a clear stance on PropTypes, but since they provide reasonable, non-breaking diagnostics (recoverable JS LogBox + component stack) it is less urgent to do so.

Reviewed By: sammy-SC

Differential Revision: D43184380

fbshipit-source-id: 0c921efef297d935a2ae5acc57ff23171356014b
2023-02-15 15:40:24 -08:00
Ruslan Shestopalyuk 96fb708d3e Make enums to work as part of data structures for C++ TurboModules codegen (#36155)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36155

[Changelog][Internal]

The PR  https://github.com/facebook/react-native/pull/36030 (diff D42884147 (ceb1d0dea6)) added support for enum types in JS to C++ bridging in C++ TurboModules.

This only worked for enums as argument types for exposed methods, but not for the cases when enums are members of complex data structures that are also exposed through a codegen.

This diff fixes this problem, so that codegen now correctly works both with enum types as method arguments, but also as data structure members.

Some part of the change is the same as D42008724 (963e45afd1), but there are also some changes related to the types, that were required.

Reviewed By: christophpurrer

Differential Revision: D43292254

fbshipit-source-id: b2d6cf4a2d4d233b8cc403ecd02b5be16d5d91a7
2023-02-15 06:03:12 -08:00
Riccardo Cipolleschi 13271d3c80 Align OfflineMirrors
Summary:
Align offline mirrors after changes

allow-large-files

## Changelog
[internal] - Align offline mirrors

Reviewed By: cortinico

Differential Revision: D43302165

fbshipit-source-id: d4903d03a54f938ca78d295b4d7c9bca213721cb
2023-02-15 04:17:06 -08:00
Ruslan Lesiutin 31ac1f8aec fix[virtualized-lists]: do not ship tests in npm package (#36143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36143

Changelog: [Internal]

Currently, some `__tests__` are included in `react-native/virtualized-lists`, added them to ignore list, so that we will remove it in the next publish

Reviewed By: christophpurrer

Differential Revision: D43159337

fbshipit-source-id: 27ed0adf85387a2e8ac902da57888f0b188b0b91
2023-02-14 04:12:39 -08:00
Vitali Zaidman ceb1d0dea6 Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators (#36030)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36030

Generate enum types in c++ turbo modules.

For enums in the ts schema file such as:
```
export enum NumEnum {
  ONE = 1,
  TWO = 2,
}
```
This would export enums and the relevant Bridging to js and from js code to the spec H files such as:
```
#pragma mark - SampleTurboModuleCxxNumEnum

enum SampleTurboModuleCxxNumEnum { ONE, TWO };

template <>
struct Bridging<SampleTurboModuleCxxNumEnum> {
  static SampleTurboModuleCxxNumEnum fromJs(jsi::Runtime &rt, int32_t value) {

    if (value == 1) {
      return SampleTurboModuleCxxNumEnum::ONE;
    } else if (value == 2) {
      return SampleTurboModuleCxxNumEnum::TWO;
    } else {
      throw jsi::JSError(rt, "No appropriate enum member found for value");
    }
  }

  static jsi::Value toJs(jsi::Runtime &rt, SampleTurboModuleCxxNumEnum value) {
    if (value == SampleTurboModuleCxxNumEnum::ONE) {
      return bridging::toJs(rt, 1);
    } else if (value == SampleTurboModuleCxxNumEnum::TWO) {
      return bridging::toJs(rt, 2);
    } else {
      throw jsi::JSError(rt, "No appropriate enum member found for enum value");
    }
  }
};

```
That code would allow us to use these enums in the cxx files like this:
```
  NativeCxxModuleExampleCxxEnumInt getNumEnum(
      jsi::Runtime &rt,
      NativeCxxModuleExampleCxxEnumInt arg);
```

Changelog: [General] [Added] Generate enum types that would be allowed to be used as well as string/number in c++ turbo modules generators

Reviewed By: christophpurrer

Differential Revision: D42884147

fbshipit-source-id: d34d1fc7ba268b570821dc108444196f69a431b2
2023-02-13 15:09:44 -08:00
Zihan Chen (MSFT) be3845adec Add minimum necessary .d.ts files to react-native-codegen (#36102)
Summary:
Add minimum necessary .d.ts files to react-native-codegen.

I found .d.ts files will be copied to `lib` so I guess no additional script is needed.

## Changelog

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

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

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

Reviewed By: cortinico

Differential Revision: D43157233

Pulled By: cipolleschi

fbshipit-source-id: 6f122f0f4cda693ba22af6dd534e9d34d069ecac
2023-02-13 04:10:20 -08:00
Nicola Corti 0487108461 RNGP - Monorepo: Make sure libraries are honoring codegenDir provided by app (#36128)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36128

This commit fixes a problem which is making harder to use the New Architecture in monorepos.
Specifically if a user specifies a `codegenDir` in their app, libraries should honor it.
This is not the case today.

The fix is to register an extension on the root project which will "pass" values from app
to libraries.

I've also cleaned up some of the logic in `readPackageJsonFile` function restricting
the access to those functions only to `.root` which is the only field they're accessing.

Fixes #35495

Changelog:
[Android] [Fixed] - Better Monorepo support for New Architecture

Reviewed By: cipolleschi

Differential Revision: D43186767

fbshipit-source-id: 5c5ca39397306120b6b6622cb728633bd331e021
2023-02-10 10:04:55 -08:00
Nicola Corti 96df8c0ac8 Remove unused variable in a test in RNGP
Summary:
Changelog:
[Internal] [Changed] - Remove unused variable in a test in RNGP

Created from CodeHub with https://fburl.com/edit-in-codehub

Reviewed By: cipolleschi

Differential Revision: D43185910

fbshipit-source-id: b1f328592e0b38654fd2e0a36304ce8f1d433b44
2023-02-10 06:57:54 -08:00
Skander Ellouze ba7f9b40a6 fix a typo in the initialNumToRenderOrDefault description's comment (#36110)
Summary:
Fix typo in the initialNumToRenderOrDefault description's comment : function's parameter should be this.props.initialNumToRender instead of this.props.initialNumToRenderOrDefault

## Changelog
[GENERAL] [FIXED] - Fixed typo in the initialNumToRenderOrDefault description's comment

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

Test Plan: Typo in a comment - no testing required

Reviewed By: christophpurrer

Differential Revision: D43160548

Pulled By: cortinico

fbshipit-source-id: 0555c7752102f431fb327b920434faaf4de4ff81
2023-02-10 02:10:55 -08:00
Nicola Corti 81e7f2fe91 Hardcode concurrentRootEnabled to true when Fabric is enabled (#36107)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36107

Having concurrentRoot disabled when Fabric is enabled is not recommended.
This simplifies the setup and makes sure that both are either enabled or disabled.

Changelog:
[Android] [Breaking] - Hardcode concurrentRootEnabled to true when Fabric is enabled

Reviewed By: cipolleschi

Differential Revision: D43127625

fbshipit-source-id: 88e5e800b55d5df228fb072bedf8533b0ab6c20d
2023-02-10 01:06:17 -08:00
Moti Zilberman d6e9891577 Reduce log level of "unrecognized font family" from Error to Info
Summary:
Changelog:
[iOS][Fixed] - Unrecognized fontFamily values no longer trigger a redbox

## Context

We are starting to roll out a new consistent approach to style errors in React Native, where malformed or semantically invalid style values will never be treated as runtime errors. Instead, bad style values will consistently fall back to known defaults; the incorrect visual rendering will serve as the main runtime diagnostic for developers. We will advise developers to rely on static types for additional diagnostics.

This work will take place over multiple commits and possibly multiple releases of React Native.

## This diff

Here we fix this issue as it applies to the `fontFamily` style prop. The legacy (Paper) renderer on iOS is the only concrete implementation that had to change. Fabric and Android already implement the correct behaviour.

h/t EvanBacon for the report: https://twitter.com/Baconbrix/status/1623039650775371792

Reviewed By: huntie

Differential Revision: D43159284

fbshipit-source-id: 6afeef3abc5781e18671708f642073d25f2347e9
2023-02-09 10:57:50 -08:00
Christoph Purrer 7c82a3fa11 Add enum example to Android/iOS rn-tester TurboModule (#35133)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35133

Add enum example to Android/iOS rn-tester TurboModule

Changelog:
[General][Added] - Add enum example to Android/iOS rn-tester TurboModule

Reviewed By: javache, cipolleschi

Differential Revision: D40711269

fbshipit-source-id: c8ad6fb7dee40b45b696660cc4d78921edafd8a1
2023-02-08 22:49:30 -08:00
Christoph Purrer 292a9904c4 react-native code-gen > C++ TurboModules enum example (#36083)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36083

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D43036612

fbshipit-source-id: fc70650bc4ba48d11f489556d1290ae9e7e58016
2023-02-08 20:24:28 -08:00
Nick Gerleman cab865be79 Fix VirtualizedList usage of potentially stale state on cell focus
Summary:
State updates can be batched together idependent of `this.state`, so we should do any calculation deriving state from state within a `setState()` callback. This fixes a bug where we were relying on potentially stale state, a RenderMask derived from `this.state` instead of the `state` callback parameter, when triggering updates from focus.

Note that this is not exercised on Android/iOS, but it on desktop/web. I noticed this a while back while making another change, but that change got abandoned, so this is the independent fix.

Changelog:
[General][Fixed] - Calculate VirtualizedList render mask for focused cell during batched state updates

Reviewed By: javache

Differential Revision: D43073415

fbshipit-source-id: dee4197ec925a6d8d427b63fb063aa4e3b58c595
2023-02-07 18:25:28 -08:00
Deepak Jacob 9d98e2cb07 Revert D41273822: Add fabric support for maintainVisibleContentPosition on iOS
Differential Revision:
D41273822 (ecf967a51d)

Original commit changeset: 7900898f2828

Original Phabricator Diff: D41273822 (ecf967a51d)

fbshipit-source-id: 0f4b9695c805407b9a41b0fec63784bd0e84be43
2023-02-07 13:06:38 -08:00
Zihan Chen (MSFT) bbed15d4ae Turbo Module supports intersection type for TypeScript (#36037)
Summary:
As [requested from community](https://github.com/reactwg/react-native-new-architecture/discussions/91#discussioncomment-4282384), intersection type is supported for component but no in turbo module. This PR fixed it.

## Changelog

[GENERAL] [CHANGED] - Turbo Module supports intersection type for TypeScript

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

Test Plan: `yarn jest react-native-codegen` passed

Reviewed By: christophpurrer

Differential Revision: D42960338

Pulled By: cipolleschi

fbshipit-source-id: d317d3155cb96643bf549d0ac3d77f503685edbc
2023-02-07 07:41:37 -08:00
shivenmian bb02ccf13f RNGP - fix: use relative paths for gradle exec invocations (#36080)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36080

For Android release builds on Windows, gradle release build fails if there are spaces in path (https://github.com/facebook/react-native/issues/34878). This is due to gradle improperly handling arguments with spaces (this is also [an open issue](https://github.com/gradle/gradle/issues/6072) on Gradle). Since the Hermes compilation and other Gradle exec invocations involve arguments which will contain spaces (if there are spaces in your path), this also means it is hard to get around this by simply escaping the spaces (eg: by using double quotes), since these arguments are not properly handled by Gradle itself.

As a workaround, this PR uses relative paths for all Gradle commands invoked for Android. As long as there aren't any spaces in the react-native directory structure (i.e this repo), this fix should work.

## Changelog

[Android][Fixed] - Used relative paths for gradle commands

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

Test Plan: `npx react-native run-android` builds and runs the app successfully on Android device, when run inside an RN0711 project with a path containing spaces (and with the changes in this PR applied) on Windows. This includes release builds (i.e with the `--variant=release` flag).

Reviewed By: cipolleschi

Differential Revision: D43080177

Pulled By: cortinico

fbshipit-source-id: 7625f3502af47e9b28c6fc7dfe1459d7c7f1362d
2023-02-07 07:29:17 -08:00
Janic Duplessis ecf967a51d Add fabric support for maintainVisibleContentPosition on iOS (#35319)
Summary:
This adds support for the `maintainVisibleContentPosition` in iOS fabric. This was previously only implemented in the old renderer. The implementation is very similar to what we currently have.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Added] - Add fabric support for maintainVisibleContentPosition on iOS

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

Test Plan:
Test in RN tester example.

https://user-images.githubusercontent.com/2677334/201484543-f7944e34-6cb7-48d6-aa28-e2a7ccdfa666.mov

Reviewed By: sammy-SC

Differential Revision: D41273822

Pulled By: jacdebug

fbshipit-source-id: 7900898f28280ff01619a4af609d2a37437c7240
2023-02-07 02:54:06 -08:00
Nick Gerleman 0daf83ac51 Reconnect VirtualizedList Source History 2/2 (Apply D41745930 + history, D42805202, D43063551)
Summary:
This change re-applies D41745930 (2e3dbe9c2f) (and D42805202 (1479b2ac26) which was also partially reverted), re-registers additions as moves, then applies D43063551 which has been added to the changes since migration.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D43068114

fbshipit-source-id: 72997700bf9962d82a988599481e255b69e68a9b
2023-02-06 20:00:19 -08:00
Nick Gerleman ebaa00e327 Reconnect VirtualizedList Source History 1/2 (Revert D41745930)
Summary:
This change reverts D41745930 (2e3dbe9c2f) as part of a stack to splice back source history which was lost (Git registered the file moves as additions).

It is expected this diff will individually fail. The entire stack should be applied at once.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D43068113

fbshipit-source-id: c8398629fe5dcc1ca4bf02f550adc00c78a8487a
2023-02-06 20:00:19 -08:00