Commit Graph

12270 Commits

Author SHA1 Message Date
Nick Gerleman bc6105016c Add standards based lexer/tokenizer for CSS values (#42626)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42626

Right now this is done by some combination of string splitting, JS side regexing, etc. This will not scale for math expressions, and gets more and more annoying when we try to add more.

In preparation for adding more units, this adds a tokenizer/lexer for a subset of CSS grammar, based on the spec. This is not hooked up to anything yet, and doesn't add a parser.

The algorithm uses a subset of the comprehensive instructions provided at https://www.w3.org/TR/css-syntax-3/#tokenizer-algorithms as a reference, with some major simplifications.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D53030661

fbshipit-source-id: c48bc572c5e02daee0b05e91830f2441528193d1
2024-01-29 17:47:30 -08:00
Nick Gerleman 359738b6ca Remove redundant std::hash enum specializations (#42651)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42651

Lots of boilerplate to define hash functions for different enums, so we can use them in `hash_combine`. This should not be needed, and seems like it might have been an artifact of older C++ version of standard library with bugs.

https://en.cppreference.com/w/cpp/utility/hash

> In addition to the above, the standard library provides specializations for all (scoped and unscoped) enumeration types. These may be (but are not required to be) implemented as std::hash<std::underlying_type<Enum>::type>.

Also moves `hash_combine` SFINAE to concepts for clarity and better error messages.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D53074535

fbshipit-source-id: 5fcb653dbe4aa51aa3d9d96f1511da3b7541270d
2024-01-29 17:39:49 -08:00
Nick Gerleman 3a789a1776 Fixup bad ANDROIDLINT Automatic Fix (#42694)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42694

D53115471 commited all the automatically fixable lints by `ANDROIDLINT`. When I looked again, closer, there was one automatic fix that I'm fairly sure is incorrect.

Before:

`outTransform.postTranslate((int) (dx + 0.5f), (int) (dy + 0.5f));`

After:

`outTransform.postTranslate((dx + 0.5f), (dy + 0.5f));`

I think the linter did this because the underlying API accepts a float, so this was (incorrectly) seen as an extraneous cast causing precision loss, but the previous behavior was using the cast and addition to round the float, instead of adding 0.5 to it.

This replaces the call with an explicit rounding, for the same behavior as before (though, I'm not sure if the rounding is intentional, since in and out are both fp).

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D53158801

fbshipit-source-id: d268a5c429663dd7da0bfce2d717589986601196
2024-01-29 13:27:11 -08:00
Samuel Susla 29df29f5e2 update react fabric renderers (#42712)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42712

changelog: [General][Changed] react@18.3.0-canary-b2d637128-20240123

Move open source React renderer to react@18.3.0-canary-b2d637128-20240123

Reviewed By: javache

Differential Revision: D53085842

fbshipit-source-id: adbf04aae12a626e88c6a4e16f78b28787f7ce12
2024-01-29 12:47:55 -08:00
Samuel Susla 39cb02f6f1 explicitly dirty yoga node when cloned in case parent is dirty (#42711)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42711

changelog: [internal]

Reviewed By: NickGerleman

Differential Revision: D53130776

fbshipit-source-id: b85a90835698ef5199622edcb64f64273d32724a
2024-01-29 12:30:12 -08:00
Riccardo Cipolleschi 5bf5f4b150 Remove dependency on PropsParserContext (#42616)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42616

PropsParserContext is an entity in Core with a lot of baggage. We used it in graphics only to access the `surfaceId` and the `contextContainer`. We don't need to bring to graphics the whole dependencies of core due to these two parts.

This change break the dependency by passing along only the elements that we actually need.

## Changelog
[Internal] - break dependencies between graphics and core by removing the include of the PropsParserContext

Reviewed By: sammy-SC

Differential Revision: D52999204

fbshipit-source-id: a4b92fc11238f5caa63e39a6e286273ab671c8de
2024-01-29 12:03:27 -08:00
Ilia Vorobev 5d559c1ff4 Removes QPL from github (#42641)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42641

This removes QPL from public github repo
Changelog: [internal]

Reviewed By: rubennorte

Differential Revision: D53041914

fbshipit-source-id: 68bea613fd50242233145cbfb34f483b01c8e086
2024-01-29 11:48:27 -08:00
HoonJoo 6f7e8e17e2 fix: community cli plugin homepage url in package.json (#42696)
Summary:
fixed homepage url in package.json file of community cli plugin.

## Changelog:
[GENERAL][CHANGED] - changed community cli plugin homepage url.
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

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

Test Plan: community-cli-plugin homepage url must be opened correctly.

Reviewed By: rubennorte

Differential Revision: D53179709

Pulled By: huntie

fbshipit-source-id: 7949a897d4fe1da228fce323fa8bb32640194273
2024-01-29 07:36:45 -08:00
szymonrybczak 93dc3ee691 fix: update error message to use npx when calling react-native (#42691)
Summary:
Just small fix for those who are copy & pasting commands from error message.

## Changelog:

[INTERNAL] [CHANGED] - Update erorr message to use `npx` when calling `react-native`

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

Test Plan: _

Reviewed By: cipolleschi

Differential Revision: D53177186

Pulled By: cortinico

fbshipit-source-id: e680cde81fde1f560dfeb1a85c8ad90090d69653
2024-01-29 07:34:58 -08:00
Dmitry Rykun b32c6c2cc1 Event name normalization (#42586)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42586

Every event name must be normalized.

The normalization strategy is:
1. If it starts with `top` -> do nothing.
2. If it starts with `on` -> replace `on` with `top`.
3. Else -> capitalize the first character and prepend `top`.

We have it for the old renderer on iOS [here](https://github.com/facebook/react-native/blob/a7586947d719a9cd2344ad346d271e7ca900de87/packages/react-native/React/Base/RCTEventDispatcher.m#L12-L21). This one is also used by the interop layer.
Static ViewConfigs being a part of the new renderer [replicate](https://github.com/facebook/react-native/blob/a7586947d719a9cd2344ad346d271e7ca900de87/packages/react-native-codegen/src/generators/components/GenerateViewConfigJs.js#L164-L172) this behavior to match the old rendered.

The Android that we have is incomplete, it is missing the [*2. If it starts with `on` -> replace `on` with `top`*]. This means that some events names that worked with the old renderer would not be compatible with the new renderer + Static ViewConfigs. Specifically every event names that start with `on`.

This diff implements event name normalization on Android.

Changelog: [Internal] - Update event normalization algorithm to match SVCs.

Reviewed By: cortinico

Differential Revision: D50604571

fbshipit-source-id: cef34d8baa2cf31f641be423a16bca7ea9fa20c4
2024-01-29 07:01:26 -08:00
Alex Hunt 273ce836a1 Skip unsupported Flow syntax in public-api-test (#42667)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42667

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D53091943

fbshipit-source-id: afbde589d2fce705f6907de929f291e7862c4258
2024-01-29 06:47:49 -08:00
Blake Friedman 3869ae4d80 Avoid using Cocoapods 1.15 until it fixes an issue affection RN. (#42702)
Summary:
Cocoapods 1.15 (https://github.com/facebook/react-native/issues/42698) current breaks the build, limit to version >= 1.13 & < 1.15

This is currently broken and affecting users, we'll remove this limit once Cocopods fixes the regression.  It's currently blocking 0.73.3.

## Changelog:
[iOS][Fixed] don't allow cocoapods 1.15.

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

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

Test Plan:
```
bundle exec pod install
```

Reviewed By: cipolleschi

Differential Revision: D53180111

Pulled By: blakef

fbshipit-source-id: 4c5dd11db6d208e8d71249443a8f85e601913abd
2024-01-29 04:12:51 -08:00
Rob Hogan cfc0ba04a1 Re-enable InspectorProxy* Jest tests (#42682)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42682

Since D53125777, these should be safe to re-enable

Changelog:
[Internal] Re-enable dev-middleware InspectorProxy* tests

Reviewed By: huntie

Differential Revision: D53125778

fbshipit-source-id: 38911b5d6f424b46d33bb4dace18c892dc5c8c1a
2024-01-27 06:49:15 -08:00
Nick Gerleman b5267d9436 Enable ANDROIDLINT in React Native (#42675)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42675

`ANDROIDLINT` config now has a base setup for RN. This enables it in arc linter, and fixes automatically fixable issues.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D53115471

fbshipit-source-id: 2556c21770f7c7ca54d1bccfff527d39df20101e
2024-01-26 21:54:37 -08:00
Nick Gerleman 5e37c1f219 Restore missing call to convertRawPropAliases (#42686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42686

D53072714 accidentally removed this call, which sets the values for props which have duplicates, and some precedence between them.

This organization is janky, and will be removed in D53073913 where we decuple the props from Yoga style (so the precedence and parsing order becomes a lot more sane).

Changelog:
[Android][Fixed] - Restore missing call to `convertRawPropAliases`

Reviewed By: mdvacca

Differential Revision: D53144603

fbshipit-source-id: 85da722b23992ea75fb681f1db15e62a0daa2a51
2024-01-26 17:19:53 -08:00
David Vacca de42893d01 Fix TextInput-textStyles-e2e test (#42685)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42685

This diff fixes the TextInput-textStyles-e2e test.
The rootcause of this issue is that we were updating the lineHeight of ReactEditText (AppCompatEditText) when lineHeight is set as a prop from React.
This is a problem, because one one side lineHeight is managed  by React Native (setting styles in the spannables) and on the other side we ar calling setLineHeight on AppCompatEditText, which breaks the rendering.

We should only manage lineHeight using RN styles, that's why I'm removing call to super.setLineHeight()

Changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53142429

fbshipit-source-id: cedf803171a490afa67252e9e7f83749502326e6
2024-01-26 15:50:31 -08:00
Phillip Pan c8ab44cf0b introduce property on RCTPushNotificationManager to hold notification that launched the app (#42628)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42628

Changelog: [iOS][Deprecated] Retrieving initial notification requires UNUserNotificationCenterDelegate setup instead of reading UIApplicationLaunchOptionsLocalNotificationKey

# how to migrate:

if you are currently using `getInitialNotification` to check the notification on an app start (warm or cold), you will need to do a migration.

have an object become the delegate of `UNUserNotificationCenterDelegate`. you can use your app's `AppDelegate` to do this.

then, override `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:`. in the implementation, add these lines:

  if ([response.actionIdentifier isEqualToString:UNNotificationDefaultActionIdentifier]) {
    id module = _reactHost ? [[_reactHost getModuleRegistry] moduleForName:"PushNotificationManager"]
                           : [_bridge moduleForClass:[RCTPushNotificationManager class]];

    if ([module isKindOfClass:[RCTPushNotificationManager class]]) {
      RCTPushNotificationManager *pushNotificationManager = (RCTPushNotificationManager *)module;
      pushNotificationManager.initialLocalNotification = response.notification;
    }
  }

# reasoning:

when you start an app from a push notification, the `UIApplicationLaunchOptionsLocalNotificationKey` in `application:didFinishLaunchingWithOptions:` will contain the notification metadata that started the app. additionally, this was stored on the bridge, which is not compatible with the new architecture. however, `UIApplicationLaunchOptionsLocalNotificationKey` has been deprecated since iOS 10, which this PR aims to address.

apple's supported API to do this is `userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:` which is on `UNUserNotificationCenterDelegate`. this is a significant change from a pull to push model. in order to make this change without having to rearchitect the product layer, we're going to store the notification on the notification native module.

another caveat is that the API follows the delegation pattern, not the listener pattern. that means we can't make our notificaiton native module the delegate here - the app will probably need `UNUserNotificationCenterDelegate` to be a top level object - usually the scope of the app delegate.

in future, i actually think we need to unify this with `handleLocalNotificationReceived:`, but right now there's forked handling between platforms and some product code is only using the pull model, so this is still the minimum change in the product layer.

Reviewed By: ingridwang

Differential Revision: D52897071

fbshipit-source-id: 579578d1b3128c5f7e81249c75cf7655b8e360e2
2024-01-26 15:33:02 -08:00
Kevin Gozali 8c4979e7a1 fix background access to UIKit in RCTAlertManager (#42684)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42684

This addressed threading issue like this:

```
Attempting to set an overrideUserInterfaceStyle from a background thread. Modifying a view controller from a background thread is not supported
```

Changelog: [iOS][Fixed] Fixed potential threading issues accessing UIKit from background in RCTAlertManager

Reviewed By: philIip

Differential Revision: D52999194

fbshipit-source-id: 8ce8a89ef932ca9b75cb93d3c9f102a6b0494580
2024-01-26 14:08:12 -08:00
Wojciech Lewicki 751eae94d4 fix: restore proper event dispatch order on Fabric (#42664)
Summary:
This PR fixes the cpp crash coming from events being consumed in `dispatchModern` before forwarding it to listeners:
https://github.com/facebook/react-native/blob/ccff2bb8d19b2db244f30293b4e8d68a524c2059/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/FabricEventDispatcher.java#L42-L45
Because of this, all listeners that require reading from the native map (like RNReanimated using event.toString()) cause a crash since the data is no longer available - [https://github.com/facebook/react-native/blob/49f6ffc92f56953b68f340783e326145a377[…]/react-native/ReactAndroid/src/main/jni/react/jni/NativeMap.cpp](https://github.com/facebook/react-native/blob/49f6ffc92f56953b68f340783e326145a377c3b0/packages/react-native/ReactAndroid/src/main/jni/react/jni/NativeMap.cpp#L16-L19)
Restoring the previous behavior, where the event was forwarded to the listeners first, and only then dispatched further solves the problem:
https://github.com/facebook/react-native/blob/ccff2bb8d19b2db244f30293b4e8d68a524c2059/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventDispatcherImpl.java#L116-L126
Was there a reason for changing the order here?

Or maybe there was another reason why the order was changed?

## Changelog:

[ANDROID] [FIXED] - Proper event dispatch order on Fabric

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

Test Plan: Run: https://github.com/WoLewicki/NewArchStylingBug/tree/%40wolewicki/show-fabric-event-crash and try to move the square. It will cause a crash in here: https://github.com/facebook/react-native/blob/ccff2bb8d19b2db244f30293b4e8d68a524c2059/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/animated/EventAnimationDriver.java#L110 when trying to read from a consumed map.

Reviewed By: sammy-SC, jessebwr

Differential Revision: D53089137

Pulled By: mdvacca

fbshipit-source-id: 8c282a417d1889732792070a404cf87acad98523
2024-01-26 12:41:50 -08:00
Jakub Trzebiatowski d4c3311296 Move all ReactSpan subclasses to a separate folder (#42594)
Summary:
Move all `ReactSpan` subclasses to a separate folder.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

I'm adding a new span class later, which was the direct motivation for this change.

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

[INTERNAL] [CHANGE] - Move all `ReactSpan` subclasses to a separate folder

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

Reviewed By: mdvacca

Differential Revision: D53123733

Pulled By: cortinico

fbshipit-source-id: 10db214a520d157c231e6f3b97948b4209a7ad4b
2024-01-26 11:58:56 -08:00
Rubén Norte f8f7949e25 Move feature flags for the event loop to ReactNativeFeatureFlags (re-land) (#42677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42677

Changelog: [internal]

This is a re-application of https://github.com/facebook/react-native/pull/42434 which had to be reverted after a problem in a previous PR.

See details in the original PR.

Reviewed By: huntie

Differential Revision: D53122991

fbshipit-source-id: 5bc4306522fc5fa48ea81d0802d0f891706cfbf5
2024-01-26 09:55:27 -08:00
Rubén Norte 5e66f41697 Implement new feature flag system (re-land) (#42678)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42678

Changelog: [internal]

This is a re-application of https://github.com/facebook/react-native/pull/42430, which had to be reverted because of crashes in optimized builds on Android:

```
Abort Reason: terminating due to uncaught exception of type facebook::jni::JniException: java.lang.ClassNotFoundException: com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsProvider
```

The root cause of that was that that class was removed because it wasn't statically referenced from Kotlin/Java, but it was dynamically referenced from C++ (in `ReactNativeFeatureFlagsProviderHolder.cpp`).

This applies the same changes + adds `DoNotStrip` annotations for the affected class and all its methods.

Reviewed By: huntie

Differential Revision: D53122992

fbshipit-source-id: efc4d5636a3f2d39b86e9c098bff408b6688b80b
2024-01-26 09:55:27 -08:00
Ramanpreet Nara 6c4ef54708 BridgelessUIManager: Finish findSubviewIn
Summary:
This is an implementation of UIManagerModule.findSubviewIn, based on the [Fabric renderer](https://github.com/facebook/react-fbsource-import/blob/772935f7320f37a14ef06a9616dd43fa090d54a3/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js#L28899-L28953).

UIManager.findSubviewIn(viewTag, point, callback)

The point is relative to viewTag's parent's (0, 0).

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D52642884

fbshipit-source-id: 775e98d23ff42d41c30644b82f5f67e788df4ee6
2024-01-26 08:42:02 -08:00
Nicola Corti 5f75e9b90d Bump NDK to 26.1 (#42656)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42656

I'm bumping the NDK to 26.1. As we already have a bump lined up to 26.0 on main,
it makes sense to go to .1 as it's declared the LTS:
https://github.com/android/ndk/wiki

Changelog:
[Android] [Changed] - Android NDK to 26.1

Reviewed By: NickGerleman

Differential Revision: D53083606

fbshipit-source-id: 12290efcfa8a72ab88c21ffe9507d08d5512d61b
2024-01-26 00:34:55 -08:00
David Vacca ffaeaba213 Back out "Implement new feature flag system"
Summary:
Original commit changeset: 0ba95803f61e

Original Phabricator Diff: D52806730

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: yungsters

Differential Revision: D53113947

fbshipit-source-id: ace1222a861a739fcd3f4b0e12c135db47a93344
2024-01-25 21:52:59 -08:00
David Vacca 31a8bc9644 Back out "Move feature flags for the event loop to ReactNativeFeatureFlags"
Summary:
Original commit changeset: e30a6f2e12b4

Original Phabricator Diff: D52819137

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: yungsters

Differential Revision: D53113944

fbshipit-source-id: daac6f2bf1e9cd16354987e17cb27f0bcda25f9d
2024-01-25 21:52:59 -08:00
Nick Gerleman 94a9791f2f Remove unshipped view/layout props-parsing paths
Summary:
We are making some decently large changes around here, to transition Fabric away from Yoga's private API, and add new units, and CSS properties. Even confined to Fabric, we have a large matrix of different paths for parsing.

This change consolidates layout props parsing to a single, tested path, used everywhere.

Concretely, this means removing:
1. MapBuffer for ViewProps
2. Iterator style props parsing (for layout props only)

MapBuffer for ViewProps to my understanding is not currently used at all, and has been live to edits, but untested, for quite some time. Iterator style props parsing is still enabled in some configurations, but we don't want to broadly ship its current form, and haven't been able to prioritize shipping it.

Both MapBuffer, and iterator style props parser, are performance wins. If we look at seriously shipping one of these again, we should look at swapping out the current path.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D53072714

fbshipit-source-id: 0a737c8c8f50b1f2c5c0b7ff0415e84a26a06abb
2024-01-25 20:03:52 -08:00
David Vacca 142f13db63 Fix rendering of textInput using lineHeight in android API level <28 (#42673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42673

Fix rendering of textInput using lineHeight in android API level <28 by removing call to ReactEditText.setLineHeight.
ReactEditText.setLineHeight was introduced in API level 28 and we actually don't need to call this method

changelog: [Internal] internal

Differential Revision: D53105649

fbshipit-source-id: f2d81cfea10de84bd47efbfeac1e21837fd49a11
2024-01-25 19:20:17 -08:00
Ramanpreet Nara 62e5980954 Fix UIManagerBinding's findNodeAtPoint (#42439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42439

UIManagerBinding's findNodeAtPoint assumes that UIManager::findNodeAtPoint returns non-null pointers. But, this is false! See [LayoutableShadowNode::findNodeAtPoint](https://github.com/facebook/react-native/blob/fd0ca4dd6209d79ac8c93dbffac2e3dca1caeadc/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp#L333-L354):

https://www.internalfb.com/code/fbsource/[7169da7945c813b35cd0a4fa15e66969c90c2481]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/core/LayoutableShadowNode.cpp?lines=333%2C354

Changelog: [General][Fixed] Fix UIManagerBinding's findNodeAtPoint

Reviewed By: cortinico, sammy-SC

Differential Revision: D52909512

fbshipit-source-id: e1da112d4f8dcf4cdc037c978d84751eb8cf6695
2024-01-25 16:56:49 -08:00
Ramanpreet Nara d11dca7ba3 UIManagerJSInterface: Fix getConstantsForViewManager types
Summary:
If Flow can be trusted, getConstantsForViewManager always gets called with a non-null string:
1. The only call-site to getConstantsForViewManager is getViewManagerConfig: [PaperUIManager.js](https://github.com/facebook/react-native/blob/822bf52c29729d25b2bfb31655cf773609a9283d/packages/react-native/Libraries/ReactNative/PaperUIManager.js#L36-L80)
2. And getViewManagerConfig always passes in a non-null string.

So, let's just make the native argument type a non-nullable string.

Thoughts?

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D52628937

fbshipit-source-id: 0ca68b38253cf134af29974af9e36380d66895a1
2024-01-25 16:56:49 -08:00
Ramanpreet Nara 4636029aca Finish lazilyLoadView
Summary:
This API was used by the old architecture to lazily register/load components:
1. Load a ViewManager's class from the disk
2. Register the ViewManager's class with React Native

See: [RCTUIManager lazilyLoadView](https://github.com/facebook/react-native/blob/822bf52c29729d25b2bfb31655cf773609a9283d/packages/react-native/React/Modules/RCTUIManager.m#L1546-L1591)

The new architecture **does not** support lazy loading of **legacy** modules/components.

Therefore, let's leave this API unimplemented until we decide to implement lazy loading of legacy stuff in new architecture.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D52677515

fbshipit-source-id: 8d49a0b54f901a3e9b3e8a9578ebb0c81de522d8
2024-01-25 16:56:49 -08:00
Samuel Susla 3c6c282c0a remove fix_stopped_surface_view_leak_android feature flag (#42666)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42666

changelog: [internal]

This is shipped, let's remove gating.

Reviewed By: javache

Differential Revision: D53088420

fbshipit-source-id: ac885596da4aab7131ac7a84ff8e6655d28d6ad3
2024-01-25 15:39:55 -08:00
Rubén Norte e04d1b47b6 Move feature flags for the event loop to ReactNativeFeatureFlags (#42434)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42434

Changelog: [internal]

The flags for the event loop were set up using different mechanisms due to the limitations of the previous feature flags systems. Now we can centralize on the new system and use them consistently on Android and iOS.

Reviewed By: RSNara

Differential Revision: D52819137

fbshipit-source-id: e30a6f2e12b4a027a906502b80a70dd48bb657b6
2024-01-25 13:55:11 -08:00
Rubén Norte 705c675d51 Implement new feature flag system (#42430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42430

This PR creates a new internal feature flags system for React Native. This is only meant to be used internally within the framework, but we might expose it externally in some form in the future to allow customizing specific feature flags in frameworks and applications.

Features:
* 2 types of flags:
  * Common: can be overridden from native and are accessible from all layers of the stack (Objective-C/Swift, Java/Kotlin, C++ and JavaScript).
  * JS-only: flags that can only be defined and accessed from JS (to allow things like hot reloading without a native build).
* 1 source of truth for each flag.
* Feature flags are application/process scoped (using C++ singletons).

See the `README.md` file in this PR for additional information.

This also adds modifies `run-ci-javascript-tests` to run a new check to make sure that the generate files are in sync with the JSON file that contains the definitions.

Changelog: [internal]

Reviewed By: huntie

Differential Revision: D52806730

fbshipit-source-id: 0ba95803f61ec2f05266ee535921321bf6d3dc6a
2024-01-25 13:55:11 -08:00
David Vacca dc2ce9e66e Fix incorrect measurement of TextInput (#42655)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42655

This bug is caused by a caching issue: when the user enters a new character into the textInput: ReactTextInput 1) caches the Spannable entered by the user and 2) it updates internal Fabric state, which triggers the measurement of the TextInput component using the cached Spannable.

The problem is that the Spannable entered by the user has the wrong "styles" for the text input. Since measurement is using the cached Spannable, then the measurement of the TextInput ends up being is incorrect.

In this diff I'm fixing the bug by updating the styles (lineHeight) of the cached spannable that is cached when the user updates the TextInput.
The styles weren't updated correctly because mTextAttributes didn't have the proper style props set

Changelog:
    [Android][Fixed] - Fix incorrect measurement of TextInput when new architecture is enabled

Reviewed By: javache, sammy-SC

Differential Revision: D52924982

fbshipit-source-id: ced9f2c348bdb9bf706028b1063858cebd5a071a
2024-01-25 11:07:12 -08:00
Nicola Corti 97d6d724e1 Cleanup srcSet for java and res (#42659)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42659

Those folders for Java don't exist anymore, I'm removing this as it's unnecessary and will default to only src/main/java.
For resources instead, I'm using `setSrcDirs` as it will replace the default, while `srcDirs()` will add those folders.
We need to replace the default res folder as we need to follow the resource folder structure of BUCK

Changelog:
[Internal] [Changed] - Cleanup srcSet for java and res

Reviewed By: cipolleschi

Differential Revision: D53083677

fbshipit-source-id: 4dc42c700ea5446bbd49c63fc43b58ba316f4944
2024-01-25 10:58:00 -08:00
Samuel Susla 889ead1f1f remove feature flag cancel_image_downloads_on_recycle (#42663)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42663

changelog: [internal]

Removing the MC, this has been shipped.

Reviewed By: rubennorte

Differential Revision: D53043474

fbshipit-source-id: 2036f6752a3930666e872df0f6418e3ad8986441
2024-01-25 08:47:56 -08:00
Pieter De Baets c9764c5a17 Clarify docs and deprecation on Event methods (#42600)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42600

Disentangled the logic for emitting touches to JS on Android. `receiveTouches` should never be used as a public API, as TouchEvents can be dispatched just like any other event, and receiveTouches is an internal helper for `TouchEvent`.

Changelog: [Android][Removed] Updated migrated guidance for EventEmitter and reduced visibility of internal TouchesHelper methods

Reviewed By: cortinico

Differential Revision: D52907393

fbshipit-source-id: a8207039c863ab23a1d93dd2d2f28e8a274c8ecf
2024-01-25 07:33:17 -08:00
Pieter De Baets 49f6ffc92f Fix Soloader call in DefaultComponentsRegistry (#42660)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42660

Calling `maybeLoadSoLibrary` from init is too late, as we call `initHybrid` before `init`. Instead use a static initializer.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53048065

fbshipit-source-id: dfd2957fd9209e02c498ee08e9cbd7c7a1a83c3e
2024-01-25 07:07:04 -08:00
Riccardo Cipolleschi e7fd142c38 Enable the DevMenu in bridgeless mode (#42657)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42657

When the RCT_DEV flag is turned on, we force the eager initialization of the DevMenu at startup.
The initialization was happening in a method of the `CxxBridgeDelegate` protocol.
In bridgeless mode, we don't have the bridge, hence we don't call this method.

I need to put the initialization code in the `RCTIntance` because the only way I found to eagerly initialize a module was to tap into the `RCTTurboModuleManager` and, in Bridgeless mode, that's seemed to be the only way.
I'm open to move the code to a better place, anyway!

## Changelog:
[Internal] - Enable the DevMenu eagerly in Bridgeless mode

Reviewed By: sammy-SC

Differential Revision: D53083637

fbshipit-source-id: 219698eab77ed115ab0f4ea43911ae883a4c9e8a
2024-01-25 06:27:14 -08:00
Jakub Trzebiatowski 2dc2d4db8f RCTAttributedTextUtils.mm: Split NSAttributedString creation (#42595)
Summary:
`RCTAttributedTextUtils.mm`: Split `NSAttributedString` creation to functions in preparation for adding new logic here.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

[INTERNAL] [CHANGE] - Refactor `NSAttributedString` creation in `RCTAttributedTextUtils.mm`

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

Reviewed By: cipolleschi

Differential Revision: D53001495

Pulled By: sammy-SC

fbshipit-source-id: 52d28e48f0a9d88d44325a73c64737fc7ac97781
2024-01-25 05:08:35 -08:00
Jakub Trzebiatowski 011152318a CustomLineHeightSpan: Increase the readability (#42592)
Summary:
Increase the readability of `CustomLineHeightSpan` by making the logic less stateful.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

[INTERNAL] [CHANGED] - Increase the readability of `CustomLineHeightSpan`

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

Test Plan:
- Prove the equivalence of the old and the new logic
- Test that the behavior of `lineHeight` doesn't change

Reviewed By: NickGerleman

Differential Revision: D53028467

Pulled By: mdvacca

fbshipit-source-id: d533bb77c8e10c29d8f2acc8cc39565d0013b03b
2024-01-25 04:40:49 -08:00
Samuel Susla a5aed1294f enable setNativeProps in animations on by default (#42603)
Summary:
Changelog: [General][Added] Enable setNativeProps in animations in the New Architecture

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

Enabling setNativeProps in animations on by default.

Reviewed By: mdvacca

Differential Revision: D52962882

fbshipit-source-id: 67921c8e36e97b7b1315dfa0d5f3bd708ccb0079
2024-01-25 03:44:22 -08:00
Jakub Trzebiatowski 87bcaa3fa1 TextLayoutUtils: Use named arguments (#42593)
Summary:
`TextLayoutUtils`: Use named arguments to ensure same-type arguments (like `start`/`end`) are not confused

This is a minor readability follow-up to https://github.com/facebook/react-native/pull/39630.

## Changelog:

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

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

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

[INTERNAL] [CHANGED] - Increase the `TextLayoutUtils` readability slightly

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

Reviewed By: NickGerleman

Differential Revision: D53028402

Pulled By: mdvacca

fbshipit-source-id: 39e99ba70b93eecfc51bda19d30a5b1977cfe406
2024-01-25 02:49:30 -08:00
szymonrybczak 78967b33c0 Bump CLI to 13.5.1 (#42183)
Summary:
Updates CLI to v13.5.1.

## Changelog:

[GENERAL] [CHANGED] - Bump CLI to 13.5.1

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

Test Plan: CI

Reviewed By: christophpurrer

Differential Revision: D52600707

Pulled By: huntie

fbshipit-source-id: f314a405d8d7e9200595b42b62d354e61f0a2964
2024-01-25 02:32:45 -08:00
Alex Hunt 02e7244b3d Improve types, fix translator compatibility for version-related modules (#42638)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42638

Enables these modules to be covered by `public-api-test`.

- Standardise as CommonJS modules, fixing compatibility with [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator).
- Use explicit object type in generated file template.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52963967

fbshipit-source-id: c9f3e35f70859c1b99b7297228ee2498f91d9041
2024-01-25 02:32:00 -08:00
Krzysztof Magiera 0ea16fd3f7 Unify codepath for retrieveing metro location on Android (#42617)
Summary:
With the current ways metro location is determined, when we want to use a different metro port this requires app to be rebuild as the port and location are stored in resource file that gets compiled to R.class. The only way to avoid app rebuild due to a port change is to use shared preferences that can be accessed from dev menu, where metro URL can be specified. However, due to a separate code-paths for retrieving bundle location and for `/inspector/device` calls, the setting only applies to the former. As a consequence, you can change metro URL in the shared preferences, but debugging would only work if you use the default port or you rebuild the app with the correct port number.

This PR removes the separate code-path for retrieving inspector URL including all the dependencies scattered across different files including the gradle plugin. We then replace calls to `PackagerConnectionSettings.getInspectorServerHost` with `PackagerConnectionSettings.getDebugServerHost` which respects the shared preferences and other possible ways of configuring the port.

I decided to remove the separate inspector URL code path, as the resource value for inspector port added in https://github.com/facebook/react-native/issues/23616 was never functioning properly due to a bug. In the said PR introduced a bug in [AndroidInfoHelpers.java](https://github.com/facebook/react-native/blob/a13d51ff1c38ea85e59f4215563c0dd05452f670/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java#L77) where `react_native_dev_server_port` was used instead `react_native_inspector_proxy_port`. As a result the added resource value was never read.

This can be potentially a breaking change as I'm removing some public methods. However I think it is unlikely anyone relied on said methods. As a part of this PR I'm also changing occurences of removed methods from ReactAndroid.api – I don't know how to test those changes since I don't understand how this file is used as it doesn't have any references in public code.

## Changelog:

[ANDROID] [FIXED] - Make Android respect metro location from shared preferences for the debugger workflow

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

Test Plan:
1. Run android app on emulator using default port
2. Check the debugger works when using "Open Debugger" option from dev menu
3. Restart metro with custom port (`--port 9090`) while keeping the app running
4. Open dev menu, click "Settings" then "Debug server host & port", put "10.0.2.2:9090" there
5. Reload the app
6. Before this change things like hot reload would continue to work while "Open Debugger" option would do nothing
7. After this change both reloading and debugging will work

Important: I haven't tested changes made to ReactAndroid.api as I don't know what this files is used for with no references in the codebase.

Reviewed By: cortinico

Differential Revision: D53010023

Pulled By: huntie

fbshipit-source-id: cc8b9c5c7e834ec9ea02b1ed5acf94f04f7b7116
2024-01-25 02:29:13 -08:00
Kudo Chien 631b6a12c5 Enable DEFINES_MODULE for DoubleConversion (#42591)
Summary:
since https://github.com/facebook/react-native/commit/32dab7a63fd0795c3aaefa766aa9f818428ed2de, `DoubleConversion` is now added as an implicit dependency for 3rd party module and it breaks swift integration. this pr tries to add the `DEFINES_MODULE` to DoubleConversion.

## Changelog:

[IOS] [FIXED] - Fixed `DoubleConversion` build error from Swift integration

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

Test Plan:
i'll need to test this on expo latest and react-native nightly build

```sh
# pull latest expo repo and get template tarball
$ git clone --depth 1 https://github.com/expo/expo.git
$ cd expo
$ yarn install
$ cd templates/expo-template-bare-minimum
$ npx pack --pack-destination ../../

# now create an expo app
$ yarn create expo -t blank@sdk-50 sdk50
$ cd sdk50
$ yarn add react-native@nightly
$ jq '.expo.runtimeVersion = { "policy": "appVersion" }' app.json > app.json.tmp && mv app.json.tmp app.json
$ npx expo prebuild -p ios --template /path/to/expo/expo-template-bare-minimum-50.0.17.tgz
$ cd ios
$ pod install
```

then it will show the error message:
```
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `ExpoModulesCore` depends upon `DoubleConversion`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
```

Reviewed By: cortinico

Differential Revision: D53048352

Pulled By: cipolleschi

fbshipit-source-id: b1e27d3d26e8543a4cb2e8062c93c68543a051c5
2024-01-25 02:05:56 -08:00
Gabriel Donadel 41c601e478 Remove ATS config patch from react_native_post_install (#42637)
Summary:
This PR removes the `apply_ats_config` function of ReactNativePodsUtils that was used inside `react_native_post_install` because it was preventing users from configuring `NSAllowsArbitraryLoads` to true in their projects, especially when building in CI as the plist file would be reset after running pod install.

## Changelog:

[IOS] [CHANGED] - Remove ATS config patch from react_native_post_install

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

Test Plan: Edit `Info.plist`, run `pod install` and check if changes have not been overwritten

Reviewed By: cortinico

Differential Revision: D53048299

Pulled By: cipolleschi

fbshipit-source-id: 8dc335fae2e05a62daf931a50fa3f7a314e76a2e
2024-01-25 02:04:18 -08:00
Riccardo Cipolleschi f4dbd15f0b Fix RCTFabric podspec (#42639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42639

When I reverted part of the deprecation of `RCT_NEW_ARCH_ENABLED`, I forget a little bit which was breaking RCTFabric podspec.

This diff fixes that.

## Changelog:
[Internal] - Bring back `RCT_NEW_ARCH_ENABLED` to Fabric to make the `RCTThirdPartyFabricComponentsProvider` work again.

Reviewed By: cortinico

Differential Revision: D53048270

fbshipit-source-id: d21e833c10b332fb70147cc65b690f88016655e6
2024-01-25 02:02:40 -08:00