Commit Graph

583 Commits

Author SHA1 Message Date
Scott Kyle 68e4e91bd4 Support optional return types
Summary:
This fixes an issue in the C++ TurboModule codegen where optional return types would result in a compiler error because they were not being defaulted to `null` when converting to `jsi::Value`.

Changelog:
Internal

Reviewed By: javache

Differential Revision: D36989312

fbshipit-source-id: 525f9ce7a5638ba5a655fa69ba9647978030ab0b
2022-06-08 21:15:53 -07:00
Nicola Corti f1c614bd0e Build RN Tester with CMake (#33937)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33937

This moves the build of RNTester from Unix Make to CMake
This will serve as a blueprint for users that are looking into using CMake end-to-end in their buildls.

In order to make this possible I had to:
* Add an `Android-prebuilt.cmake` file that works similar to the `Android-prebuilt.mk` for feeding prebuilt .so files to the consumer build.
* Update the codegen to use `JSI_EXPORT` on several objects/classes as CMake has stricter visibility rules than Make
* Update the sample native module in `nativemodule/samples/platform/android/` to use CMake instead of Make

Changelog:
[Internal] [Changed] - Build RN Tester with CMake

Reviewed By: cipolleschi

Differential Revision: D36760309

fbshipit-source-id: b99449a4b824b6c0064e833d4bcd5969b141df70
2022-06-06 08:07:14 -07:00
Michael Lee (Engineering) 2d66bd4851 Rename the folly headers_only target to warn
Summary:
This target is not a good idea for a number of reasons:
1. It groups up multiple targets which breaks the dependency graph
2. It does not handle dependency remapping correctly
3. It has no mirror into fbcode

We should warn people this is a bad idea

Reviewed By: alexmalyshev

Differential Revision: D36519357

fbshipit-source-id: d60ca3237c7710118732578fecd1b2fc8903321b
2022-05-26 08:17:27 -07:00
Scott Kyle c006722e6c Fix nullability lost on readonly types
Summary:
This fixes an issue where nullability was lost on readonly types in TurboModules specs. The "outside" nullability would be ignored in favor of only respecting the "inside" nullability (i.e. `?$ReadOnly<{}>` vs `$ReadOnly<?{}>`). It now ensure either is propagated correctly.

Changelog:
[General][Fixed] Fix nullability lost on readonly types in TurboModule specs

Reviewed By: RSNara

Differential Revision: D36615346

fbshipit-source-id: 42408d9298703f4c382657f573480d2574d6c973
2022-05-24 19:35:29 -07:00
Scott Kyle 3c569f546c Support mixed types only for C++
Summary:
There are cases where we want to pass arbitrary types to a TurboModule, which may then handle the values appropriately, but we haven't supported this use case. Since C++ TurboModules can accept any `jsi::Value` (unlike Java/ObjC) and we have real-world need for this (otherwise we must require JSON serialization), this now allows `mixed` (`unknown` in TypeScript) for C++-only TurboModules.

Changelog:
[General][Added] C++ TurboModule methods can now use mixed types

Reviewed By: RSNara

Differential Revision: D36611299

fbshipit-source-id: bbf29dfcc6aed67e213bb3eab06537c18c7db1fe
2022-05-24 19:35:29 -07:00
Pieter De Baets 5451f890a1 Cache method IDs in JavaTurboModule
Summary:
Codegen a static field for every caller of `invokeJavaMethod` to cache the jmethodID that should be used for the method, which saves us a string-based name lookup at invocation time.

Changelog: [internal]

Reviewed By: genkikondo

Differential Revision: D36376056

fbshipit-source-id: 298430746a8f25a5337aba05b56876ba789e2344
2022-05-18 09:12:10 -07:00
Pieter De Baets 3337add547 Pass string by ref in TurboModule lookup path
Summary:
Avoid unnecessary string copies

Changelog: [internal]

Reviewed By: nlutsenko

Differential Revision: D36312750

fbshipit-source-id: caf0985f988eb497de3be3c0526809593b01a9e2
2022-05-13 07:12:48 -07:00
Nicola Corti 2a274c1a08 Bump React Native Codegen to 0.70.0
Summary:
I'm updating the versioning schema of `react-native-codegen` to use minor instead of patch versions.

Historically we used to use a version as `0.0.15` and incrementally bump it.
Today, we had to do released a patched version of `react-native-codegen` for React Native 0.68.

Therefore, we're moving to use a versioning scheme as `0.<RN-VERSION>.x` which gives more flexibility and allows us to follow-up on specific version of the codegen for every RN version, should we need to.

`react-native-codegen` 0.70 is essentially a re-publishing of 0.0.16 from `main`

Changelog:
[General] [Changed] - Bump React Native Codegen to 0.70.0

Reviewed By: motiz88

Differential Revision: D36244307

fbshipit-source-id: 475615e5dbc4e6bc850f64110c060a1c87544292
2022-05-09 09:23:20 -07:00
Anandraj Govindan 883a93871c Working around Long paths limitation on Windows (#33784)
Summary:
Cherry picking https://github.com/facebook/react-native/pull/33707 to main branch

This change is extending the changes made by alespergl to reduce the file paths and command lengths of ndk build commands
Essentially we are shortening the length of the source files by using relative paths instead of absolute paths as enumerated by the wildcard expression
This commit is extending the fix by including all the new modules introduced into RN for the new architecture, including the generated modules.
We are also reverting the ndk bump as ndk23 is crashing frequently when building RN with new arch. The reduced file paths lengths ensures the ndk bump is not required for relatively short application paths.

Fix building RN with new architecture on Windows boxes by using relative paths for C++ sources

## Changelog

Fix building RN with new architecture on Windows boxes by using relative paths for C++ sources

[CATEGORY] [TYPE] - Message

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

Test Plan: Verified building on windows box

Reviewed By: javache

Differential Revision: D36241928

Pulled By: cortinico

fbshipit-source-id: 1ce428a271724cbd3b00a24fe03e7d69253f169b
2022-05-09 04:42:53 -07:00
Pieter De Baets 9d3d5e13f0 Switch buck schema codegen to yarn_workspace_binary (#33773)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33773

I noticed this was a very slow part of my build because each instance of the binary would run its own yarn install. Instead use the yarn_workspace approach to share a single yarn setup.

Changelog: [Internal]

Reviewed By: d16r

Differential Revision: D36164350

fbshipit-source-id: 5290587010fe6021b758bda98bf01995fdf14acd
2022-05-06 04:31:37 -07:00
Nicola Corti b9bb30b1ad Bump React Native Codegen to 0.0.16 (#33749)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33749

Yet another bump of the Codegen to ship new features for RN 0.69

Changelog:
[Internal] [Changed] - Bump React Native Codegen to 0.0.16

Reviewed By: cipolleschi

Differential Revision: D36096803

fbshipit-source-id: 46e118f633eff2abf636737e69718e8fcb3608ed
2022-05-04 04:04:10 -07:00
Riccardo Cipolleschi e4d0153a67 Update CodeGen to leverage the outputDir as suggested in diff review (#33729)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33729

This PR addresses [this comment](https://www.internalfb.com/diff/D35820848?dst_version_fbid=496290878846487&transaction_fbid=355967423221044).

It makes the CodeGen to the `outputDir` as base directory for the codegen.

Finally, it updates the unit tests accordingly.

## Changelog
[iOS][Changed] - use `outputDir` as base directory for the codegen and remove the possibility to customize the intermediate path. The generated code requires specific paths in the `#include` directive.

Reviewed By: cortinico, dmitryrykun

Differential Revision: D35935282

fbshipit-source-id: a9ad4e296efb042cf34b20db5eebb59614beb5f6
2022-05-04 04:04:10 -07:00
Riccardo Cipolleschi 6718500eaa Support the type == all properly
Summary:
This Diff introduces some changes in the CodeGen to properly generate the types in the right folder.

## Issue
The codegen on iOS defines the output folder once, before creating the generated code.
When the code we have to generate is just a TurboModule (TM) or a Fabric Component (FC), this mechanism works properly.

However, if a library has to generate both TM and FC, actually using the library type `all`, all the code is generated using the TurboModules' output folder.
(**Note:** Android only works in this way)

This generates invalid code because all the FC's `#import` directives assumes that the code is generated in the FC output path which, in this case, is not.

## Solution

The adopted solution moves the responsibility to decide where the files has to be generated to the CodeGen step instead of in the preparatory phases.

The two paths are precomputed in the `generate-artifacts.js` script (the entry point for the CodeGen) and they are passed to all the scripts that requires them.

Once they reach the `RNCodegen.js` file, the generators creates the files and save them in the proper paths.

## Changelog
[iOS][Changed] - CodeGen now supports the `"all"` library type.

Reviewed By: cortinico, dmitryrykun

Differential Revision: D35820848

fbshipit-source-id: ce7f5393936e2ae17f8b2c970f6a011d27f641f2
2022-05-04 04:04:10 -07:00
George Zahariev e7d9e4dbb5 Collapse object initialization in Xplat
Summary:
Collapse multiline object initialization into one single object literal (as much as possible).

Run codemod (requires temporary xplat task runner config changes), then manual fixes.

```
./scripts/typedjs/flow/runner codemod lti/collapseObjectInitialization ~/fbsource/xplat/js/
```

- Announcement: [post](https://fb.workplace.com/groups/flowlang/posts/903386663600331)
- Support group: [Flow Support](https://fb.workplace.com/groups/flow)

drop-conflicts

Format:
```
arc f
```
Sort imports
```
hg l -n | xargs js1 lint --fix --rule 'fb-tools/sort-requires'
```

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D36112168

fbshipit-source-id: 23db87c3bd8ffe693019ffeb5ac8300ec46c8532
2022-05-03 21:55:01 -07:00
Nicola Corti 208422fe8e Bump React Native Codegen to 0.0.15
Summary:
For RN 0.69, we want to ship all the changes we have on master
for React Native Codegen.

Changelog:
[Internal] [Changed] - Bump React Native Codegen to 0.0.15

Reviewed By: cipolleschi

Differential Revision: D35964934

fbshipit-source-id: d6b6c36a9a077cb53113907ea59da3148e18e5cd
2022-04-28 04:18:28 -07:00
John Wang ffaa5d69bc Add @Nullable to WritableMap and WritableArray for Android Java spec generator
Summary:
We're adding a native module that returns a Nullable type. This makes the Java spec and the implementation to be the same.

Changelog:
[Android][Added] - Generate `Nullable` for optional objects and arrays in module codegen.

Reviewed By: yungsters

Differential Revision: D35651333

fbshipit-source-id: d73c87340e33cf79831915ce6892e457ef369175
2022-04-22 16:55:29 -07:00
Rob Hogan 47d742ae58 Update graceful-fs->^4.2.4, micromatch->^4.0.4
Summary:
A couple of semver-minor/patch dependency bumps to reduce the number of distinct requirements across the repo.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D35748473

fbshipit-source-id: 270c9a1b828aba20e03ac27600eb3a6e4ce2f0ec
2022-04-19 18:56:51 -07:00
Scott Kyle 3c1a814465 Fix visibility of C++ TM spec library when focusing
Summary:
This fixes an oversight where focusing fails if a C++ TurboModule is in the build graph. See line 391 in `rn_codegen_components` that does the same thing.

Changelog:
Internal

Reviewed By: mdvacca

Differential Revision: D35663755

fbshipit-source-id: d7d2e0109fd536586292d333b7d53b7b2e948d86
2022-04-15 11:08:31 -07:00
Scott Kyle c7380ba113 Support function return types
Summary:
This adds the option for a TurboModule spec to use a "Cxx" suffix to unblock additional capabilities. This extends the pattern where TurboModules can have an "Android" or "IOS" suffix to exclude codegen for the other platform. When in `cxxOnly` mode, the parser will allow function return types (and additional features will be added over time).

Changelog:
[General][Added] C++ TurboModule methods can return functions

Reviewed By: christophpurrer

Differential Revision: D35364346

fbshipit-source-id: 768eb0ec2a1cbe3e458466064247d7e7f01135ff
2022-04-05 00:37:53 -07:00
Scott Kyle 6e0fa5f15e Support optional types for C++ TurboModules
Summary:
Update C++ TurboModule codegen to wrap nullable types in `std::optional` whereas before the conversion would cause a crash.

Changelog:
Internal

Reviewed By: mdvacca, nlutsenko

Differential Revision: D35299708

fbshipit-source-id: 7daa50fe8b16879c5b3a55a633aa3f724dc5be30
2022-04-01 16:58:52 -07:00
Wei Han 0353852297 fix //xplat/js/react-native-github:codegen_rn_components_schema_rncore (#33518)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33518

Changelog: [Internal]

When building with buck2, `setup_env_vars.sh` cannot be found. exporting setup_env_vars.sh and adding it as a dep to `write_to_json` fixes it.

Reviewed By: d16r

Differential Revision: D35188154

fbshipit-source-id: e1e1be4c83a57e443a181efaf1af3e6c8e6452f9
2022-03-30 14:12:50 -07:00
Nicola Corti 94d0afe6e3 Bump codegen to 0.0.14 (#33475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33475

To unblock the broken iOS circle ci, I'm bumping codegen to 0.0.14

Changelog:
[General] [Changed] - Bump codegen to 0.0.14

Reviewed By: ShikaSD

Differential Revision: D35079748

fbshipit-source-id: 703773ec2a5fd864b9c9a2f8d29359a4046c18a4
2022-03-23 11:50:27 -07:00
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