Commit Graph

12270 Commits

Author SHA1 Message Date
Antoine Doubovetzky 56d7a87e84 Fix assertGenericTypeAnnotationHasExactlyOneTypeParameter throwing wrong error (#35134)
Summary:
1. I noticed there was a mistake in the [IncorrectlyParameterizedGenericParserError](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/errors.js#L159):
```
if (
  genericTypeAnnotation.typeParameters.type ===
    'TypeParameterInstantiation' &&
  genericTypeAnnotation.typeParameters.params.length !== 1
) {
```

Here we should replace ` 'TypeParameterInstantiation'` with ` 'TSTypeParameterInstantiation'` when the language is `TypeScript`.

The result is that we get a ["Couldn't create IncorrectlyParameterizedGenericParserError"](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/errors.js#L172) error instead of ["Module testModuleName: Generic 'typeAnnotationName' must have exactly one type parameter."](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L88).

I added a [test case](https://github.com/facebook/react-native/commit/2f161166c033cc9de67e04cd683554b05c6173f8) to cover this case:
<img width="1008" alt="Capture d’écran 2022-10-30 à 13 55 56" src="https://user-images.githubusercontent.com/17070498/198879598-ab5a6092-8cbf-422a-9993-2f3f92c9d84c.png">

2. Looking closely at where IncorrectlyParameterizedGenericParserError is used, I noticed that the logic was duplicated in [assertGenericTypeAnnotationHasExactlyOneTypeParameter](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/parsers-commons.js#L65).

I believe that the logic should reside in `assertGenericTypeAnnotationHasExactlyOneTypeParameter` so I split the `IncorrectlyParameterizedGenericParserError` in 2 different errors.

## 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
-->

[Internal] [Changed] - Fix assertGenericTypeAnnotationHasExactlyOneTypeParameter throwing wrong error

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

Test Plan: I tested using Jest and Flow commands.

Reviewed By: rshest

Differential Revision: D40853200

Pulled By: cipolleschi

fbshipit-source-id: 7040e57e0a2f511ba23fd4c54beae2ccff2fa89d
2022-10-31 13:56:27 -07:00
Gabriel Donadel Dall'Agnol ea55e3bf8d chore: Unify codegen Flow and TS default case from translateTypeAnnotation (#35086)
Summary:
This PR unifies the Flow and TS `default:` case from codegen `translateTypeAnnotation` function into a single function
called `translateDefault` inside `parser-commons.js` as requested on https://github.com/facebook/react-native/issues/34872.

## Changelog

[Internal] [Changed] - Unify codegen Flow and TS default case from translateTypeAnnotation

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

Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

![image](https://user-images.githubusercontent.com/11707729/197931439-a0f0f7cd-eee7-4908-a7f1-856b40954178.png)

Reviewed By: cortinico

Differential Revision: D40801612

Pulled By: cipolleschi

fbshipit-source-id: 612768d6fabe091ac428e7d8416c6da059fe1332
2022-10-31 13:56:27 -07:00
Riccardo Cipolleschi ab7b4d4cd8 Restore Filtering platform in codegen (#35028)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35028

**This Diff require a bump in the react-native-codegen (including this [commit](https://github.com/facebook/react-native/commit/7680bdeb4f96a8092393372a59c77a9d7b729cae)) to work**

This diff sets up iOS and Android to pass their platform to the codegen so that we can have platform-specific specs.

## Changelog
[General][Added] - Enable platform-specific Codegen Specs

Reviewed By: cortinico

Differential Revision: D40516395

fbshipit-source-id: 0624f0bfb93c90f78131a605a4847e780783bbaf
2022-10-31 12:31:00 -07:00
Riccardo Cipolleschi a2166b24f8 bump codegen to v0.71.1 (#35154)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35154

This diff bumps the codegen to v0.71.1, preparing it for the branch cut.

## Changelog
[General][Changed] - Bump codegen version

Reviewed By: dmytrorykun

Differential Revision: D40852498

fbshipit-source-id: ba1dc87f3726bc27cbd176f160c62a0bdc291433
2022-10-31 12:31:00 -07:00
Christoph Purrer 87c356d56c Add Map / indexed object support for TypeScript parser (#35098)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35098

Changelog:
[General][Fixed] [react-native-codegen] react-native-codegen : Add Map / indexed object support for TypeScript parser

In flow we can expose Maps via the following syntax in TM specs

`
+getMap: (arg: {[key: string]: ?number}) => {[key: string]: ?number};
`

In TypeScript writing the same spec:

`
readonly getMap: (arg: { [key: string]: number | null; }) => { [key: string]: number | null; };
`

leads to an exception the TypeScript code-gen parser

```UnsupportedObjectPropertyTypeAnnotationParserError: Module NativeTurboModuleCxx: 'ObjectTypeAnnotation' cannot contain 'TSIndexSignature'.
    at react-native-github/packages/react-native-codegen/src/parsers/typescript/modules/index.js:309:23```
```
This change fixes the TypeScript parser

Reviewed By: cipolleschi

Differential Revision: D40753368

fbshipit-source-id: 0eef8ecb63d1ed049fde1e75cc6f2ec627f1f232
2022-10-30 05:48:57 -07:00
Gabriel Donadel Dall'Agnol 87d65803ab chore: Extract codegen case 'Float' into a single emitFloat function (#35124)
Summary:
## Summary

This PR extracts the content of the codegen case `'Float'` into a single `emitFloat` function inside the `parsers-primitives.js` file and uses it in both Flow and TypeScript parsers as requested on https://github.com/facebook/react-native/issues/34872. This also adds unit tests to the new `emitFloat` function.

## Changelog

[Internal] [Changed]  - Extract the content of the case 'Float' into a single emitFloat function

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

Test Plan:
Run `yarn jest react-native-codegen` and ensure CI is green

![image](https://user-images.githubusercontent.com/11707729/198704932-202e2cd7-5b04-4009-b47e-b4999fee6c98.png)

Reviewed By: rshest

Differential Revision: D40828746

Pulled By: cipolleschi

fbshipit-source-id: 9c7cecf7268f16aaef29065c1983ad9a4dd18dbe
2022-10-29 06:40:54 -07:00
Nicola Corti cec9a34f6c Sets the namespace via Gradle and not via AndroidManifest (#35094)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35094

Currently the build on console is firing this warning:
```
> Task :app:processDebugMainManifest
package="com.androidtemplateproject" found in source AndroidManifest.xml: /tmp/AndroidTemplateProject/android/app/src/main/AndroidManifest.xml.
Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
```

This diff fixes it so users won't see it anymore on 0.71

Changelog:
[Android] [Fixed] - Sets the namespace via Gradle and not via AndroidManifest

Reviewed By: cipolleschi

Differential Revision: D40724654

fbshipit-source-id: 9b01748a22e9993b60e17bf25acbc68ba8e4eb77
2022-10-29 06:35:38 -07:00
Riccardo Cipolleschi ec5a4301a3 Separatedly enable TM/Fabric (#35117)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35117

This mimics some behavior we have in Android that allow uesers to turn on selectively TM and Fabric.

Notice that if fabric is enabled, TM must be enabled as well, otherwise the app won't work

## Changelog
[iOS][Added] - Added the possibility to selectively enable TM and Fabric with the new Architecture

Reviewed By: cortinico

Differential Revision: D40794328

fbshipit-source-id: b7fc7bb819d05566dcd335832cab224f80b23346
2022-10-29 04:00:24 -07:00
Lorenzo Sciandra cd25fb3240 chore(deps): add wanted dependencies to remove yarn warnings (#35122)
Summary:
This is take 2 of this https://github.com/facebook/react-native/pull/35088, see this comment for why https://github.com/facebook/react-native/pull/35088#issuecomment-1295091902

I wanted to start working on a thing but this barrage of warnings was very annoying so ended up doing this instead: a very small PR to take care of some warnings during yarn install.

It doesn't change anything (the versions are the ones already used all around the repo), just makes yarn happier.

## 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
-->

[General] [Fixed] - add wanted dependencies to remove yarn warnings

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

Test Plan:
### Before

<img width="1920" alt="Screenshot 2022-10-26 at 10 53 32" src="https://user-images.githubusercontent.com/16104054/197996489-f463be29-b35b-45cc-9d9c-2d176579fb7d.png">

### After

<img width="947" alt="Screenshot 2022-10-26 at 10 52 19" src="https://user-images.githubusercontent.com/16104054/197996505-3d60b319-006b-45ab-83bf-2f431272fdcd.png">

Reviewed By: cortinico

Differential Revision: D40804260

Pulled By: rshest

fbshipit-source-id: 86af14c885d6d63a0d60bb85f204d17d8757f72a
2022-10-28 13:01:48 -07:00
Sam Zhou 281f7a7524 Annotate React hooks on xplat
Summary:
Changelog:
[Internal]

Reviewed By: pieterv

Differential Revision: D40699106

fbshipit-source-id: 236fcd1001e60f508f70a651ca2d0a602b50c19a
2022-10-28 12:10:27 -07:00
Antoine Doubovetzky 8c69b6cf78 Extract throwIfUnsupportedFunctionParamTypeAnnotationParserError function (#35057)
Summary:
This PR is a task from https://github.com/facebook/react-native/issues/34872:

> Extract the UnsupportedFunctionParamTypeAnnotationParserError in its own throwing function (if it does not exists already) and reuse that function passing a proper type. Then, refactor the code using a dictionary and avoiding the three different ifs in both parsers.

## 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
-->

[Internal] [Changed] - Extract the UnsupportedFunctionParamTypeAnnotationParserError in its own throwing function in error-utils

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

Reviewed By: lunaleaps

Differential Revision: D40721099

Pulled By: cipolleschi

fbshipit-source-id: af5e4cd275d0049047d35660559b94a27e660e40
2022-10-28 07:21:15 -07:00
Christoph Purrer 089684ee56 Remove remaining TV_OS fragments (#35110)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35110

Changelog:
[General][Fixed] Remove remaining TV_OS fragments

Reviewed By: shwanton

Differential Revision: D40775881

fbshipit-source-id: 122ff8737de35689ee0951b068997ee546c7019c
2022-10-28 02:50:49 -07:00
Nicola Corti 6a43fafd78 Cleanup the template documentation after RNGP & hermesEnabled to gradle.properties (#35108)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35108

I've rewritten the comment in the android/app/build.gradle.
They were really old, contained wrong links and most of the people ignored it.

I've also moved the enabling of Hermes to the `gradle.properties` file.
RNGP still supports the old method, but we must be sure that we notify
library authors if they were reading project.ext.react.enableHermes in the past
(also the website needs to be updated).

I've also cleaned up the CircleCI setup as now we can specify Hermes enabled/disabled
via the CLI (this will also make easier to do e2e testing).

Changelog:
[Android] [Changed] - Cleanup the template documentation after RNGP & hermesEnabled to gradle.properties

Reviewed By: cipolleschi

Differential Revision: D40762872

fbshipit-source-id: 2c09245e0a923faac53cc6c8a89e99788ae47f8a
2022-10-27 14:40:27 -07:00
Nicola Corti ba5454c421 Bump RNGP to 0.71.7
Summary:
Just bumping RNGP to make the new sources avialable to the template.

Changelog:
[Internal] [Changed] - Bump RNGP to 0.71.7

Reviewed By: cipolleschi

Differential Revision: D40760927

fbshipit-source-id: 909c88377a231ea6678c6af14c5594fdc4830b79
2022-10-27 09:52:06 -07:00
Nicola Corti 2097278d2a Update the template to load the correct JS engine at runtime. (#35095)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35095

This change will make sure that we load the correct JS engine at runtime,
by using the BuildConfig flag that RNGP sets for us.

This will solve a lot of noise in adb logcat for users seeing
stacktraces mentioning failing to load `jscexecutor` library.

This is also a breaking change, but as the API was not widely used nor
advertised in the template, we should be fine by just mentioning this in the release notes.

Changelog:
[Android] [Changed] - Update the template to load the correct JS engine at runtime

Reviewed By: cipolleschi

Differential Revision: D40710597

fbshipit-source-id: d59a7a52b22a9bf273ea89094c6620c3ecf6eb00
2022-10-27 04:47:25 -07:00
Nicola Corti 3f77736e15 RNGP - Do not set GENERATED_SRC_DIR and REACT_ANDROID_BUILD_DIR (#35101)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35101

Those CMake variables are effectively unused now. They're raising a warning on CMake builds
of templates + let's not expose them as we haven't released RNGP yet, before libraries
or other tools start relying on them.

Changelog:
[Internal] [Changed] - RNGP - Do not set GENERATED_SRC_DIR and REACT_ANDROID_BUILD_DIR

Reviewed By: cipolleschi

Differential Revision: D40751998

fbshipit-source-id: 13f54a6247e4734c21c263f8b1e6b4b9e8ba406c
2022-10-27 04:10:57 -07:00
Nicola Corti 1f42ff0815 Bump AGP to 7.3.1 (#35100)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35100

That's just a minor bump of AGP before the branch cut.

Changelog:
[Android] [Changed] - Bump AGP to 7.3.1

allow-large-files

Reviewed By: cipolleschi

Differential Revision: D40752006

fbshipit-source-id: 4856bc7ca275cf46d3afcc7c24928c5f1d5e6e33
2022-10-27 03:33:29 -07:00
Nicola Corti 2df63e52f4 RNGP - Use the File Api to specify cliPath and remove ComposeSourceMap path (#35092)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35092

As we're close to the cut of the 0.71 branch, I'll take the opportunity to polish
our Gradle public API.
We're exposing a mixture of Path (String) and File (java.io.File or RegularFileProperty).
Here I've moved everything to use File as it's more configurable for the users,
specifically if they're using monorepos or other setup.

This also allows us to remove the resolution logic for the cliPath.

Changelog:
[Internal] [Changed] - RNGP - Use the File Api to specify cliPath and remove ComposeSourceMap path

Reviewed By: cipolleschi

Differential Revision: D40710595

fbshipit-source-id: a17095eebae5123b70fd2b8e3d512656817006ca
2022-10-26 13:05:03 -07:00
Nicola Corti 1069841837 Make it easier for user to toggle only Fabric or TurboModules in New Architecture (#35091)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35091

This diff refines the DefaultNewArchitectureEntryPoint to make it easier for user to
either turn on Fabric, TurboModules or both.

Changelog:
[Internal] [Changed] - Make it easier for user to toggle only Fabric or TurboModules in New Architecture

Reviewed By: cipolleschi

Differential Revision: D40710596

fbshipit-source-id: 236060b2ebccb1bf25e7f5c0fc15f54c5ce5f608
2022-10-26 13:03:33 -07:00
Nicola Corti 2ff08e8bd8 RNGP - Do the .so cleanup using pickFirst and exclude (#35093)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35093

It turns out that using the Artifacts API to manipulate the APK to remove
.so has unintended side effects and is causing the `installDebug` and `installRelease`
commands to fail.

I've resorted to register a packaging option for each variant to make sure we include only
the correct artifacts we want.

This should fix the current startup crash that is experienced on main.

Changelog:
[Android] [Fixed] - RNGP - Do the .so cleanup using pickFirst and exclude

Reviewed By: cipolleschi

Differential Revision: D40722285

fbshipit-source-id: 982e1e9c474522fc4419c969ede5ee14e5404f3a
2022-10-26 10:46:39 -07:00
Nicola Corti 7d61b9d81a RNGP - Remove enableCodegenInApps and infer it from package.json (#35083)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35083

We don't need to `enableCodegenInApps` keys but we can instead rely on the
existence of the `codegenConfig` key inside the `package.json` to decide if
Codegen should run in App modules or not.

Changelog:
[Internal] [Changed] - RNGP - Remove enableCodegenInApps and infer it from package.json

Reviewed By: cipolleschi

Differential Revision: D40687079

fbshipit-source-id: cd4a6c67caa19c1d199ae75388a0551339f876a0
2022-10-26 10:41:02 -07:00
youedd 0627cd69cd Refactor translate UniontypeAnnotation (#35050)
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> [Assigned to youedd] This task is more advanced than the others Create a function to unify the [unionType](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/modules/index.js#L372-L396) and the [TSUnionType](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/modules/index.js#L407-L431). This task may share some logic from the previous task. The function should accept a ParserType parameter to implement the proper logic to extract the memberType variable. Ideally, we should create a couple of supporting functions to implement those logics.

## 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
-->

[Internal] [Changed] - Refactor translate UniontypeAnnotation

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

Test Plan:
`yarn jest react-native-codegen`
![image](https://user-images.githubusercontent.com/19575877/197334084-2daeed7e-8e87-4140-b8c3-07f2de3f0496.png)

Reviewed By: cortinico

Differential Revision: D40637299

Pulled By: cipolleschi

fbshipit-source-id: 1490001a3398c3af79d465c40de3c3687f058523
2022-10-26 10:02:01 -07:00
dhruvtailor7 cba56eadd2 Extract getConfigType function to parsers/utils.js (#35035)
Summary:
This PR is part of https://github.com/facebook/react-native/issues/34872.
This PR contains two changes, extracting the visitor object and then factoring out the `getConfigType()` function to the `parsers/utils.js` file. Then we can reuse the same function in both flow and typescript by passing the extracted visitor object.

## Changelog

[Internal] [Changed] - Extract visitor object in the same file and factor out `getConfigType()` to `parsers/utils.js`.

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

Test Plan: Output of `yarn jest react-native-codegen` ensures all passed test cases

Reviewed By: cortinico

Differential Revision: D40548855

Pulled By: cipolleschi

fbshipit-source-id: 310b8565322a4e4800a3fffc67479a9dfa45d620
2022-10-26 10:02:01 -07:00
Benny Singer cf5addf423 Revert D40716713: chore(deps): add wanted dependencies to remove yarn warnings
Differential Revision:
D40716713 (https://github.com/facebook/react-native/commit/8422c5315caf5cf696791a5ad49ed0fbd37ef9df)

Original commit changeset: eeb95a91c6cd

Original Phabricator Diff: D40716713 (https://github.com/facebook/react-native/commit/8422c5315caf5cf696791a5ad49ed0fbd37ef9df)

fbshipit-source-id: e85f111e7da0381e09f8a23d3bd0d553b3a7c4a9
2022-10-26 07:22:28 -07:00
Lorenzo Sciandra 8422c5315c chore(deps): add wanted dependencies to remove yarn warnings (#35088)
Summary:
I wanted to start working on a thing but this barrage of warnings was very annoying so ended up doing this instead: a very small PR to take care of some warnings during yarn install.

It doesn't change anything (the versions are the ones already used all around the repo), just makes yarn happier.

Also, while doing that I found a dependency that was lying there unused for 2 years so took care of it.

## 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
-->

[General] [Fixed] - add wanted dependencies to remove yarn warnings

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

Test Plan:
### Before

<img width="1920" alt="Screenshot 2022-10-26 at 10 53 32" src="https://user-images.githubusercontent.com/16104054/197996489-f463be29-b35b-45cc-9d9c-2d176579fb7d.png">

### After

<img width="947" alt="Screenshot 2022-10-26 at 10 52 19" src="https://user-images.githubusercontent.com/16104054/197996505-3d60b319-006b-45ab-83bf-2f431272fdcd.png">

Reviewed By: jacdebug

Differential Revision: D40716713

Pulled By: robhogan

fbshipit-source-id: eeb95a91c6cdf37edfe868fefe4ba04aebe500ec
2022-10-26 06:42:50 -07:00
Christoph Purrer d0599ac56b Back out "Add enum example to Android/iOS rn-tester TurboModule" (#35089)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35089

Changelog:
[General][Fixed] - Back out "Add enum example to Android/iOS rn-tester TurboModule"

This broke the rn-tester adding due to an invalid flow-enum setup. Needs further investigation

Reviewed By: cipolleschi

Differential Revision: D40714320

fbshipit-source-id: 9831276762f90df0ffaca3304382fe5925009343
2022-10-26 06:30:14 -07:00
Marco Fiorito c868d5b26c refactor(rn tester app): change activity indicator to hooks (#35071)
Summary:
This pull request migrates the activity indicator example to using React Hooks.

## Changelog
[General] [Changed] - RNTester: Migrate ActivityIndicator to hooks

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

Test Plan: The animation works exactly as it did as when it was a class component

Reviewed By: jacdebug

Differential Revision: D40698379

Pulled By: NickGerleman

fbshipit-source-id: 08b275fcc4e3a10b5872e0031fa2ecce5360a7b9
2022-10-26 03:21:04 -07:00
Nick Gerleman b655e69bad Fix RCTLoggingTests in OSS (#35085)
Summary:
fd91748146 added a condition not to pump an extra message when we didn't see symbolication warnings (which do not seem to show up in a stock internal build), but I missed that the test specific to RCTLogLevelError checked for string containment instead of equality, and the last assertion we process on log level is incorrect in OSS as a result.

Changelog:
[Internal][Fixed] - Fix RCTLoggingTests in OSS

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

Test Plan:
`test_ios-Hermes` passes again in OSS: https://github.com/facebook/react-native/pull/35085 (JSC and Android failures look unrelated)

RCTLoggingTests still pass running `buck test //xplat/js/react-native-github/packages/rn-tester:RNTesterIntegrationTests`

Reviewed By: rshest

Differential Revision: D40699773

Pulled By: NickGerleman

fbshipit-source-id: 5acc8ec2b26a1f9acac2f070b85f1d65ee15a011
2022-10-26 01:43:19 -07:00
Héctor Ramos adaa4fe71e trivial: display target name in CocoaPods output
Summary:
Without this, the CocoaPods output would display multiple "Building RNTester..." logs. With these changes, we make it clear that these are separate targets that are being configured.

Changelog: [internal]

Reviewed By: mdvacca, cipolleschi

Differential Revision: D40656813

fbshipit-source-id: a317112e804d08b9e64e2d62e8b27e4045b317b0
2022-10-25 16:25:20 -07:00
Christoph Purrer 02e4fcd825 Add enum example to Android/iOS rn-tester TurboModule
Summary:
Add enum example to Android/iOS rn-tester TurboModule

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

Reviewed By: javache

Differential Revision: D40619020

fbshipit-source-id: a113c5c78bcff3275e80d11bce8d0e6421b0b97d
2022-10-25 14:40:08 -07:00
Nick Gerleman fd91748146 Fix deadlock in RCTLoggingTests
Summary:
Some portions of continuous test runs RNTesterIntegrationTests will hang for an hour when running in Sandcastle without outputting anything. Locally debugging, I see a deadlock waiting on a semaphore, where the test assumed an extraneous symbolication warning would be fired.

This change makes it so that we only look for the extraneous messages if we haven't already seen the target message, since they do not seem to show up in local testing. I also added assertions per semaphore that the log statement is propagated within a still very gracious 10 seconds. This means we still can see what tests are running/failing if this test has issues, instead of a deadlocked test runner with no output.

Changelog:
[Internal][Fixed] - Fix deadlock in RCTLoggingTests

Reviewed By: cipolleschi

Differential Revision: D40667275

fbshipit-source-id: ab78f3c2ef47e2fd740b1dad2a65912e9542301d
2022-10-25 14:15:42 -07:00
Nicola Corti c96c76eb91 Update the template to use RNGP (#35075)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35075

This diff updates the New App template for Android to use the React Native Gradle Plugin.
With this we can:
1. Get rid of all the C++ code.
2. Remove a lot of New Architecture logic in the build.gradle
3. Reuse the prebuilts of React Native/Hermes via prefab

Changelog:
[Android] [Changed] - Update the template to use RNGP

Reviewed By: cipolleschi

Differential Revision: D40673732

fbshipit-source-id: 70935248993d1e24904c982e75f12ad580faa9d8
2022-10-25 13:13:14 -07:00
Marshall Roch 68983b6631 fix some flow reference-before-declaration errors
Summary:
The `typeof X` type annotation now respects the initialization state of `X`: if `X` hasn't been declared it will be an error to get its type.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D40638870

fbshipit-source-id: 57459dec30ec5b87397365a709f2d846c87e378a
2022-10-25 11:07:40 -07:00
Christoph Purrer 745f3ee8c5 react-native-code-gen Add Enum Type support for iOS/Android TurboModules
Summary:
Adding enum support to Android/iOS generated code

Changelog:
[General][Added] - react-native-code-gen Add Enum Type support for iOS/Android TurboModules

Reviewed By: javache

Differential Revision: D38967241

fbshipit-source-id: d8bb3019dab198e16905a6422e877cd751119122
2022-10-25 08:27:47 -07:00
Riccardo Cipolleschi 5940d25cc1 Create the Parser interface (#35036)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35036

This diff is the base to create a polimorphic behavior for TypeScript and Flow parser. This type will allow to share a lot of code between the parsers and also to keep their differences a part.

It will be the base diff/PR for further tasks in the Codegen umbrella Issue

## Changelog:
[General][Added] - Parser interface to divide parser logic.

Reviewed By: cortinico

Differential Revision: D40548707

fbshipit-source-id: e632ba52b00b43e50306e3a792a841e72e8c07f4
2022-10-25 05:01:19 -07:00
Nicola Corti c419b4fa0c Bump react-native-gradle-plugin to 0.71.5
Summary:
Bumping RNGP to make sure all the changes are available for 0.71

I've also removed the caret from react-native's package.json as
I don't want .5 to be used by template tests yet.
The Android template needs to be updated in order to use
that version of the Gradle plugin.

Changelog:
[Internal] [Changed] - Bump react-native-gradle-plugin to 0.71.5

Reviewed By: cipolleschi

Differential Revision: D40642114

fbshipit-source-id: 70359efc3d2300e9c04c1b361c45061fd1c2931b
2022-10-25 03:24:38 -07:00
Héctor Ramos 2b348fe009 Update RNTester bundle identifier
Summary:
Change RNTester bundle identifier to match Meta's provisioning profiles.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D40532706

fbshipit-source-id: efcd524eb1630a522bcb8a4875a3eed02b5b5e13
2022-10-24 15:52:42 -07:00
Riccardo Cipolleschi 52d37aa403 Back out "add oncall annotation for BUCK files in xplat based on supermodule information - /home/s2shi/tmp/xplat_buck_oncall/xplat_buck_batch10" (#35064)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35064

Original commit changeset: 0fb0db845c04

Original Phabricator Diff: D40610875 (https://github.com/facebook/react-native/commit/d941940b4ce7ed9030be4f72980fb45d9b62365d)

Open source is using BUCK 1 which does not seem to have the `oncall` directive.

Backing it out because it is breaking the external CI.

## Changelog
[internal]

Reviewed By: cortinico

Differential Revision: D40635873

fbshipit-source-id: 79ebd4db0972520fcca6ccb8c1725657a8ef7949
2022-10-24 10:44:39 -07:00
Nicola Corti 421bf983ed Unbreak test_android by passing the correct file to hermesc (#35067)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35067

I accidentally broke test_android by landing a diff without waiting for
the full CI output.

Changelog:
[Internal] [Fixed] - Unbreak test_android by passing the correct file to hermesc

Reviewed By: cipolleschi

Differential Revision: D40638239

fbshipit-source-id: 1d03106f3b144f537265910df095a6023b181d85
2022-10-24 09:24:44 -07:00
Donald Webster 9a43e53a06 Revert D40613108: 4/n Display a RedBox with the JS stack (instead of native stack) when an unhandled JS exceptions occurs - Try 2
Differential Revision:
D40613108 (https://github.com/facebook/react-native/commit/5449148482271d60c87f6e5fa4483e69d4410320)

Original commit changeset: f36c3b39a216

Original Phabricator Diff: D40613108 (https://github.com/facebook/react-native/commit/5449148482271d60c87f6e5fa4483e69d4410320)

fbshipit-source-id: 079deac137610eeebd231bd97930efda6b284fff
2022-10-24 08:56:55 -07:00
Gabriel Donadel Dall'Agnol 20718e6b8c feat: Add role prop to Text component (#34976)
Summary:
As pointed out by necolas on https://github.com/facebook/react-native/issues/34424#issuecomment-1261482517 we forgot we add the `role` prop mapping to the `Text` component. This PR adds a new `role` prop to `Text`, mapping the web `role` values to the already existing `accessibilityRole` prop and moves the `roleToAccessibilityRoleMapping` to a common file that can be imported by both the `Text` and `View` components as requested on https://github.com/facebook/react-native/issues/34424. This PR also updates the RNTester AcessebilityExample to include a test using this new prop.

## Changelog

[General] [Added] - Add role prop to Text component

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

Test Plan:
1. Open the RNTester app and navigate to the Accessibility Example page
2. Test the `role` prop through the `Text with role = heading` section

Reviewed By: yungsters

Differential Revision: D40596039

Pulled By: jacdebug

fbshipit-source-id: f72f02e8bd32169423ea517ad18b598b52257b17
2022-10-24 08:38:47 -07:00
Nicola Corti 8ad86c70b6 RNGP - Add Variant Support (#35063)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35063

This is part of a series of tasks to make the React Native Gradle Plugin (RNGP) variant-aware.

Here I'm add Variant support to RNGP via the Variant API from AGP 7.x

A short summary of changes:
- I've pushed a number of breaking changes to ReactExtension (we should document them in the release notes). Specifically I've removed properties which I believe were unnecessary and confusing
- I've removed all the extra logic to do the .so cleanups and use the new tasks that use the Artifacts API
- I've introduced only a `debuggableVariants` to make all the decisions for the bundling and minification which should be sufficient for users
- I've removed all the funcional interfaces are replaced them with lists as they're easy to handle and understand for users.

Changelog:
[Android] [Changed] - Added Flavor Support to React Native Gradle Plugin (RNGP)

Reviewed By: cipolleschi

Differential Revision: D40335028

fbshipit-source-id: d9ac1437de8a27db2e93df15b13772b221e036b2
2022-10-24 07:00:36 -07:00
Nicola Corti 2cc2ca1d1c RNGP - Automatically Configure Dependencies for ReactNative & Hermes
Summary:
This is part of a series of tasks to make the React Native Gradle Plugin (RNGP) variant-aware.

I'm extending RNGP to do autoconfiguration of dependencies for React Native and Hermes Engine using the Utils classes which were introduced before.

Changelog:
[Internal] [Changed] - RNGP - Automatically Configure Dependencies for ReactNative & Hermes

Reviewed By: cipolleschi

Differential Revision: D40633487

fbshipit-source-id: d4240987a9400fff2ec2aff2d13afc5b24778598
2022-10-24 07:00:36 -07:00
Nicola Corti 56d8c23f7b RNGP - Introduce enableCodegenInApps
Summary:
This is part of a series of tasks to make the React Native Gradle Plugin (RNGP) variant-aware.

Historically we used to enable the codegen only for library modules. This is not working well for apps like RN Tester which don't have library modules but are running the codegen.

Therefore I'm introducing the `enableCodegenInApps` that is allowing apps to turn off the codegen if needed.

Changelog:
[Internal] [Changed] - RNGP - Introduce enableCodegenInApps

Reviewed By: cipolleschi

Differential Revision: D40633106

fbshipit-source-id: dc2ae9bbfe5b7940f9e9fe505ab2198a42c8a3f6
2022-10-24 07:00:36 -07:00
Nicola Corti 41fec07e20 RNGP - Top level property enableHermes -> hermesEnabled
Summary:
This is part of a series of tasks to make the React Native Gradle Plugin (RNGP) variant-aware.

Here I'm renaming the top level property to enable hermes from `enableHermes` to `hermesEnabled`. We have a bunch of other properties which are called *Enabled. This one was following a different convention.

I'm retaining the backward compatibility for users using `project.ext.react.enableHermes` so this is not going to be a breakign change.

Changelog:
[Internal] [Changed] - RNGP - Top level property enableHermes -> hermesEnabled

Reviewed By: cipolleschi

Differential Revision: D40633109

fbshipit-source-id: 9d7efad6cb3bb382d1beb56966795a3f42bdaae6
2022-10-24 07:00:36 -07:00
Nicola Corti 074e3f0009 RNGP - Introduce the BundleAndHermesCTask
Summary:
This is part of a series of tasks to make the React Native Gradle Plugin (RNGP) variant-aware.

Here I'm creating a new task BundleAndHermesCTask that is variant-aware.
Historically we had problems with the Bundle and the Hermes task being separated and overriding their own output. Consolidating those two steps in a single one will make it easier to support seaprate variants.

I'm going to use this task in a subsequent diff.

Changelog:
[Internal] [Changed] - RNGP - Introduce the BundleAndHermesCTask

Reviewed By: cipolleschi

Differential Revision: D40633108

fbshipit-source-id: 89f6d32ef219626ed5d4c5a0b8ac804c6704b2d6
2022-10-24 07:00:36 -07:00
Paige Sun 5449148482 4/n Display a RedBox with the JS stack (instead of native stack) when an unhandled JS exceptions occurs - Try 2
Summary:
Changelog: [iOS][Changed] Display a RedBox with the JS stack (instead of native stack) when an unhandled JS exceptions occurs

-----

# A0) Bridge mode, Unhandled Exception, FBiOS
Unhandled exception goes to FBReactModule, but the JS Stack is not parsed correctly.
https://www.internalfb.com/code/fbsource/[312d5cbdd7278247a84619786b12a44c4400fcc0]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=1488%2C1493

See `****** FBReactModule handleFatalError` in the logs P539306390, and compare with correct behavior in (A1) in the Test Plan.

https://pxl.cl/2h6h3

{F782257996}

-----

# A) Before diff, rn-tester
Open to rn-tester -> APIs -> Crash Examples -> JS Crash.

Set `RCTParseUnhandledJSErrorStackNatively` to YES.
https://www.internalfb.com/code/fbsource/[98880e52ee78be3614e5d9a2ce3292f6a7b5e413]/xplat/js/react-native-github/React/Base/RCTConstants.m?lines=73

{F783395297}

----

build_on_commit[ios_fbios-arm64-dylibs-jackalope-iphoneos-production_build]

Reviewed By: RSNara

Differential Revision: D40613108

fbshipit-source-id: f36c3b39a2167402ee3730db8b40b53a0b80aa60
2022-10-23 16:42:00 -07:00
Jonathan Keljo e69e6f4014 supermodule:xplat/default/public.react_native.infra
Reviewed By: javache

Differential Revision: D40376280

fbshipit-source-id: d76e692fd8a571614729d0fb15ebde8895d3de28
2022-10-23 15:55:13 -07:00
Stanley Shi d941940b4c add oncall annotation for BUCK files in xplat based on supermodule information - /home/s2shi/tmp/xplat_buck_oncall/xplat_buck_batch10
Differential Revision: D40610875

fbshipit-source-id: 0fb0db845c041265faf0a06877d05ffbb55ba648
2022-10-21 22:39:18 -07:00
Donald Webster 9e68eea2c8 Revert D40387938: 4/n Display a RedBox with the JS stack (instead of native stack) when an unhandled JS exceptions occurs
Differential Revision:
D40387938 (https://github.com/facebook/react-native/commit/ff398e4e2632ece8a6f22d744e96e489ca3b9d92)

Original commit changeset: 2abea657476d

Original Phabricator Diff: D40387938 (https://github.com/facebook/react-native/commit/ff398e4e2632ece8a6f22d744e96e489ca3b9d92)

fbshipit-source-id: 0b5dbe417abf25d5723c70337189dfb42570e56d
2022-10-21 12:59:54 -07:00