Commit Graph

870 Commits

Author SHA1 Message Date
David Vacca b7191cde4e Move TurboModule from com.facebook.react.turbomodule -> com.facebook.react.internal.turbomodule (#39682)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39682

Move TurboModule from com.facebook.react.turbomodule -> com.facebook.react.internal.turbomodule

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: RSNara

Differential Revision: D49523696

fbshipit-source-id: fee155f4fb7acf0f28f900c79f7aa38074bec0e6
2023-10-09 19:24:19 -07:00
Sunbreak af7bf9371c Fix typo of JSI module Cpp codegen (#39604)
Summary:
Fix code generatetion comment from `GenerateModuleH.js` to `GenerateModuleCpp.js`

## Changelog:

[GENERAL] [FIXED] - Fix typo of JSI module Cpp codegen

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

Test Plan: None

Reviewed By: christophpurrer

Differential Revision: D49558245

Pulled By: cortinico

fbshipit-source-id: 28b6a6f4da0f5f973717f785fe21db86179f1996
2023-09-25 12:30:34 -07:00
Pieter Vanderwerff 29f62a41b4 Deploy 0.217.0 to fbsource (#39610)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39610

Reviewed By: SamChou19815

Differential Revision: D49522399

fbshipit-source-id: 98dc8ce53a4dea2b68909fda5f92251c6cc91717
2023-09-22 17:29:26 -07:00
Alex Hunt eaec4f7fda Fix Codegen build script on EdenFS (#39566)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39566

Fixes running the `build.sh` script for `react-native-codegen` when on [EdenFS](https://github.com/facebook/sapling). This would previously fail due a filesystem "unable to copy extended attributes" error.

This only affects development within the React Native monorepo. Practically, this equates to a workflow improvement for Meta engineers when creating `RNTester` builds.

NOTE: **This is temporary**. The change from `mv` to `cp -R` makes this script more expensive, which will make Android builds via Gradle take slightly longer. I have a WIP cleanup planned which will 1/ move `react-native-codegen` to the [shared monorepo build setup](https://github.com/facebook/react-native/pull/38718), and 2/ drop this step entirely from the Android Gradle build.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D49468891

fbshipit-source-id: 25d5db81798cf8ab150a135174a45f4d4c2cb5a2
2023-09-21 04:09:43 -07:00
Samuel Susla 7c928fffcc Remove use of folly::F14FastMap from React Native (#39496)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39496

changelog: [internal]

Remove use of folly::F14FastMap in favour of std::unordered_map.

Reviewed By: fkgozali

Differential Revision: D48968297

fbshipit-source-id: fa1e80534f817e1e37f932558c09e418a23383e8
2023-09-18 06:27:45 -07:00
Nick Gerleman 17154a661f C++ 20 all the things (#39454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39454

1. Build with C++ 20 everywhere.
2. Update folly in OSS build to avoid a warning, and let us opt out of heavy bits required for supporting coroutines (we are still more than a year behind).
3. Update the folly podspec for the new version of folly
4. Update the many, many, copy/pasted header search paths for folly dependencies to be able to resolve fmt, now exposed to folly headers
4. Replaces a deprecated atomic usage with equivalent.
5. Fixes a deprecated implicit capturing `this` by value in lambda (same behavior, added a TODO because it seems sus)

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49271685

fbshipit-source-id: 16610f7bcd1032d5796cc11f1cfa92a33d8c2593
2023-09-15 01:17:55 -07:00
Nicola Corti cf33e048dc Remove Codegen buck-oss scripts as they're unused (#39422)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39422

Those scripts were used when Buck OSS was invoking codegen. As we don't do Buck OSS anymore, we can remove them.

Changelog:
[Internal] [Changed] - Remove Codegen buck-oss scripts as they're unused

Reviewed By: huntie

Differential Revision: D49229846

fbshipit-source-id: fad0526e609bab159c56a62b85c91690e4cdbbce
2023-09-13 08:46:52 -07:00
Ruslan Shestopalyuk 0c292f3934 Fix bad formatting of generated C++ code (#39212)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39212

## Changelog:
[Internal] -

Some of the generated C++ code was badly formatted - even though it's normally not supposed to be read by humans, sometimes it's still useful/needed, so it helps when it's more readable.

Reviewed By: christophpurrer

Differential Revision: D48827010

fbshipit-source-id: 3481af68ee6158902007c431e72e631d852c8b3c
2023-08-30 10:40:47 -07:00
Ruslan Shestopalyuk 3c6bf7bf32 Suport type aliases for TM getConstants() return type (#39136)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39136

## Changelog:
[Internal] -

`getConstants()` method  for TM was enforced to only use object literals for the return type specs.

This limits flexibility, in particular those data structures can't be consequently exported and picked up by codegen (not even mentioning the potential need for copypasting those obejct literals around).

This relaxes this restriction.

Note that I've been digging into the development history in order to find out whether there was any particular historical reason for such a limitation, but couldn't find any, so I assume it was rather incidental.

Reviewed By: christophpurrer

Differential Revision: D48620652

fbshipit-source-id: 92d6ba531fc99fb9b25b4957ae123e7832f44ee4
2023-08-24 06:54:03 -07:00
Dr. Sergey Pogodin a323249e0a A fix in Codegen for Windows build host (#36542)
Summary:
Android builds with new arch fail on Windows build host (https://github.com/facebook/react-native/issues/36475). This tiny correction fixes generation of `schema.json` (without it codegen failed to find any files, and generated empty schema). Unfortunately, does not fixes the issue with Windows host entirely, as builds still fail later (on ninja build step).

## Changelog:
[Android] [Fixed] - A bug fix for Android builds with new arch on Windows host.

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

Reviewed By: NickGerleman

Differential Revision: D48563587

Pulled By: cortinico

fbshipit-source-id: acd510308ce9768fb17d3a33c7927de3237748ac
2023-08-22 15:14:06 -07:00
Siddarth Kumar 1d8727966d add emitBuildEventSchema to parser commons (#38810)
Summary:
[Codegen 119] This PR introduces `emitBuildEventSchema` to parser commons and abstracts the logic out of typescript and parser events as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Add `emitBuildEventSchema` to parser commons and update usages.

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

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

## Screenshot of test passing locally:

<img width="1047" alt="Screenshot 2023-08-07 at 8 03 49 AM" src="https://github.com/facebook/react-native/assets/64726664/ab87f004-d9f8-4b5f-800b-0e724430301f">

Reviewed By: rshest

Differential Revision: D48155051

Pulled By: cipolleschi

fbshipit-source-id: a3db3f4783d60681b366a871b1d2ee32eb864bc0
2023-08-08 11:52:26 -07:00
Kyaw Thura ccd191d79a - Extract the content into handleEventHandler (#38805)
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> Extract the content of the if branches that handle the EventHandlers ([Flow](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L131-L151), [TypeScript](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L150-L171)) into a handleEventHandler function in parsers-commons.js. This will take a name, a typeAnnotation, a parser and a findEventArgumentsAndType function as parameters. Use the switch based approach from TypeScript.

## Changelog:

[Internal][Changed]: Extract the content into handleEventHandler

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

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

Reviewed By: rshest

Differential Revision: D48100350

Pulled By: cipolleschi

fbshipit-source-id: 5de6deacd50e87ea0ec96147fff7c14ba55e5368
2023-08-07 03:41:39 -07:00
Facebook Community Bot 305dd4bfe5 Re-sync with internal repository (#38794)
Co-authored-by: Facebook Community Bot <6422482+facebook-github-bot@users.noreply.github.com>
2023-08-04 17:22:07 +01:00
Luiz Ozorio e22d1a10cb Parser create getTypeAnnotationName(typeAnnotation) (#37580)
Summary:
> [Codegen 134 - Assigned to cloudpresser] Create a function getTypeAnnotationName(typeAnnotation) in the Parser base class. Implement it using [this code for Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L211) and [this code for Typescript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L223). Replace the callsites with the new function.

This is part of https://github.com/facebook/react-native/issues/34872

bypass-github-export-checks

## Changelog:

[INTERNAL] [ADDED] - getTypeAnnotationName(typeAnnotation) in parser

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

Test Plan: `yarn jest packages/react-native-codegen` > new tests written, as well as coverage from existing tests

Reviewed By: rshest

Differential Revision: D46439051

Pulled By: cipolleschi

fbshipit-source-id: c0ccddc11b56d77788b4957381fbbaa82d992b01
2023-08-04 03:01:57 -07:00
Denis 5eaf28b247 add emitUnionProp in parser primitives (#38705)
Summary:
[Codegen 131] This PR add a function `emitUnionProp` to the parser-primitives, as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[INTERNAL] [ADDED] - Add `emitUnionProp` function to parser-primitives

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

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

Reviewed By: christophpurrer

Differential Revision: D47921708

Pulled By: rshest

fbshipit-source-id: c2c081c6317928e5eb8b0c1d0640c7b7f40a4b0b
2023-08-01 01:43:31 -07:00
Siddarth Kumar 8bcfc493ea add getPaperTopLevelNameDeprecated to parsers (#38683)
Summary:
[Codegen 135] This PR introduces `getPaperTopLevelNameDeprecated` to parser base class and abstracts the logic out of typescript and parser events as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Add `getPaperTopLevelNameDeprecated` to parser base class and update usages.

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

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

## Screenshot of test passing locally:
<img width="1060" alt="Screenshot 2023-07-30 at 10 04 24 AM" src="https://github.com/facebook/react-native/assets/64726664/3f61377b-9f44-45e8-bece-d4fd6bcc4567">

Reviewed By: cipolleschi

Differential Revision: D47902816

Pulled By: rshest

fbshipit-source-id: 6fab53e02cfc3f0aaa3ffd795c3fe1d2f723e060
2023-07-31 07:52:19 -07:00
Denis 6d5be2630c refactor(codegen): add getLiteralValue in parser (#38651)
Summary:
[Codegen 130] This PR add a `getLiteralValue` function to the Parser interface, which returns the literal value of an union represented, given an option. as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[INTERNAL] [ADDED] - Add `getLiteralValue` function to codegen Parser

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

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

Reviewed By: cipolleschi

Differential Revision: D47912960

Pulled By: rshest

fbshipit-source-id: d9426fef4c0f92c5244d5c4c72202ec29099b76e
2023-07-31 04:56:25 -07:00
Roy Berger f396067cca Add module name constant to class for downstream use (#38295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/38295

Move constant to class instance so customers can use strongly typed name, feedback from D46159001

Changelog:
[Internal] [Changed] - Add module name constant to codegen'd class for downstream use

Reviewed By: christophpurrer

Differential Revision: D47095993

fbshipit-source-id: 741d0d837bf912d6b32e5f12c5df871563d46686
2023-07-11 13:03:17 -07:00
Arushi Kesarwani 2eb25cbdbe Update Node.js to v18 in all RN packages (#37791)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37791

## Bump minimum Node JS version to 18 via `react-native/package.json#engines`

In https://github.com/facebook/react-native/pull/35443 we bumped up the node version from 16 to 18.

Node 16 [ends maintenance releases on 2023-09-11](https://nodejs.org/en/blog/announcements/nodejs16-eol/), and bumping this minimum will allow other associated Node JS tools (CLI, Metro, Jest) to reduce their support burden.

This follows up by formally making Node 18 the minimum supported version.

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

**Changelog:**
[General][Breaking] Bump minimum Node JS version to 18

Reviewed By: cortinico, NickGerleman

Differential Revision: D46583997

fbshipit-source-id: 1f31e2f205ac8b09494c2a7d3b73b9f36eff221b
2023-06-22 09:53:21 -07:00
Brandon Austin a108dcb2ce Move verifyProprsNotAlreadyDefined Function To parsers-commons.js (#37963)
Summary:
Move the `verifyProprsNotAlreadyDefined` functions [from Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js#L220-L229) and [from TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js#LL486-L495) to the parsers-commons.js file. Use the new function in place of the others.

## Changelog:

[Internal] [Changed] - Moved `verifyProprsNotAlreadyDefined` to `parsers-commons.js`

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

Reviewed By: cipolleschi

Differential Revision: D46841711

Pulled By: rshest

fbshipit-source-id: 4c7e85d8e184126d16c520b0e56b4c291babff06
2023-06-20 09:53:47 -07:00
tarunrajput 24f7707418 add emitObjectProp in parser primitives (#37904)
Summary:
This is a follow up PR to https://github.com/facebook/react-native/issues/37872 as it was not merged correctly.

## 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]: Add emitObjectProp in parser primitives

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

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

Reviewed By: cipolleschi

Differential Revision: D46753690

Pulled By: rshest

fbshipit-source-id: a1d0a727222066f3721f62427a51ee0317e06f13
2023-06-15 11:47:37 -07:00
tarunrajput 202b965fed add emitObjectProp in parser primitives (#37872)
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> Create a function emitObjectProp(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L84-L93) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L87-L96) into that function. Use that function in the original call site.

## 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]: Add emitObjectProp in parser primitives

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

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

Reviewed By: cipolleschi

Differential Revision: D46715634

Pulled By: rshest

fbshipit-source-id: 6c58002df132bc5b05a10a19f8611819d7179cb1
2023-06-14 11:53:02 -07:00
Gabriel Donadel b5f52216b0 Add getObjectProperties function to Parser (#37789)
Summary:
[Codegen 128] This PR add a `getObjectProperties` function to the Parser interface, which returns the properties of an object represented by a type annotation as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[INTERNAL] [ADDED] - Add getObjectProperties function to codegen Parser

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

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

Reviewed By: cipolleschi

Differential Revision: D46584748

Pulled By: rshest

fbshipit-source-id: 7f509b6f8754472a9b3048214345dc94265604ba
2023-06-13 07:45:47 -07:00
Nicola Corti 3a246ed024 Remove CallInvoker parameter from toJs method in Codegen (#37832)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37832

This parameter is currently unused and is causing Android builds to fail
as they compile with `-Wall`

This is a follow-up to https://github.com/facebook/react-native/pull/37454/ as that PR updated only the `fromJs` and not the `toJs` method as well.

Changelog:
[Internal] [Changed] - Remove CallInvoker parameter from toJs method in Codegen

Reviewed By: rshest

Differential Revision: D46647110

fbshipit-source-id: 1f3e22aca7a3df11ac02b5c4b89c9311b8b1798c
2023-06-12 12:46:00 -07:00
Randall71 67eb4946e3 (codegen 133) - Parser extractTypeFromTypeAnnotation (#37752)
Summary:
> [Codegen 133 - Assigned to Randall71] Create an extractTypeFromTypeAnnotation(typeAnnotation) function in the Parser base class. Implement it using [this code for Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L193-L197) and [this code for TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L189-L193). Replace the invocation of that function with the one from the parser

This is part of 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

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

Test Plan: yarn jest packages/react-native-codegen > new tests written, as well as coverage from existing tests

Reviewed By: cipolleschi

Differential Revision: D46520245

Pulled By: rshest

fbshipit-source-id: 8c5d8ca8b46fb44399089c6b694998874463ecc8
2023-06-08 14:58:15 -07:00
tarunrajput 942bd615d1 extract buildPropertiesForEvent to parsers-commons (#37714)
Summary:
## 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
-->

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

> Extract buildPropertiesForEvent into parsers-commons.js file. Use the code from either [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L258-L272) or [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L277-L288) which now should be equal. Delete the original ones and use the newly created method instead of those.

[Internal][Changed]: Extract buildPropertiesForEvent and update callsites

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

Test Plan: `yarn test`

Reviewed By: cipolleschi

Differential Revision: D46514046

Pulled By: rshest

fbshipit-source-id: 120e9a09180735f8eeb0419b16eac566d5dcc6ba
2023-06-08 14:39:28 -07:00
Pieter Vanderwerff 08dc0a63ce Update prettier to v2.8.8 (#37738)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37738

Upgrade Prettier to the latest stable version, 2.8.8.

Reviewed By: SamChou19815

Differential Revision: D46403769

fbshipit-source-id: 551d64db0b701a8d3f275900dd8f6324c115a3e6
2023-06-06 20:06:25 -07:00
Siddarth Kumar a497882384 Add function emitMixedProp to parser-primitives (#37608)
Summary:
[Codegen 132] This PR introduces `emitMixedProp` to parser-primitives and abstracts the logic out of typescript and parser events as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Add emitMixedProp  to parser-primitives and update usages.

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

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

## Screenshot of tests passing locally:

<img width="1182" alt="Screenshot 2023-05-28 at 12 46 49 PM" src="https://github.com/facebook/react-native/assets/64726664/dbea4daf-d954-4c7f-b121-c6aad1fb318e">

Reviewed By: dmytrorykun

Differential Revision: D46275638

Pulled By: cipolleschi

fbshipit-source-id: 803d82055c7925e49aca1f408b5c7a50c687349a
2023-06-06 02:31:51 -07:00
MaeIg 663a018709 Extract getTypeAnnotationFromProperty from buildPropertiesForEvent into specific parsers (#37573)
Summary:
This PR aims to remove the duplicated logic in [flow|typescript]/components/events.js files to move it in specific parsers. It is a task of https://github.com/facebook/react-native/issues/34872:
> [Codegen 114 - Assigned to MaeIg] Add a function getTypeAnnotationFromProperty(property) in the Parser object and implement it in FlowParser and TypeScriptParser, using the implementation you can find in the [parsers/flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L174-L177) and parsers/typescript/components/events.js. Use the parsers in the buildPropertiesForEvent.

## Changelog:

[Internal] [Changed] - Extract getTypeAnnotationFromProperty from buildPropertiesForEvent into specific parsers

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

Test Plan:
Flow:
<img width="600" alt="image" src="https://github.com/facebook/react-native/assets/40902940/554bb82d-b492-4550-9a84-254fc4f78285">

Eslint:
<img width="498" alt="image" src="https://github.com/facebook/react-native/assets/40902940/53a302b7-c2aa-4008-9583-2e3b4cddc14c">

Jest:
<img width="395" alt="image" src="https://github.com/facebook/react-native/assets/40902940/c7ff53f1-2be1-4099-b2e6-081128cf5333">

Reviewed By: dmytrorykun

Differential Revision: D46190831

Pulled By: cipolleschi

fbshipit-source-id: 393a4c4968139ee7061ed4ea524d083af6950e38
2023-06-06 02:31:51 -07:00
tarunrajput 8ffaede05a add handleGenericTypeAnnotation in parser-commons (#37525)
Summary:
Part of https://github.com/facebook/react-native/issues/34872
Move the switch construct from [parsers/typescript/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/utils.js#L59-L93) and [parsers/flow/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/utils.js#L56-L81) to the parsers-commons.js file, in a handleGenericTypeAnnotation function. Use that function in place of the switch.

## 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][Added]: Added handleGenericTypeAnnotation in parsers-commons

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

Test Plan: `yarn test`

Reviewed By: cortinico

Differential Revision: D46264650

Pulled By: cipolleschi

fbshipit-source-id: a315ee8cad24d91c9e98e5533d4cdc8b43ebc9a0
2023-06-06 02:31:51 -07:00
Siddarth Kumar e73c00f576 Add getProperties to Parsers and update usages (#37633)
Summary:
[Codegen 138] This PR introduces `getProperties` to Parser base class and implements the function in Typescript and Flow Parsers.
This PR also gets rid of `getProperties` from :
- `packages/react-native-codegen/src/parsers/typescript/components/componentsUtils.js`
- `packages/react-native-codegen/src/parsers/flow/components/componentsUtils.js`
and updates the usages with `getProperties` from the respective parser objects as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Add getProperties  to Parsers base class and update usages.

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

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

## Screenshot of tests passing locally:

![Screenshot 2023-05-31 at 4 38 41 PM](https://github.com/facebook/react-native/assets/64726664/dd660369-eabd-4c2e-a440-a41ed6f9d47a)

Reviewed By: cipolleschi

Differential Revision: D46322882

Pulled By: rshest

fbshipit-source-id: 5506ce5ff395946ea8c1258b152716fea0142b95
2023-06-05 11:48:04 -07:00
ahmadao2214 52154e54a2 Create emitInt32Prop function (#37663)
Summary:
Create a function emitInt32Prop(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L53-L59) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L63-L69) into that function. Use that function in the original call site.

## Changelog:
[INTERNAL][ADDED] - emitInt32Prop in parser-primitves

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

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

Reviewed By: cipolleschi

Differential Revision: D46437495

Pulled By: rshest

fbshipit-source-id: cebe3958c2ad9c4ab9a6c087fee4317b5e57bc58
2023-06-05 07:48:22 -07:00
shubham0142 34c19232d3 refactor(codegen): extract getCommandProperties to parsers-common (#37666)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Extract the buildCommandProperties function ([Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/index.js#L76-L80), [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/index.js#L64-L113)) from the index.js's files to the parsers-commons.js file.

## 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][Added]: Extract getCommandProperties to parsers-common

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

Test Plan: yarn test react-native-codegen

Reviewed By: cipolleschi

Differential Revision: D46437431

Pulled By: rshest

fbshipit-source-id: 578b94b9d9fec90ac91fa2a56c707abc46b05b99
2023-06-05 05:11:19 -07:00
Sam Zhou 0191d16712 Fix bad utility type definitions (#37662)
Reviewed By: panagosg7

Differential Revision: D46364595

fbshipit-source-id: 5dcd484cd292d5b83b0b114675ec3c8059aefe6b
2023-06-01 14:41:00 -07:00
foestauf 1a1e399466 Create a function emitFloatProp (#37500)
Summary:
part of https://github.com/facebook/react-native/issues/34872

> Create a function emitFloatProp(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L69-L75) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L79-L85) into that function. Use that function in the original call site.

bypass-github-export-checks
## Changelog:

[INTERNAL] [ADDED] - emitFloatProp in parser primitves

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

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

Reviewed By: dmytrorykun

Differential Revision: D46073527

Pulled By: cipolleschi

fbshipit-source-id: 556b3aa0e0d330929e006758ec88d0a6889f87bc
2023-05-25 02:59:23 -07:00
Leonardo Rota-Rossi 8ca085c09c Create a function emitDoubleProp (#37515)
Summary:
> Create a function emitDoubleProp(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L61-L67) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L71-L77) into that function. Use that function in the original call site.

bypass-github-export-checks

## Changelog:

[INTERNAL][ADDED] - emitDoubleProp in parser primitves

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

Test Plan: yarn jest packages/react-native-codegen

Reviewed By: cortinico

Differential Revision: D46149450

Pulled By: cipolleschi

fbshipit-source-id: 78381214a79c33d975dff490599d510e8001254e
2023-05-25 02:59:23 -07:00
Luiz Ozorio 706239814e Create emitStringProp function (#37527)
Summary:
> Create a function emitStringProp(name: string, optional: boolean) in parser-primitives.js. Factor out the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L45-L51) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L57-L61) into that function. Use that function in the original call site.

bypass-github-export-checks

## Changelog:

[INTERNAL][ADDED] - emitStringProp in parser-primitves

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

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

Reviewed By: cortinico

Differential Revision: D46144200

Pulled By: cipolleschi

fbshipit-source-id: 076b530905ba7c28cfb2151e29e589026010c3c3
2023-05-25 02:59:23 -07:00
Frank Calise 66f4a9168b Codegen 123: add parser-primitive function for emitBoolProp (#37488)
Summary:
Part of https://github.com/facebook/react-native/issues/34872, Improving Codegen

Reduces code duplication by creating a helper function `emitBoolProp(name: string, optional: boolean)` in `parser-primitives.js`. Refactors the code from [Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/events.js#L37-L43) and [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/events.js#L47-L53) to utilize the new function.

bypass-github-export-checks

## Changelog:

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

Pick one each for the category and type tags:

[INTERNAL] [CHANGED] - Extract contents of the case `BooleanTypeAnnotation` and `TSBooleanKeyword` into a single `emitBoolProp` function

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

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

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

<img width="392" alt="image" src="https://github.com/facebook/react-native/assets/374022/79dae56d-e12d-4be2-9426-50a72e893dfe">

Reviewed By: dmytrorykun

Differential Revision: D46073996

Pulled By: cipolleschi

fbshipit-source-id: 4af67e7e9c3ee1712159c7a647790cb431cfb17a
2023-05-25 02:59:23 -07:00
shubham0142 af8b03d805 refactor(codegen): add throwIfTypeAliasIsNotInterface in error-utils (#37530)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Extract the code that checks whether typeAlias.type is an InterfaceDeclaration ([Flow](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/flow/components/index.js#L76-L80), [TypeScript](https://github.com/facebook/react-native/blob/d8ced6f8953cd896471983714e722caf50783960/packages/react-native-codegen/src/parsers/typescript/components/index.js#L76-L80)) into a throwIfTypeAliasIsNotInteface error. Create this new function in the error-utils.js file.

bypass-github-export-checks

## 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][Added]: Add throwIfTypeAliasIsNotInterface in error-utils

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

Test Plan: yarn test react-native-codegen

Reviewed By: dmytrorykun

Differential Revision: D46143299

Pulled By: cipolleschi

fbshipit-source-id: 3eb0f5d687d3a4f64822540f4f572d872b81828f
2023-05-25 02:59:23 -07:00
Pranav Yadav e240879057 Refactor: Extract findComponentConfig(...) to parsers-commons.js (#37547)
Summary:
This PR extracts the `findComponentConfig(...)` Flow and TS from the `index.js`'s files to the `parser-commons.js` file.

bypass-github-export-checks

## Changelog:

[INTERNAL][CHANGED] - Refactor: Extract `findComponentConfig(...)` from Flow & TS to `parsers-commons.js`

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

Test Plan: - `yarn flow && yarn test packages/react-native-codegen`  → should be green.

Reviewed By: cortinico

Differential Revision: D46143481

Pulled By: cipolleschi

fbshipit-source-id: f9a456b1d58312422b17463ed2b60ee5fda16462
2023-05-25 02:59:23 -07:00
shubham0142 cf8184d5ab refactor(codegen): add undefinedLiteralTypeAnnotation prop in parsers (#37450)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Add an undefinedLiteralTypeAnnotation: string property into the Parser object and implement it in the FlowParser (returning VoidLiteralTypeAnnotation) and in the TypeScriptPArser(returning TSUndefinedKeyword). Replace them in and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L158).

bypass-github-export-checks

## 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][Added]: Add undefinedLiteralTypeAnnotation property in parsers

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

Test Plan: yarn test

Reviewed By: dmytrorykun

Differential Revision: D45904567

Pulled By: cipolleschi

fbshipit-source-id: edd26198e4c8b191a473d5b0ff96a6dc1fec8576
2023-05-25 02:59:23 -07:00
Siddarth Kumar fc927d1fb7 Add getProps to Parsers and fix up usages (#37504)
Summary:
[Codegen 87] This PR introduces `getProps` to the Parser class and implements this function in Typescript and Flow Parsers.

We also get rid of the following files from :
- `packages/react-native-codegen/src/parsers/typescript/components/props.js`
-  `packages/react-native-codegen/src/parsers/flow/components/props.js`

as requested on https://github.com/facebook/react-native/issues/34872

bypass-github-export-checks

## Changelog:

[Internal] [Changed] - Add `getProps ` to Parsers and update usages.

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

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

Reviewed By: cortinico

Differential Revision: D46074152

Pulled By: cipolleschi

fbshipit-source-id: aa6a1a556c9b4a4a6209221f70c8add46ed2d08b
2023-05-25 02:59:23 -07:00
Riccardo Cipolleschi 8dcaa4cc3b Remove duplicated code that resulted after a merge conflict. (#37477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37477

When creating a stack of several codegen fixes, a conflit generated some duplicated code we moved to the parsers from the utils.

This change removes that duplicated cone.

## Changelog:
[Genearal][Fixed] - Remove duplicated code.

Reviewed By: cortinico

Differential Revision: D45979013

fbshipit-source-id: 78cb89df81305221258e283ba5924135d498e800
2023-05-22 03:35:46 -07:00
Riccardo Cipolleschi 718582d3bb Fixing Typo in Codegen's Interface Declaration (#37475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37475

We recently landed a change with a typo in the interface declaration. We just fixed the typo

## Changelog:
[General][Fixed] - Fixed a typo in the interface declaration

Reviewed By: robhogan

Differential Revision: D45978419

fbshipit-source-id: f44dbcd5c1706b9582b997a5eb6c0a82d0e422cc
2023-05-22 03:35:46 -07:00
Lorenzo Sciandra f10dd3f666 bump @babel/* packages (#35787)
Summary:
X-link: https://github.com/facebook/metro/pull/987

While working on https://github.com/facebook/react-native/pull/35786 I noticed some inconsistencies in the versioning for Babel and Flow across the monorepo. So in this PR I wanted to address that so that for 0.72 we'll have the codebase in a more consistent shape.

Happy to split in multiple PRs if needed.

## Changelog
[GENERAL] [CHANGED] - Bump Babel packages to ^7.20.0 (or closest latest release), bump flow parser to 0.206.0 in a few places that were left out from latest bump

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

Test Plan: CI is green.

Reviewed By: cipolleschi

Differential Revision: D42384881

Pulled By: hoxyq

fbshipit-source-id: 21fd43391d12722cf707c3cdbbb36f49c036359d
2023-05-18 14:05:38 -07:00
Christoph Purrer f7dcc65a3f Remove unused jsInvoker from Cxx TM enums (#37454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37454

Raised here: https://github.com/reactwg/react-native-releases/discussions/54#discussioncomment-5914928

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45918922

fbshipit-source-id: 931d2017c37e7327ba472c36e3ac0b29b74d093d
2023-05-17 08:33:36 -07:00
Antoine Doubovetzky f05252ae4e refactor(codegen): extract throwIfArgumentPropsAreNull function in error-utils (#37252)
Summary:
This PR contains task 117 from https://github.com/facebook/react-native/issues/34872:
> [Codegen 117] Extract the code that throws if argumentProps are null in a throwIfArgumentPropsAreNull function in the error-utils.js file. Use it in the [flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L240-L242) and in the [typescript/components/event.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L230-L231) files

bypass-github-export-checks

## 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] - Extract throwIfArgumentPropsAreNull function in error-utils

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

Test Plan: I tested using Jest and Flow commands.

Reviewed By: dmytrorykun

Differential Revision: D45865671

Pulled By: cipolleschi

fbshipit-source-id: 6711dbed0a5ccd56075e0d13ffa13b222979b8c7
2023-05-17 03:45:34 -07:00
Kyaw Thura b5c01ee945 Add a nullLiteralTypeAnnotation: string property into the Parser object (#37387)
Summary:
Part of https://github.com/facebook/react-native/issues/34872
> [Codegen 110] Add a nullLiteralTypeAnnotation: string property into the Parser object and implement it in the FlowParser (returning
NullLiteralTypeAnnotation) and in the TypeScriptParser(returning TSNullKeyword). Replace them in the [parsers/flow/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/components/events.js#L137-L138) and [parsers/typescript/components/events.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/components/events.js#L157).

bypass-github-export-checks

## Changelog:

[Internal][Added]: Add nullLiteralTypeAnnotation property in Parser object

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

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

Reviewed By: dmytrorykun

Differential Revision: D45779075

Pulled By: cipolleschi

fbshipit-source-id: 4ebcf8e1039d7e9188fdfe811fae1720fcba1994
2023-05-17 03:45:34 -07:00
shubham0142 9301c8fea5 codegen 107: add interfaceDeclaration prop in parsers (#37361)
Summary:
part of codegen issue https://github.com/facebook/react-native/issues/34872

> Add a interfaceDeclaration: string property to the Parser class. Implement it in the Flow parser so that it returns InterfaceDeclaration and in the TypeScriptParser so that it returns TSInterfaceDeclaration. Replace the case in the switch  in the [parsers/typescript/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/utils.js#L69) with this prop.

bypass-github-export-checks

## 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][Added]: Add interfaceDeclaration property in parsers

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

Test Plan: yarn test

Differential Revision: D45769316

Pulled By: cipolleschi

fbshipit-source-id: a7f3c6339984e643e3e35fb5b920442aea027b78
2023-05-17 03:45:34 -07:00
tarunrajput 91c60cb365 Codegen 106: add enumDeclaration property in parser class (#37355)
Summary:
Part of Codegen Issue: https://github.com/facebook/react-native/issues/34872

> Add a enumDeclaration: string property to the Parser class. Implement it in the Flow parser so that it returns EnumDeclaration and in the TypeScriptParser so that it returns TSEnumDeclaration. Replace the case in the switch  in the [parsers/flow/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/flow/utils.js#L66) and [parsers/typescript/utils.js](https://github.com/facebook/react-native/blob/e133100721939108b0f28dfa9f60ac627c804018/packages/react-native-codegen/src/parsers/typescript/utils.js#L78) with this prop.

bypass-github-export-checks

## 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][Added] - Add enumDeclaration property in parser class

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

Test Plan: ```yarn test```

Reviewed By: christophpurrer

Differential Revision: D45736088

Pulled By: cipolleschi

fbshipit-source-id: 706a9f1fff52563e12dd6fc54cb0e89c396bba7c
2023-05-17 03:45:34 -07:00