Commit Graph
2768 Commits
Author SHA1 Message Date
Rubén NorteandFacebook GitHub Bot c7bef93af0 Rename performance.reactNativeStartupTiming as performance.rnStartupTiming (#42762)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42762

This renames `performance.reactNativeStartupTiming` as `performance.rnStartupTiming` to align with the recommended vendor prefix for React Native.

This API is still private, so it's safe to rename.

Changelog: [internal]

Reviewed By: javache

Differential Revision: D53264515

fbshipit-source-id: 6e7a222901071594cac0ca8a0ac78e56e60ab132
2024-01-31 07:16:21 -08:00
Nicola CortiandFacebook GitHub Bot 123934581b Fix broken test_android on main (#42763)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42763

Fix broken test_android on main

Changelog:
[Internal] [Changed] - Fix broken test_android on main

Reviewed By: cipolleschi

Differential Revision: D53264488

fbshipit-source-id: 58e0f3512878aa424bb6e1f0c930ff6c0769ee43
2024-01-31 05:30:35 -08:00
zhongwuzwandFacebook GitHub Bot 0bbc311c8a Fixes root view's background color in bridgeless mode (#42739)
Summary:
Fixes root view's background color in bridgeless mode, the top area has white background color when in dark mode.

Before:
![Simulator Screenshot - iPhone 15 - 2024-01-30 at 23 28 48](https://github.com/facebook/react-native/assets/5061845/4359385d-370d-48cf-a58e-e2e9eb871400)

After:
![Simulator Screenshot - iPhone 15 - 2024-01-30 at 23 25 39](https://github.com/facebook/react-native/assets/5061845/5e9d2029-43d2-40c3-b2cb-c8a9ee80a5e1)

## Changelog:

[IOS] [FIXED] - [iOS] Fixes the root view's background color in bridgeless mode

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

Test Plan: Run RNTester and see the top area's background color.

Reviewed By: cortinico

Differential Revision: D53263621

Pulled By: javache

fbshipit-source-id: f18128464c9171ba8e0f6858c0608ce757349d27
2024-01-31 03:25:24 -08:00
ankit-tailorandFacebook GitHub Bot 8fca1c5854 fix: font variant typings (#42760)
Summary:
This PR fixes the typings for `fontVariant` style prop. Flow file has below typings but they were missing in typescript file.

```
  fontVariant?:
  | 'small-caps'
  | 'oldstyle-nums'
  | 'lining-nums'
  | 'tabular-nums'
  | 'common-ligatures'
  | 'no-common-ligatures'
  | 'discretionary-ligatures'
  | 'no-discretionary-ligatures'
  | 'historical-ligatures'
  | 'no-historical-ligatures'
  | 'contextual'
  | 'no-contextual'
  | 'proportional-nums'
  | 'stylistic-one'
  | 'stylistic-two'
  | 'stylistic-three'
  | 'stylistic-four'
  | 'stylistic-five'
  | 'stylistic-six'
  | 'stylistic-seven'
  | 'stylistic-eight'
  | 'stylistic-nine'
  | 'stylistic-ten'
  | 'stylistic-eleven'
  | 'stylistic-twelve'
  | 'stylistic-thirteen'
  | 'stylistic-fourteen'
  | 'stylistic-fifteen'
  | 'stylistic-sixteen'
  | 'stylistic-seventeen'
  | 'stylistic-eighteen'
  | 'stylistic-nineteen'
  | 'stylistic-twenty';
```

## Changelog:

[GENERAL] [ADDED] - Added missing typings for fontVariant style prop.

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

Test Plan: Tested manually.

Reviewed By: cortinico

Differential Revision: D53263569

Pulled By: javache

fbshipit-source-id: b127e0377cf9ceb50d094294d188f87a23038e5b
2024-01-31 03:13:18 -08:00
Kevin GozaliandFacebook GitHub Bot 841e00edaf iOS: RCTImageLoader: use static request counter for request IDs (#42720)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42720

The request ID was used for in-memory request caching purpose only. There wasn't much reason to use the sophisticated monotonic number, so let's just use a static 64-bit unsigned int counter. With the more-or-less unique UUID prefix, this should have an extremely low chance of collision.

Changelog: [Internal]

Reviewed By: philIip, sammy-SC

Differential Revision: D53205641

fbshipit-source-id: e6da12029624058dc877e9cbe2000af4df938870
2024-01-30 23:05:59 -08:00
David VaccaandFacebook GitHub Bot 25c5d1c341 Mark classes of package animated as @Nullsafe (#42727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42727

All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53200096

fbshipit-source-id: 2d965ebcb568e7bbff4b37db11070c5079fa6394
2024-01-30 17:26:31 -08:00
David VaccaandFacebook GitHub Bot 6cae417828 Fix wrong type in kotlin (#42726)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42726

initHybrid always return a HybridData. we shouldn't allow null here.

changelog: [internal] internal

Reviewed By: cortinico, NickGerleman

Differential Revision: D53200101

fbshipit-source-id: 284a69c48928e88ad35c1f52cbf01afbfb1ea818
2024-01-30 17:26:31 -08:00
David VaccaandFacebook GitHub Bot db6c98eac1 Deprecate com/facebook/react/config/ReactFeatureFlags (#42718)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42718

Deprecate com/facebook/react/config/ReactFeatureFlags, to be replaced by com.facebook.react.internal.featureflags.ReactNativeFeatureFlags

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D53199655

fbshipit-source-id: 32bdc526e377ff70e2df3c97a259066a25180231
2024-01-30 15:46:23 -08:00
Jack PopeandFacebook GitHub Bot c7479b07ae Add react-native-test-renderer package (#42644)
Summary:
The goal is to provide testing utilities that use Fabric and concurrent rendering by default to support the new RN architecture. Currently most testing is done through ReactTestRenderer, which is an overly-simplified rendering environment, non-concurrent by default, and over exposes internals. A dedicated RN environment in JS can allow for more realistic test execution.

This is the initial commit to create the `react-native-test-renderer` package. It currently only offers a simple toJSON() method on the root of a test, which is used for snapshot unit tests. We will be iterating here to add a query interface, event handling, and more.

## Changelog:
[GENERAL] [ADDED] - Added react-native-test-renderer package for Fabric rendered integration tests

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

Test Plan:
```
$> cd packages/react-native-test-renderer
$> yarn jest
```

Output:

```
 PASS  src/renderer/__tests__/render-test.js
  render
    toJSON
      ✓ returns expected JSON output based on renderer component (7 ms)

Test Suites: 1 passed, 1 total
1 passed, 1 total
Snapshots:   1 passed, 1 total
Time:        2.869 s
```

Reviewed By: yungsters

Differential Revision: D53183101

Pulled By: jackpope

fbshipit-source-id: 8e29ba35f55f6c4eb2613ab106bc669d72f33d1d
2024-01-30 12:54:26 -08:00
Rubén NorteandFacebook GitHub Bot 2108269ea8 Move flags unused in OSS from legacy ReactNativeFeatureFlags (JS) to the new system (#42433)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42433

Changelog: [internal]

The only flags we know are being [assigned](https://github.com/search?type=code&q=%2FReactNativeFeatureFlags%5C.%5Cw%2B+%3D%2F+lang%3AJavaScript+NOT+path%3AReactNative%2FReactNativeFeatureFlags.js+NOT+path%3Apackages%2Freact-native+NOT+is%3Afork) in OSS are:
* `shouldEmitW3CPointerEvents`
* `shouldPressibilityUseW3CPointerEventsForHover`

So we can migrate all the rest relatively safely.

Reviewed By: javache

Differential Revision: D52905703

fbshipit-source-id: 5c9689f1d3a6133ee7c4a057437cf2ce4f8cddf5
2024-01-30 09:50:24 -08:00
zhongwuzwandFacebook GitHub Bot 3d71b11e84 Fixes semantic color not work when dark mode changed (#42737)
Summary:
When we changed dark mode, the semantic color was not applied because we use color components, it's not dynamic. So let's store the `UIColor` for semantic color directly.

https://github.com/facebook/react-native/assets/5061845/bd6d15fe-01eb-4ad7-9844-a19ef8585dae

## Changelog:

[IOS] [FIXED] - [Fabric] Fixes semantic color not work when dark mode changed

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

Test Plan: semantic color changed when switch dark mode.

Reviewed By: christophpurrer

Differential Revision: D53226806

Pulled By: cipolleschi

fbshipit-source-id: 66d5417fa1bb6a5da498e903675a93b20d920c0a
2024-01-30 09:27:18 -08:00
Pieter De BaetsandFacebook GitHub Bot c1c1f0d6b9 Use xplat-init for internal builds (#42738)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42738

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D53087308

fbshipit-source-id: a1d9365fe74ada58d94719a8598134a1a6cd6067
2024-01-30 09:26:56 -08:00
Moti ZilbermanandFacebook GitHub Bot b7025fe156 Create stub InstanceTarget, send execution context notifications (#42636)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42636

Changelog: [Internal]

Models the Native instance lifecycle in the modern CDP backend, by:

1. Registering the instance, once created, with `PageTarget`.
2. While an instance is registered, delegating messages from `PageAgent` to an internal `InstanceAgent`.
3. Unregistering the instance once it is invalidated and about to be destroyed.

We use this infrastructure to implement two simple behaviours that will be superseded in future diffs (mainly by delegating work to the JSVM), but that are useful as stubs for testing:

* Sending [`Runtime.executionContextDestroyed`](https://cdpstatus.reactnative.dev/devtools-protocol/tot/Runtime#event-executionContextDestroyed), [`Runtime.executionContextsCleared`](https://cdpstatus.reactnative.dev/devtools-protocol/tot/Runtime#event-executionContextsCleared), and [`Runtime.executionContextCreated`](https://cdpstatus.reactnative.dev/devtools-protocol/tot/Runtime#event-executionContextCreated) events to the frontend when reloading the instance.
* Implementing a toy version of [`Runtime.getHeapUsage`](https://cdpstatus.reactnative.dev/devtools-protocol/tot/Runtime#method-getHeapUsage) (that always reports zero memory usage) to exercise the Page→Instance message dispatching logic.

iOS Bridge/Bridgeless and `PageTargetTest` are the only integrations that exist as of this diff, and are all updated here; Android will follow later.

## Object lifetimes

* PageTarget owns an InstanceTarget that it creates (in `registerInstance`) and destroys (in `unregisterInstance`).
* `registerInstance` returns a raw `InstanceTarget&` reference, which becomes invalid upon calling `unregisterInstance`. It's the caller's responsibility to stop using the reference at the point of calling `unregisterInstance`.
* InstanceTarget holds a raw `InstanceTargetDelegate&` reference. It's the caller's responsibility to keep this reference valid at least until `unregisterInstance` returns.

## Thread safety

* As with PageTarget's constructor and destructor, It's the caller's responsibility to invoke `registerInstance` and `unregisterInstance` on the main thread (or using appropriate synchronisation).
* `InstanceAgent` handles messages on the same thread as `PageAgent` (typically the platform-specific main thread) and receives a copy of the same thread-safe `FrontendChannel` for sending messages back.

Reviewed By: huntie

Differential Revision: D51214056

fbshipit-source-id: 2dc2ff30d2dda6887871831a818aa117ca3e6e91
2024-01-30 08:56:17 -08:00
Riccardo CipolleschiandFacebook GitHub Bot c5258b5b2a Exclude platform/windows from React-graphics
Summary:
Internally, we synched the windows folders in react-native. This added the `windows` folder in the `platform` folder of react/graphics.

This breaks the build for iOS internally as the `React-graphics` pod is now importing both the `ios` and the `windows` folders, but, of course, some of the Windows headers are not available to iOS.

This change excludes the windows folder from the iOS Pod, when building for Meta engineers.

## Changelog:
[internal] - exclude the `plafrom/windows` folder from the `React-graphics` pod.

Reviewed By: motiz88

Differential Revision: D53228890

fbshipit-source-id: 2be5b71f6556e5da76496f0d64a98318477ad3c5
2024-01-30 08:36:19 -08:00
Pieter De BaetsandFacebook GitHub Bot 650541222d Change null-check in DefaultComponentsRegistry (#42731)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42731

This matches the behaviour we have for DefaultTurboModuleManagerDelegate, where we handle the lack of this being set gracefully. It's probably worth still logging this, as it may point at an incorrectly configured app.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53048064

fbshipit-source-id: 3ef10da3a7779a1274a1a1793387cf8cdf36c535
2024-01-30 07:59:59 -08:00
Nicola CortiandFacebook GitHub Bot 2f523f0acf Bump FBJNI to 0.6.0 (#42735)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42735

This realigns the NDK versions used to build the two tools.

Changelog:
[Internal] [Changed] - Bump FBJNI to 0.6.0

Reviewed By: cipolleschi

Differential Revision: D53223301

fbshipit-source-id: 640e9008ed460e58423fb26b6e7030e264ef9320
2024-01-30 07:34:46 -08:00
D NandFacebook GitHub Bot b133bf6024 fix: [TS] Update translateX & translateY types to support % (#42671)
Summary:
After update to the latest `react-native` version
we discover that we are unable to use `number%` value for `translate*` props :

```tsx
StyleSheet.create({
  root: {
    transform: [
      { translateX: '-50%'  },
      // ^^^^^^ TS Error: Type string is not assignable to type AnimatableNumericValue | undefined
    ],
  }
});
```

 ---

percentage values are supported, demo: https://snack.expo.dev/retyui/test-tstransform

## Changelog:

[GENERAL] [FIXED] - Update typescript definition of `translateX` & `translateX` to be able to use percentage values

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

Test Plan: `yarn tsc --noEmit`

Reviewed By: rozele, cortinico

Differential Revision: D53146046

Pulled By: NickGerleman

fbshipit-source-id: 3486e7a9b55b98c36cc96b2bca4bb27841061e80
2024-01-30 07:10:47 -08:00
Alex HuntandFacebook GitHub Bot e97ba475aa Relocate and refactor set-rn-version script (#42730)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42730

Reviewing and modernising this script as part of simplifying our release publish workflow.

- Drop unused `--dependency-versions` arg from CLI entry point
- Simplify templating approach
- Type as Flow
- Drop dependencies on `shelljs` and `yargs`
- Relocate under `scripts/releases/`
- Rewrite tests as snapshot tests

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D53001971

fbshipit-source-id: e55a71a0bb37e3e18ba1e582a5c46ddd58823d81
2024-01-30 06:46:50 -08:00
Rubén NorteandFacebook GitHub Bot 9ef6d606a7 Fix broken ReactNativeFeatureFlagsTest test on iOS (#42699)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42699

Changelog: [internal]

The test was fine on C++. The reason is probably that C++ destroys the process between tests (effectively resetting singletons) while iOS doesn't.

This fixes the test by implementing a correct `TearDown` method to reset the flags.

Reviewed By: rshest

Differential Revision: D53178474

fbshipit-source-id: 6a0f67f1a59fe47f73a495344d4c0daa8eafa3c4
2024-01-30 06:09:27 -08:00
zhongwuzwandFacebook GitHub Bot 4c108aaae4 Add Fabric dynamic color support (#42117)
Summary:
Fixes https://github.com/facebook/react-native/issues/42006 .

## Changelog:

[IOS] [ADDED] - Add Fabric dynamic color support

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

Test Plan:
Dynamic color worked.

![image](https://github.com/facebook/react-native/assets/5061845/c6e988c1-9d6b-4c09-a5e9-2f1960bbfcc5)

![image](https://github.com/facebook/react-native/assets/5061845/dcccdef7-990b-4367-b21f-38cabc7040ae)

Reviewed By: javache, sammy-SC

Differential Revision: D52512672

Pulled By: cipolleschi

fbshipit-source-id: f91da08e0bdd07a987289bd82585722496bdc280
2024-01-30 05:29:56 -08:00
Oskar KwaśniewskiandFacebook GitHub Bot d00d35e872 Fix retrieving current appearance in multi-window apps (#42231)
Summary:
This PR resolves issues with retrieving appearance in multi-window apps by calling `RCTKeyWindow()` instead of retrieving the AppDelegate window property. It also does small optimization in the RCTAlertController.

## Changelog:

[IOS] [FIXED] - Fix retrieving current appearance in multi-window apps

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

Test Plan: CI Green, it should work the same as before

Reviewed By: NickGerleman

Differential Revision: D52802756

Pulled By: cipolleschi

fbshipit-source-id: 60b5f7045f41be19caae5102f0dc321d4ecdcd2f
2024-01-30 04:52:34 -08:00
ankit-tailorandFacebook GitHub Bot fb5f79ceb5 fix: fontWeight typings (#42707)
Summary:
This PR fixes the typings for `fontWeight` style prop. Flow file has below typings but they were missing in typescript file.

```
  fontWeight?:
    | 'normal'
    | 'bold'
    | '100'
    | '200'
    | '300'
    | '400'
    | '500'
    | '600'
    | '700'
    | '800'
    | '900'
    | 100
    | 200
    | 300
    | 400
    | 500
    | 600
    | 700
    | 800
    | 900
    | 'ultralight'
    | 'thin'
    | 'light'
    | 'medium'
    | 'regular'
    | 'semibold'
    | 'condensedBold'
    | 'condensed'
    | 'heavy'
    | 'black'
    | undefined;
```

## Changelog:

[GENERAL] [ADDED] - Added missing typings for fontWeight style prop.

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

Test Plan: Tested manually.

Reviewed By: cortinico

Differential Revision: D53191119

Pulled By: NickGerleman

fbshipit-source-id: 47c00ea81be5aa217d57be0609cfc7bd4e8e6843
2024-01-30 04:21:30 -08:00
Riccardo CipolleschiandFacebook GitHub Bot fe337f25be Make bridgeless the default when the New Arch is enabled (#42714)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42714

For 0.74, we would like to have Bridgeless as the default when the New Architecture is enabled.

## Changelog:
[Android][Breaking] - Make bridgeless the default when the New Arch is enabled

Reviewed By: cortinico

Differential Revision: D52600227

fbshipit-source-id: 0d967c73cd805710c501c020ad892f059a0fb117
2024-01-30 03:35:11 -08:00
Riccardo CipolleschiandFacebook GitHub Bot c91af773fa Make bridgeless the default when the New Arch is enabled (#42182)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42182

For 0.74, we would like to have Bridgeless as the default when the New Architecture is enabled.

## Changelog:
[iOS][Breaking] - Make bridgeless the default when the New Arch is enabled

Reviewed By: cortinico

Differential Revision: D52598104

fbshipit-source-id: a551bbdda7f7b76d1647036137983e39e612ea45
2024-01-30 03:35:11 -08:00
Riccardo CipolleschiandFacebook GitHub Bot 8d710bfaca Refactor RCT_handleKeyCommand to avoid concurrency issues (#42708)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42708

When pressing `r` on simulator in Bridgeless mode, we have a race condition between:
- RCTKeyCommands evaluating the blocks to be invoked
- ReactNative invalidating the DevMenu with the list of RCTKeyCommands (on which ReactNative is iterating).

The fix checks which commands need to be executed, stores them in an array and then iterates on the array, which is local to the function call, avoiding any concurrency issue.

## Changelog:
[iOS][Fixed] - Refactored RCT_handleKeyCommand to avoid concurrency issues

Reviewed By: motiz88

Differential Revision: D53186262

fbshipit-source-id: 60ae8974a9df7289395c8a9e9abe2e34e4c40309
2024-01-30 03:12:50 -08:00
Ramanpreet NaraandFacebook GitHub Bot 8a8f74b7b2 Deprecate UIManager.{show,dismiss}PopupMenu
Summary:
This API is better implemented as a component: PopupMenuAndroid. Please see the ancestor diff D52712758.

Changelog: [Android][Deprecated] Deprecate UIManager.showPopupMenu, and UIManager.dismissPopupMenu

Reviewed By: mdvacca

Differential Revision: D52887565

fbshipit-source-id: 42da6bdaa707395c5694ec8ae3eb77b64cdefb69
2024-01-29 18:54:14 -08:00
Ramanpreet NaraandFacebook GitHub Bot 35308a73a5 Open source PopupMenuAndroid
Summary:
In React Native 0.75, we will remove UIManager.showPopupMenu(), UIManager.dismissPopupMenu().

To replace that API, we are introducing this <PopupMenuAndroid> component. This component works in both Fabric and Paper!

For the usage, please see PopupMenuAndroidExample.js.

Changelog: [Android][Added] - Introduce PopupMenuAndroid to replace UIManager.showPopupMenu()

Reviewed By: mdvacca

Differential Revision: D52712758

fbshipit-source-id: a87628a168d64fabbcc4d0f7b694fa639a927448
2024-01-29 18:54:14 -08:00
Ramanpreet NaraandFacebook GitHub Bot 7f549ec7be Deprecate BatchedBridge.registerCallableModule (#42717)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42717

This diff introduces a new bridge/bridgeless-agnostic api for registering JavaScript modules with React Native.

Usage:
```
import {registerCallableModule} from 'react-native';

registerCallableModule('FooModule', () => {...});
registerCallableModule('BarModule', {...});
```

Changelog: [General][Deprecated] - Deprecate BatchedBridge.registerCallableModule. Please use registerCallableModule instead

Reviewed By: javache

Differential Revision: D52805387

fbshipit-source-id: c7e77f0450ce1b0de349fa540c3a812256da054f
2024-01-29 18:41:54 -08:00
Nick GerlemanandFacebook GitHub Bot daa308027a Migrate enableSpannableBuildingUnification to new feature flag system (#42716)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42716

Migrates this to the new flag system just added.

Made a quick change to the Android template, to mark Kotlin accessors as `JvmStatic` to make calling from Java more idiomatic.

Next diff will wire to MC.

Changelog: [Internal]

Reviewed By: rubennorte, mdvacca

Differential Revision: D53198874

fbshipit-source-id: 6ab5b279d9ac59733c6e820c25be72383ce0e54a
2024-01-29 18:15:22 -08:00
Nick GerlemanandFacebook GitHub Bot 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 GerlemanandFacebook GitHub Bot 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 GerlemanandFacebook GitHub Bot 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 SuslaandFacebook GitHub Bot 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 SuslaandFacebook GitHub Bot 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 CipolleschiandFacebook GitHub Bot 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 VorobevandFacebook GitHub Bot 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
szymonrybczakandFacebook GitHub Bot 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 RykunandFacebook GitHub Bot 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 HuntandFacebook GitHub Bot 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 FriedmanandFacebook GitHub Bot 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
Nick GerlemanandFacebook GitHub Bot 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 GerlemanandFacebook GitHub Bot 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 VaccaandFacebook GitHub Bot 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 PanandFacebook GitHub Bot 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 GozaliandFacebook GitHub Bot 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 LewickiandFacebook GitHub Bot 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 TrzebiatowskiandFacebook GitHub Bot 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 NorteandFacebook GitHub Bot 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 NorteandFacebook GitHub Bot 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 NaraandFacebook GitHub Bot 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