Commit Graph
34076 Commits
Author SHA1 Message Date
Moti Zilberman b3a7a13ff8 RuntimeTarget refactor - Add RuntimeExecutor to RuntimeTarget
Summary:
Changelog: [Internal]

I'm refactoring the way the Runtime concept works in the modern CDP backend to bring it in line with the Page/Instance concepts.

Overall, this will let us:

* Integrate with engines that require us to instantiate a shared Target-like object (e.g. Hermes AsyncDebuggingAPI) in addition to an per-session Agent-like object.
* Access JSI in a CDP context (both at target setup/teardown time and during a CDP session) to implement our own engine-agnostic functionality (`console` interception, `Runtime.addBinding`, etc).
* Manage CDP execution contexts natively in RN, and (down the line) enable first-class debugging support for multiple Runtimes in an Instance.

The core diffs in this stack will:

* ~~Introduce a `RuntimeTarget` class similar to `{Page,Instance}Target`. ~~
* ~~Make runtime registration explicit (`InstanceTarget::registerRuntime` similar to `PageTarget::registerInstance`). ~~
* ~~Rename the existing `RuntimeAgent` interface to `RuntimeAgentDelegate`.~~
* ~~Create a new concrete `RuntimeAgent` class similar to `{Page,Instance}Agent`.~~
* Provide `RuntimeTarget` and `RuntimeAgent` with primitives for safe JSI access, namely a `RuntimeExecutor` for scheduling work on the JS thread. *← This diff*
  * We'll likely develop a similar mechanism for scheduling work on the "main" thread from the JS thread, for when we need to do more than just send a CDP message (which we can already do with the thread-safe `FrontendChannel`) in response to a JS event.

## Architecture diagrams

Before this stack:
https://pxl.cl/4h7m0

After this stack:
https://pxl.cl/4h7m7

Reviewed By: hoxyq

Differential Revision: D53266710

fbshipit-source-id: df3a181fcc8e033c37a7f4f430f23a29b326b56a
2024-02-14 07:13:19 -08:00
Edmond Chui 496724fbdb Remove URI encoding
Summary:
Changelog: [Internal]

Fixed double-encoding for the websocket url.
`URLSearchParams` already encode the values, passing a pre-encoded `encodeUriComponent` string will cause it to double-encode, making the value unreadable when decoding once.

Missed these lines while splitting the initial diff stack.
Added tests now.

Reviewed By: motiz88

Differential Revision: D53721568

fbshipit-source-id: cfaaa7eb50c40364c904e9ffc5698201df8ab22b
2024-02-14 05:20:46 -08:00
Samuel Susla 3272b05c3d update react renderers with unified feature flags
Summary:
# changelog:
[General][Changed] - sync React renderers to 18.3.0-canary-03d6f7cf0-20240209

Syncs React renderers to https://github.com/facebook/react/commit/03d6f7cf007cb3b2a3a65e6ec29be02aafd87870 which is canary for 18.3.0-canary-03d6f7cf0-20240209.

This includes feature flag changes: https://github.com/facebook/react/commit/36b078cc7a50ad0cd66e7f6b4b8e4a1295e47f67

Reviewed By: javache

Differential Revision: D53704743

fbshipit-source-id: 3f4fd5eddf300217e06b0642acb3c683849c5228
2024-02-14 05:13:17 -08:00
Moti Zilberman 48f1f2d0db RuntimeTarget refactor - Store weak refs to agents in RuntimeTarget
Summary:
Changelog: [Internal]

Applies to RuntimeTarget → RuntimeAgent the same pattern we use for InstanceTarget → InstanceAgent (D53266708) and PageTarget → PageTargetSession: the target has `weak_ptr`s to its agents/sessions so it can (1) dispatch events to them and (2) assert that they are destroyed before the target itself is destroyed.

In RuntimeTarget this will primarily serve as an event dispatching mechanism from JS (single target) to CDP (multiple sessions), with the addition of threading abstractions in upcoming diffs.

Reviewed By: hoxyq

Differential Revision: D53266706

fbshipit-source-id: 64d7226a1aebf00e0ad178f28101a568e9bc6c53
2024-02-14 04:19:35 -08:00
Moti Zilberman 04eadf6a6c RELAND [RN][CDP] [3/n] RuntimeTarget refactor - RuntimeAgent --> RuntimeAgentDelegate
Summary:
This is a resubmission of D53266707 with a fix in the OSS version of `HermesExecutorFactory` (it was incorrectly referencing `HermesRuntimeAgent.h` which doesn't exist anymore). The original diff summary follows.

 ---

Changelog: [Internal]

I'm refactoring the way the Runtime concept works in the modern CDP backend to bring it in line with the Page/Instance concepts.

Overall, this will let us:

* Integrate with engines that require us to instantiate a shared Target-like object (e.g. Hermes AsyncDebuggingAPI) in addition to an per-session Agent-like object.
* Access JSI in a CDP context (both at target setup/teardown time and during a CDP session) to implement our own engine-agnostic functionality (`console` interception, `Runtime.addBinding`, etc).
* Manage CDP execution contexts natively in RN, and (down the line) enable first-class debugging support for multiple Runtimes in an Instance.

The core diffs in this stack will:

* ~~Introduce a `RuntimeTarget` class similar to `{Page,Instance}Target`.~~ (D53233914)
* ~~Make runtime registration explicit (`InstanceTarget::registerRuntime` similar to `PageTarget::registerInstance`).~~ (D53233914)
* Rename the existing `RuntimeAgent` interface to `RuntimeAgentDelegate`.   *← This diff*
* Create a new concrete `RuntimeAgent` class similar to `{Page,Instance}Agent`.   *← Also in this diff*
* Provide `RuntimeTarget` and `RuntimeAgent` with primitives for safe JSI access, namely a `RuntimeExecutor` for scheduling work on the JS thread.
  * We'll likely develop a similar mechanism for scheduling work on the "main" thread from the JS thread, for when we need to do more than just send a CDP message (which we can already do with the thread-safe `FrontendChannel`) in response to a JS event.

## Architecture diagrams

Before this stack:
https://pxl.cl/4h7m0

After this stack:
https://pxl.cl/4h7m7

Reviewed By: EdmondChuiHW

Differential Revision: D53748590

fbshipit-source-id: bd0cf9f74b95abc52b4903f8a7afddcefa303d8a
2024-02-14 04:19:35 -08:00
Rubén Norte b97f3e779a Move Web performance APIs to private directory (#42769)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42769

Changelog: [internal]

These APIs are not currently enabled in OSS, so moving the modules should be safe and not considered a breaking change.

Reviewed By: NickGerleman

Differential Revision: D53267565

fbshipit-source-id: edd3daa7c5043e44e5fd4b1af074093ed3ef4152
2024-02-14 03:58:10 -08:00
Alex Hunt a68ae2e2cc Rename and document monorepo publish script (#42989)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42989

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607805

fbshipit-source-id: 8bbf82c02b54b20404de834800ae49d3fa43baee
2024-02-14 02:57:36 -08:00
Nicola Corti 6a4d011c6b Backport addUIBlock and prependUIBlock to Fabric for Android
Summary:
The `.addUIBlock` and `.prependUIBlock` APIs on UiManagerModule are missing on Fabric.
Here I'm re-implementing them to make migration to Fabric easier.

Set of changes:
- Moved `NativeViewHierarchyManager` to `NativeViewHierarchyManagerImpl` and extracted an interface
- Moved `addUIBlock` and `prependUIBlock` to the shared `UIManager` interface
- Added a `InteropUIBlockListener` class that takes care of executing the UI Blocks, implemented as a `UIManagerListener`

Changelog:
[Android] [Changed] - Changed the API of addUIBlock and prependUIBlock to implement it also in Fabric.

Reviewed By: mdvacca

Differential Revision: D53612514

fbshipit-source-id: 1cddbc391477318064f15c733a380983c3737373
2024-02-14 02:10:48 -08:00
David Vacca cc2a73aa4d Revert initialization of event emits during initial rendering in Fabric
Summary:
Original commit changeset: 0b56b7495db6

Original Phabricator Diff: D53108114

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D53746331

fbshipit-source-id: 95daf5660845eb9a5dd84da85833727aed4e65e3
2024-02-14 00:00:48 -08:00
Nick Gerleman 3b2c4a1834 Partial Back out "[react-native] Move CSSTokenizer to "react/renderer/css""
Summary:
Removes the OSS build logic I added in D53377527, to turn Android build green (target not yet used outside tests).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D53746020

fbshipit-source-id: 6e8a8e111a307b955b838c0522d3d0802e3865c3
2024-02-13 21:51:46 -08:00
Nick Gerleman c9a9e5dc82 Back out "RuntimeTarget refactor - RuntimeAgent --> RuntimeAgentDelegate"
Summary:
This one snuck in with new OSS buid failures after when we had another change cause a failure. Back it out, to get CI passing.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D53745683

fbshipit-source-id: f889bf7541e6f664053d5c0e4851cb448cdbb615
2024-02-13 21:51:46 -08:00
Nick Gerleman f2d09651e0 CSSDeclaredStyle
Summary:
Adds a sparse `CSSDeclaredStyle` structure to represent the collection of declarations from the user, before being further processed/computed. This will later be procssed into computed style.

Also fixes up some bad naming wrt specified value and declared value.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D53696422

fbshipit-source-id: 4258c86a29a0b2251c969b299b5b4703c06696db
2024-02-13 20:13:22 -08:00
Nick Gerleman 516c4ccb71 Fix CSSParser constexpr-iness
Summary:
I originally marked most of this as constexpr, since the code around the variant, and parsing, were already header only and avoiding allocations, and was pretty leaf node.

`reinterpret_cast` and similar is not allowed under constexpr until C++ 26, which `CSSValue` was using. We change our method of storage to a recursively defined union, which is the same underlying implementation of `std::variant` (and is how it is constexpr).

`std::pow` is also not constexpr until C++ 26 which means we can't assign a CSSValue which tokenizes a decimal number... But... constexpr here is more a bonus, and not worth pulling in constexpr math library to do it.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D53696265

fbshipit-source-id: 01442ab9222b3f3ef8ccb01383648fb2e1f747dd
2024-02-13 20:13:22 -08:00
Nick Gerleman 383b90719b Add test for parseCSSProp for prop without keyword specialization
Summary: Didn't have a test for this before. Add one.

Reviewed By: joevilches

Differential Revision: D53537840

fbshipit-source-id: 30872e2dd5b4c35eab7ee66b6f6f322ff0b7735c
2024-02-13 20:13:22 -08:00
Nick Gerleman 2cc0d032bb Flesh out CSSPropDefinition
Summary:
1. Add "initial" values, and whether the prop should be inherited (currently only applies to direction).
2. Add some more border properties that we can replicate with the current data types we support, that are part of valid CSS. These are in ViewProps today instead of YogaStylableProps, but style computation can read both at once.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D53537101

fbshipit-source-id: cce926ba0caba0467493611e3000d1ba396de19e
2024-02-13 20:13:22 -08:00
Nick Gerleman c37fc74212 Add CSSProp and CSSPropDefinition (#42913)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42913

This structures properties into a `CSSProp` enum (so that we can have a runtime-key per style prop), associated with a `CSSPropDefinition` structure which groups the supported types and keywords. This has some niceness of removing the macro bits, but more importantly, means we can query parse related information without a field of the value yet existing (need for sparse storage of CSS values). In the future, it will serve as where we define "initial" values, and likely, the processes for interpolation and inheritance.

We restructure `CSSValueVariant` to not always support keywords, as it may not be a valid possibility for computed values (which do not have CSS wide keywords). Computed values themselves may also reduce more keywords than the global ones (e.g. border width computed value absolutizes keywords).

We also flesh out more of the prop definitions, and parsing. All the properties here relay back to YogaStylableProps of today, but I intentionally filled out the prop definitions a bit more than we do anything with right now (will design higher level to ignore unknown props).

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D53518450

fbshipit-source-id: 1b48ae2513a258d15c5e7fd16ef06f1b6be8dab2
2024-02-13 20:13:22 -08:00
Nick Gerleman a8f239d957 Add <ratio> support to CSSValueVariant and parseCSSValue() (#42879)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42879

Adds support for parsing and storing a component value of the <ratio> CSS basic data type. This would allow removing `processAspectRatio` from viewconfigs later, which we would need for correct substitution of functions/expressions resulting in the ratio numerator/denominator.

This also fleshes out the parser a bit more, and does some renaming, and convention setting.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D53457930

fbshipit-source-id: bed79e05978ed4152c865cdf90701dea779c8622
2024-02-13 20:13:22 -08:00
Nick Gerleman 7e47df0a41 Add CSSValueVariant and parseCSSValue()
Summary:
This adds:
1. `CSSValueVariant`: A union-y type, mapping to a collection of CSS basic data types, and a set of allowed keywords. The aim here is to more closely model the data types after the CSS spec, to allow RN to store them correctly, while not taking up too much space. These types will form the foundation of Yoga prop storage (and probably some other props down the line), so compactness is a priority.
2. `parseCSSValue()`: This uses the previously added Tokenizer, along with parsing rules, to be able to parse a single component value, into a literal keyword, `<length>`, `<length-percentage>`, `<percentage>`, or `<number>`. This will be wired to the props parsing infrastructure.

See D53461299 for an example of what this will look like in props storage.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D53342595

fbshipit-source-id: 3f00dfd7c0ead3dbef4605a61e9859cf69945fe5
2024-02-13 20:13:22 -08:00
Nick Gerleman f63efaf920 Move CSSTokenizer to "react/renderer/css" (#42832)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42832

Various analogs to CSS types and utilities currently exist between `core` and `components/view`. These don't really belong well with either, so this adds a top-level "css" library, and moves `CSSTokenizer` there.

This is statically linked into Fabric binary on Android OSS.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D53377527

fbshipit-source-id: e2d3091ecb3533ecde4d0a08084369b4909532c3
2024-02-13 20:13:22 -08:00
Nick Gerleman 6c2f0888a4 Back out "Migrate flag enablePropIteratorSetter to new system"
Summary:
Original commit changeset: d6fd1e819abb

Original Phabricator Diff: D52810065

Changelog: [Internal]

Reviewed By: lunaleaps, mdvacca

Differential Revision: D53736651

fbshipit-source-id: 5ffd61467af0b87b0bc125c5a4b25575f32642ee
2024-02-13 19:06:21 -08:00
Moti Zilberman 0378941dff RuntimeTarget refactor - RuntimeAgent --> RuntimeAgentDelegate
Summary:
Changelog: [Internal]

I'm refactoring the way the Runtime concept works in the modern CDP backend to bring it in line with the Page/Instance concepts.

Overall, this will let us:

* Integrate with engines that require us to instantiate a shared Target-like object (e.g. Hermes AsyncDebuggingAPI) in addition to an per-session Agent-like object.
* Access JSI in a CDP context (both at target setup/teardown time and during a CDP session) to implement our own engine-agnostic functionality (`console` interception, `Runtime.addBinding`, etc).
* Manage CDP execution contexts natively in RN, and (down the line) enable first-class debugging support for multiple Runtimes in an Instance.

The core diffs in this stack will:

* ~~Introduce a `RuntimeTarget` class similar to `{Page,Instance}Target`.~~ (D53233914)
* ~~Make runtime registration explicit (`InstanceTarget::registerRuntime` similar to `PageTarget::registerInstance`).~~ (D53233914)
* Rename the existing `RuntimeAgent` interface to `RuntimeAgentDelegate`.   *← This diff*
* Create a new concrete `RuntimeAgent` class similar to `{Page,Instance}Agent`.   *← Also in this diff*
* Provide `RuntimeTarget` and `RuntimeAgent` with primitives for safe JSI access, namely a `RuntimeExecutor` for scheduling work on the JS thread.
  * We'll likely develop a similar mechanism for scheduling work on the "main" thread from the JS thread, for when we need to do more than just send a CDP message (which we can already do with the thread-safe `FrontendChannel`) in response to a JS event.

## Architecture diagrams

Before this stack:
https://pxl.cl/4h7m0

After this stack:
https://pxl.cl/4h7m7

Reviewed By: hoxyq

Differential Revision: D53266707

fbshipit-source-id: e14867931d10e1739e6dab6dbd7d3386c685c3c2
2024-02-13 14:45:36 -08:00
Rubén Norte ced4994247 Migrate flag enablePropIteratorSetter to new system (#42432)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42432

Changelog: [internal]

This feature flag is accessed through `CoreFeatures` but it's initialized a few different ways:
* Android: assigned via `ReactFeatureFlags`, which is overridden by apps.
* iOS: `ReactNativeConfig` that's mapped to a dynamic configuration.

This migrates the flag to the new feature flag system.

Reviewed By: mdvacca, RSNara

Differential Revision: D52810065

fbshipit-source-id: d6fd1e819abbc4c3dee9e6221d8f99384f5197f5
2024-02-13 12:33:57 -08:00
Luna Wei 23a66444f7 Fix nightly publish
Summary:
Changelog: [Internal] - `get-and-update-packages` was deleted in D53487874 also actually published the monorepo packages.

Update publish-npm to publish the updated nightly monorepo packages

Reviewed By: cipolleschi

Differential Revision: D53697621

fbshipit-source-id: 21facb49739ba64c43b921117356715be3d8868a
2024-02-13 12:21:20 -08:00
Nicola Corti 1e49f93b19 Fix autolinking for local app Fabric components
Summary:
Autolinking local app fabric component requires user to manipulate the C++ code.
This removes this requirement by generating the code necessary to register all the discovered Fabric Components.

I've updated the RN-Tester Android setup to use this mechanism also.

Changelog:
[Android] [Fixed] - Fix autolinking for local app Fabric components

Reviewed By: cipolleschi

Differential Revision: D53710676

fbshipit-source-id: 667af4bcf7fa99563081330aa64d072faf50863b
2024-02-13 11:29:13 -08:00
Riccardo Cipolleschi 4236538cbd Fix dismissal on the Old Architecture
Summary:
The recent change to make onDismiss work on Fabric broke the Modal on Paper (see [this comment](https://www.internalfb.com/diff/D52959996?dst_version_fbid=236415652884499&transaction_fbid=896066412296150)).

This change will fix that behavior.

The problem was that we were resetting the `isRendered` state only when the Modal receives the event from the Event emitter AND if it has the `onDismiss` callback set.
However, we should hide the component in any case if the ids match, and invoke the onDismiss if it is set.

## Changelog
[iOS][Fixed] - Make sure that Modal is dismissed correctly in Paper

Reviewed By: janeli-100005636499545

Differential Revision: D53686165

fbshipit-source-id: a1de0b29dca7c099e9fa0282ec80cae9a8fd6bc3
2024-02-13 10:51:12 -08:00
Nicola Corti 94bfde4424 Update RNGP to handle cxxModule in codegenConfig
Summary:
RNGP now supports parsing the cxxModule field in codegenConfig and passes it over to codegen.

Changelog:
[Internal] [Changed] - Update RNGP to handle cxxModule in codegenConfig

Reviewed By: cipolleschi

Differential Revision: D53669912

fbshipit-source-id: 702f09ccf793f9205f0c8b54346c5d809695c35d
2024-02-13 09:35:39 -08:00
Nicola Corti 2e3508d6cb Add cxxModule to RN-Tester's codegenConfig
Summary:
This introduces the `cxxModule` field for RNTester where the local TM-CXX modules
are specified.

Changelog:
[Internal] [Changed] - Add cxxModule to RN-Tester's codegenConfig

Reviewed By: cipolleschi

Differential Revision: D53669913

fbshipit-source-id: 97b9985b94efe79566d2d06f6081e65fb66478ff
2024-02-13 09:35:39 -08:00
Phillip Pan 59c5edfe63 resolve getInitialNotification with userInfo dict instead of whole notification
Summary:
Changelog: [Internal]

`getInitialNotification` only expect the user info dictionary of the dictionary, not the complete formatted notification.

Reviewed By: cipolleschi

Differential Revision: D53691569

fbshipit-source-id: 9a24629d2e50544c55ea5cd16097bd88dad950ec
2024-02-13 08:32:47 -08:00
Moti Zilberman 19012ca9ee RuntimeTarget refactor - ensure safe destruction of Instance Agents and Targets
Summary:
Changelog: [Internal]

In D53233914 we copied PageTarget's approach for keeping track of its sessions into InstanceTarget (for keeping track of InstanceAgents). Here we complete that pattern by asserting that the agents are destroyed before their respective targets.

NOTE: We might want to encapsulate this pattern in a helper/template class at some point. For now I'm going with the explicit approach.

Reviewed By: hoxyq

Differential Revision: D53266708

fbshipit-source-id: 4a90fde6c68e87d4667c44f81f8578a7a9072474
2024-02-13 08:14:17 -08:00
Moti Zilberman 415bb718ff RuntimeTarget refactor - Create RuntimeTarget, RuntimeTargetDelegate
Summary:
Changelog: [Internal]

I'm refactoring the way the Runtime concept works in the modern CDP backend to bring it in line with the Page/Instance concepts.

Overall, this will let us:

* Integrate with engines that require us to instantiate a shared Target-like object (e.g. Hermes AsyncDebuggingAPI) in addition to an per-session Agent-like object.
* Access JSI in a CDP context (both at target setup/teardown time and during a CDP session) to implement our own engine-agnostic functionality (`console` interception, `Runtime.addBinding`, etc).
* Manage CDP execution contexts natively in RN, and (down the line) enable first-class debugging support for multiple Runtimes in an Instance.

The core diffs in this stack will:

* Introduce a `RuntimeTarget` class similar to `{Page,Instance}Target`.  *← This diff*
* Make runtime registration explicit (`InstanceTarget::registerRuntime` similar to `PageTarget::registerInstance`).   *← Also in this diff*
* Rename the existing `RuntimeAgent` interface to `RuntimeAgentDelegate`.
* Create a new concrete `RuntimeAgent` class similar to `{Page,Instance}Agent`.
* Provide `RuntimeTarget` and `RuntimeAgent` with primitives for safe JSI access, namely a `RuntimeExecutor` for scheduling work on the JS thread.
  * We'll likely develop a similar mechanism for scheduling work on the "main" thread from the JS thread, for when we need to do more than just send a CDP message (which we can already do with the thread-safe `FrontendChannel`) in response to a JS event.

## Architecture diagrams

Before this stack:
https://pxl.cl/4h7m0

After this stack:
https://pxl.cl/4h7m7

Reviewed By: hoxyq

Differential Revision: D53233914

fbshipit-source-id: 166ae3e25059bd9c9c051a0a3312a3ba78a3935a
2024-02-13 08:14:17 -08:00
Nicola Corti b366b4b42e Back out "Fix autolinking for local app Fabric components"
Summary:
Original commit changeset: 28c376fbd08c

Original Phabricator Diff: D53661231

Reviewed By: cipolleschi

Differential Revision: D53709386

fbshipit-source-id: aab2d99327460cc82591f7de5e6e0296f7695cd6
2024-02-13 07:27:54 -08:00
Moti Zilberman 8a12cfd2d1 Fix UB in SessionState init
Summary:
Changelog: [Internal]

Specifies initial values for `SessionState`'s bool fields to avoid relying on undefined behaviour.

Reviewed By: hoxyq

Differential Revision: D53704064

fbshipit-source-id: 798365a8eed8acea3aa50083bf325a0288765097
2024-02-13 07:14:49 -08:00
Riccardo Cipolleschi 46d7f8a669 Generate code to allow for linking custom Module that conforms to some protocols (#42923)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42923

This Diff implement the logic to:
- Read some lists of class names provided by libraries that conforms to some protocols we defined as extension points.
- Generate a provider in the React-Codegen podspec, whose code lives alongside the app code.
- Glue the app and the generated code together, allowing to link custom protocols

## Changelog
[iOS][Added] - Allow libraries to provide module which conforms to protocols meant to be extension points.

Reviewed By: RSNara

Differential Revision: D53441411

fbshipit-source-id: f53bc6ea0417e6122d8918df2614bcb9937a515a
2024-02-13 06:18:54 -08:00
Nicola Corti f9a5b30e5a Fix autolinking for local app Fabric components (#42962)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42962

Autolinking local app fabric component requires user to manipulate the C++ code.
This removes this requirement by generating the code necessary to register all the discovered Fabric Components.

I've updated the RN-Tester Android setup to use this mechanism also.

Changelog:
[Android] [Fixed] - Fix autolinking for local app Fabric components

Reviewed By: RSNara

Differential Revision: D53661231

fbshipit-source-id: 28c376fbd08c326f117f8d420485d63e2b4b1241
2024-02-13 05:29:24 -08:00
Nicola Corti 922fe91278 Cleanup BUCK artifacts (#42990)
Summary:
Those files are stale from Buck OSS. I'm removing them.
I'm also updating the RN-Tester instructions to be up-to-date.

## Changelog:

[INTERNAL] - Cleanup BUCK artifacts

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

Test Plan: Nothing to test

Reviewed By: NickGerleman

Differential Revision: D53705337

Pulled By: cortinico

fbshipit-source-id: 685fc346870c5f123660cb5af2e30fb64842127a
2024-02-13 05:07:54 -08:00
Dmitry Rykun 6974697b04 Use paperTopLevelNameDeprecated in generated EventEmitters if defined (#42812)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42812

There is a way of defining events where you specify additional string type parameter in the EventHandler in the spec. This additional type parameter is an overridden top level event name, that can be completely unrelated to the event handler name.
More context here D16042065.

Let's say we have
```
onLegacyStyleEvent?: ?BubblingEventHandler<LegacyStyleEvent, 'alternativeLegacyName'>
```
This will produce the following entry in the view config:
```
topAlternativeLegacyName: {
  phasedRegistrationNames: {
    captured: 'onLegacyStyleEventCapture',
    bubbled: 'onLegacyStyleEvent'
  }
}
```
This means that React expects `topAlternativeLegacyName`.
But the generated EventEmitter looks like this:
```
void RNTMyNativeViewEventEmitter::onLegacyStyleEvent(OnLegacyStyleEvent $event) const {
  dispatchEvent("legacyStyleEvent", [$event=std::move($event)](jsi::Runtime &runtime) {
    auto $payload = jsi::Object(runtime);
    $payload.setProperty(runtime, "string", $event.string);
    return $payload;
  });
}
```
The native component will emit `legacyStyleEvent` (`topLegacyStyleEvent` after normalization) that React will not be able to handle.

This issue only happens on iOS because Android doesn't use EventEmitter currently.

To address this issue we'll use `paperTopLevelNameDeprecated` for the generated EventEmitters if it is defined.

Changelog: [iOS][Fixed] - Fixed support for event name override in component specs.

Reviewed By: cortinico, mdvacca, cipolleschi

Differential Revision: D53310654

fbshipit-source-id: 018d5b11d8d36e2ecf900b9d8d6fe3e2ed71f80b
2024-02-13 04:31:25 -08:00
Dmitry Rykun 4d07aae7ef RNTester: add legacy style event to MyNativeViewNativeComponent (#42809)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42809

This diff adds a legacy style event to `MyNativeViewNativeComponent`.
This is a way of defining events where you specify additional string type parameter in the EventHandler in the spec. This additional type parameter is an overridden top level event name, that can be completely unrelated to the event handler name.
In this example it is `onLegacyStyleEvent` and `alternativeLegacyName`.
More context here D16042065.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53310318

fbshipit-source-id: 4dec08c872acdfd09b9939f690fb7bc777149580
2024-02-13 02:47:53 -08:00
Alex Hunt d243cd9ca9 Add Flow and document template init script, simplify args (#42898)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42898

- Add Flow, switch from `yargs` to `parseArgs` (built-in to Node.js, Flow-safe).
- Document script via `--help` output (relevant ahead of reusing this script for local release testing).
- Relocate and add Flow to `setup-verdaccio.js` util.

Also:
- Remove `--reactNativeRootPath` arg.
- Tweak other arg names.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D53484322

fbshipit-source-id: d828e5606bbff032109ecccca9c8f8e337d78626
2024-02-13 02:32:21 -08:00
Alex Hunt 280f37336d Update InspectorFlags to source from ReactNativeFeatureFlags (#42665)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42665

- Replace the internals of `InspectorFlags` to use the new `ReactNativeFeatureFlags` setup.
- Remove call sites to `InspectorFlags::initFromConfig`.

After this diff, all `InspectorFlags` are configured from `ReactNativeFeatureFlags.json`.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D53049790

fbshipit-source-id: 90c2b128a9c316546c3f8f8f88e2c08a9f55ae72
2024-02-13 02:10:19 -08:00
Alex Hunt ce3ce1194b Remove RCTAppSetupPrepareApp overload and InspectorFlags call (#42642)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42642

Removes call to `InspectorFlags::initFromConfig`, since this approach is being replaced with `ReactNativeFeatureFlags`. This change is separated out as it originally made a public API deprecation.

Changelog:
[iOS][Deprecated] - **Un-deprecates** `RCTAppSetupPrepareApp` (reverts #41976)

Reviewed By: motiz88

Differential Revision: D53048207

fbshipit-source-id: 8624020f1e9e19f9f1ee75af9b177e922e36c5d9
2024-02-13 02:10:19 -08:00
Nicola Corti 0575033f76 Do not invoke envinfo on windows
Summary:
CI is broken. Let's not bother attempting to fixing it as it's attempting to call `envinfo` on Windows
which no one really looks into.
Also the maintainer is unresponsive: https://github.com/tabrindle/envinfo/issues/238

Changelog:
[Internal] [Changed] - Do not invoke envinfo on windows

Reviewed By: cipolleschi

Differential Revision: D53698194

fbshipit-source-id: db90ae6e773cf0a2f72ca1fc2d5faa3f56ed2edc
2024-02-13 00:59:26 -08:00
David Vacca f32950a96d Update nullability for usages of handleTouchEvent (#42961)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42961

Update nullability for usages of handleTouchEvent

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D53652922

fbshipit-source-id: ed26bffcbc3ddcfb82605e9e5439f9a9516459fc
2024-02-12 19:20:05 -08:00
Luna Wei 8a94bf0dba Fix CircleCI template tests by excluding dry-run build types
Summary:
Changelog: [Internal] - We still use the `dry-run` build variant in template tests on CircleCI

Previous diff migrated `set-rn-version` to `set-version` for dry-run, prealpha, and nightly build types. I didn't realize that template test flow used `dry-run` builds. I thought it was just for commitlies (which are deprecated).

To properly migrate this site, I need to fix the template test flow to accept monorepo packages at the same version as the dry-run react-native version (1000-<commithash>)

For now, let's just make this change more precise, and only update the nightly flow

See this error: {F1455663616}

Template test flow doesn't fake publish the monorepo packages at this version -- they're still using the versions off of main

Reviewed By: mdvacca

Differential Revision: D53688238

fbshipit-source-id: 6b64baca7eac842f2207fe13a3046b18459228da
2024-02-12 18:42:26 -08:00
David Vacca 282127d6e0 Fix lints in FabricUIManager (#42970)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42970

Fix lints in FabricUIManager

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D53636010

fbshipit-source-id: caab6821377b1bde11d2bed9cc2ef13283b8185f
2024-02-12 15:38:15 -08:00
David Vacca 8cd6f39024 Migrate UIManagerListener to kotlin
Summary:
Migrate UIManagerListener to kotlin

changelog: [internal] internal

Reviewed By: tdn120

Differential Revision: D53672556

fbshipit-source-id: c07d206dacaec9dfcfb4b73a64efbd3e8c4848b6
2024-02-12 13:23:00 -08:00
Luna Wei 2090fe5cf8 Add support for bumping packages on main after release cut (#42958)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42958

Changelog: [Internal] - Add support to `set-version` that we can bump the monorepo packages on main

This should be used after we cut a release branch. The release crew should then run

`yarn set-version 0.next.0-main --skip-react-native-version`

This makes sure we don't update `react-native` on main branch and keep it at 1000.0.0

This essentially replaces:
`yarn bump-all-updated-packages --release-branch-cutoff`
in this step: https://reactnative.dev/contributing/release-branch-cut-and-rc0#12-bump-minor-version-of-all-monorepo-packages-in-main

The reason for this change is to consolidate all the places where we update the version to one place, set-version.

Currently we do this in many fragmented places
* bump-all-updated-packages
* set-rn-version
* get-and-update-packages (deleted in the prev diff)

In the future, I want to get rid of `skip-react-native-version` but we'll need to remove the `1000.0.0` nomenclature. This unblocks us to just use this script for now.

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D53648688

fbshipit-source-id: 4f76366f8d340ec5aeaba1d3a26eba8b18a0166c
2024-02-12 12:07:51 -08:00
Luna Wei 34abd79475 Use set-version for nightly publishes (#42903)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42903

Changelog: [Internal] - Update publish-npm to use `set-version` for nightly builds

Now that `set-version` basically does what `set-rn-version` does, this diff uses this logic for nightlies only (as dry-run/pre-alpha variants are non-functional right now)

This does not change the flow of build-type `'release'` -- that will still use `set-rn-version` via CircleCI ([job](https://fburl.com/code/6xo3ijwg), [script](https://fburl.com/code/bo8np0tb))  We will eventually replace that too but that will be later.

This allows us to delete `get-and-update-packages.js` which was a helper written specifically for updating monorepo packages for nightlies.

The purpose of this is to eventually conform all version updates to use `set-version` in all types of releases (nightlies, stable)

bypass-github-export-checks

Reviewed By: cipolleschi

Differential Revision: D53487874

fbshipit-source-id: 734b528ef5bd095ac68f86701ae105daa30c7d68
2024-02-12 12:07:51 -08:00
Alex Hunt d190ccafd3 Add retry to monorepo publish script (#42964)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42964

We've seen npm publishes fail occasionally in CI as part of this script, most recently in S391653. This change adds a single retry, per package, during the execution of this script, in an attempt to reduce the chance of manual interventions after a broken pipeline.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53607808

fbshipit-source-id: 526d9c33d51ec57702efba3c199bad313c1bf2d4
2024-02-12 10:43:48 -08:00
Alex Hunt 273a5177e0 Use npm as source of truth for updated packages (make publish script rerunnable) (#42944)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42944

Updates `find-and-publish-all-bumped-packages` to use the npm registry as the source of truth, similar to tools like Lerna (`lerna publish from-package`). **This enables safe reruns of the publish script**, and replaces the previous Git-diff-detection implementation.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D53607807

fbshipit-source-id: 135808b7ce36cf463c9f53a8059500b83f8b6679
2024-02-12 10:43:48 -08:00
Alex Hunt b41a33ede9 Move metro-config package into monorepo build, enable TS generation (#41836)
Summary:
This adds `react-native/metro-config` to the monorepo build tool and emits the missing typescript declarations.

Right now, we do have typescript declarations on `metro-config`, but not `react-native/metro-config`. Which makes everything a bit harder extend from "[the default React Native metro config](https://github.com/facebook/react-native/pull/36502)" in Expo.

> Note, I also added the same `exports` block from `react-native/dev-middleware` for conformity.

One open question here is, why aren't we exporting _all_ helper functions from `metro-config`? To me, its a bit weird that we need both `metro-config` _and_ `react-native/metro-config` as `loadConfig` isn't exported.

## Changelog:

[INTERNAL] [FIXED] - Emit typescript declaration files for `react-native/metro-config`

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

Test Plan:
Run the build tool, and check if the typescript declarations are emitted for `react-native/metro-config`.

```
yarn build metro-config
```

Reviewed By: hoxyq

Differential Revision: D51943453

Pulled By: huntie

fbshipit-source-id: cfaffe5660053fc9a9fcbe3dacf7f6ccc2bde01b
2024-02-12 05:20:38 -08:00