Commit Graph

12270 Commits

Author SHA1 Message Date
Nick Gerleman 002396beae Fix cached spannable measurement path (#44409)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44409

This is kind of a mess.

D56800381 moved us away from code relying on legacy TextLayoutManager, under the assumption we weren't using the old one anymore. It turns out we were still using the legacy TextLayoutManager for the sole case of  cached spannables, where we ask FabricUIManager to measure using non-mapbuffer path, and pass the cache key (no underlying attributedstring). After the diff, we call default VM measure function, which returns zero size. This specifically breaks measurements of uncontrolled TextInput components.

This updates that path to use the same TextLayoutManager as we use for everything else.

This model breaks some code which assumes the AttributedString is present, instead of just para attributes. The redundant calls to get fragments is expensive and already something on my radar to fix, but for now, we mostly just no-op, the same way the old TextLayoutManager did when fragments were not set. This needs a good cleanup.

Changelog:
[Android][Fixed] - Fix cached spannable measurement path

Reviewed By: javache

Differential Revision: D56963152

fbshipit-source-id: 6dc0e29f6b63d367be1ba0be82dfbc18c4654ab2
2024-05-03 20:48:27 -07:00
Phillip Pan 05a4232dd5 add forward compatibility for bridgeless CallInvoker API (#44376)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44376

Changelog: [Internal]

In order to make migration a little bit cleaner, I thought it would be nice to implement forward compatibility for RCTCallInvokerModule. This way, the consumer doesn't have to have branching logic when they try to retrieve the callInvoker in their code, and can remove a callsite to the bridge.

Reviewed By: RSNara

Differential Revision: D56807993

fbshipit-source-id: 6c9aa74db15e04b8ab632d230b3e525363a4d1ca
2024-05-03 16:38:26 -07:00
George Zahariev 1d2221ab4e Update hermes-parser and related packages in fbsource to 0.21.0, take 2 (#44395)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44395

Bump hermes-parser and related packages to [0.21.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: SamChou19815

Differential Revision: D56900032

fbshipit-source-id: 073aeb6f538bb4b56bf309fbd3f9edb2f04b30d0
2024-05-03 11:19:05 -07:00
Tim Yung 5062c5256e RN: Define name on Mock Components in Jest (#44399)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44399

Improves the result of `mockComponent` in React Native's Jest environment so that it has an accurate `name` property.

This will be important when React enables deriving component stack locations via error stack frames.

Changelog:
[General][Changed] - `mockComponent` now also mocks `name`

Reviewed By: kassens

Differential Revision: D56914915

fbshipit-source-id: 1bea3e8773c56f70a89d2171c436f85178676373
2024-05-03 08:16:36 -07:00
Pieter De Baets a16f7dc547 Improve spec-compliance of bridgeless timer implementation (#44380)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44380

* setInterval's second argument is optional, and defaults to 0
* setTimeout is spec'ed to return a positive integer.

There's also no need to use HostObjects here to represent the timer index, it just hurts performance and makes this code more complex for no clear reason.

Changelog: [General][Fixed] New architecture timer methods now return integers instead of an opaque object.

Reviewed By: RSNara

Differential Revision: D56863422

fbshipit-source-id: fd3e75303662d865083d01e2bfe8633bac151a0e
2024-05-03 08:04:05 -07:00
Nicola Corti b163ed8655 RNGP - Fix core Autolinking attemping to link dependencies without a android block (#44385)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44385

The current core autolinking is failing if a dependency doesn't have an `android` block.
Instead we should filter out all the dependencies that don't have an `android` definition when generating code.

Fixes https://github.com/reactwg/react-native-releases/issues/276

Changelog:
[Internal] [Changed] - RNGP - Fix core Autolinking attemping to link dependencies without a `android` block

Reviewed By: blakef

Differential Revision: D56876267

fbshipit-source-id: 900b13bec697fceac50c994f277621a10e281410
2024-05-03 01:51:28 -07:00
Phillip Pan 7ea84bd3eb deprecate RCTRuntimeExecutorModule (#44377)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44377

Changelog: [iOS][Deprecated] deprecate RCTRuntimeExecutorModule

After we make CallInvoker available to native modules, we don't need this. Document it and mark it as deprecated.

Reviewed By: RSNara

Differential Revision: D56848799

fbshipit-source-id: 5628eef01a53bfd29d5b89c0398a938bdd87b0ac
2024-05-03 01:29:13 -07:00
Phillip Pan 8f9ff89093 introduce CallInvoker API for bridgeless modules (#44378)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44378

Changelog: [iOS][Added] introduce CallInvoker support in bridgeless native modules

I am adding this API in favor of RCTRuntimeExecutor. CallInvoker is now preferred because after #43375, the CallInvoker has access to the jsi::Runtime. Since the community is using CallInvoker already for their async access use cases, CallInvoker is the preferred choice of RuntimeExecutor / RuntimeScheduler because of easier migration. Also, having a wrapper like CallInvoker will give us more flexibility in the future if we want to expand this API.

Reviewed By: RSNara

Differential Revision: D56807994

fbshipit-source-id: 5c3585356d016a50645eda3af2d3bbe00298b4e4
2024-05-03 01:29:13 -07:00
Christoph Purrer eb1b42fa8b Sort spec members
Summary:
The motiviation of this change is to produce sorted / stable native module schemas which members are alphabetically sorted. The benefit is mainly for verifying test fixtures as now new test cases will be inserted at predicatable spots.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D56741776

fbshipit-source-id: 842af73cac3b4859d2074e6a5206015924e87201
2024-05-02 20:31:50 -07:00
Tim Yung abb7070a51 RN/Relay: Upgrade to React v18.3.1 (#44397)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44397

X-link: https://github.com/facebook/metro/pull/1270

Upgrades `react-native` and `relay` to the newly published `react@18.3.1`.

Changelog:
[General][Changed] - Upgrade to `react@18.3.1`

Reviewed By: jackpope

Differential Revision: D56901818

fbshipit-source-id: 423d35205bb533c6a39c0fed25a1ffea1f0bc12d
2024-05-02 16:18:26 -07:00
Pieter De Baets 88de74b2dc Do not pass ReactContext to getViewManagersMap (#44379)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44379

A common pattern to implement `ViewManagerOnDemandReactPackage` is to use a `getViewManagersMap` helper. If we capture `ReactApplicationContext` there, we will indefinitely retain the the very first ReactApplicationContext, and break/leak across reloads. Instead we should pass the `ReactApplicationContext` whenever we construct the ViewManager.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D56838427

fbshipit-source-id: 76583dd7f5564ed29f0dbfcef33d8d288cbb90e0
2024-05-02 13:25:18 -07:00
Nick Gerleman bbb52c575d Rename TextLayoutManagerMapBuffer to TextLayoutManager
Summary:
Clean this up, now that there is only one TextLayoutManager.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56801446

fbshipit-source-id: 1b81a16031ab520d06d8935000d5019609f8a254
2024-05-02 12:50:15 -07:00
Nick Gerleman 8871b95cda Delete old Android TextLayoutManager
Summary:
No longer used after last diff.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56801475

fbshipit-source-id: 45320418493cb47cc9df192de3dcc73284005fb4
2024-05-02 12:50:15 -07:00
Nick Gerleman 1499e67b39 Remove code relying on non-MapBuffer TextLayoutManager
Summary:
These are all either dead, or duplicate code (e.g. for spannable cache). Let's delete it, so we can get rid of the redundant TextLayoutManager that is no longer getting new updates.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D56800381

fbshipit-source-id: 264c2ede43b765ff094d3d3976ad8535579cc4d9
2024-05-02 12:50:15 -07:00
Ramanpreet Nara 5a8fe43673 <ScrollView/>: Add static ViewConfig for scrollEventThrottle
Summary:
This prop was introduced into horizontal <ScrollView/> in D35735978.

**Note:** This prop did not work for bridgeless mode.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56854758

fbshipit-source-id: 2b25296a065b01f11aa04c2ff06cabf64ff5fce1
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 35f1e308e8 <ScrollView/>: Add static ViewConfig for maintainVisibleContentPosition
Summary:
This prop was introduced for horizontal and vertical scrollview in D40642469.

That diff updated the native view configs only.

**Note:** This prop did not work for bridgeless mode.

Partial fix: Add the prop to vertical scrollview: D54223244

Full fix: this diff.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56854757

fbshipit-source-id: aff2da407f4df4575ceb66d3d381a144fa07a8e9
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 0a8e2c81a9 <ScrollView/>: Add native view config for horizontal
Summary:
horizontal was introduced here: D55367445

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56831754

fbshipit-source-id: 289bb8c5c8fd1c84b84b524d374b31f99766eb04
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 87e8dde9a5 <Image/>: Add native view config for source
Summary:
<Image/>'s source prop was introduced in D51479305.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56831756

fbshipit-source-id: 55d67e74b0dcb5c7b107eac030192b941d8c9d51
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 457372c87e Add native view config for {margin,padding}{block,inline} props
Summary:
The margin/padding props were introduced in this diff: D41267765

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56846578

fbshipit-source-id: 396cab3fdd63d9c630690157a385f1ae53208bb7
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 063ae7d3e8 Add native view config for inset props
Summary:
The insets props were introduced in this diff: D42193661

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56849870

fbshipit-source-id: 7be2a5825086ac954fdb8bc3bb86b57a2fa6d326
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 8c3f8a3e6b Add static view config for onClickCapture
Summary:
onClick was made into a capture event in this diff: D45745906
- Partial fix: D51551255
- Full fix: this diff.

**Note:** This prop did not work for bridgeless mode.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56849867

fbshipit-source-id: 15acc16b162e0dd17513c6452008331e3fee4526
2024-05-02 12:46:05 -07:00
Ramanpreet Nara ef1e84e425 Add native view config for collapsableChildren
Summary:
collapsableChildren was introduced in D56226241

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56849868

fbshipit-source-id: b2b08bfc2b8a35a863a91a53e1bee0b700c50f69
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 5e46712dc8 Add native view config for experimental_layoutConformance
Summary:
experimental_layoutConformance was added in this diff: D47940100

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56849869

fbshipit-source-id: 2346a869aa9d87916d074e54306d3c1230b7a91c
2024-05-02 12:46:05 -07:00
Ramanpreet Nara 3ffdace137 Fix comments in LayoutShadowNode!
Summary: Changelog: [Internal]

Reviewed By: javache

Differential Revision: D56831755

fbshipit-source-id: 04b8c131355d711224085caeb6a26eb4c17db755
2024-05-02 12:46:05 -07:00
Jesse Sahli 1ca35bb211 Revert D56857738: Update hermes-parser and related packages in fbsource to 0.21.0
Differential Revision:
D56857738

Original commit changeset: 6027f529df8a

Original Phabricator Diff: D56857738

fbshipit-source-id: e2725cd97bc6954ddd2494cad28ef34eccc5d104
2024-05-02 12:09:53 -07:00
aleqsio 00b366159d Hotfix privacy manifest aggregation script (#44390)
Summary:
As pointed out by liamjones here:
https://github.com/facebook/react-native/pull/44214#discussion_r1587755403

The original PR did introduce a bug in the `find/first` check, but in my testing, we do need to look at `group.name`, so let's make sure we check both.

This also makes it play nice with an existing file even if it is added to a different directory, by appending to it instead of forcing it to exist in the main group.

## Changelog:

[IOS] [FIXED] - Fix privacy aggregation

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

Test Plan: Tested on rn-tester

Reviewed By: cipolleschi

Differential Revision: D56893594

Pulled By: philIip

fbshipit-source-id: b92589bc2bed9d07e9af20c56a8b9f6c61d864f0
2024-05-02 11:40:07 -07:00
George Zahariev 55dc853d07 Update hermes-parser and related packages in fbsource to 0.21.0
Summary:
Bump hermes-parser and related packages to [0.21.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: pieterv

Differential Revision: D56857738

fbshipit-source-id: 6027f529df8a5e1e3cf3b2d383f399f9e1050e96
2024-05-02 10:30:44 -07:00
Alex Hunt 185f63b0db Add experiment to configure internal debugger branding (#44388)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44388

Towards the open source rollout of the `rn_fusebox.ts` entry point.

NOTE: Requires https://github.com/facebookexperimental/rn-chrome-devtools-frontend/pull/59, but can (and should) be landed safely beforehand.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D56883040

fbshipit-source-id: acee5d53c0f93ef9dc2d498001291b1e35237824
2024-05-02 09:15:30 -07:00
Alex Hunt 817f610983 Update debugger-frontend from 24b0c81...141c8c93
Summary:
This is a major sync, featuring our recent rebase of `chromium/6344`.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D56884975

fbshipit-source-id: bc91f66bfc92464ab8fa99893ab0181077041b79
2024-05-02 09:15:24 -07:00
Blake Friedman b38f80aeb6 update shared build to strip Babel wrapper (#44339)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44339

We require the wrapper code for in repository calls to these packages directly from node (i.e. using CommonJS).  This wrapper code typically sits at the entrypoint of the build packages (i.e. `index.js`).

NOTE: This unblocks an issue preventing me from landing further work on the `helloworld` cli replacing the community template.

## Problem:
The [flow-api-translator](https://www.npmjs.com/package/flow-api-translator) library doesn't allow CommonJS `module.exports` when generating TypeScript Type Defintions.

## Change
1. At the built time, this strips out our wrapper code and sets up the dist/ folder appropriately for npm distribution.
2. Updated the `package.json` files to consistently share Flow types

Changelog: [Internal] refactor build packages output to remove wrapper.

NOTE: Added better error messages when users deviated from the current pattern:
{F1501571608}

Reviewed By: huntie

Differential Revision: D56762162

fbshipit-source-id: f110b31e4ad780998dbc81a2482891ac8d8c6458
2024-05-02 04:00:21 -07:00
Pieter De Baets d280772ea4 Remove manual flattening of pointerEvents in View (#44352)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44352

Confirmed in https://github.com/facebook/react/commit/d779eba4b375134f373b7dfb9ea98d01c84bc48e that style properties already take priority over direct props, so we can avoid flattening style here.

Changelog: [General][Fixed] Small performance tweak to View wrapper to avoid unnecessary style flattening.

Reviewed By: sammy-SC

Differential Revision: D56740899

fbshipit-source-id: ceec3e9665e2f69637c832af7dc59ce2feb65e24
2024-05-01 22:50:10 -07:00
Arushi Kesarwani 63043b79be Fix shouldShowDevMenuOrReload in RELEASE
Summary:
In RELEASE mode, the `devSupportManager` received is ReleaseDevSupportManager for which `showDevOptionsDialog()` & `handleReloadJS()` is a no-op
https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/ReleaseDevSupportManager.java

Which is expected since this is a capability only in Dev mode(useDeveloperSupport = true). However, ATM `shouldShowDevMenuOrReload()` returns true in RELEASE as well which is a bug.

Since there is no need for `shouldShowDevMenuOrReload()` in RELEASE, changing it's logic to introduce that check, early exit and return false in case of RELEASE.

Changelog:
[Android][Fixed] shouldShowDevMenuOrReload() in RELEASE mode

Reviewed By: RSNara

Differential Revision: D56851473

fbshipit-source-id: e9e12b0bec8aead5e9227fcd676459ca54490b61
2024-05-01 21:27:58 -07:00
Arushi Kesarwani bdcc979bab Fix onKeyLongPress() in RELEASE
Summary:
In RELEASE mode, the `devSupportManager` received is ReleaseDevSupportManager for which `showDevOptionsDialog()` is a no-op
https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/ReleaseDevSupportManager.java#L66

Which is expected since this is a capability only in Dev mode(useDeveloperSupport = true). However, ATM `onKeyLongPresss()` returns true in RELEASE as well which is a bug.

Since there is no need for `onKeyLongPress()` in RELEASE, changing it's logic to introduce that check and return false in case of RELEASE.

Changelog:
[Android][Fixed] onKeyLongPress() in RELEASE mode

Reviewed By: christophpurrer, RSNara

Differential Revision: D56850466

fbshipit-source-id: 92d2c8572b32d065f5f9d54e22588bb085b9dcc9
2024-05-01 21:27:58 -07:00
Eric Rozell 67bc65df85 Add C++ header for default TurboModules and cross-platform reuse (#44361)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44361

In order to keep all platforms in sync (Android, iOS, Windows, etc.), it makes sense to consolidate all C++ TurboModules that we want available by default on all platforms to a shared C++ header / implementation.

This moves the duplicated code from Android and iOS to such a shared module provider and updates relevant build specs.

## Changelog

[Internal]

Reviewed By: christophpurrer

Differential Revision: D56835783

fbshipit-source-id: 7322ed054ded5749973885c63257e5caf23b3fc3
2024-05-01 20:16:16 -07:00
John Ward 0383669a4b Only schedule Choreographer callbacks if there's an active animation
Summary:
Changelog: [Internal]
A very similar diff was attempted with D50647971 and reverted in D51617862. The main difference here is all behavior is gated behind the feature flag. Before, we were enqueuing the extra frame callback on start_animating_node even if ondemand choreographer was disabled.

Reviewed By: javache

Differential Revision: D56085369

fbshipit-source-id: fa6335303fe98199b18fa2b4819110afb8efcc0d
2024-05-01 16:41:53 -07:00
Arushi Kesarwani dfa6519749 getJavaScriptContextHolder() in BridgelessReactContext (#44360)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44360

Support `getJavaScriptContextHolder()` in BridgelessReactContext

Changelog:
[Android][Added] - getJavaScriptContextHolder() supported in BridgelessReactContext since it's supported in ReactContext[Bridge]

Reviewed By: philIip, RSNara

Differential Revision: D56834958

fbshipit-source-id: e274adc01b0993012f36224d5afaa3918997c13c
2024-05-01 16:10:04 -07:00
Kudo Chien 539922339b fix ReactActivity.getReactDelegate().reload() (#44223)
Summary:
fixing some problem for `ReactActivity.getReactDelegate().reload()` from https://github.com/facebook/react-native/issues/43521:
- the `reload()` does not work for bridge mode on release build

## Changelog:

[ANDROID] [FIXED] - Fixed app reloading for `ReactActivity.getReactDelegate().reload()`.

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

Test Plan:
tried to temporary change toast.show as reload and test from rn-tester
```diff
 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
+++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/toast/ToastModule.kt
@@ -10,6 +10,7 @@ package com.facebook.react.modules.toast
 import android.view.Gravity
 import android.widget.Toast
 import com.facebook.fbreact.specs.NativeToastAndroidSpec
+import com.facebook.react.ReactActivity
 import com.facebook.react.bridge.NativeModule
 import com.facebook.react.bridge.ReactApplicationContext
 import com.facebook.react.bridge.UiThreadUtil
@@ -30,9 +31,11 @@ public class ToastModule(reactContext: ReactApplicationContext) :
       )

   override public fun show(message: String?, durationDouble: Double) {
-    val duration = durationDouble.toInt()
-    UiThreadUtil.runOnUiThread(
-        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+//    val duration = durationDouble.toInt()
+//    UiThreadUtil.runOnUiThread(
+//        Runnable { Toast.makeText(getReactApplicationContext(), message, duration).show() })
+    val activity = reactApplicationContext.currentActivity as? ReactActivity
+    activity?.reactDelegate?.reload()
   }

   override public fun showWithGravity(
```

tried for different mode
- [x] bridge mode + debug build
- [x] bridgeless mode + debug build
- [x] bridge mode + release build
- [x] bridgeless mode + release build

Reviewed By: fkgozali

Differential Revision: D56795975

Pulled By: arushikesarwani94

fbshipit-source-id: 895eab1927ba6db748ebb32c0fd5313f19cf9d1b
2024-05-01 15:21:44 -07:00
Pieter De Baets 90663081de Expose BaseJavaModule constructors through ViewManager
Summary:
ViewManagers are all BaseJavaModule, and thus have access to methods like `getReactApplicationContext`. We don't expose the appropriate constructors though to pass this context down from the base class.

Not a breaking change, as the no-arg constructor is still used implicitly.

Changelog: [Android][Fixed] ViewManagers can pass context to their base class.

Reviewed By: fabriziocucci

Differential Revision: D56804318

fbshipit-source-id: b0e6b15dfd7786073da058beccfaba2ff30daf5a
2024-05-01 11:49:53 -07:00
Tim Yung 387250112e RN: Configure no-string-refs as Error
Summary:
In a future release of React Native, string refs will no longer be supported. This increases the severity of the `no-string-refs` lint rule to convey this.

Changelog:
[General][Changed] - `no-string-refs` is now a lint error

Reviewed By: kassens

Differential Revision: D56826663

fbshipit-source-id: 603f5b205bb9fd8a5dcb8ee917f6a2ba1ac47e6e
2024-05-01 10:21:18 -07:00
Moti Zilberman 694e8e7dce Document HostFunction dtor threading requirement
Summary:
Changelog: [Internal]

Updates the doc comment on `Function::createFromHostFunction` to
mention that (a copy of) the provided `std::function` may be destroyed
on an arbitrary thread, much like `HostObject` (where this is already
documented).

Reviewed By: neildhar

Differential Revision: D56628194

fbshipit-source-id: 1939602135e83a9c36896c395816054376026edc
2024-05-01 09:25:12 -07:00
Samuel Susla d77f806960 pass trait when shadow node is cloned from update state (#44355)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44355

changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D56765820

fbshipit-source-id: 5bfd2231883c25a0d9149bb07d529da796fd921e
2024-05-01 06:02:06 -07:00
Riccardo Cipolleschi f19371f28d Remove getSurfacePresenter and getModuleRegistry from RCTHost
Summary:
This change removes a couple of method from RCTHost which were not following the iOS convention for names.

We deprecated them in 0.74 and now that the branch is cut, we can remove them.

## Changelog:
[iOS][Breaking] - Remove `getSurfacePresenter` and `getModuleRegistry` from RCTHost

Reviewed By: sammy-SC

Differential Revision: D56633554

fbshipit-source-id: 88fd1525bfe68ca1f6c2d8403d0dec505a23e9f8
2024-05-01 03:54:55 -07:00
Riccardo Cipolleschi 94537c7beb Honor requiresMainQueueSetup in bridgeless mode for ViewManagers
Summary:
We [received an issue](https://github.com/react-native-maps/react-native-maps/issues/5042) in OSS where a ViewManager was configured to be initialized on the main queue, but it wasn't.
This was creating a soft crash and showing a RedBox to the user.
The library was going through the Interop Layer.

This change makes sure that, if the ViewManager is configured to be setup in the main queue, we retrieve the constants from the Main Queue

## Changelog
[iOS][Fixed] - Extract the constants from ViewManagers in the UI Thread if needed.

Reviewed By: sammy-SC

Differential Revision: D56762253

fbshipit-source-id: ca807b34d6e61418da9fd6a639a05f3394879f7c
2024-05-01 03:53:10 -07:00
Rubén Norte c3b7aac143 Migrate enableGranularShadowTreeStateReconciliation from CoreFeatures to ReactNativeFeatureFlags
Summary:
Changelog: [internal]

Migrating this feature flag (which is currently unused) to the new system, so we can test it in production and ship it soon.

Reviewed By: NickGerleman

Differential Revision: D56766553

fbshipit-source-id: 42d44cdd163568564e789cdffe1683e78fe91b53
2024-05-01 03:41:42 -07:00
Gijs Weterings 237ddb4dbf Fix Circle CI builds due to incorrect UnsupportedEnumDeclarationParserError import
Summary:
Changelog: [Internal]

The import style used
```
npm ERR! /home/circleci/react-native/packages/react-native-codegen/lib/parsers/typescript/modules/index.js:13
npm ERR! import {UnsupportedEnumDeclarationParserError} from '../../errors';
npm ERR! ^^^^^^
npm ERR!
npm ERR! SyntaxError: Cannot use import statement outside a module
npm ERR!     at internalCompileFunction (node:internal/vm:73:18)
npm ERR!     at wrapSafe (node:internal/modules/cjs/loader:1175:20)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1219:27)
npm ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1113:32)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:960:12)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1137:19)
npm ERR!     at require (node:internal/modules/helpers:121:18)
npm ERR!     at Object.<anonymous> (/home/circleci/react-native/packages/react-native-codegen/lib/parsers/typescript/parser.js:60:19)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1255:14)
```
is not supported.

Reviewed By: philIip

Differential Revision: D56809538

fbshipit-source-id: 4b42f9e964d49c4fe3c3a4020eb2b3860fdd810c
2024-05-01 03:16:15 -07:00
Soe Lynn a9a7382d95 Fix findNodeAtPoint returns incorrect view
Summary:
This work is based on Ruslan's https://www.internalfb.com/intern/diff/D56185630/

Changelog: [Internal]
`Expectation`: In React DevTools, user should be able to select an element on screen and it will show you what React component rendered it. This doesn't work in RN app that is using JS navigation

`Root Cause`:
In Fabric, when we try to find `ShadowNode` in the `ShadowTree`, `pointerEvents` props are not considered during the lookup of node using coordinate. Hence, in React DevTools when we inspect element, it was hightlighting the overlay `View` with `pointerEvents` props `box-none` was getting highlighted instead of its children view in the hierarchy.

Reviewed By: javache

Differential Revision: D56334314

fbshipit-source-id: ebfe58c5a1516add347c2c21ab5d075f804df8a9
2024-05-01 00:51:59 -07:00
Nick Gerleman 7f5bff48dd Remove "deduplicated" Spannable path
Summary:
This removes the bulk of code added in https://github.com/facebook/react-native/pull/39630.

We're not shipping it, as it caused performance regressions.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D56796936

fbshipit-source-id: 82f3a51cf145bc1695d70393e1f050685a1e6174
2024-04-30 22:30:05 -07:00
Christoph Purrer 536edf3726 Don't support float enums
Summary:
Changelog: [General][BREAKING] Don't support 'float' enums in Turbo Modules

- The current implementation of 'float enums' in C++ does not work as invalid results are returned.
- At potential fix could still cause rounding errors when crossing language bounaries, e.g. `4.6` can become `4.5599999942..`
- C++ enum classes don't support float: https://eel.is/c++draft/dcl.enum#2.sentence-4

> The type-specifier-seq of an enum-base shall name an integral type; any cv-qualification is ignored.

Hence removing the feature of `float enums` for now

Reviewed By: NickGerleman

Differential Revision: D52120405

fbshipit-source-id: 3685ad0629e16ff9db424ba67e07d09df6027553
2024-04-30 21:52:09 -07:00
Jakub Piasecki 12aef32b82 Apply padding to the text attachements (#44258)
Summary:
Paddings are not applied to inline views in text, this PR fixes that.

Closes https://github.com/facebook/react-native/issues/42099

## Changelog:

[GENERAL] [FIXED] - Fixed padding not being applied to inline views in text

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

Test Plan:
<details>
<summary>A simple test case</summary>

```jsx
      <Text style={{paddingHorizontal: 40, paddingVertical: 40, backgroundColor: 'green', width: 300 }}>
        <View style={{backgroundColor: 'red', width: 50, height: 50}} />
        foobar foobar
        <View style={{backgroundColor: 'red', width: 50, height: 50}} />
      </Text>
```

|iOS before|iOS after|Android before|Android after|
|-|-|-|-|
|<img width="502" alt="Screenshot 2024-04-25 at 17 17 50" src="https://github.com/facebook/react-native/assets/21055725/e6981de0-6714-4bb0-a006-547b30374b8a">|<img width="546" alt="Screenshot 2024-04-25 at 17 15 56" src="https://github.com/facebook/react-native/assets/21055725/51e8458b-ad4e-4755-865c-664414bfee55">|<img width="457" alt="Screenshot 2024-04-26 at 11 18 17" src="https://github.com/facebook/react-native/assets/21055725/ac351eff-6d24-40a0-bf7e-0cf3782e9368">|<img width="457" alt="Screenshot 2024-04-26 at 11 17 11" src="https://github.com/facebook/react-native/assets/21055725/3284a79a-157d-43ea-b080-849520e2ee7d">|

</details>

Reviewed By: christophpurrer

Differential Revision: D56789213

Pulled By: NickGerleman

fbshipit-source-id: 2dd0e4bf291e20b3e4c4d73f58079d1abafc3f8e
2024-04-30 20:59:35 -07:00
Alan Lee 639d890dff add missing struct member initialization in Props.h (#44294)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44294

**Problem:**

It was discovered while testing 3 party library, generated member variables in a C++ `struct` in `Props.h` is not initialized.
Also `WithDefault` would not work as well.
(For the problematic case it was a `boolean` but would also apply to other primitive types.)

If there is no default initialization and the component prop is optional and the user of the native component does not set the prop then the variable is never initialized and this is problematic for primitive types in C++ where no initialization results in an undefined behavior.

**Proposed solution:**

(Following C++Core Guideline of [always initialize](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-always).)
Reusing `generatePropsString()` used by `ClassTemplate` to generate props for `StructTemplate` as well.
updated relevant test snapshots.
This change is only concerning the `Props.h` file.

**Changelog:**
[General][Fixed] - fixed `Props.h` created from codegen missing default initializers in C++ `struct`

Reviewed By: cipolleschi

Differential Revision: D56659457

fbshipit-source-id: 0d21ad20c0491a7e8bb718cd3156da65def72f23
2024-04-30 18:29:31 -07:00