Commit Graph

38536 Commits

Author SHA1 Message Date
David Vacca 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 Vacca 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 Vacca 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 Pope 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
Alex Hunt 2f818b464f Fix import in publish-npm script (#42740)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42740

Follow-up to a CircleCI breakage introduced by D53001971.

This was missed by both the typechecker (no Flow in file) and CI (no PR-time jobs covering this script).

Changelog: [Internal]

Reviewed By: cortinico, GijsWeterings, cipolleschi

Differential Revision: D53228096

fbshipit-source-id: fbbe1538ee52b8452399d86489239434d3a068be
2024-01-30 10:59:02 -08:00
Rubén Norte 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
zhongwuzw 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 Baets 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 Zilberman 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 Cipolleschi 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 Baets 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 Corti 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 N 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 Hunt 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 Norte 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
zhongwuzw 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śniewski 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-tailor 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 Cipolleschi 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 Cipolleschi 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 Cipolleschi 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 Nara 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 Nara 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 Nara 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 Gerleman 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 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
Blake Friedman 55978804dc Changelog: 0.73.3 (#42709)
Summary:
## Changelog: [Internal] Generated 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

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

Reviewed By: huntie

Differential Revision: D53188549

Pulled By: blakef

fbshipit-source-id: 4d5eab7d393777d14c2848b33626dfa7c3be5b02
2024-01-29 11:13:55 -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
Rob Hogan 2055ca0583 Set BUILD_EXCLUDE_BABEL_REGISTER: true under Jest tests (#42690)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42690

Issues triggered by `InspectorProxy*` tests under `packages/dev-middleware` (T169943794) can be root-caused to `dev-middleware` performing Babel registration within a test run, after Jest has hooked its own transformer.

Babel registration is only required when running this code (`dev-middleware`, etc) directly from source - we already have the `BUILD_EXCLUDE_BABEL_REGISTER` mechanism to strip it out from production builds, but we currently don't prevent registration under tests, where Jest's transformer should be allowed to do its work.

This adds the same `babel-plugin-transform-define` mechanism that we use for production builds to the Jest transformer.

Changelog:
[Internal] Prevent inadvertent Babel registration during running of repo tests

Reviewed By: huntie

Differential Revision: D53125777

fbshipit-source-id: 1f0a20315c96edaf79054e29a80c7a9561e5b352
2024-01-27 06:49:15 -08:00
Rob Hogan 41b256a776 Babel-ignore node_modules on Windows consistently with others (#42681)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42681

CI failures in Windows JS tests recently (https://github.com/facebook/react-native/pull/41463) were caused by the triggering of Babel registration during tests, due to an import of `packages/dev-middleware` (index), breaking subsequent transformation of other tests.

## Root cause
Example of a problematic import:
https://github.com/facebook/react-native/blob/a5d8ea4579c630af1e4e0fe1d99ad9dc0915df86/packages/dev-middleware/src/__tests__/ServerUtils.js#L15

..which triggers a Babel registration:
https://github.com/facebook/react-native/blob/a5d8ea4579c630af1e4e0fe1d99ad9dc0915df86/packages/dev-middleware/src/index.js#L16-L18

That registration behaves differently on Windows due to the `ignore: [/\/node_modules\/\]`, which doesn't match against Windows path separators - Babel matches against system separators.

In particular, this changed whether `node_modules/flow-parser` was transformed when loading the RN Babel transformer. Transforming this file causes a `console.warn` from Babel due to its size:
> [BABEL] Note: The code generator has deoptimised the styling of /Users/robhogan/workspace/react-native/node_modules/flow-parser/flow_parser.js as it exceeds the max of 500KB.

This throws due to our setup:
https://github.com/facebook/react-native/blob/a5d8ea4579c630af1e4e0fe1d99ad9dc0915df86/packages/react-native/jest/local-setup.js#L27

This all manifests as the first test following a Babel registration (within the same Jest worker) that requires the RN Babel transformer throwing during script transformation.

## This change
This is the minimally disruptive change that makes Babel registration behaviour consistent between Windows and other platforms. The more durable solution here would be *not* to rely on any Babel registration for Jest, which has its own `ScriptTransformer` mechanism for running code from source. Given the fragile way our internal+OSS Babel set up hangs together that's a higher-risk change, so I'll follow up separately.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D53124578

fbshipit-source-id: 074a8e139e506a5dceec13f07d412599fb292d92
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