Commit Graph

1111 Commits

Author SHA1 Message Date
Erich Graham 45e2941367 Remove folly import in GenerateModuleObjCpp
Summary:
Changelog:

[iOS][Changed]
Replaced folly::Optional with std::optional from C++17 in Objc module generator.

Reviewed By: philIip

Differential Revision: D32367103

fbshipit-source-id: f0d254c4add7d6d2e0bdbceb09a852b4a01ea8c7
2022-03-22 17:10:18 -07:00
Andrei Shikov ca090ac977 Place CONFIGURE_DEPENDS in a right place for generated CMakeLists.txt
Summary:
In the previous template, configure depends was placed after the globbing expression, causing CMake warning.

Changelog: [Internal] - Correct globbing for CMake config in the codegen

Reviewed By: cortinico

Differential Revision: D35044874

fbshipit-source-id: 4f022bfaaec3a84141f4be7de96c56a545639e56
2022-03-22 06:11:36 -07:00
Andrei Shikov 062a6169ce Generate CMakeLists.txt for codegen modules
Summary:
Generates `CMakeLists.txt` for the codegen the same way as we generate Android.mk

Changelog: [Internal] - CMakeLists.txt for codegen targets

Reviewed By: cortinico

Differential Revision: D34821864

fbshipit-source-id: 0cbe7a450a4a064e2285890253ae152fb03267c2
2022-03-15 19:32:22 -07:00
Andrei Shikov 5d5addd661 Separate folly into runtime + folly_futures specific for hermes inspector
Summary:
Rearranges folly_futures configuration into a static library only required for `hermes-inspector` + `folly_runtime` which merges `folly_json` and mutex-related implementations `folly_futures` was used for. As `hermes-executor-debug` is removed by `vmCleanup` configurations later, it allows to shave additional 300KB from the release APK size.

Changelog: [Internal] - Rearrange folly build to reduce APK size

Reviewed By: cortinico

Differential Revision: D34342514

fbshipit-source-id: b646680343e6b9a7674019506b87b96f6007caf2
2022-03-13 15:15:21 -07:00
Scott Kyle 31f0796237 Add codegen for C++ TurboModule automatic type conversions
Summary:
This adds the *option* for C++ TurboModules to use a `*CxxSpec<T>` base class that extends the existing (and unchanged) corresponding `*CxxSpecJSI` base class with code-generated methods that use `bridging::calFromJs` to safely convert types between JSI and C++. If a type conversion cannot be made, then it will fail to compile.

Changelog:
[General][Added] - Automatic type conversions for C++ TurboModules

Reviewed By: christophpurrer

Differential Revision: D34780512

fbshipit-source-id: 58b34533c40652db8e3aea43804ceb73bcbe97a5
2022-03-11 12:47:51 -08:00
Scott Kyle ceeb8ec8b1 Remove need to copy JSI arguments
Summary:
Since the generated functions move JSI arguments as rvalues into these methods, using const lvaue references doesn't provide any benefit, and in fact hinders our ability to *move* arguments somewhere else and instead requires having to confusingly copy them instead (which JSI makes more difficult).

Changelog:
Internal

Reviewed By: nlutsenko

Differential Revision: D34704455

fbshipit-source-id: 520a358d8a7adeb848e7d7eb204f7154f8f4b58d
2022-03-07 19:21:51 -08:00
Scott Kyle 269fa37bb8 Indent C++ method declarations
Summary:
This moves the `indent` function into a `Utils` module so it can be also used to properly indent the abstract methods declarations in a C++ TurboModule spec.

Changelog:
Internal

Reviewed By: nlutsenko

Differential Revision: D34704456

fbshipit-source-id: 88a3a672e4860927b5dd1f5107f40da7b5a83e51
2022-03-07 19:21:51 -08:00
Scott Kyle 402ad82027 Don't crash from wrong types
Summary:
The `get*` methods will assert and thus crash if JS passes a value by the wrong type. Although we have type checking, we should strive to never crash the app if an incorrect value slips by. The `as*` variants will throw an error back into JS instead.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D34630900

fbshipit-source-id: 5ec55ca08ca7a1f43b2d9bfbb1d4e6fa89146e12
2022-03-04 08:02:17 -08:00
Samuel Susla c2e4ae39b8 Add support for C++17 in OSS
Summary: changelog: Add support for C++17

Reviewed By: cortinico

Differential Revision: D34612257

fbshipit-source-id: 88a0307a750f2e0793a639b7a2b670a4571332fe
2022-03-04 07:25:59 -08:00
Ramanpreet Nara f47082be11 Generate Props C++ structs on all platforms
Summary:
The props generator assumes that Props are used only on iOS. (i.e: the generator doesn't generate the props code if the iOS platform is excluded). However, Props are also used on Android. So, this diff makes us generate Props for all platforms.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D34559900

fbshipit-source-id: 0c25835dd57aa55a094152c147a9f952b9bc6850
2022-03-01 16:27:52 -08:00
Paige Sun 3eae11e72f Migrate dev method codegenNativeComponent to be Bridgeless compatible
Summary: Changelog: [Internal] Migrate dev method codegenNativeComponent to be Bridgeless compatible

Reviewed By: RSNara

Differential Revision: D34513074

fbshipit-source-id: d71fbf066453ac8c407d0cf41c2dc7fa80c87688
2022-03-01 13:30:55 -08:00
Ian Childs ff568b0b1f Add label to run genrule locally
Summary: Changelog: [Internal]

Reviewed By: ndmitchell

Differential Revision: D34552708

fbshipit-source-id: 06e1950676713a95622c4ec38be87c9944dadb29
2022-03-01 10:18:40 -08:00
Scott Kyle a0a2958cda Expose C++ TurboModule codegen
Summary:
This adjusts the previously unused (but fully working!) `rn_codegen_cxx_modules` rule to be consistent with the other codegen rules and calls it from the `rn_codegen` with the "JSI" suffix to not conflict with the other rules, and to match the convention established by hand-written C++ TurboModules.

Changelog:
Internal

Reviewed By: RSNara

Differential Revision: D34451208

fbshipit-source-id: 4d779b068dfa4f7fd73fd3bca354fffe86d01f73
2022-02-28 17:08:03 -08:00
Andres Suarez 75348acbfc Fix unnecessary LICENSELINT suppressions
Reviewed By: zsol

Differential Revision: D34526295

fbshipit-source-id: f511370dc3186bc396d68a2e6d5e0931facbeb42
2022-02-28 11:53:40 -08:00
Ian Childs 22ac11a580 Mark some RN genrules as using local filesystem paths
Summary: Changelog: [Internal]

Differential Revision: D34380030

fbshipit-source-id: f444f176b56a7fd93f69936fdae2c81f26b310fe
2022-02-23 09:23:21 -08:00
Andrei Shikov b1a779392d Enable Kotlin build in OSS (#33160)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33160

Enables Kotlin build in RNAndroid, while adjusting the package structure to help with path/package inconsistency.

Moves `react/uimanager/interfaces` files into `react/uimanager` to make sure package name matches with file location and updates Buck configuration to still include it as a separate target.

Changelog: [Android][Changed] - Moved `com/react/facebook/uimanager/interfaces` files into `com/react/facebook/uimanager` to enable Kotlin build

Reviewed By: cortinico

Differential Revision: D34381179

fbshipit-source-id: 252588d9c7f62b8019bdfcce66197628d63e63a1
2022-02-22 10:22:52 -08:00
Ian Childs bb8ddd6c12 Use realpath instead of readlink
Summary:
Changelog: [Internal]

Generated with:

```
python3 codemod.py -d xplat/js --extensions=sh 'THIS_DIR=\$\(cd -P "\$\(dirname "\$\(readlink "\${BASH_SOURCE\[0\]}"' 'THIS_DIR=$(cd -P "$(dirname "$(realpath "${BASH_SOURCE[0]}"'```

Reviewed By: motiz88

Differential Revision: D34379955

fbshipit-source-id: c60521cd6508b203f48ca8c890c450319991c2d4
2022-02-22 02:23:02 -08:00
Paige Sun f8158f8a03 Replace DummyUIManager with BridgelessUIManager. Log errors for deprecated methods in Bridgeless.
Summary:
Changelog: [Internal]

* Rename DummyUIManager to BridgelessUIManager
* Cleanup `RCTVirtualText` & `RCTShimmeringView` since the native changes from T107747313 are already in production, so these two will components always return a viewConfig in prod.

- `console.error` when deprecated Bridge UIManager method are being accessed.
- Make sure new BridgelessUIManager.js has the same method definition as [NativeUIManager.js](https://www.internalfb.com/code/fbsource/[e80c98b816183dcdfde1e81de01ba99aa6e30ed2]/xplat/js/react-native-github/Libraries/ReactNative/NativeUIManager.js?lines=15)

Reviewed By: RSNara

Differential Revision: D34203081

fbshipit-source-id: 99aafc2372b118d0c8cc41f7376e136dabae9bd5
2022-02-14 16:31:15 -08:00
Nicola Corti 327c4d7a08 Place Android.mk dependencies on separate lines for codegen.
Summary:
That's a really nit change, but when we moved the Makefile deps to be on separate
lines, we havent' done the same for the codegen. Here I'm doing it.

Changelog:
[Internal] [Changed] - Place Android.mk dependencies on separate lines for codegen

Reviewed By: ShikaSD

Differential Revision: D34144715

fbshipit-source-id: be9d5fb75b6b93c0b2bb479145053ae6f201e1fc
2022-02-10 09:40:52 -08:00
Ramanpreet Nara 971ba5c26b Re-introduce {eventName}: true ViewConfig ValidAttributes in Static ViewConfigs
Summary:
# Problem
I removed the {eventName}: true entries from ViewConfigs validAttributes in D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a). These entries were iOS-only. I removed them to achieve platform-consistency in native ViewConfigs.

This change broke the onLayout event for all React Native components. So, I reverted D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for native ViewConfigs server-side. But I never got around to reverting D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for static ViewConfigs.

# Changes
This diff reverts D33303950 (https://github.com/facebook/react-native/commit/ca5aaa766329055f206e51b2eaefcba4f282b05a) for Static ViewConfigs, with server-side gating.

Now, these {eventName}: true ViewConfig validAttribute will be inserted into all view configs (static and native) **by default**.

Calling RCTDisableViewConfigEventValidAttributes(YES) on iOS will remove {eventName}: true ViewConfig ValidAttributes entries from Static ViewConfigs. (Previously, this method only removed the entries from native ViewConfigs).

https://www.internalfb.com/code/fbsource/[6615b0675bdf]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=344

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D33933403

fbshipit-source-id: 17823ed99f97d7851f04e5cdab9c95667df13253
2022-02-08 19:11:08 -08:00
Pieter De Baets b0bae21249 Improve error when using mutable object as prop
Summary:
I was trying to add an object property to my ViewManager and got a really opaque error (and I almost thought Objects weren't supported by the codegen) until I realized it expected the object to wrapped in a $ReadOnly type.

Changelog: [Internal] Improved error in codegen

Reviewed By: mdvacca

Differential Revision: D34006557

fbshipit-source-id: b3ab15a40cb66fdcd377f4e68df92060498e8e7f
2022-02-07 09:06:31 -08:00
Paige Sun ab843c5736 Disable static ViewConfigs in bridge mode & enable for bridgeless mode - for codegenNativeComponent
Summary:
Changelog: [Internal]

Since DummyUIManager.getViewManagerConfig() & hasViewManagerConfig() are the same, it's safe to ship this before the native changes in this stack lands.

Reviewed By: RSNara

Differential Revision: D33832926

fbshipit-source-id: c0f0a169d02397e0f9125bb45d95d395c8bbc492
2022-01-28 23:39:38 -08:00
Paige Sun 63605323b0 2/4 Fix RNHostListComponentListRoute to validate SVCs with NVCs
Summary: Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D33715385

fbshipit-source-id: d8d31e92dd934648f8431a508a78e2813c462f8f
2022-01-25 15:23:46 -08:00
Dmitry Rykun 37e5cc966f Bump to version 0.0.13
Summary:
Bump react-native-codegen version to include new fixes and improvements.
Changelog: [internal] Updated react-native-codegen version

Reviewed By: cortinico

Differential Revision: D33684175

fbshipit-source-id: bfc6cb627659c7cdfca2676894bece5f02aff767
2022-01-21 07:30:41 -08:00
Michaël De Boey c279a186fa chore(deps): update jscodeshift (#32905)
Summary:
This will include https://github.com/facebook/jscodeshift/pull/473, which will fix the problems with the `colors` package (see https://github.com/facebook/jscodeshift/issues/474)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Security] - update `jscodeshift`

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

Test Plan: N/A

Reviewed By: cortinico

Differential Revision: D33623209

Pulled By: yungsters

fbshipit-source-id: 38f366cb2e004cca55cd921c61a9e88439c8e784
2022-01-19 10:54:15 -08:00
Nicola Corti 450967938a Do not include Facebook license on users codegen'd code (#32840)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32840

Closes #31516
I've cherry-picked the original PR that had merge conficts + updated all
the headers as the one for the TurboModule generators were not handled.

Original Commit Message from acoates

The codegen generates a Facebook copyright notice at the top of the generated files.

While this might make sense on the core files, this codegen will be run on external components too.
The notice also refers to a LICENSE file in the root of this project, which might not be there if this is run on another project.
I did a quick look at some of the codegen that we ship within windows dev tools, and it looks like we normally just have comments
saying the file was codegen'd and so the file shouldn't be manually edited.
Open to suggestions on what the comment header should say.

Changelog:
[General] [Changed] - Do not include Facebook license on users codegen'd code

Reviewed By: ShikaSD

Differential Revision: D33455176

fbshipit-source-id: b247e72efb242e79d99b388c80e4126633e5234d
2022-01-19 08:07:35 -08:00
Ramanpreet Nara 76613ec4cd Generate one Bubbling/Direct event entry when custom top name is provided
Summary:
## Context
Inside native ViewConfigs, events are declared using these bubbling/direct EventType maps:
```
{
  uiViewClassName: '...',
  bubblingEventTypes: {
    topFoo: {
      registrationName: "onFoo"
    }
  },
  directEventTypes: {},
  validAttributes: {
  },
}
```

**Pattern:** Note that the top name (i.e: topFoo) is just the registration name (i.e: onFoo) but with "on" replaced with "top".

On Android, registration names and top names don't have to follow this pattern. The top name can be **anything.** See ReactionsDockView:

https://www.internalfb.com/code/fbsource/[c430d46ed69a03a9d9f40cefa335a6d8bb92f8ec]/fbandroid/java/com/facebook/feedback/reactions/ui/overlay/react/ReactionsDockViewManager.java?lines=26-28%2C32-34%2C38

Here, ReactionDismissedEvent.EVENT_NAME is "topDismiss"

https://www.internalfb.com/code/fbsource/[c9f92314a5c46e561a831100dab82164808b05d0]/fbandroid/java/com/facebook/feedback/reactions/ui/overlay/react/ReactionDismissedEvent.java?lines=10-11%2C26

And so to provide you the flexibility to specify a custom topName, the codegen supports a customTopName in the direct/bubbling event types:

```
onDismissWithFeedbackReaction: DirectEventHandler<Event, 'topDismiss'>,
```

This generates the two bubbling event type entries in ReactionsDockView:
```
{
  uiViewClassName: '...',
  bubblingEventTypes: {
    // custom top name
    topDismiss: {
      registrationName: "onDismissWithFeedbackReaction"
    },
    // what the top name should actually be
    topDismissWithFeedbackReaction: {
      registrationName: "onDismissWithFeedbackReaction"
    }
  },
  directEventTypes: {},
  validAttributes: {
  },
}
```

**The Problem:** The entry created for "topDismissWithFeedbackReaction" is not necessary. This additional entry creates a discrepancy between ReactionsDockView's static ViewConfig and native ViewConfig. Therefore, this diff removes the second unnecessary entry.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D33418730

fbshipit-source-id: 3988ff6906ad1b2e1ef988a19c64d1e042381ab1
2022-01-11 14:22:14 -08:00
Paige Sun 7c63e0d5bc 3/5 For codegenNativeComponent, with SVC enabled, use UIManager hasViewManagerConfig instead of getViewManagerConfig
Summary:
With SVC enabled for codegenNativeComponent, use `UIManager.hasViewManagerConfig(viewManagerName)` instead of `UIManager.getViewManagerConfig(viewManagerName)` to check for whether the native component is in the app BUCK binary.

This is safe because `global.__fbStaticViewConfig` is gated with MC, and the purpose of SVCs is to stop using `getViewManagerConfig` to get view configs from the Paper view managers. Currently no QEs have SVCs enabled.

Changelog:
[Fabric][JS] For codegenNativeComponent, with SVC enabled, use UIManager hasViewManagerConfig instead of getViewManagerConfig

Reviewed By: RSNara

Differential Revision: D33511365

fbshipit-source-id: 58c7020903137e2b5c80ef34a956be04de51628b
2022-01-10 17:26:37 -08:00
Ramanpreet Nara ca5aaa7663 Remove {eventName}: true from ViewConfig validAttributes
Summary:
For every direct and bubbling event, RCTComponentData (iOS-only) creates a {eventName}: true entry in the component's ViewConfig validAttributes. This entry is unnecessary, and creates a discrepancy between ViewConfigs on iOS vs Android.

This diff removes this entry for all events to:
1. Reduce bloat in native ViewConfigs
2. Create consistency betweeen Android and iOS.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D33303950

fbshipit-source-id: 870c8a2a6d41156ac89bd8554eb09f292bb6108e
2022-01-06 19:09:53 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Luna Wei 679e131972 Fix remaining CircleCI eslint warnings
Summary: Changelog: [Internal] Fix up remaining eslint warnings

Reviewed By: TheSavior

Differential Revision: D33259372

fbshipit-source-id: 5032e64d16a67297068fb8aa8899a07382e944cd
2021-12-21 12:34:28 -08:00
Kevin Gozali fb39d45ed5 C++ - better => butter
Summary:
Renaming the `better` utilities to `butter`:
- to prevent claims that this library is superior to others - it really depends on use cases
- to indicate ease of use throughout the codebase, easily spread like butter

Changelog: [C++][Changed] Renaming C++ better util to butter, used by Fabric internals

Reviewed By: JoshuaGross

Differential Revision: D33242764

fbshipit-source-id: 26dc95d9597c61ce8e66708e44ed545e0fc5cff5
2021-12-20 22:25:14 -08:00
Charles Dudley 821382b9f7 TypeScript Module Tests
Summary:
Tests for Native Modules. Fixtures, Failures and the e2e tests were copied from the flow parser, modified for TypeScript and then the snapshots were diff'ed to ensure the parsers generated the same schema given the same (in spirit, different in syntax) input.

Changelog:
[General][Add] - Tests for TypeScript support for Native Module Codegen spec parsing

Reviewed By: RSNara

Differential Revision: D33081127

fbshipit-source-id: 3d7270dddd568090ec93d475a08a6a6011dad63c
2021-12-20 14:20:22 -08:00
Charles Dudley f9e512e8fe TypeScript Component Tests
Summary:
Tests for Native Components. Fixtures, Failures and the e2e tests were copied from the flow parser, modified for TypeScript and then the snapshots were diff'ed to ensure the parsers generated the same schema given the same (in spirit, different in syntax) input.

Changelog:
[General][Add] - Tests for TypeScript support for Native Component Codegen spec parsing

Reviewed By: RSNara

Differential Revision: D33080789

fbshipit-source-id: ae71d384f6d93da6b89eeb179c4ba7ebcd6ae03d
2021-12-20 14:20:22 -08:00
Charles Dudley f4e32ac5bf Copy Flow parser tests to prepare TypeScript Parser
Summary:
These files are directly copied from the flow parser to aid in reviewing the next two Diffs: D33080789 and D33081127.

The only things that were changed during the copy are the import/require paths to ensure this diff could ship independently. (For this diff, these tests will still test the flow parser instead of importing the typescript parser).

Changelog:
[Internal][Add] - Copy Flow parser tests to aid in Diff review

Reviewed By: RSNara

Differential Revision: D33136296

fbshipit-source-id: 007e18618c9eba13728d19e4e342fbe9642adacc
2021-12-20 14:20:22 -08:00
Charles Dudley 078f6310ba Choose parser based on file extension
Summary:
This adds the main entry point for the TypeScript parser as well as adds the logic to use the new parser if the spec file's extension is `.ts`

`js/react-native-github/packages/react-native-codegen/src/parsers/typescript/index.js` is mostly a direct copy from the flow parser.

Changelog:
[General][Add] - Choose Flow or WIP TypeScript Codegen parser based on spec's file extension

Reviewed By: RSNara

Differential Revision: D33081296

fbshipit-source-id: 267823685e6723e3c1f19752bbbe692e895c075b
2021-12-20 14:20:21 -08:00
Charles Dudley 0d3036abde TypeScript Modules
Summary:
Similar to D33080623, this is the logic for parsing Native Modules and the files were copied from the flow parser and updated for TypeScript. The logic and code path is almost identical to the flow parser.

Also, like D33080623, while there is considerable duplication to the flow parser, I decided there are enough subtle differences to warrant keeping this logic separate.

Changelog:
[General][Add] - Add WIP TypeScript support for Native Module Codegen spec parsing

Reviewed By: RSNara

Differential Revision: D33081035

fbshipit-source-id: 5a196e4693df73c0fb88abafe2b4e6be032ea7ed
2021-12-20 14:20:21 -08:00
Charles Dudley a9632c5ec5 Copy Flow parser modules logic to prepare TypeScript parser
Summary:
These files are directly copied from the flow parser to aid in reviewing the next Diff, D33081035

Changelog:
[Internal][Add] - Copy Flow parser module logic to aid in Diff review

Reviewed By: RSNara

Differential Revision: D33134982

fbshipit-source-id: 9afea2ce15404338fd2c920a8b7eafe980f18688
2021-12-20 14:20:21 -08:00
Charles Dudley 7615bde023 TypeScript Components
Summary:
This is the logic for parsing Native Components. The files were copied from the flow parser and updated for TypeScript specific types and differences in the shape of the AST. The logic and code path is almost identical to the flow parser.

While there is considerable duplication to the flow parser, I decided there are enough subtle differences to warrant keeping this logic separate.

Changelog:
[General][Add] - Add WIP TypeScript support for Native Component Codegen spec parsing

Reviewed By: RSNara

Differential Revision: D33080623

fbshipit-source-id: a68c8d4c4570e65a88a97dcea3cd18a6976c53c7
2021-12-20 14:20:21 -08:00
Charles Dudley c532fcff90 Copy Flow parser components logic to prepare TypeScript parser
Summary:
These files are directly copied from the flow parser to aid in reviewing the next Diff, D33080623

Changelog:
[Internal][Add] - Copy Flow parser component logic to aid in Diff review

Reviewed By: RSNara

Differential Revision: D33130222

fbshipit-source-id: ba7233b17d698793559da8b81bb7e1a78654e614
2021-12-20 14:20:21 -08:00
Charles Dudley 114d5a8a17 TypeScript parser foundation
Summary:
These are utility functions that the TypeScript parser uses and are copied from and follows the same logic as the flow parser with some TypeScript specific changes.  Also added dependency of `babel/parser` as the parsing engine we're using for TypeScript.

Changelog:
[General][Add] - Add foundation for WIP TypeScript parser for Codegen

Reviewed By: RSNara

Differential Revision: D33080527

fbshipit-source-id: d4bd515af549a41f07a2e3ee1a16b5ed678180b2
2021-12-20 14:20:21 -08:00
Charles Dudley 165dfbcc87 Copy Flow parser foundation for TypeScript parser
Summary:
This is a direct copy of the following files from the flow parser:

```
react-native-codegen/src/parsers/flow/errors.js
react-native-codegen/src/parsers/flow/utils.js
```

Changelog:
[Internal][Added] - Copy flow parser foundation files to aid in diff review

Reviewed By: RSNara

Differential Revision: D33137685

fbshipit-source-id: 1345c8bb0785c90b2bd64d4e6e2447f3fdb0ae6b
2021-12-20 14:20:21 -08:00
Ubax 3e6902244a fix: Removes interface only check from third party components GenerateThirdPartyFabricComponentsProvider (#32779)
Summary:
Currently the codegen does not include component with field `interfaceOnly` set to `true` in the `ThirdPartyFabricComponentsProvider`.

These components need to be added to this file, so that non-core components can be used in fabric.

## Changelog

[General [Fixed] - Fixes GenerateThirdPartyFabricComponentsProvider

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

Test Plan:
Run codegen with component outside of core on iOS.

Check if components with and without `interfaceOnly` are added to `RCTThirdPartyFabricComponentsProvider`

Reviewed By: cortinico

Differential Revision: D33235363

Pulled By: ShikaSD

fbshipit-source-id: e7224d2123e4da0da912fe677dae32d3aaea2ec8
2021-12-20 11:45:44 -08:00
Charles Dudley 3a01dc41e6 Flow parser cleanup
Summary:
This diff stack enables codegen to parse TypeScript spec files and generate an identical schema to our current Flow parser.

This first diff is a small cleanup of our current flow parser.

Changelog:
[General][Fixed] - Fix typo in error string and improve consistency in Codegen's flow parser tests

Reviewed By: sota000

Differential Revision: D33080423

fbshipit-source-id: 7bf817761a7704d807a0b809c9f2270354b5c6fa
2021-12-15 15:59:38 -08:00
Alex Koller 2e3bcdfda5 Update prop generator to allow value prop name
Summary:
So I was adding a new HTTPCookie prop to our WebView native component and found that my build was [failing](https://www.internalfb.com/diff/D32602297?dst_version_fbid=338931330931416) due to "redefinition of `value`". Looks like we use the name of the prop as a variable name during codegen, and this can conflict with some other hardcoded variable names. Rather than try and come up with a better prop name, I figured we can just append some string to our codegen name to reduce the chance for conflicts.

Changelog:
[Internal][Changed] - Change codegen variable naming to prevent conflicts to prop names

Reviewed By: JoshuaGross

Differential Revision: D32967807

fbshipit-source-id: 1b3631ec783b229eddfd3c801ffbb397910fc882
2021-12-09 12:02:29 -08:00
Sota Ogo 74f3913128 Version bump
Summary:
I added some functionalities to react-native-codegen to support the new architecture. Publishing the new version so that those are available to use.

Changelog: [internal] Updated react-native-codegen version

Reviewed By: cortinico

Differential Revision: D32941951

fbshipit-source-id: f1ab3d72c76ac153939c634655a4725b4f49d48d
2021-12-08 20:56:35 -08:00
Nicola Corti 28aeb7b865 Do not .lowerCase the library name when codegenerating TurboModule Specs
Summary:
The Codegen is generating a broken output if using the default library name: `Packages<GradleModuleName>Spec`.
This diff is fixing the codegenerator to don't call the `.lowerCase` on the library name when generating the Makefile.

Changelog:
[Android] [Fixed] - Do not .lowerCase the library name when codegenerating TurboModule Specs

Reviewed By: ShikaSD

Differential Revision: D32597578

fbshipit-source-id: dee729a44134d7b3878074507191bb2a1c200608
2021-11-24 11:57:52 -08:00
Ramanpreet Nara 6b1ccef71f Update FabricComponentsProvider to use template functions
Summary:
## Rationale
- Consistency with our other generators.
- Past effort, with rationale: D32021441 (https://github.com/facebook/react-native/commit/3848f48943d0530c3712394b9e405ebddf21cf3b)

Changelog: [Internal]

Reviewed By: sota000

Differential Revision: D32546918

fbshipit-source-id: 5167ca5d7154c0e2fa0867521feaf6a6a382900e
2021-11-18 18:15:34 -08:00
Nicola Corti aa4da248c1 Do not opt-out fbsource/xplat/js/react-native-github/packages from CLANGFORMAT
Summary:
As we're working on C++ code for RNTester to integrate Fabric, we should enable CLANGFORMAT for the files over there.

Changelog:
[Internal] [Changed] - Enable CLANGFORMAT on fbsource/xplat/js/react-native-github/packages

Reviewed By: ShikaSD

Differential Revision: D32493605

fbshipit-source-id: 7b5d63f6d2fae1a1aa1e782738953c8cd2cdbe4b
2021-11-18 04:44:46 -08:00
Evan Yeung 037e346197 Add LTI annotations to xplat/js
Summary:
This diff runs the codemod to add type annotations to function parameters in preparation for Flow's local type inference (LTI) project. I ran the codemod over xplat/js and reverted any files that had flow errors in them. See the list of commands run to see the regeneration of various files.

Changelog:
[Internal][Changed] - Added type annotations

Reviewed By: yungsters

Differential Revision: D32075270

fbshipit-source-id: 6a9cd85aab120b4d9e690bac142a415525dbf298
2021-11-10 15:40:15 -08:00