Compare commits

...
Author SHA1 Message Date
Christian Falch aaff0d37e2 Updated snapshot 2025-06-25 15:35:20 +02:00
Christian Falch 16a89816fc [ios][prebuild] revert changes in ReactCodegen template
After switching to the new backwards compatible cocoapods structure with prebuilts, we no longer need any change in the ReactCodegen template.

This commit fixes this.
2025-06-25 15:28:14 +02:00
Nicola Corti 04858ecbab Bump AGP to 8.11.0 (#52248)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52248

Just keep the AGP version update.

Changelog:
[Android] [Changed] - Bump AGP to 8.11.0

Reviewed By: rshest

Differential Revision: D77292284

fbshipit-source-id: 2d0bfe1b50e613690bc3cc6b81ae352136543fd4
2025-06-25 03:49:48 -07:00
Christian Falch d8e00f0bb1 Added backwards compatible use of prebuild through cocoapods (#52252)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52252

Instead of declaring two different sets of Pods for prebuilt and build from source, this commit now keeps the pod structure the same for both modes so that consuming libraries can expect to have the same pods and header files available - without this, libraries would have to be updated to take advantage of the prebuilds.

This PR does:
- Added React-Core-prebuilt as a pod in React-Core if prebuilt is enabled
- Simplified react_native_pods to keep pods structure and add React-Core-prebuilt pod if prebuilts are enabled
- Added function for selecting source sets based on prebuilt/build from source

To be able to function both in prebuilt and in regular build from source mode, all podspecs are now using the switch function podspec_sources so that they only include header files if we are in prebuild mode.

Also added React-Core-prebuilt as dependency on React-Core if we are in prebuilt mode so that we install the React.XCFramework.

## Changelog:

[IOS] [FIXED] - Added backwards compatible use of prebuild through cocoapods

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

Test Plan:
Tested in RN-Tester both with and without prebuild.

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D77296047

Pulled By: cipolleschi

fbshipit-source-id: f3eb4d56b2a78bfc8e10ad852746be1ceaf828b2
2025-06-25 03:44:03 -07:00
Christian Falch 07f6f70aef Add missing RCTVibration target in SwiftPM (#52223)
Summary:
`Package.swift` was missing the `RCTVibration` target. This commit adds this target.

## Changelog:

[Internal] - Added RCTVibration to SwiftPM

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

Test Plan: Tested in RN-Tester both with and without prebuild.

Reviewed By: cortinico

Differential Revision: D77257066

Pulled By: cipolleschi

fbshipit-source-id: 13c918387a2ed4a8e3941ddce8b7ba11c24eaab5
2025-06-25 03:44:03 -07:00
Alex Hunt ece8ca82cd Update JS API snapshot to group exports in single block (#52235)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52235

Adds `organizeDeclarations` transform, replacing `sortTypeDefinitions`.

All `export declare ...` statements are now collected and represented at the end of the snapshot in a single `export {}` block — significantly improving readability and diffing.

Changelog: [Internal]

Reviewed By: j-piasecki

Differential Revision: D77150017

fbshipit-source-id: 1bd451c0e2a18fd6fc0504970b10a5d2502ac872
2025-06-25 02:55:42 -07:00
Tim Yung 08a59c59e0 VirtualView: Minimize Events w/ Render State (#52245)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52245

Changes `VirtualView` to avoid dispatching redundant mode change events by reading the last committed `renderState` to determine whether the desired render state is already in effect.

This enables `VirtualView` to avoid dispatching synchronous `Visible` mode change events when a previous `Prerender` mode change event has already been committed.

Changelog:
[Internal]

Reviewed By: lunaleaps

Differential Revision: D77271865

fbshipit-source-id: 75418aec1416995737f308a1beff407f2cedb940
2025-06-25 02:18:52 -07:00
Jakub Piasecki fbd44ade3a Change Animated methods' local names to avoid symbol collisions in the API snapshot (#52219)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52219

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D77221690

fbshipit-source-id: 149711ee8c9d89c50178bf3d41de8b44fbc1d464
2025-06-25 00:16:24 -07:00
Jakub Piasecki 4f94028ca6 Reduce symbol collisions in the API snapshot (#52213)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52213

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D77207979

fbshipit-source-id: 10d8b9c8f24ddb52423197f5aa300402b1e45ebe
2025-06-25 00:16:24 -07:00
generatedunixname89002005287564 0a567a63cd Fix CQS signal modernize-concat-nested-namespaces in xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/jni/first-party/fbgloginit (#52217)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52217

Reviewed By: javache

Differential Revision: D77211475

fbshipit-source-id: 22a89c5211ffc5f9f09ad27dc5e2597c6ceefd99
2025-06-24 22:55:27 -07:00
Tim Yung 19ebd4c188 VirtualView: Prerender w/o Window Focus (#52240)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52240

Changes `VirtualView` to detect when its window is not in a focused window (e.g. scroll position or layout changes when it is blurred) and to instead dispatch an async `Prerender` event instead of a sync `Visible` event.

This minimizes unnecessary main thread synchronous work that is needed for a view that is not important to the user experience.

Changelog:
[Internal]

Reviewed By: mdvacca

Differential Revision: D77261958

fbshipit-source-id: 32acef9bc938005a0d73c5166f1741aebadf23bb
2025-06-24 22:33:07 -07:00
George Zahariev a2a72e239d Enable experimental Flow 'match' syntax for react-native-github/packages/react-native/src/private/components/virtualview/ (#52236)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52236

Enable experimental Flow 'match' syntax for `react-native-github/packages/react-native/src/private/components/virtualview/` and adopt in one case to see if there are any issues.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D77250963

fbshipit-source-id: 0b2a5817a05f3332031f0c0590fe956eaa74ddd3
2025-06-24 17:55:57 -07:00
Cao Doan fedceecc37 Correct some cpp imports (#52212)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52212

Correcting some C++ imports that show up when build with Xcode 26:
- Missing `<string>` imports.
- `<tgmath.h>` is a deprecated C++ header file, which in this case can be substituted with `<cmath>`.

## Changelog: [Internal]

[iOS][Fixed] - Fix deprecated C++ imports

Reviewed By: zhenma

Differential Revision: D77192276

fbshipit-source-id: 30c836947cb3eb54f6e7ac42b87fd2493334a4f4
2025-06-24 15:38:23 -07:00
Sam Zhou e3047db0dc Deploy 0.274.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D77246379

fbshipit-source-id: 4a86da380109e85b5e1d53f5723f6ea07e6ea429
2025-06-24 12:58:53 -07:00
Andrew Datsenko 1e212f91bc Add remaining dependencies (#52202)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52202

Changelog: [Internal]

Build fantom_tester for OSS

Reviewed By: mdvacca

Differential Revision: D76928253

fbshipit-source-id: a95e8751326f45a25cd512b7a5d05260b37a0305
2025-06-24 12:33:59 -07:00
Riccardo Cipolleschi 4f1f72ea34 Fix downloading nightly prebuilds (#52233)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52233

When working on [c1bf39bfdf](https://github.com/facebook/react-native/commit/c1bf39bfdfaa0381be3a20d0d89ce159e482afe1) I forgot to add a `.body` to extract the body from the response.

As a result, we can't install prebuilds in a nightly.

This change fixes this.

## Changelog:
[Internal] -

Reviewed By: realsoelynn

Differential Revision: D77241914

fbshipit-source-id: 013ed927e1a3cd6476a551995577ade80c477dd7
2025-06-24 12:05:51 -07:00
Sam Zhou fe1aacae6d Pre-suppress errors in fbsource ahead of 0.274.0 release (#52232)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52232

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D77230727

fbshipit-source-id: 890b819ffa3ea9996fa11d254215ea1304ba02b4
2025-06-24 11:04:37 -07:00
Jorge Cabiedes Acosta a82b5acf3d Fix jumping talkback triggering scroll when reaching a view with accessibilityOrder (#52231)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52231

Not calling `super.onInitializeAccessibilityNodeInfo` on the host view with accessibilityOrder prevents setting proper dimensions for the node that backs the view which leads TalkBack to trigger scrolling when under a ScrollVIew.

We still need the host's node to not be accessible so we still set it to not be focusable and not have a content description since this should be handled by the virtual views

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D77180494

fbshipit-source-id: fe8794cf421cdc9548cf3e18a62d4bb3e8c26b09
2025-06-24 09:37:36 -07:00
Jorge Cabiedes Acosta 8cc2874d3f Fix View Coopting View edge case on Android (#52066)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52066

Before, to disable views that were excluded from the order we were setting them to be not important for accessibility. This however breaks coopting behavior of parent views, because parent views will not announce content descriptions of children that are not important for accessibility.

Instead of disabling by setting `important for accessibility = no` now we just set `isFocusable = false` which disables focusing but still allows parent views to coopt

We also add functionality to restore view focusability when enabling disabling screen readers since `isFocusable` changes keyboard focusability and when screen readers are disabled we don't want to change it.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D76745057

fbshipit-source-id: cc237c5f8a4b894a7caa3e34207080777de440ac
2025-06-24 09:37:36 -07:00
Alex Hunt d012b2c19b Fix stripUnstableApis to match type alias declarations (#52229)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52229

Changelog: [Internal]

Reviewed By: j-piasecki

Differential Revision: D77148443

fbshipit-source-id: 423da38dfe5ca42e639e274461868a51e9987384
2025-06-24 09:15:53 -07:00
Alex Hunt cfc6960bc4 Update all transforms to apply sequentially (#52228)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52228

To avoid unexpected behaviour, apply all Babel transforms within `build-types` sequentially, so that each transform plugin has an accurate starting AST.

Changelog: [Internal]

Reviewed By: j-piasecki

Differential Revision: D77148444

fbshipit-source-id: f86beac12b7a08ef800e28db1ff88755970cf64e
2025-06-24 09:15:53 -07:00
Alex Hunt ef742dbc68 Subfolder build-types transforms by language (#52230)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52230

Reorganisation/refactoring.

Changelog: [Internal]

Reviewed By: j-piasecki

Differential Revision: D77148446

fbshipit-source-id: fd29c6d47347efd5ad3da933b2112e864064dba7
2025-06-24 09:15:53 -07:00
Alex Hunt 11a1ad7a98 Expose *AnimationConfig types (#52227)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52227

Changelog:
[General][Added] - Expose additional `*AnimationConfig` types on the `Animated` namespace

Differential Revision: D77222030

fbshipit-source-id: 8fd01d820c3c8d6e952a4115578ecc83ae7a0d0f
2025-06-24 08:55:21 -07:00
Alex Hunt b01a5f91fe Expose Animated.InterpolationConfig type (#52224)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52224

Changelog:
[General][Added] - `InterpolationConfig` is now exposed on the `Animated` namespace

Differential Revision: D77222031

fbshipit-source-id: c64c2f348bc899c598ee86c637300037a5a8de6f
2025-06-24 08:55:21 -07:00
Mateo Guzmán 65ae3dafcd Migrate UIManagerHelper to Kotlin (#52209)
Summary:
Migrate com.facebook.react.uimanager.UIManagerHelper to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.uimanager.UIManagerHelper to Kotlin

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

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: javache

Differential Revision: D77210140

Pulled By: cortinico

fbshipit-source-id: 7a6669a6d92d33241d3f42edbabf20170a5a6ddf
2025-06-24 08:06:13 -07:00
Mateo Guzmán d3495fd162 Migrate ReactApplicationContext to Kotlin (#52208)
Summary:
Migrate com.facebook.react.bridge.ReactApplicationContext to Kotlin.

## Changelog:

[INTERNAL] - Migrate com.facebook.react.bridge.ReactApplicationContext to Kotlin

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

Test Plan:
```bash
yarn test-android
yarn android
```

Reviewed By: javache

Differential Revision: D77209812

Pulled By: cortinico

fbshipit-source-id: 2dae094d363e60efe05b4f2b3d55f0f84d921495
2025-06-24 08:03:22 -07:00
Andrew Datsenko 252e1345bf Move fantom into OSS (#52201)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52201

Changelog: [Internal]

Moving fantom tester into OSS.

Reviewed By: rubennorte

Differential Revision: D76928252

fbshipit-source-id: 3faf4a236eacba17896e0a440bac7a5032d063f9
2025-06-24 07:24:41 -07:00
Andrew Datsenko dd1b795abe Introduce react_native_android_dep (#52194)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52194

Changelog: [Internal]

Introducing a way to include sources and deps via function that react_native_android_dep.

This will help with Fantom OSS build.

Reviewed By: cortinico

Differential Revision: D77146189

fbshipit-source-id: 06b09d433741506bc1f58fbf1f9e6add9a9cff91
2025-06-24 07:24:41 -07:00
Mateo Guzmán c125f306c2 Kotlin: fix static code analysis weak warnings (4/n) (#52207)
Summary:
Static code analysis reports several weak warnings, many of which seem to be leftovers after Kotlin migration. This PR addresses quite a few:

- [Redundant curly braces in string template](https://www.jetbrains.com/help/inspectopedia/RemoveCurlyBracesFromTemplate.html)
- [Redundant call to toString() in string template](https://www.jetbrains.com/help/inspectopedia/RemoveToStringInStringTemplate.html)

## Changelog:

[INTERNAL] - Kotlin: fix static code analysis weak warnings (4/n)

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

Test Plan:
```sh
yarn android
yarn test-android
```

Reviewed By: javache

Differential Revision: D77209873

Pulled By: cortinico

fbshipit-source-id: 2bf5fcf7dcbf02632e721aab0688f73d15f220b9
2025-06-24 06:36:11 -07:00
Alex Hunt 03ab6a3098 Add nocommit to V2 JS API snapshot (#52200)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52200

Remains in an experimental format. Add `\nocommit` to prevent accidental inclusion in the repo right now.

Also disable ESLint rule `redundant-undefined/redundant-undefined`.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D77150743

fbshipit-source-id: 645e7db5af2c2a648eef7c8f7e324bc1264b8065
2025-06-24 06:31:04 -07:00
Riccardo Cipolleschi 46b562b9b3 Ship the new React-Core-prebuilt.podspec in the package.json (#52221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52221

It is currently not possible to use prebuilds, because we are missing the `React-Core-prebuilt.podspec` from the npm package we publish.

This change should fix it.

## Changelog:
[iOS][Added] - Ship the `React-Core-prebuilt.podspec` in the package.json

Reviewed By: cortinico

Differential Revision: D77223271

fbshipit-source-id: ab068e1711fdd86f3f0069dc9aa3c0a591fcd26b
2025-06-24 06:01:36 -07:00
Riccardo Cipolleschi c1bf39bfdf Fix download of nightlies with SwiftPM (#52215)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52215

We were not handling the download of the XML properly. Using `Net::HTTP.get` will directly return the body and that won't let us check on the status code of the response.

## Changelog:
[Internal] - use get_response instead of get when downloading the maven metadata

Reviewed By: cortinico

Differential Revision: D77216121

fbshipit-source-id: 4da0abff1624c687977a7b77db8a15f19e6b887d
2025-06-24 06:01:36 -07:00
nishan (o^▽^o) f238b74658 - Use CAGradientLayer for radial gradient (#52117)
Summary:
This PR replaces Core Graphics implementation with Core Animation for radial gradients. I found that `endPoints` for radial gradient type works differently than linear gradient type. The `endPoint.x` accounts for horizontal length and `endPoint.y` accounts for vertical. This makes it possible to draw ellipse gradients. So we don't need the core graphics API anymore.

## Changelog:

[IOS] [CHANGED] - Optimised Radial Gradients.

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

Pick one each for the category and type tags:

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

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

Test Plan: Non breaking change. Test Radial gradient example from RNTester. Compare results with web, android and iOS. Each platform should render the gradients identically.

Reviewed By: rshest

Differential Revision: D77140709

Pulled By: javache

fbshipit-source-id: 6e3ad9fcf8e819d340ccf5f5946beb140e616cb0
2025-06-24 05:10:30 -07:00
Mateo Guzmán 76e2ab4ac8 Kotlin: fix static code analysis weak warnings (3/n) (#52206)
Summary:
Static code analysis reports several weak warnings, many of which seem to be leftovers after Kotlin migration. This PR addresses quite a few:

- [Return or assignment can be lifted out](https://www.jetbrains.com/help/inspectopedia/LiftReturnOrAssignment.html)
- [Verbose nullability and emptiness check](https://www.jetbrains.com/help/inspectopedia/VerboseNullabilityAndEmptiness.html)
- [Size check can be replaced with 'isNotEmpty()'](https://www.jetbrains.com/help/inspectopedia/ReplaceSizeCheckWithIsNotEmpty.html)

## Changelog:

[INTERNAL] - Kotlin: fix static code analysis weak warnings (3/n)

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

Test Plan:
```sh
yarn android
yarn test-android
```

Reviewed By: javache

Differential Revision: D77209766

Pulled By: cortinico

fbshipit-source-id: c154ec6578125c16ad37c9dd15295a2edcacee4a
2025-06-24 04:55:33 -07:00
Mo Javad 35dba09724 Add explicit Build Tools Version to RN Tester Android App Benchmark (#52216)
Summary:
After bumping to SDK version 36, the build process for Android was still pulling in SDK v35 unnecessarily. This PR fixes that issue.

## Changelog:

[ANDROID] [FIXED] - Added explicit build tool version to RN Tester build.gradle to avoid automatic installation of Android SDK Build Tools.

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

Test Plan:
Tested in fork pipeline to ensure it's working correctly.

This is the logs from the pipeline before:
![image](https://github.com/user-attachments/assets/9dc7f158-8dea-437e-836e-e5f500b3d5ff)

And this is after the fix:
![image](https://github.com/user-attachments/assets/c6cc1c0a-5823-41cb-ba32-027b69d6eaa6)

Reviewed By: rshest

Differential Revision: D77219569

Pulled By: cortinico

fbshipit-source-id: 7a0ca462d00bfc4b015a30807aaef999ff60c719
2025-06-24 04:34:46 -07:00
Mateo Guzmán 9e96acbd0f Kotlin: fix static code analysis weak warnings (2/n) (#52205)
Summary:
Static code analysis reports several weak warnings, many of which seem to be leftovers after Kotlin migration. This PR addresses:

- [Kotlin Java methods should be replaced with Kotlin analog](https://www.jetbrains.com/help/inspectopedia/ReplaceJavaStaticMethodWithKotlinAnalog.html)

## Changelog:

[INTERNAL] - Kotlin: fix static code analysis weak warnings (2/n)

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

Test Plan:
```sh
yarn android
yarn test-android
```

Reviewed By: javache

Differential Revision: D77209667

Pulled By: cortinico

fbshipit-source-id: 09b01a170abf43248b8fdb6a08498d278b9d03bd
2025-06-24 03:40:58 -07:00
Alex Hunt 40b8f4ad22 Adjust source types for better output (#52199)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52199

Minor fixes to naming and generic type compatibility (→ TypeScript).

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D77148914

fbshipit-source-id: 2d3e65170f261b97ea8cf705d1a40a6f7bc5bcc7
2025-06-24 02:57:34 -07:00
George Zahariev 3306691d64 Update hermes-parser and related packages in xplat and socialvr to 0.29.0 (#52211)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52211

Update hermes-parser and related packages in xplat and socialvr to 0.29.0

Changelog: [Internal]

Blocked on: https://fb.workplace.com/groups/relay.support/posts/28766057099682865

Reviewed By: SamChou19815

Differential Revision: D77004095

fbshipit-source-id: 5400ac07c0cbf1f9709d374929d842af9dd15d08
2025-06-23 19:19:50 -07:00
Antonio Pires f184b591cf adding scrollTo, and imperative handle exports for ScrollView (#52204)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52204

Changelog:
[General][Added] - Expose `ScrollViewImperativeMethods` and `ScrollViewScrollToOptions` types to public API

Reviewed By: huntie

Differential Revision: D76920770

fbshipit-source-id: 01b0a2788f7b8a3bad0b57e24b04a7380233ac34
2025-06-23 12:13:02 -07:00
Joe Vilches 62d8d30652 Revamp the accessibility order example in RNTester (#52122)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52122

Would love to have a place with all the edge cases we can come back to when we try and tweak things.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D76942595

fbshipit-source-id: ce6e293e2c068383e54404af71a29a0586dbc04e
2025-06-23 11:07:52 -07:00
generatedunixname89002005287564 60967fdffb Fix CQS signal modernize-use-nullptr in xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/components/textinput/platform/android/react/renderer/components/androidtextinput (#52145)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52145

Reviewed By: javache

Differential Revision: D77010402

fbshipit-source-id: db2823f888b1fca279ff13f8a323e074fcdf61f0
2025-06-23 09:55:44 -07:00
Zane Bauman 4b91b63094 fix: add missing getNativeScrollRef type for ScrollView (#52203)
Summary:
### The Problem

When trying to measure the location of a `View` within a `ScrollView` (ie. for scrolling to the view), the current recommended method is to use `measureLayout` on the nested view to determine its location inside the containing scroll view:

```tsx
const MyComponent = () => {
  const scrollViewRef = useRef<ScrollView>(null);
  const nestedViewRef = useRef<View>(null);

  const scrollToNestedView = () => {
    if (!scrollViewRef.current || !nestedViewRef.current) {
      return;
    }

    nestedViewRef.current.measureLayout(
      scrollViewRef.current.getInnerViewNode(),
      (x, y) => { scrollViewRef.current.scrollTo({ y, animated: true }); },
    );
  }

  return (
    <ScrollView ref={scrollViewRef}>
      <View ref={nestedViewRef}>
        { /* content */ }
      </View>
    </ScrollView>
  );
}
```

This is valid in the Typescript types layer. However, the only two methods on `ScrollView` to use in this scenario that are [available in the type definitions](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/ScrollView/ScrollView.d.ts#L830) are `getScrollableNode` and `getInnerViewNode` – both of these methods [return a `number`](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/ScrollView/ScrollView.js#L139-L140). The issue is that a `number` not a valid value to use with `measureLayout` because [its source returns early for that type](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js#L91-L102).

(Note, you can also use `findNodeHandle` with the scroll view ref, but this also returns a `number`.)

### The Solution

The long-term solution would be to update the types for both `measureLayout` and `ScrollView`. However, that would constitute a breaking change and require some fairly expansive updates. Instead, I am proposing an additive solution.

`ScrollView` has [a public method called `getNativeScrollRef`](https://github.com/facebook/react-native/blob/e69f0726cd2616fb112d2e4fabfeaafc8cada5d7/packages/react-native/Libraries/Components/ScrollView/ScrollView.js#L142) which returns the underlying `HostInstance`. This method correctly works in the runtime layer, but is not supported in the types layer. This PR exposes the public method in the type definition so that we can properly access the underlying instance without using `ts-ignore`.

## Changelog:[GENERAL] [FIXED] - Expose `ScrollView.getNativeScrollRef` on the type definition to allow accessing the underlying `HostInstance`.

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

Test Plan: None needed. This is only a type update exposing existing functionality.

Reviewed By: cortinico

Differential Revision: D77153959

Pulled By: rshest

fbshipit-source-id: 5880695da85406ed9fe49a1b736b5754db0e6382
2025-06-23 09:55:32 -07:00
generatedunixname89002005287564 7f7655d711 Fix CQS signal modernize-concat-nested-namespaces in xplat/js/react-native-github/packages/react-native/ReactCommon/cxxreact (#52146)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52146

Reviewed By: javache

Differential Revision: D77014011

fbshipit-source-id: 35afa03482c9a4d1fe11325421615a7214337e2a
2025-06-23 09:52:30 -07:00
Dawid Małecki 76e04fac82 Replace shelljs in run-ci-javascript-tests.js (#52095)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52095

This diff removes `shelljs` from `run-ci-javascript-tests.js` and replaces `echo, exec, and exit` methods.

### Motivation

Decrease number of references to `shelljs` across the react-native-github.

Changelog:
[Internal]

Reviewed By: NickGerleman

Differential Revision: D76512374

fbshipit-source-id: 6e02901b570cf9a36bd13a075106a7066a85a2d9
2025-06-23 09:39:44 -07:00
Rubén Norte 18f4db44ef Clean up dead logic in RuntimeScheduler_Modern and simplify logic (#52192)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52192

Changelog: [internal]

When we shipped the event loop we removed the need to run only expired tasks in `RuntimeScheduler_Modern`, but we never cleaned up the code properly. This does it.

Reviewed By: javache

Differential Revision: D77142978

fbshipit-source-id: f808edf80a134f487723fa36ab7a3593e4efe2d3
2025-06-23 08:34:50 -07:00
Rubén Norte 251eb3fd4c Log task ID when scheduling and executing tasks in RuntimeScheduler (#52191)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52191

Changelog: [internal]

Some time ago we added logging for the timer ID in Systrace/Perfetto so we could see where timers were scheduled vs. executed.

This diff adds support for the same functionality for tasks in the runtime scheduler.

Reviewed By: javache

Differential Revision: D77039038

fbshipit-source-id: 792d2fe29b44fb209f9129f46f9d661dad7ebdff
2025-06-23 08:34:50 -07:00
Rubén Norte 3782fe865d Improve tracing metadata for IntersectionObserverManager (#52190)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52190

Changelog: [internal]

This adds some tracing metadata to IntersectionObserver to contextualize the performance of certain operations (logging how many observers it's processing).

Reviewed By: javache

Differential Revision: D77039037

fbshipit-source-id: 9cee79ac0509f57e4658a16142f3fe2d10d71fdf
2025-06-23 08:34:50 -07:00
Rubén Norte 5742227dd8 Add Fantom benchmark for RuntimeScheduler (#52189)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52189

Changelog: [internal]

This creates a benchmark to measure the changes in performance in RuntimeScheduler.

Reviewed By: javache

Differential Revision: D77142979

fbshipit-source-id: 1a6e6824f4c6fdb8d2c5cbad77fb4b8ba406ef29
2025-06-23 08:34:50 -07:00
Christian Falch 90654e4ba2 Integrate React Core prebuilds with apps (#52138)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52138

Integrate React Core prebuilds with apps

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

## Changelog:

[IOS] [ADDED] - Added support for using prebuilt RNCore with Cocoapods

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76980286

Pulled By: cipolleschi

fbshipit-source-id: 0ef34599cf7a60e54f799708bce93bcf6fb9d950
2025-06-23 08:13:56 -07:00
Christian Falch 60c01b4715 Update RNDependencies podspec to fail fast if framework is missing (#52134)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52134

Update RNDependencies podspec to fail fast if framework is missing

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

## Changelog:

[IOS] [CHANGED] - Fail fast when pod install i f using prebuild if frameworks are not present in the disk.

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76980282

Pulled By: cipolleschi

fbshipit-source-id: 6ab029d0cb06e2f0a3d99ea9fc7b375865e7a966
2025-06-23 08:13:56 -07:00
Christian Falch 69e028da45 Update the xcframework.js script to support swift (#52135)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52135

Update the xcframework.js script to support Swift

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

## Changelog:

[INTERNAL] - Update the xcframework.js script to support Swift

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76980285

Pulled By: cipolleschi

fbshipit-source-id: 4e5486b79c406ba4b375e2ada24cbe5450e2346f
2025-06-23 08:13:56 -07:00
Christian Falch 152cb538f6 Update ReactCodegen to support Core prebuilds (#52137)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52137

Update ReactCodegen to support Core prebuilds

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

## Changelog:

[IOS] [CHANGED] - Update ReactCodegen to support Core prebuilds

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76980283

Pulled By: cipolleschi

fbshipit-source-id: 4b120203e9e1628a63580b0b3b2e882837c0b818
2025-06-23 08:13:56 -07:00
Christian Falch 2ec6e3d901 Update rndependencies.rb to use the same logic of rncore.rb (#52136)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52136

Update rndependencies.rb to use the same logic of rncore.rb

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

## Changelog:

[INTERNAL] - Update rndependencies.rb to use the same logic of rncore.rb

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76980284

Pulled By: cipolleschi

fbshipit-source-id: a7f09d931c66e2fdf468a09da4be1d40847f472b
2025-06-23 08:13:56 -07:00
Christian Falch 1a86ee17fb Add React-Core-prebuild.podspec to integrate React native core prebuilds using cocoapods (#52133)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52133

Add React-Core-prebuild.podspec to integrate React native core prebuilds using cocoapods

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

## Changelog:

[IOS] [ADDED] - Add `React-Core-prebuild.podspec` to integrate React native core prebuilds using cocoapods

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico

Differential Revision: D76980281

Pulled By: cipolleschi

fbshipit-source-id: ce102837d6df6ab0fa2e55862cc0c954125bd362
2025-06-23 08:13:56 -07:00
Christian Falch 8888cf9a2d Introduce rncore.rb to manage the core prebuilds (#52109)
Summary:
Introduce rncore.rb to manage the prebuilds of RNCore.

## Context
This PR introduces the first working version of building React Native apps on iOS using prebuilt RNCore and cocoapods.

- Added React-Core-prebuilt.podspec for installing/consuming XCFrameworks
- Added logic in react_native_pods.rb for switching between build from source and using prebuilts
- Added rncore.rb - utilities for the ReactCore prebuilts
- Updated rndependencies with some extra error handling modelled after rncode.rb
- Added support for hard linking headers and modules in each inner framework in the XCFramework in xcframework.js

## Swift:
To enable support for the objective-c types from swift, the swift compiler uses a module map to gather exports from the framework (module.modulemap). This file basically points to an umbrella header file that exports the valid objective-c types (non c++) to Swift. In addition these files are read from the DerivedData and not the project source - so it is a bit hard to control everyting.

I was initially not able to use cocoapods own module definitions (module_name, module_file props) to use a custom module map. I finally found that these files are expected in the deriveddata (build folder) where only the active inner framework is copied - so then I had to hard link both module map and header files for each arch.

bypass-github-export-checks

## Changelog:

[INTERNAL] - Added script to handle React Core prebuilds

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

Test Plan:
Run with RN Tester. We need to remove all extra pods from RNTester pod file since none of them are yet compatible with prebuilt (they reference non-prebuilt pods)

Rollback Plan:

Reviewed By: cortinico, rshest

Differential Revision: D76979549

Pulled By: cipolleschi

fbshipit-source-id: 7a2b1809bf58b600293cc33ca2dcff0060f3fab0
2025-06-23 08:13:56 -07:00
Ruslan Shestopalyuk 27c97ac942 Minimal implementation for ImageLoaderModule in ReactCxxPlatform (#52198)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52198

# Changelog:
[Internal] -

This provides an implementation of what was the RnCxx ImageLoaderModule stub inside ReactCxxPlatform, allowing the clients use dependency injection to provide the actual platform specific image loading functionality.

Reviewed By: javache

Differential Revision: D77015269

fbshipit-source-id: 7355dd75692c1f564de8c3daffd6c8a79182dc09
2025-06-23 07:44:36 -07:00
Nicola Corti e69f0726cd Make EventDispatcherImpl internal (#52154)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52154

I wasn't able to find any meaningful usage of `EventDispatcherImpl` in OSS, therefore I'm making this class internal.

Changelog:
[Internal] [Changed] -

Reviewed By: javache

Differential Revision: D77024759

fbshipit-source-id: e1ff3329cedf96a8c75edb9b9ccc1ce21adfab11
2025-06-23 07:35:06 -07:00
Nicola Corti 1ced97fbe6 Convert EventDispatcherImpl to Kotlin (#52150)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52150

This is another class moving from Java to Kotlin.

Changelog:
[Internal] [Changed] -

Reviewed By: javache

Differential Revision: D77021952

fbshipit-source-id: 0b04a10bcbe65b7dc14ddd2821f80d90a43f8610
2025-06-23 07:35:06 -07:00
Nicola Corti ff7e24f19a @DoNotStrip ReactModalHostView to prevent instacrash on release (#52195)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52195

RNTester is currently instacrashing on release due to use minifying the `ReactModalHostView`.
In that class there is a static method that is accessed by JNI so we should annotated this class
as `DoNotStrip` as otherwise we won't be able to access it.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D77148010

fbshipit-source-id: c5b2758fa2919bc1f5885433202a45b4c3f8ff99
2025-06-23 07:24:47 -07:00
Nicola Corti d9ec57a3b9 Add further logging to help investigate T228303477 (#52185)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52185

It seems like one of the activity on the stack is not properly implementing `DefaultHardwareBackBtnHandler`.
This will make the crash more clear as it will be clear which activity is the one responsible for the crash.

Changelog:
[Internal] [Changed] -

Reviewed By: javache

Differential Revision: D77142320

fbshipit-source-id: 1913976d1ad5d3ceafcfc0569f3b74dad9e919ae
2025-06-23 06:07:50 -07:00
Nicola Corti 33fed54a16 Truncate the changelog pre-80 to a separate file.
Summary:
Splitting the CHANGELOG as it's getting too big to handle.

Changelog:
[Internal] [Changed] -

bypass-github-export-checks

Reviewed By: cipolleschi

Differential Revision: D77025333

fbshipit-source-id: cf2d54f2096f9c8c6a3fadb354d0c3065370440d
2025-06-23 06:00:07 -07:00
Andrew Datsenko 7b7b538d6b fix cmake empty spaces and naming (#52186)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52186

Changelog: [Internal]
Minor fixes to spacing in cmake files and naming inconsistency

Reviewed By: cortinico

Differential Revision: D77141854

fbshipit-source-id: d1e12e571dbc0f7630d9d38faad7b22d0833dd2f
2025-06-23 04:25:59 -07:00
Pieter De Baets 9612d2e225 NativeAnimated Kotlin nits (#52148)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52148

Address some Android Studio lint suggestions

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D77017839

fbshipit-source-id: c0e025ee7eaae74560cfc8ff6ecc45a893e0dda1
2025-06-23 04:24:58 -07:00
Pieter De Baets ee8b66e278 View clipping Kotlin nits (#52147)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52147

Simplify some of the nullability / checkNotNull behaviour

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D76334294

fbshipit-source-id: 32c2d0ab50713789ddf6af5e40083bae2161c91f
2025-06-23 04:24:58 -07:00
Susmita Horrow f214a52a9a Revert D76814453: Reduce symbol collisions in the API snapshot
Differential Revision:
D76814453

Original commit changeset: fffbf585d63e

Original Phabricator Diff: D76814453

fbshipit-source-id: 418ae90fb49c8c05f077bca7e434c039ad49c7ba
2025-06-23 01:43:20 -07:00
Jakub Piasecki f338db9c17 Reduce symbol collisions in the API snapshot (#52085)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52085

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D76814453

fbshipit-source-id: fffbf585d63e282443830c08397ae5e4d745785a
2025-06-23 00:34:05 -07:00
Jakub Piasecki fe4047fe3a Replace ElementConfig with directly imported props (#51971)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51971

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D76502294

fbshipit-source-id: ed98c5e6d9ef5fd6a4d1adbd6a88ce8cda52b969
2025-06-22 23:58:45 -07:00
Andrew Datsenko 9f479ff8d6 Add react_cxx_platform_react_utils cmake (#52177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52177

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_utils

Reviewed By: christophpurrer

Differential Revision: D77038580

fbshipit-source-id: 7cdd8defd57629342095587bd3e1819e04af50bd
2025-06-22 23:48:38 -07:00
Andrew Datsenko dda8ab69d4 Add react_cxx_platform_react_threading cmake (#52176)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52176

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_threading

Reviewed By: christophpurrer

Differential Revision: D77038544

fbshipit-source-id: 950e28af49c5de3870e11e03d5123f22a0f04a6b
2025-06-22 23:48:38 -07:00
Andrew Datsenko f04d1f1ef7 Add react_cxx_platform_react_runtime cmake (#52178)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52178

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_runtime

Reviewed By: christophpurrer

Differential Revision: D77038450

fbshipit-source-id: 54515f1aff84632c8a86abd8970107a1bd8ca043
2025-06-22 23:48:38 -07:00
Andrew Datsenko 54a1e41694 Add react_cxx_platform_react_renderer_uimanager cmake (#52175)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52175

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_renderer_uimanager

Reviewed By: christophpurrer

Differential Revision: D77038183

fbshipit-source-id: 736651e170884f69313711f744c40194f259bfa1
2025-06-22 23:48:38 -07:00
Andrew Datsenko 269cf58140 Add react_cxx_platform_react_renderer_scheduler cmake (#52174)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52174

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_renderer_scheduler

Reviewed By: christophpurrer

Differential Revision: D77038129

fbshipit-source-id: f843c719d08f42f379042484542f4f4e5b94a2c6
2025-06-22 23:48:38 -07:00
Andrew Datsenko 941853974b Add react_cxx_platform_react_renderer_animated cmake (#52173)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52173

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_renderer_animated

Reviewed By: christophpurrer

Differential Revision: D77038030

fbshipit-source-id: 6ca45f0251c74dc49b5c1d72c42575b80248eb2a
2025-06-22 23:48:38 -07:00
Andrew Datsenko 36c0826f56 Add react_cxx_platform_react_profiling cmake (#52172)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52172

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_profiling

Reviewed By: christophpurrer

Differential Revision: D77037934

fbshipit-source-id: 555a00cc59d48fd167810ba29075fb4cb3e53d62
2025-06-22 23:48:38 -07:00
Andrew Datsenko 7970f79078 Add react_cxx_platform_react_nativemodule cmake (#52171)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52171

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_nativemodule

Reviewed By: christophpurrer

Differential Revision: D77037835

fbshipit-source-id: 09346824c5e39ca9c41edeb22462d65408d95f18
2025-06-22 23:48:38 -07:00
Andrew Datsenko 37e863e866 Add react_cxx_platform_react_logging cmake (#52170)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52170

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_logging

Reviewed By: christophpurrer

Differential Revision: D77037715

fbshipit-source-id: ea21160473d876c0014dcfc2d17323b2e0c4c0b2
2025-06-22 23:48:38 -07:00
Andrew Datsenko 5961edd825 Add react_cxx_platform_react_io cmake (#52169)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52169

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_io

Reviewed By: christophpurrer

Differential Revision: D77037593

fbshipit-source-id: 849c2b0b0de14b9a583b997f3137763df59b4af1
2025-06-22 23:48:38 -07:00
Andrew Datsenko 71d6d86ed6 Add react_cxx_platform_react_http cmake (#52167)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52167

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_http

Reviewed By: christophpurrer

Differential Revision: D77037486

fbshipit-source-id: 7e90ed26cefa407a1e64ebdad8ac5835803c2c49
2025-06-22 23:48:38 -07:00
Andrew Datsenko 0a7e1342cd Add react_cxx_platform_react_devsupport cmake (#52166)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52166

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_devsupport

Reviewed By: christophpurrer

Differential Revision: D77037372

fbshipit-source-id: e6ed42492f29abfb93fe22b0c01a5d3a2ca7cf53
2025-06-22 23:48:38 -07:00
Andrew Datsenko 891656d055 Add react_cxx_platform_react_coremodules cmake (#52165)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52165

Changelog: [Internal]
Add cmake lib react_cxx_platform_react_coremodules

Reviewed By: christophpurrer

Differential Revision: D77036283

fbshipit-source-id: 54141d32f61d1025ae40c60335a6831ec038217e
2025-06-22 23:48:38 -07:00
Andrew Datsenko abbef4a0b8 Add react_renderer_observers_mutation cmake (#52164)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52164

Changelog: [Internal]
Add cmake library react_renderer_observers_mutation

Reviewed By: christophpurrer

Differential Revision: D77036195

fbshipit-source-id: 6661b6aecab83b1fd254dd7f7fca1c906538aee5
2025-06-22 23:48:38 -07:00
Andrew Datsenko e888329e9a Add react_renderer_observers_intersection cmake (#52163)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52163

Changelog: [Internal]
Add cmake library react_renderer_observers_intersection

Reviewed By: christophpurrer

Differential Revision: D77036086

fbshipit-source-id: 9f7c2c9574c09f7775362a6155433fa194111f0b
2025-06-22 23:48:38 -07:00
Andrew Datsenko 1f8374e1dd Add react_nativemodule_webperformance cmake (#52162)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52162

Changelog: [Internal]
Add cmake library react_nativemodule_webperformance

Reviewed By: christophpurrer

Differential Revision: D77035999

fbshipit-source-id: da267ddf10d9a9de315038142f7764d81190131a
2025-06-22 23:48:38 -07:00
Andrew Datsenko a10ee5808b Add react_nativemodule_mutationobserver cmake (#52161)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52161

Changelog: [Internal]
Add missing lib react_nativemodule_mutationobserver

Reviewed By: christophpurrer

Differential Revision: D77035742

fbshipit-source-id: f900024f0ad4f4e4596c4fa5730463277ee17242
2025-06-22 23:48:38 -07:00
Andrew Datsenko ab2ce4f2d8 add react_nativemodule_intersectionobserver cmake (#52160)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52160

Changelog: [Internal]
Add missing cmake lib for react_nativemodule_intersectionobserver

Reviewed By: christophpurrer

Differential Revision: D77035609

fbshipit-source-id: d6c372d48a2c60b403b33d1477e6085347fe8633
2025-06-22 23:48:38 -07:00
Andrew Datsenko ee256d11ae Add react_nativemodule_fantomspecificmethods cmake (#52159)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52159

Changelog: [Internal]
Add missing cmake target for react_nativemodule_fantomspecificmethods

Reviewed By: christophpurrer

Differential Revision: D77035521

fbshipit-source-id: caedff8d4479c1bff3d03ec149b15a8cd5458092
2025-06-22 23:48:38 -07:00
Andrew Datsenko 1f53d51e64 RN] Add missing link libraries for react_nativemodule_defaults (#52158)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52158

Changelog: [Internal]
As title

Reviewed By: christophpurrer

Differential Revision: D77035424

fbshipit-source-id: 745cecd5e6d16a8cea6b2a883992fec75b565d31
2025-06-22 23:48:38 -07:00
Andrew Datsenko 4f71a9434d Create react/nativemodule/cputime/CMakeLists.txt (#52157)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52157

Changelog: [Internal]

Add CMakeLists for `react/nativemodule/cputime`

Reviewed By: christophpurrer

Differential Revision: D77035337

fbshipit-source-id: c18289ed0558f8be7ba62f71bd74978a7c768e11
2025-06-22 23:48:38 -07:00
Andrew Datsenko ed9969b3d0 Fix cmake build for devtoolsruntimesettings (#52156)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52156

Changelog: [Internal]

Fix devtoolsruntimesettings lib as it needs to be OBJECT library as it has source code included.

Reviewed By: christophpurrer

Differential Revision: D77035122

fbshipit-source-id: 27ad7fe637512afc79f3dcc6b0846dcfd4f22504
2025-06-22 23:48:38 -07:00
Andrew Datsenko 04da4800da Gate RN_SERIALIZABLE_STATE behind ANDROID flag (#52155)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52155

Changelog: [Internal]

Gating RN_SERIALIZABLE_STATE behind ANDROID flag so we can build ReactCommon with cmake when targeting different platforms.
This will help build reac-native-fantom for OSS.

Reviewed By: christophpurrer

Differential Revision: D77034689

fbshipit-source-id: 15f9192c90693f4743f31fcf72f593802b622c47
2025-06-22 23:48:38 -07:00
Jakub Piasecki bc093b8fa9 Remove undefined from optional type members in the API snapshot (#52009)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52009

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D76596252

fbshipit-source-id: 3d6c0ee10cbbb71435933e2ad74f1acc962f14b4
2025-06-22 23:29:29 -07:00
buschco fbbd20dd63 publish index.js.flow instead of index.flow.js (#52179)
Summary:
I think in https://github.com/facebook/react-native/commit/50667eceb1be4771375d6a3cc2f4e42d4d8aad3a the file name was mixed up. Instead of `index.flow.js` it should be `index.js.flow` (see https://github.com/facebook/react-native/blob/main/packages/react-native/index.js.flow)

Should fix https://github.com/facebook/react-native/issues/51885

## Changelog:

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

[General][Added] Publish top-level Flow types for `react-native`

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

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

Test Plan:
Steps to reproduce

1. Setup a react-native project with flow (or clone https://github.com/buschco/react-native-flow + `cd ReproducerApp && npm i`)
2. `import {Alert} from 'react-native'` -> `Alert` has type `any`
3. add `index.js.flow` File (https://github.com/facebook/react-native/blob/v0.79.3/packages/react-native/index.js.flow) to `node_modules/react-native/index.js.flow` -> `Alert` no longer `any`

Reviewed By: christophpurrer

Differential Revision: D77052871

Pulled By: robhogan

fbshipit-source-id: 32b0052a9d96486aff66a1f6e4577ff62cbcd97e
2025-06-21 01:06:03 -07:00
Zeya Peng 710e08cd54 Add Fantom test for layout props & fix an issue in c++ animated (#52110)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52110

## Changelog:

[General] [Internal] - Add Fantom test for layout props

With this test it turns out `layoutStyleUpdated_` on PropsAnimatedNode actually can change after animation update, because its connected StyleAnimatedNodes might be changing. This bug was introduced since D74602321

Reviewed By: rshest

Differential Revision: D76753864

fbshipit-source-id: 5bebb11340086390df20c89adf80abaa63cadc90
2025-06-20 16:04:48 -07:00
Zeya Peng cc442eb8c8 Add Fantom.getFabricUpdateProps (#52108)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52108

## Changelog:

[General] [Added] - Add Fantom.getFabricUpdateProps

For reading fabric update props scheduled via `UIManager::updateShadowTree`

Reviewed By: rshest

Differential Revision: D76857429

fbshipit-source-id: d19312d0b1c6460258a7949054e66313f05afdbf
2025-06-20 16:04:48 -07:00
Mateo Guzmán aaad7e083d Kotlin: fix static code analysis weak warnings (1/n) (#52153)
Summary:
Static code analysis reports several weak warnings, many of which seem to be leftovers after Kotlin migration. This PR addresses quite a few:

- [Convert to primary constructor](https://www.jetbrains.com/help/inspectopedia/ConvertSecondaryConstructorToPrimary.html)
- [If-Then foldable to '?.'](https://www.jetbrains.com/help/inspectopedia/IfThenToSafeAccess.html)
- [Non-canonical modifier order](https://www.jetbrains.com/help/inspectopedia/SortModifiers.html)

## Changelog:

[INTERNAL] - Kotlin: fix static code analysis weak warnings (1/n)

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

Test Plan:
```sh
yarn android
yarn test-android
```

Reviewed By: christophpurrer

Differential Revision: D77042260

Pulled By: arushikesarwani94

fbshipit-source-id: ea210976ccbcecbe4843ff5205238a83fc75d43b
2025-06-20 16:03:34 -07:00
Nicola Corti 999f437b02 Add categories for 0.80 changelog
Summary:
I've added categories for all the entries + sorted them alphabetically.

Changelog:
[Internal] [Changed] -

bypass-github-export-checks

Reviewed By: fabriziocucci

Differential Revision: D77025334

fbshipit-source-id: 4c29bf3fa299078689473d7cf3c7cf8a79f4c097
2025-06-20 10:21:52 -07:00
Pieter De Baets ffb37373ba Schedule OnViewAttachMountItems in GuardedRunnable (#52143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52143

Noticed that some of the `IndexOutOfBoundsException` crashes we've been tracking we're not being reported as soft errors because they were not running wrapped by the RN ExceptionHandler

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D77017423

fbshipit-source-id: 760297a0c5ee3d58577931829a31d312dacffdf1
2025-06-20 08:42:32 -07:00
Alex Hunt e297fe1582 Improve CLI output for build-types (#52151)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52151

Update `yarn build-types` with incremental progress output in the terminal. Minor refactoring.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D77022957

fbshipit-source-id: d4a000a85c779fbdcda317164413b29674474178
2025-06-20 08:21:29 -07:00
Andrew Datsenko 386a930afb HermesInstance::createJSRuntime integration (#52111)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52111

Changelog: [Internal]

JSRuntime integration with executor on messagequeue.

Inching closer to full integration with the rest of RN.

Reviewed By: rshest

Differential Revision: D76752667

fbshipit-source-id: 0ef8fe0c615dc1eb45355f7502e01663772ebf13
2025-06-20 07:08:28 -07:00
Nicola Corti 281f48daf4 Bump compileSdk to 36 (#52141)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52141

This is to make sure we're using buildTools 36 (Android 16) to compile everything.

Changelog:
[Internal] [Changed] -

Reviewed By: rshest

Differential Revision: D77014531

fbshipit-source-id: 65b16abce7f88c4a4c0b8b1b77e632cff2e64197
2025-06-20 06:09:47 -07:00
361 changed files with 11431 additions and 7156 deletions
+3 -1
View File
@@ -47,6 +47,8 @@ packages/react-native/flow/
[options]
enums=true
experimental.pattern_matching=true
experimental.pattern_matching.includes=<PROJECT_ROOT>/packages/react-native/src/private/components/virtualview/
casting_syntax=both
component_syntax=true
@@ -103,4 +105,4 @@ untyped-import
untyped-type-import
[version]
^0.273.1
^0.274.0
+4871
View File
File diff suppressed because it is too large Load Diff
+260 -5133
View File
File diff suppressed because it is too large Load Diff
+6 -6
View File
@@ -58,7 +58,7 @@
"@typescript-eslint/parser": "^7.1.1",
"ansi-styles": "^4.2.1",
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
"babel-plugin-syntax-hermes-parser": "0.28.1",
"babel-plugin-syntax-hermes-parser": "0.29.0",
"babel-plugin-transform-define": "^2.1.4",
"babel-plugin-transform-flow-enums": "^0.0.2",
"clang-format": "^1.8.0",
@@ -76,11 +76,11 @@
"eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-redundant-undefined": "^0.4.0",
"eslint-plugin-relay": "^1.8.3",
"flow-api-translator": "0.28.1",
"flow-bin": "^0.273.1",
"flow-api-translator": "0.29.0",
"flow-bin": "^0.274.0",
"glob": "^7.1.1",
"hermes-eslint": "0.28.1",
"hermes-transform": "0.28.1",
"hermes-eslint": "0.29.0",
"hermes-transform": "0.29.0",
"inquirer": "^7.1.0",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
@@ -96,7 +96,7 @@
"node-fetch": "^2.2.0",
"nullthrows": "^1.1.1",
"prettier": "2.8.8",
"prettier-plugin-hermes-parser": "0.28.1",
"prettier-plugin-hermes-parser": "0.29.0",
"react": "19.1.0",
"react-test-renderer": "19.1.0",
"rimraf": "^3.0.2",
@@ -81,6 +81,7 @@ export default function createDevMiddleware({
projectRoot,
serverBaseUrl,
logger,
// $FlowFixMe[prop-missing]
unstable_browserLauncher = DefaultBrowserLauncher,
unstable_eventReporter,
unstable_experiments: experimentConfig = {},
@@ -18,8 +18,8 @@
"bugs": "https://github.com/facebook/react-native/issues",
"main": "index.js",
"devDependencies": {
"babel-plugin-syntax-hermes-parser": "0.28.1",
"hermes-eslint": "0.28.1"
"babel-plugin-syntax-hermes-parser": "0.29.0",
"hermes-eslint": "0.29.0"
},
"engines": {
"node": ">= 22.14.0"
+2 -2
View File
@@ -32,8 +32,8 @@
"source-map-support": "0.5.0"
},
"devDependencies": {
"babel-plugin-syntax-hermes-parser": "0.28.1",
"hermes-eslint": "0.28.1"
"babel-plugin-syntax-hermes-parser": "0.29.0",
"hermes-eslint": "0.29.0"
},
"engines": {
"node": ">= 22.14.0"
@@ -1,5 +1,5 @@
[versions]
agp = "8.10.1"
agp = "8.11.0"
gson = "2.8.9"
guava = "31.0.1-jre"
javapoet = "1.13.0"
@@ -67,7 +67,7 @@
"@babel/plugin-transform-unicode-regex": "^7.24.7",
"@babel/template": "^7.25.0",
"@react-native/babel-plugin-codegen": "0.80.0-main",
"babel-plugin-syntax-hermes-parser": "0.28.1",
"babel-plugin-syntax-hermes-parser": "0.29.0",
"babel-plugin-transform-flow-enums": "^0.0.2",
"react-refresh": "^0.14.0"
},
@@ -28,7 +28,7 @@
"dependencies": {
"@babel/core": "^7.25.2",
"@react-native/babel-preset": "0.80.0-main",
"hermes-parser": "0.28.1",
"hermes-parser": "0.29.0",
"nullthrows": "^1.1.1"
},
"peerDependencies": {
+2 -2
View File
@@ -30,7 +30,7 @@
],
"dependencies": {
"glob": "^7.1.1",
"hermes-parser": "0.28.1",
"hermes-parser": "0.29.0",
"invariant": "^2.2.4",
"nullthrows": "^1.1.1",
"yargs": "^17.6.2"
@@ -43,7 +43,7 @@
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.7",
"@babel/plugin-transform-optional-chaining": "^7.24.8",
"@babel/preset-env": "^7.25.3",
"hermes-estree": "0.28.1",
"hermes-estree": "0.29.0",
"micromatch": "^4.0.4",
"prettier": "2.8.8",
"rimraf": "^3.0.2"
@@ -9,6 +9,8 @@
#import <React/RCTUIManager.h>
#import <React/RCTViewManager.h>
#import <string>
static UIColor *UIColorFromHexString(const std::string hexString)
{
unsigned rgbValue = 0;
@@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "*.{m}"
s.source_files = podspec_sources("*.{m}", "")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTActionSheet"
+2 -2
View File
@@ -29,7 +29,7 @@ export type EventConfig<T> = {
platformConfig?: PlatformConfig,
};
export function attachNativeEvent(
export function attachNativeEventImpl(
viewRef: any,
eventName: string,
argMapping: $ReadOnlyArray<?Mapping>,
@@ -181,7 +181,7 @@ export class AnimatedEvent {
'Only native driven events need to be attached.',
);
this._attachedEvent = attachNativeEvent(
this._attachedEvent = attachNativeEventImpl(
viewRef,
eventName,
this._argMapping,
@@ -10,6 +10,10 @@
import AnimatedImplementation from './AnimatedImplementation';
export type {DecayAnimationConfig} from './animations/DecayAnimation';
export type {SpringAnimationConfig} from './animations/SpringAnimation';
export type {TimingAnimationConfig} from './animations/TimingAnimation';
export {default as FlatList} from './components/AnimatedFlatList';
export {default as Image} from './components/AnimatedImage';
export {default as ScrollView} from './components/AnimatedScrollView';
@@ -33,6 +37,7 @@ export type {default as AnimatedNode} from './nodes/AnimatedNode';
export type {default as AnimatedAddition} from './nodes/AnimatedAddition';
export type {default as AnimatedDiffClamp} from './nodes/AnimatedDiffClamp';
export type {default as AnimatedDivision} from './nodes/AnimatedDivision';
export type {InterpolationConfigType as InterpolationConfig} from './nodes/AnimatedInterpolation';
export type {default as AnimatedModulo} from './nodes/AnimatedModulo';
export type {default as AnimatedMultiplication} from './nodes/AnimatedMultiplication';
export type {default as AnimatedSubtraction} from './nodes/AnimatedSubtraction';
@@ -20,7 +20,7 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation';
import type {SpringAnimationConfig} from './animations/SpringAnimation';
import type {TimingAnimationConfig} from './animations/TimingAnimation';
import {AnimatedEvent, attachNativeEvent} from './AnimatedEvent';
import {AnimatedEvent, attachNativeEventImpl} from './AnimatedEvent';
import DecayAnimation from './animations/DecayAnimation';
import SpringAnimation from './animations/SpringAnimation';
import TimingAnimation from './animations/TimingAnimation';
@@ -47,39 +47,39 @@ export type CompositeAnimation = {
...
};
const add = function (
const addImpl = function (
a: AnimatedNode | number,
b: AnimatedNode | number,
): AnimatedAddition {
return new AnimatedAddition(a, b);
};
const subtract = function (
const subtractImpl = function (
a: AnimatedNode | number,
b: AnimatedNode | number,
): AnimatedSubtraction {
return new AnimatedSubtraction(a, b);
};
const divide = function (
const divideImpl = function (
a: AnimatedNode | number,
b: AnimatedNode | number,
): AnimatedDivision {
return new AnimatedDivision(a, b);
};
const multiply = function (
const multiplyImpl = function (
a: AnimatedNode | number,
b: AnimatedNode | number,
): AnimatedMultiplication {
return new AnimatedMultiplication(a, b);
};
const modulo = function (a: AnimatedNode, modulus: number): AnimatedModulo {
const moduloImpl = function (a: AnimatedNode, modulus: number): AnimatedModulo {
return new AnimatedModulo(a, modulus);
};
const diffClamp = function (
const diffClampImpl = function (
a: AnimatedNode,
min: number,
max: number,
@@ -120,7 +120,7 @@ const maybeVectorAnim = function (
const aY = anim((value: AnimatedValueXY).y, configY);
// We use `stopTogether: false` here because otherwise tracking will break
// because the second animation will get stopped before it can update.
return parallel([aX, aY], {stopTogether: false});
return parallelImpl([aX, aY], {stopTogether: false});
} else if (value instanceof AnimatedColor) {
const configR = {...config};
const configG = {...config};
@@ -146,12 +146,12 @@ const maybeVectorAnim = function (
const aA = anim((value: AnimatedColor).a, configA);
// We use `stopTogether: false` here because otherwise tracking will break
// because the second animation will get stopped before it can update.
return parallel([aR, aG, aB, aA], {stopTogether: false});
return parallelImpl([aR, aG, aB, aA], {stopTogether: false});
}
return null;
};
const spring = function (
const springImpl = function (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: SpringAnimationConfig,
): CompositeAnimation {
@@ -179,7 +179,7 @@ const spring = function (
}
};
return (
maybeVectorAnim(value, config, spring) || {
maybeVectorAnim(value, config, springImpl) || {
start: function (callback?: ?EndCallback): void {
start(value, config, callback);
},
@@ -204,7 +204,7 @@ const spring = function (
);
};
const timing = function (
const timingImpl = function (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: TimingAnimationConfig,
): CompositeAnimation {
@@ -233,7 +233,7 @@ const timing = function (
};
return (
maybeVectorAnim(value, config, timing) || {
maybeVectorAnim(value, config, timingImpl) || {
start: function (callback?: ?EndCallback, isLooping?: boolean): void {
start(value, {...config, isLooping}, callback);
},
@@ -258,7 +258,7 @@ const timing = function (
);
};
const decay = function (
const decayImpl = function (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: DecayAnimationConfig,
): CompositeAnimation {
@@ -275,7 +275,7 @@ const decay = function (
};
return (
maybeVectorAnim(value, config, decay) || {
maybeVectorAnim(value, config, decayImpl) || {
start: function (callback?: ?EndCallback): void {
start(value, config, callback);
},
@@ -300,7 +300,7 @@ const decay = function (
);
};
const sequence = function (
const sequenceImpl = function (
animations: Array<CompositeAnimation>,
): CompositeAnimation {
let current = 0;
@@ -363,7 +363,7 @@ type ParallelConfig = {
stopTogether?: boolean,
...
};
const parallel = function (
const parallelImpl = function (
animations: Array<CompositeAnimation>,
config?: ?ParallelConfig,
): CompositeAnimation {
@@ -431,9 +431,9 @@ const parallel = function (
return result;
};
const delay = function (time: number): CompositeAnimation {
const delayImpl = function (time: number): CompositeAnimation {
// Would be nice to make a specialized implementation
return timing(new AnimatedValue(0), {
return timingImpl(new AnimatedValue(0), {
toValue: 0,
delay: time,
duration: 0,
@@ -441,13 +441,13 @@ const delay = function (time: number): CompositeAnimation {
});
};
const stagger = function (
const staggerImpl = function (
time: number,
animations: Array<CompositeAnimation>,
): CompositeAnimation {
return parallel(
return parallelImpl(
animations.map((animation, i) => {
return sequence([delay(time * i), animation]);
return sequenceImpl([delayImpl(time * i), animation]);
}),
);
};
@@ -458,7 +458,7 @@ type LoopAnimationConfig = {
...
};
const loop = function (
const loopImpl = function (
animation: CompositeAnimation,
// $FlowFixMe[prop-missing]
{iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {},
@@ -514,7 +514,7 @@ const loop = function (
};
};
function forkEvent(
function forkEventImpl(
event: ?AnimatedEvent | ?Function,
listener: Function,
): AnimatedEvent | Function {
@@ -531,7 +531,7 @@ function forkEvent(
}
}
function unforkEvent(
function unforkEventImpl(
event: ?AnimatedEvent | ?Function,
listener: Function,
): void {
@@ -540,7 +540,7 @@ function unforkEvent(
}
}
const event = function <T>(
const eventImpl = function <T>(
argMapping: $ReadOnlyArray<?Mapping>,
config: EventConfig<T>,
): any {
@@ -606,25 +606,25 @@ export default {
* See https://reactnative.dev/docs/animated#node
*/
Node: AnimatedNode,
decay,
timing,
spring,
add,
subtract,
divide,
multiply,
modulo,
diffClamp,
delay,
sequence,
parallel,
stagger,
loop,
event,
decay: decayImpl,
timing: timingImpl,
spring: springImpl,
add: addImpl,
subtract: subtractImpl,
divide: divideImpl,
multiply: multiplyImpl,
modulo: moduloImpl,
diffClamp: diffClampImpl,
delay: delayImpl,
sequence: sequenceImpl,
parallel: parallelImpl,
stagger: staggerImpl,
loop: loopImpl,
event: eventImpl,
createAnimatedComponent,
attachNativeEvent,
forkEvent,
unforkEvent,
attachNativeEvent: attachNativeEventImpl,
forkEvent: forkEventImpl,
unforkEvent: unforkEventImpl,
/**
* Expose Event class, so it can be used as a type for type checkers.
+2 -2
View File
@@ -17,7 +17,7 @@ import type {DecayAnimationConfig} from './animations/DecayAnimation';
import type {SpringAnimationConfig} from './animations/SpringAnimation';
import type {TimingAnimationConfig} from './animations/TimingAnimation';
import {AnimatedEvent, attachNativeEvent} from './AnimatedEvent';
import {AnimatedEvent, attachNativeEventImpl} from './AnimatedEvent';
import AnimatedImplementation from './AnimatedImplementation';
import createAnimatedComponent from './createAnimatedComponent';
import AnimatedColor from './nodes/AnimatedColor';
@@ -188,7 +188,7 @@ export default {
loop,
event: AnimatedImplementation.event,
createAnimatedComponent,
attachNativeEvent,
attachNativeEvent: attachNativeEventImpl,
forkEvent: AnimatedImplementation.forkEvent,
unforkEvent: AnimatedImplementation.unforkEvent,
Event: AnimatedEvent,
@@ -17,6 +17,7 @@ import ensureInstance from '../../../src/private/__tests__/utilities/ensureInsta
import * as Fantom from '@react-native/fantom';
import {createRef} from 'react';
import {Animated, View, useAnimatedValue} from 'react-native';
import {allowStyleProp} from 'react-native/Libraries/Animated/NativeAnimatedAllowlist';
import * as ReactNativeFeatureFlags from 'react-native/src/private/featureflags/ReactNativeFeatureFlags';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
@@ -152,6 +153,7 @@ test('animation driven by onScroll event', () => {
test('animated opacity', () => {
let _opacity;
let _opacityAnimation;
const viewRef = createRef<HostInstance>();
function MyApp() {
@@ -182,7 +184,7 @@ test('animated opacity', () => {
expect(viewElement.getBoundingClientRect().x).toBe(0);
Fantom.runTask(() => {
Animated.timing(_opacity, {
_opacityAnimation = Animated.timing(_opacity, {
toValue: 0,
duration: 30,
useNativeDriver: true,
@@ -194,8 +196,10 @@ test('animated opacity', () => {
0,
);
// TODO(T223344928): this shouldn't be neccessary with cxxNativeAnimatedRemoveJsSync:true
Fantom.runWorkLoop();
// TODO: this shouldn't be neccessary since animation should be stopped after duration
Fantom.runTask(() => {
_opacityAnimation?.stop();
});
expect(root.getRenderedOutput({props: ['opacity']}).toJSX()).toEqual(
<rn-view opacity="0" />,
@@ -475,3 +479,61 @@ describe('Value.extractOffset', () => {
Fantom.runWorkLoop();
});
});
test('animate layout props', () => {
const viewRef = createRef<HostInstance>();
allowStyleProp('height');
let _animatedHeight;
let _heightAnimation;
function MyApp() {
const animatedHeight = useAnimatedValue(0);
_animatedHeight = animatedHeight;
return (
<Animated.View
ref={viewRef}
style={[
{
width: 100,
height: animatedHeight,
},
]}
/>
);
}
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<MyApp />);
});
const viewElement = ensureInstance(viewRef.current, ReactNativeElement);
Fantom.runTask(() => {
_heightAnimation = Animated.timing(_animatedHeight, {
toValue: 100,
duration: 10,
useNativeDriver: true,
}).start();
});
Fantom.unstable_produceFramesForDuration(10);
// TODO: this shouldn't be neccessary since animation should be stopped after duration
Fantom.runTask(() => {
_heightAnimation?.stop();
});
// $FlowFixMe[incompatible-use]
expect(Fantom.unstable_getDirectManipulationProps(viewElement).height).toBe(
100,
);
expect(Fantom.unstable_getFabricUpdateProps(viewElement).height).toBe(100);
expect(root.getRenderedOutput({props: ['height']}).toJSX()).toEqual(
<rn-view height="100.000000" />,
);
});
@@ -15,7 +15,9 @@ import type {
} from '../createAnimatedComponent';
import RefreshControl from '../../Components/RefreshControl/RefreshControl';
import ScrollView from '../../Components/ScrollView/ScrollView';
import ScrollView, {
type ScrollViewProps,
} from '../../Components/ScrollView/ScrollView';
import flattenStyle from '../../StyleSheet/flattenStyle';
import splitLayoutProps from '../../StyleSheet/splitLayoutProps';
import StyleSheet from '../../StyleSheet/StyleSheet';
@@ -26,21 +28,20 @@ import useAnimatedProps from '../useAnimatedProps';
import * as React from 'react';
import {cloneElement, useMemo} from 'react';
type AnimatedScrollViewProps = React.ElementConfig<typeof ScrollView>;
type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
/**
* @see https://github.com/facebook/react-native/commit/b8c8562
*/
const AnimatedScrollView: AnimatedComponentType<
AnimatedScrollViewProps,
ScrollViewProps,
AnimatedScrollViewInstance,
> = function AnimatedScrollViewWithOrWithoutInvertedRefreshControl({
ref: forwardedRef,
...props
}: {
ref?: React.RefSetter<AnimatedScrollViewInstance>,
...AnimatedProps<AnimatedScrollViewProps>,
...AnimatedProps<ScrollViewProps>,
}) {
// (Android only) When a ScrollView has a RefreshControl and
// any `style` property set with an Animated.Value, the CSS
@@ -111,7 +112,7 @@ const AnimatedScrollViewWithInvertedRefreshControl =
// Handle animated props on `NativeDirectionalScrollView`.
const [scrollViewAnimatedProps, scrollViewRef] = useAnimatedProps<
AnimatedScrollViewProps,
ScrollViewProps,
AnimatedScrollViewInstance,
>(intermediatePropsForScrollView);
const ref = useMergeRefs<AnimatedScrollViewInstance>(
@@ -10,13 +10,10 @@
import type {AnimatedComponentType} from '../createAnimatedComponent';
import Text from '../../Text/Text';
import Text, {type TextProps} from '../../Text/Text';
import createAnimatedComponent from '../createAnimatedComponent';
import * as React from 'react';
export default (createAnimatedComponent(
(Text: $FlowFixMe),
): AnimatedComponentType<
React.ElementConfig<typeof Text>,
React.ElementRef<typeof Text>,
>);
): AnimatedComponentType<TextProps, React.ElementRef<typeof Text>>);
@@ -8,6 +8,7 @@
* @format
*/
import type {ViewProps} from '../../Components/View/ViewPropTypes';
import type {AnimatedComponentType} from '../createAnimatedComponent';
import View from '../../Components/View/View';
@@ -15,6 +16,6 @@ import createAnimatedComponent from '../createAnimatedComponent';
import * as React from 'react';
export default (createAnimatedComponent(View): AnimatedComponentType<
React.ElementConfig<typeof View>,
ViewProps,
React.ElementRef<typeof View>,
>);
@@ -21,7 +21,7 @@ import type AnimatedValue from './nodes/AnimatedValue';
import createAnimatedPropsHook from '../../src/private/animated/createAnimatedPropsHook';
import composeStyles from '../../src/private/styles/composeStyles';
import View from '../Components/View/View';
import {type ViewProps} from '../Components/View/ViewPropTypes';
import useMergeRefs from '../Utilities/useMergeRefs';
import * as React from 'react';
import {useMemo} from 'react';
@@ -60,9 +60,7 @@ type NonAnimatedProps =
| 'disabled'
| 'accessibilityLabel';
type PassThroughProps = $ReadOnly<{
passthroughAnimatedPropExplicitValues?: React.ElementConfig<
typeof View,
> | null,
passthroughAnimatedPropExplicitValues?: ViewProps | null,
}>;
export type AnimatedProps<Props: {...}> = {
@@ -42,7 +42,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,S,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,S,cpp}", "**/*.h")
# This guard prevent to install the dependencies when we run `pod install` in the old architecture.
s.compiler_flags = other_cflags
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{h,m,mm}"
s.source_files = podspec_sources("*.{h,m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTBlob"
s.pod_target_xcconfig = {
+6 -4
View File
@@ -281,10 +281,12 @@ export type ButtonProps = $ReadOnly<{
```
*/
const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
const NativeTouchable:
| typeof TouchableNativeFeedback
| typeof TouchableOpacity =
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
type ButtonRef = React.ElementRef<typeof Touchable>;
type ButtonRef = React.ElementRef<typeof NativeTouchable>;
const Button: component(
ref?: React.RefSetter<ButtonRef>,
@@ -362,7 +364,7 @@ const Button: component(
: importantForAccessibility;
return (
<Touchable
<NativeTouchable
accessible={accessible}
accessibilityActions={accessibilityActions}
onAccessibilityAction={onAccessibilityAction}
@@ -391,7 +393,7 @@ const Button: component(
{formattedTitle}
</Text>
</View>
</Touchable>
</NativeTouchable>
);
};
@@ -8,6 +8,7 @@
* @format
*/
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
import type {
GestureResponderEvent,
LayoutChangeEvent,
@@ -26,8 +27,6 @@ import useAndroidRippleForView, {
import * as React from 'react';
import {memo, useMemo, useRef, useState} from 'react';
type ViewStyleProp = React.ElementConfig<typeof View>['style'];
export type {PressableAndroidRippleConfig};
export type PressableStateCallbackType = $ReadOnly<{
@@ -24,7 +24,7 @@ import * as React from 'react';
* sensor housing area on iPhone X).
* @deprecated Use `react-native-safe-area-context` instead. This component will be removed in a future release.
*/
const exported: component(
const SafeAreaView: component(
ref?: React.RefSetter<React.ElementRef<typeof View>>,
...props: ViewProps
) = Platform.select({
@@ -32,4 +32,4 @@ const exported: component(
default: View,
});
export default exported;
export default SafeAreaView;
@@ -10,6 +10,7 @@
import type * as React from 'react';
import {Constructor} from '../../../types/private/Utilities';
import {Insets} from '../../../types/public/Insets';
import {HostInstance} from '../../../types/public/ReactNativeTypes';
import {ColorValue, StyleProp} from '../../StyleSheet/StyleSheet';
import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
import {
@@ -878,6 +879,12 @@ export class ScrollView extends ScrollViewBase {
// Undocumented
getInnerViewNode(): any;
/**
* Returns a reference to the underlying native scroll view, or null if the
* native instance is not mounted.
*/
getNativeScrollRef: () => HostInstance | null;
/**
* @deprecated Use scrollTo instead
*/
@@ -1480,6 +1480,7 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
// then the second tap goes to the actual interior view)
const {keyboardShouldPersistTaps} = this.props;
const keyboardNeverPersistTaps =
// $FlowFixMe[sketchy-null-bool]
!keyboardShouldPersistTaps || keyboardShouldPersistTaps === 'never';
if (typeof e.target === 'number') {
@@ -1562,6 +1563,7 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
const {keyboardShouldPersistTaps} = this.props;
const keyboardNeverPersistsTaps =
// $FlowFixMe[sketchy-null-bool]
!keyboardShouldPersistTaps || keyboardShouldPersistTaps === 'never';
// Dismiss the keyboard now if we didn't become responder in capture phase
@@ -32,7 +32,7 @@ export type {EventSubscription, EmitterSubscription};
export type NativeEventSubscription = EventSubscription;
// $FlowFixMe[unclear-type] unclear type of events
type UnsafeObject = Object;
type UnsafeNativeEventObject = Object;
/**
* `NativeEventEmitter` is intended for use by Native Modules to emit events to
@@ -46,8 +46,8 @@ type UnsafeObject = Object;
*/
export default class NativeEventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
_nativeModule: ?NativeModule;
@@ -25,7 +25,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,cpp}", "**/*.h")
s.header_dir = "FBLazyVector"
end
@@ -8,9 +8,10 @@
#import <React/RCTImageLoaderLoggable.h>
#import <React/RCTImageLoaderProtocol.h>
#import <React/RCTImageURLLoader.h>
// TODO (T61325135): Remove C++ checks
#ifdef __cplusplus
#import <string>
namespace facebook::react {
struct ImageURLLoaderAttribution {
@@ -7,7 +7,7 @@
#import <React/RCTImageUtils.h>
#import <tgmath.h>
#import <cmath>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/UTCoreTypes.h>
@@ -32,7 +32,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTImage"
s.pod_target_xcconfig = {
@@ -229,7 +229,8 @@ function _processUpdate() {
*/
const InteractionManager = (
ReactNativeFeatureFlags.disableInteractionManager()
? require('./InteractionManagerStub').default
? // $FlowFixMe[incompatible-variance]
require('./InteractionManagerStub').default
: InteractionManagerImpl
) as typeof InteractionManagerImpl;
@@ -45,7 +45,7 @@ type OnAnimationDidFailCallback = () => void;
let isLayoutAnimationEnabled: boolean =
ReactNativeFeatureFlags.isLayoutAnimationEnabled();
function setEnabled(value: boolean) {
function setLayoutAnimationEnabled(value: boolean) {
isLayoutAnimationEnabled = isLayoutAnimationEnabled;
}
@@ -115,7 +115,7 @@ function configureNext(
}
}
function create(
function createLayoutAnimation(
duration: number,
type?: LayoutAnimationType,
property?: LayoutAnimationProperty,
@@ -129,12 +129,16 @@ function create(
}
const Presets = {
easeInEaseOut: (create(
easeInEaseOut: (createLayoutAnimation(
300,
'easeInEaseOut',
'opacity',
): LayoutAnimationConfig),
linear: (create(500, 'linear', 'opacity'): LayoutAnimationConfig),
linear: (createLayoutAnimation(
500,
'linear',
'opacity',
): LayoutAnimationConfig),
spring: ({
duration: 700,
create: {
@@ -180,7 +184,7 @@ const LayoutAnimation = {
/**
* Helper for creating a config for `configureNext`.
*/
create,
create: createLayoutAnimation,
Types: Object.freeze({
spring: 'spring',
linear: 'linear',
@@ -208,7 +212,7 @@ const LayoutAnimation = {
spring: (configureNext.bind(null, Presets.spring): (
onAnimationDidEnd?: OnAnimationDidEndCallback,
) => void),
setEnabled,
setEnabled: setLayoutAnimationEnabled,
};
export default LayoutAnimation;
@@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTLinking"
s.pod_target_xcconfig = {
+1 -2
View File
@@ -15,6 +15,7 @@ import type {
ListRenderItemInfo,
ViewabilityConfigCallbackPair,
ViewToken,
VirtualizedListProps,
} from '@react-native/virtualized-lists';
import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
@@ -181,8 +182,6 @@ type FlatListBaseProps<ItemT> = {
...OptionalProps<ItemT>,
};
type VirtualizedListProps = React.ElementConfig<typeof VirtualizedList>;
export type FlatListProps<ItemT> = {
...Omit<
VirtualizedListProps,
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "**/*.{h,m,mm}"
s.source_files = podspec_sources("**/*.{h,m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTAnimation"
s.pod_target_xcconfig = {
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTNetwork"
s.pod_target_xcconfig = {
@@ -130,7 +130,7 @@ const PERMISSIONS = Object.freeze({
*
* See https://reactnative.dev/docs/permissionsandroid
*/
class PermissionsAndroid {
class PermissionsAndroidImpl {
PERMISSIONS: PermissionsType = PERMISSIONS;
RESULTS: $ReadOnly<{
DENIED: 'denied',
@@ -297,5 +297,6 @@ class PermissionsAndroid {
}
}
const PermissionsAndroidInstance: PermissionsAndroid = new PermissionsAndroid();
const PermissionsAndroidInstance: PermissionsAndroidImpl =
new PermissionsAndroidImpl();
export default PermissionsAndroidInstance;
@@ -13,8 +13,8 @@ import type {RootTag} from '../Types/RootTagTypes';
import type {IPerformanceLogger} from '../Utilities/createPerformanceLogger';
import type {DisplayModeType} from './DisplayMode';
type Task = (taskData: any) => Promise<void>;
export type TaskProvider = () => Task;
type HeadlessTask = (taskData: any) => Promise<void>;
export type TaskProvider = () => HeadlessTask;
export type ComponentProvider = () => React.ComponentType<any>;
export type ComponentProviderInstrumentationHook = (
@@ -25,6 +25,6 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,cpp}", "**/*.h")
s.header_dir = "RCTRequired"
end
@@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTSettings"
s.pod_target_xcconfig = {
@@ -26,7 +26,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{h,m,mm}"
s.source_files = podspec_sources("**/*.{h,m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTText"
s.framework = ["MobileCoreServices"]
@@ -25,7 +25,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,h,m,mm,cpp}", "**/*.h")
s.header_dir = "RCTTypeSafety"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
@@ -9,6 +9,4 @@
*/
export * from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
import NativeDeviceInfo from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
export default NativeDeviceInfo;
export {default} from '../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo';
@@ -23,7 +23,7 @@ type Options = $ReadOnly<{
excludedPlatforms?: $ReadOnlyArray<'iOS' | 'android'>,
}>;
export type NativeComponentType<T> = HostComponent<T>;
export type NativeComponentType<T: {...}> = HostComponent<T>;
// If this function runs then that means the view configs were not
// generated at build time using `GenerateViewConfigJs.js`. Thus
@@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "*.{m,mm}"
s.source_files = podspec_sources("*.{m,mm}", "**/*.h")
s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs"
s.header_dir = "RCTVibration"
s.pod_target_xcconfig = {
@@ -136,7 +136,7 @@ export type EventConfig<T> = {
useNativeDriver: boolean,
platformConfig?: PlatformConfig,
};
declare export function attachNativeEvent(
declare export function attachNativeEventImpl(
viewRef: any,
eventName: string,
argMapping: $ReadOnlyArray<?Mapping>,
@@ -166,7 +166,10 @@ declare export default {
`;
exports[`public API should not change unintentionally Libraries/Animated/AnimatedExports.js.flow 1`] = `
"export { default as FlatList } from \\"./components/AnimatedFlatList\\";
"export type { DecayAnimationConfig } from \\"./animations/DecayAnimation\\";
export type { SpringAnimationConfig } from \\"./animations/SpringAnimation\\";
export type { TimingAnimationConfig } from \\"./animations/TimingAnimation\\";
export { default as FlatList } from \\"./components/AnimatedFlatList\\";
export { default as Image } from \\"./components/AnimatedImage\\";
export { default as ScrollView } from \\"./components/AnimatedScrollView\\";
export { default as SectionList } from \\"./components/AnimatedSectionList\\";
@@ -185,6 +188,7 @@ export type { default as AnimatedNode } from \\"./nodes/AnimatedNode\\";
export type { default as AnimatedAddition } from \\"./nodes/AnimatedAddition\\";
export type { default as AnimatedDiffClamp } from \\"./nodes/AnimatedDiffClamp\\";
export type { default as AnimatedDivision } from \\"./nodes/AnimatedDivision\\";
export type { InterpolationConfigType as InterpolationConfig } from \\"./nodes/AnimatedInterpolation\\";
export type { default as AnimatedModulo } from \\"./nodes/AnimatedModulo\\";
export type { default as AnimatedMultiplication } from \\"./nodes/AnimatedMultiplication\\";
export type { default as AnimatedSubtraction } from \\"./nodes/AnimatedSubtraction\\";
@@ -222,53 +226,53 @@ exports[`public API should not change unintentionally Libraries/Animated/Animate
reset: () => void,
...
};
declare const add: (
declare const addImpl: (
a: AnimatedNode | number,
b: AnimatedNode | number
) => AnimatedAddition;
declare const subtract: (
declare const subtractImpl: (
a: AnimatedNode | number,
b: AnimatedNode | number
) => AnimatedSubtraction;
declare const divide: (
declare const divideImpl: (
a: AnimatedNode | number,
b: AnimatedNode | number
) => AnimatedDivision;
declare const multiply: (
declare const multiplyImpl: (
a: AnimatedNode | number,
b: AnimatedNode | number
) => AnimatedMultiplication;
declare const modulo: (a: AnimatedNode, modulus: number) => AnimatedModulo;
declare const diffClamp: (
declare const moduloImpl: (a: AnimatedNode, modulus: number) => AnimatedModulo;
declare const diffClampImpl: (
a: AnimatedNode,
min: number,
max: number
) => AnimatedDiffClamp;
declare const spring: (
declare const springImpl: (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: SpringAnimationConfig
) => CompositeAnimation;
declare const timing: (
declare const timingImpl: (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: TimingAnimationConfig
) => CompositeAnimation;
declare const decay: (
declare const decayImpl: (
value: AnimatedValue | AnimatedValueXY | AnimatedColor,
config: DecayAnimationConfig
) => CompositeAnimation;
declare const sequence: (
declare const sequenceImpl: (
animations: Array<CompositeAnimation>
) => CompositeAnimation;
type ParallelConfig = {
stopTogether?: boolean,
...
};
declare const parallel: (
declare const parallelImpl: (
animations: Array<CompositeAnimation>,
config?: ?ParallelConfig
) => CompositeAnimation;
declare const delay: (time: number) => CompositeAnimation;
declare const stagger: (
declare const delayImpl: (time: number) => CompositeAnimation;
declare const staggerImpl: (
time: number,
animations: Array<CompositeAnimation>
) => CompositeAnimation;
@@ -277,19 +281,19 @@ type LoopAnimationConfig = {
resetBeforeIteration?: boolean,
...
};
declare const loop: (
declare const loopImpl: (
animation: CompositeAnimation,
$$PARAM_1$$?: LoopAnimationConfig
) => CompositeAnimation;
declare function forkEvent(
declare function forkEventImpl(
event: ?AnimatedEvent | ?Function,
listener: Function
): AnimatedEvent | Function;
declare function unforkEvent(
declare function unforkEventImpl(
event: ?AnimatedEvent | ?Function,
listener: Function
): void;
declare const event: <T>(
declare const eventImpl: <T>(
argMapping: $ReadOnlyArray<?Mapping>,
config: EventConfig<T>
) => any;
@@ -309,25 +313,25 @@ declare export default {
Color: typeof AnimatedColor,
Interpolation: typeof AnimatedInterpolation,
Node: typeof AnimatedNode,
decay: typeof decay,
timing: typeof timing,
spring: typeof spring,
add: typeof add,
subtract: typeof subtract,
divide: typeof divide,
multiply: typeof multiply,
modulo: typeof modulo,
diffClamp: typeof diffClamp,
delay: typeof delay,
sequence: typeof sequence,
parallel: typeof parallel,
stagger: typeof stagger,
loop: typeof loop,
event: typeof event,
decay: typeof decayImpl,
timing: typeof timingImpl,
spring: typeof springImpl,
add: typeof addImpl,
subtract: typeof subtractImpl,
divide: typeof divideImpl,
multiply: typeof multiplyImpl,
modulo: typeof moduloImpl,
diffClamp: typeof diffClampImpl,
delay: typeof delayImpl,
sequence: typeof sequenceImpl,
parallel: typeof parallelImpl,
stagger: typeof staggerImpl,
loop: typeof loopImpl,
event: typeof eventImpl,
createAnimatedComponent: typeof createAnimatedComponent,
attachNativeEvent: typeof attachNativeEvent,
forkEvent: typeof forkEvent,
unforkEvent: typeof unforkEvent,
attachNativeEvent: typeof attachNativeEventImpl,
forkEvent: typeof forkEventImpl,
unforkEvent: typeof unforkEventImpl,
Event: typeof AnimatedEvent,
};
"
@@ -628,10 +632,9 @@ exports[`public API should not change unintentionally Libraries/Animated/compone
`;
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedScrollView.js 1`] = `
"type AnimatedScrollViewProps = React.ElementConfig<typeof ScrollView>;
type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
"type AnimatedScrollViewInstance = React.ElementRef<typeof ScrollView>;
declare const AnimatedScrollView: AnimatedComponentType<
AnimatedScrollViewProps,
ScrollViewProps,
AnimatedScrollViewInstance,
>;
declare export default typeof AnimatedScrollView;
@@ -648,7 +651,7 @@ exports[`public API should not change unintentionally Libraries/Animated/compone
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedText.js 1`] = `
"declare export default AnimatedComponentType<
React.ElementConfig<typeof Text>,
TextProps,
React.ElementRef<typeof Text>,
>;
"
@@ -656,7 +659,7 @@ exports[`public API should not change unintentionally Libraries/Animated/compone
exports[`public API should not change unintentionally Libraries/Animated/components/AnimatedView.js 1`] = `
"declare export default AnimatedComponentType<
React.ElementConfig<typeof View>,
ViewProps,
React.ElementRef<typeof View>,
>;
"
@@ -695,9 +698,7 @@ type NonAnimatedProps =
| \\"disabled\\"
| \\"accessibilityLabel\\";
type PassThroughProps = $ReadOnly<{
passthroughAnimatedPropExplicitValues?: React.ElementConfig<
typeof View,
> | null,
passthroughAnimatedPropExplicitValues?: ViewProps | null,
}>;
export type AnimatedProps<Props: { ... }> = {
[K in keyof Props]: K extends NonAnimatedProps
@@ -1538,10 +1539,10 @@ exports[`public API should not change unintentionally Libraries/Components/Butto
accessibilityHint?: ?string,
accessibilityLanguage?: ?Stringish,
}>;
declare const Touchable:
declare const NativeTouchable:
| typeof TouchableNativeFeedback
| typeof TouchableOpacity;
type ButtonRef = React.ElementRef<typeof Touchable>;
type ButtonRef = React.ElementRef<typeof NativeTouchable>;
declare const Button: component(
ref?: React.RefSetter<ButtonRef>,
...props: ButtonProps
@@ -1757,8 +1758,7 @@ declare export default typeof LayoutConformanceNativeComponent;
`;
exports[`public API should not change unintentionally Libraries/Components/Pressable/Pressable.js 1`] = `
"type ViewStyleProp = React.ElementConfig<typeof View>[\\"style\\"];
export type { PressableAndroidRippleConfig };
"export type { PressableAndroidRippleConfig };
export type PressableStateCallbackType = $ReadOnly<{
pressed: boolean,
}>;
@@ -1932,11 +1932,11 @@ export { default } from \\"../../../src/private/specs_DEPRECATED/components/RCTS
`;
exports[`public API should not change unintentionally Libraries/Components/SafeAreaView/SafeAreaView.js 1`] = `
"declare const exported: component(
"declare const SafeAreaView: component(
ref?: React.RefSetter<React.ElementRef<typeof View>>,
...props: ViewProps
);
declare export default typeof exported;
declare export default typeof SafeAreaView;
"
`;
@@ -4179,11 +4179,11 @@ exports[`public API should not change unintentionally Libraries/EventEmitter/Nat
type EmitterSubscription = EventSubscription;
export type { EventSubscription, EmitterSubscription };
export type NativeEventSubscription = EventSubscription;
type UnsafeObject = Object;
type UnsafeNativeEventObject = Object;
declare export default class NativeEventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeNativeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
constructor(nativeModule?: ?NativeModule): void;
@@ -4859,13 +4859,13 @@ export type LayoutAnimationProperties = $ReadOnly<{
}>;
type OnAnimationDidEndCallback = () => void;
type OnAnimationDidFailCallback = () => void;
declare function setEnabled(value: boolean): void;
declare function setLayoutAnimationEnabled(value: boolean): void;
declare function configureNext(
config: LayoutAnimationConfig,
onAnimationDidEnd?: OnAnimationDidEndCallback,
onAnimationDidFail?: OnAnimationDidFailCallback
): void;
declare function create(
declare function createLayoutAnimation(
duration: number,
type?: LayoutAnimationType,
property?: LayoutAnimationProperty
@@ -4877,7 +4877,7 @@ declare const Presets: {
};
declare const LayoutAnimation: {
configureNext: typeof configureNext,
create: typeof create,
create: typeof createLayoutAnimation,
Types: LayoutAnimationTypes,
Properties: LayoutAnimationProperties,
checkConfig(...args: Array<mixed>): void,
@@ -4885,7 +4885,7 @@ declare const LayoutAnimation: {
easeInEaseOut: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
linear: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
spring: (onAnimationDidEnd?: OnAnimationDidEndCallback) => void,
setEnabled: typeof setEnabled,
setEnabled: typeof setLayoutAnimationEnabled,
};
declare export default typeof LayoutAnimation;
"
@@ -4940,8 +4940,7 @@ declare export default typeof FillRateHelper;
`;
exports[`public API should not change unintentionally Libraries/Lists/FlatList.js 1`] = `
"declare const VirtualizedList: typeof VirtualizedLists.VirtualizedList;
type RequiredProps<ItemT> = {
"type RequiredProps<ItemT> = {
data: ?$ReadOnly<$ArrayLike<ItemT>>,
};
type OptionalProps<ItemT> = {
@@ -4971,7 +4970,6 @@ type FlatListBaseProps<ItemT> = {
...RequiredProps<ItemT>,
...OptionalProps<ItemT>,
};
type VirtualizedListProps = React.ElementConfig<typeof VirtualizedList>;
export type FlatListProps<ItemT> = {
...Omit<
VirtualizedListProps,
@@ -6147,7 +6145,7 @@ type PermissionsType = $ReadOnly<{
}>;
export type PermissionStatus = \\"granted\\" | \\"denied\\" | \\"never_ask_again\\";
export type Permission = $Values<PermissionsType>;
declare class PermissionsAndroid {
declare class PermissionsAndroidImpl {
PERMISSIONS: PermissionsType;
RESULTS: $ReadOnly<{
DENIED: \\"denied\\",
@@ -6168,7 +6166,7 @@ declare class PermissionsAndroid {
permissions: Array<Permission>
): Promise<{ [permission: Permission]: PermissionStatus, ... }>;
}
declare const PermissionsAndroidInstance: PermissionsAndroid;
declare const PermissionsAndroidInstance: PermissionsAndroidImpl;
declare export default typeof PermissionsAndroidInstance;
"
`;
@@ -6434,8 +6432,8 @@ declare export default typeof AppContainer;
`;
exports[`public API should not change unintentionally Libraries/ReactNative/AppRegistry.flow.js 1`] = `
"type Task = (taskData: any) => Promise<void>;
export type TaskProvider = () => Task;
"type HeadlessTask = (taskData: any) => Promise<void>;
export type TaskProvider = () => HeadlessTask;
export type ComponentProvider = () => React.ComponentType<any>;
export type ComponentProviderInstrumentationHook = (
component_: ComponentProvider,
@@ -8365,7 +8363,7 @@ declare export default typeof NativeDevLoadingView;
exports[`public API should not change unintentionally Libraries/Utilities/NativeDeviceInfo.js 1`] = `
"export * from \\"../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo\\";
declare export default typeof NativeDeviceInfo;
export { default } from \\"../../src/private/specs_DEPRECATED/modules/NativeDeviceInfo\\";
"
`;
@@ -8656,7 +8654,7 @@ exports[`public API should not change unintentionally Libraries/Utilities/codege
paperComponentNameDeprecated?: string,
excludedPlatforms?: $ReadOnlyArray<\\"iOS\\" | \\"android\\">,
}>;
export type NativeComponentType<T> = HostComponent<T>;
export type NativeComponentType<T: { ... }> = HostComponent<T>;
declare function codegenNativeComponent<Props: { ... }>(
componentName: string,
options?: Options
@@ -8961,12 +8959,12 @@ declare export default ErrorUtils;
`;
exports[`public API should not change unintentionally Libraries/vendor/emitter/EventEmitter.js 1`] = `
"type UnsafeObject = Object;
"type UnsafeEventObject = Object;
export interface EventSubscription {
remove(): void;
}
export interface IEventEmitter<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> {
addListener<TEvent: $Keys<TEventToArgsMap>>(
eventType: TEvent,
@@ -8982,8 +8980,8 @@ export interface IEventEmitter<
}
declare export default class EventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
constructor(): void;
@@ -9063,6 +9061,8 @@ export type {
export { default as RefreshControl } from \\"./Libraries/Components/RefreshControl/RefreshControl\\";
export { default as SafeAreaView } from \\"./Libraries/Components/SafeAreaView/SafeAreaView\\";
export type {
ScrollViewImperativeMethods,
ScrollViewScrollToOptions,
ScrollResponderType,
ScrollViewProps,
ScrollViewPropsAndroid,
@@ -12,7 +12,7 @@ import type {TransformVisitor} from 'hermes-transform';
const {
visitors: stripPrivateProperties,
} = require('../../../../scripts/build-types/transforms/stripPrivateProperties');
} = require('../../../../scripts/build-types/transforms/flow/stripPrivateProperties');
const translate = require('flow-api-translator');
const {existsSync, promises: fs} = require('fs');
const glob = require('glob');
@@ -9,14 +9,14 @@
*/
// $FlowFixMe[unclear-type] unclear type of events
type UnsafeObject = Object;
type UnsafeEventObject = Object;
export interface EventSubscription {
remove(): void;
}
export interface IEventEmitter<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> {
addListener<TEvent: $Keys<TEventToArgsMap>>(
eventType: TEvent,
@@ -41,7 +41,7 @@ interface Registration<TArgs> {
}
type Registry<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> = {
[K in keyof TEventToArgsMap]: Set<Registration<TEventToArgsMap[K]>>,
};
@@ -68,8 +68,8 @@ type Registry<
*/
export default class EventEmitter<
TEventToArgsMap: $ReadOnly<
Record<string, $ReadOnlyArray<UnsafeObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
Record<string, $ReadOnlyArray<UnsafeEventObject>>,
> = $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
> implements IEventEmitter<TEventToArgsMap>
{
#registry: Registry<TEventToArgsMap>;
@@ -157,7 +157,7 @@ export default class EventEmitter<
}
function allocate<
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeObject>>>,
TEventToArgsMap: $ReadOnly<Record<string, $ReadOnlyArray<UnsafeEventObject>>>,
TEvent: $Keys<TEventToArgsMap>,
TEventArgs: TEventToArgsMap[TEvent],
>(
+10
View File
@@ -495,6 +495,14 @@ let reactRCTNetwork = RNTarget(
dependencies: [.yoga, .jsi, .reactTurboModuleCore]
)
/// React-RCTVibration.podspec
let reactRCTVibration = RNTarget(
name: .reactRCTVibration,
path: "Libraries/Vibration",
linkedFrameworks: ["AudioToolbox"],
dependencies: [.yoga, .jsi, .reactTurboModuleCore]
)
/// React-RCTAppDelegate.podspec
let reactAppDelegate = RNTarget(
name: .reactAppDelegate,
@@ -560,6 +568,7 @@ let targets = [
reactRCTText,
reactRCTBlob,
reactRCTNetwork,
reactRCTVibration,
reactRCTLinking,
reactCoreModules,
reactTurboModuleBridging,
@@ -731,6 +740,7 @@ extension String {
static let reactRCTText = "React-RCTText"
static let reactRCTBlob = "React-RCTBlob"
static let reactRCTNetwork = "React-RCTNetwork"
static let reactRCTVibration = "React-RCTVibration"
static let reactRCTActionSheet = "React-RCTActionSheet" // Empty target
static let reactRCTLinking = "React-RCTLinking"
static let reactCoreModules = "React-CoreModules"
@@ -0,0 +1,79 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
require "json"
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
version = package['version']
source = ReactNativeCoreUtils.resolve_podspec_source()
Pod::Spec.new do |s|
s.name = "React-Core-prebuilt"
s.version = version
s.summary = "The core of React Native prebuilt frameworks."
s.homepage = "https://reactnative.dev/"
s.license = package["license"]
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.vendored_frameworks = "React.xcframework"
s.preserve_paths = '**/*.*'
s.header_mappings_dir = 'React.xcframework/Headers'
s.source_files = 'React.xcframework/Headers/**/*.{h,hpp}'
s.module_name = 'React'
s.module_map = 'React.xcframework/Modules/module.modulemap'
s.public_header_files = 'React.xcframework/Headers/**/*.h'
add_rn_third_party_dependencies(s)
# We need to make sure that the React.xcframework is copied correctly - in the downloaded tarball
# the root directory is the framework, but when using it we need to have it in a subdirectory
# called React.xcframework, so we need to move the contents of the tarball into that directory.
# This is done in the prepare_command.
# We need to make sure that the headers are copied to the right place - local tar.gz has a different structure
# than the one from the maven repo
s.prepare_command = <<~'CMD'
CURRENT_PATH=$(pwd)
XCFRAMEWORK_PATH="${CURRENT_PATH}/React.xcframework"
# Check if XCFRAMEWORK_PATH is empty
if [ -z "$XCFRAMEWORK_PATH" ]; then
echo "ERROR: XCFRAMEWORK_PATH is empty."
exit 0
fi
mkdir -p "${XCFRAMEWORK_PATH}"
find "$CURRENT_PATH" -mindepth 1 -maxdepth 1 ! -name "$(basename "$XCFRAMEWORK_PATH")" -exec mv {} "$XCFRAMEWORK_PATH" \;
CMD
# If we are passing a local tarball, we don't want to switch between Debug and Release
if !ENV["RCT_TESTONLY_RNCORE_TARBALL_PATH"]
script_phase = {
:name => "[RNDeps] Replace React Native Core for the right configuration, if needed",
:execution_position => :before_compile,
:script => <<-EOS
. "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
CONFIG="Release"
if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then
CONFIG="Debug"
fi
# TODO(T228219721): Add this for React Native Core as well
##### "$NODE_BINARY" "$REACT_NATIVE_PATH/third-party-podspecs/replace_dependencies_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT"
EOS
}
# :always_out_of_date is only available in CocoaPods 1.13.0 and later
if Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.13.0')
# always run the script without warning
script_phase[:always_out_of_date] = "1"
end
s.script_phase = script_phase
end
end
+12 -5
View File
@@ -66,7 +66,7 @@ Pod::Spec.new do |s|
s.default_subspec = "Default"
s.subspec "Default" do |ss|
ss.source_files = "React/**/*.{c,h,m,mm,S,cpp}"
ss.source_files = podspec_sources("React/**/*.{c,h,m,mm,S,cpp}", "React/**/*.h")
exclude_files = [
"React/CoreModules/**/*",
"React/DevSupport/**/*",
@@ -76,17 +76,24 @@ Pod::Spec.new do |s|
"React/Inspector/**/*",
"React/Runtime/**/*",
]
# The default is use hermes, we don't have jsc installed
exclude_files = exclude_files.append("React/CxxBridge/JSCExecutorFactory.{h,mm}")
ss.exclude_files = exclude_files
ss.private_header_files = "React/Cxx*/*.h"
# Include prebuilt if we're not building from source
if !ReactNativeCoreUtils.build_rncore_from_source()
ss.dependency "React-Core-prebuilt", version
end
end
s.subspec "DevSupport" do |ss|
ss.source_files = "React/DevSupport/*.{h,mm,m}",
"React/Inspector/*.{h,mm,m}"
ss.source_files = podspec_sources(["React/DevSupport/*.{h,mm,m}",
"React/Inspector/*.{h,mm,m}"],
["React/DevSupport/*.h",
"React/Inspector/*.h"])
ss.dependency "React-Core/Default", version
ss.dependency "React-Core/RCTWebSocket", version
@@ -94,7 +101,7 @@ Pod::Spec.new do |s|
end
s.subspec "RCTWebSocket" do |ss|
ss.source_files = "Libraries/WebSocket/*.{h,m}"
ss.source_files = podspec_sources("Libraries/WebSocket/*.{h,m}", "Libraries/WebSocket/*.h")
ss.dependency "React-Core/Default", version
end
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
#import <tgmath.h>
#import <CoreGraphics/CoreGraphics.h>
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@@ -32,7 +32,7 @@ Pod::Spec.new do |s|
s.compiler_flags = '-Wno-nullability-completeness'
s.source = source
s.source_files = "**/*.{c,m,mm,cpp}"
s.source_files = podspec_sources("**/*.{c,m,mm,cpp}", "**/*.h")
s.ios.exclude_files = "PlatformStubs/**/*"
exclude_files = ["RCTStatusBarManager.mm"]
@@ -32,6 +32,12 @@ typedef NS_ENUM(NSInteger, RCTVirtualViewMode) {
RCTVirtualViewModeHidden = 2,
};
typedef NS_ENUM(NSInteger, RCTVirtualViewRenderState) {
RCTVirtualViewRenderStateUnknown = 0,
RCTVirtualViewRenderStateRendered = 1,
RCTVirtualViewRenderStateNone = 2,
};
/**
* Checks whether one CGRect overlaps with another CGRect.
*
@@ -67,6 +73,7 @@ static BOOL CGRectOverlaps(CGRect rect1, CGRect rect2)
@implementation RCTVirtualViewComponentView {
RCTScrollViewComponentView *_lastParentScrollViewComponentView;
std::optional<enum RCTVirtualViewMode> _mode;
enum RCTVirtualViewRenderState _renderState;
std::optional<CGRect> _targetRect;
}
@@ -74,6 +81,7 @@ static BOOL CGRectOverlaps(CGRect rect1, CGRect rect2)
{
if (self = [super initWithFrame:frame]) {
_props = VirtualViewShadowNode::defaultSharedProps();
_renderState = RCTVirtualViewRenderStateUnknown;
}
return self;
@@ -81,11 +89,27 @@ static BOOL CGRectOverlaps(CGRect rect1, CGRect rect2)
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
{
const auto &newViewProps = static_cast<const VirtualViewProps &>(*props);
if (!_mode.has_value()) {
const auto &newViewProps = static_cast<const VirtualViewProps &>(*props);
_mode = newViewProps.initialHidden ? RCTVirtualViewModeHidden : RCTVirtualViewModeVisible;
}
// If disabled, `_renderState` will always be `RCTVirtualViewRenderStateUnknown`.
if (ReactNativeFeatureFlags::enableVirtualViewRenderState()) {
switch (newViewProps.renderState) {
case 1:
_renderState = RCTVirtualViewRenderStateRendered;
break;
case 2:
_renderState = RCTVirtualViewRenderStateNone;
break;
default:
_renderState = RCTVirtualViewRenderStateUnknown;
break;
}
}
[super updateProps:props oldProps:oldProps];
}
@@ -219,7 +243,18 @@ static BOOL CGRectOverlaps(CGRect rect1, CGRect rect2)
switch (newMode) {
case RCTVirtualViewModeVisible:
[self dispatchSyncModeChange:event];
if (_renderState == RCTVirtualViewRenderStateUnknown) {
// Feature flag is disabled, so use the former logic.
[self dispatchSyncModeChange:event];
} else {
// If the previous mode was prerender and the result of dispatching that event was committed, we do not need to
// dispatch an event for visible.
const auto wasPrerenderCommitted = oldMode.has_value() && oldMode == RCTVirtualViewModePrerender &&
_renderState == RCTVirtualViewRenderStateRendered;
if (!wasPrerenderCommitted) {
[self dispatchSyncModeChange:event];
}
}
break;
case RCTVirtualViewModePrerender:
if (!oldMode.has_value() || oldMode != RCTVirtualViewModeVisible) {
@@ -72,6 +72,12 @@ class SchedulerDelegateProxy : public SchedulerDelegate {
[scheduler.delegate schedulerDidSynchronouslyUpdateViewOnUIThread:tag props:props];
}
void schedulerDidUpdateShadowTree(const std::unordered_map<Tag, folly::dynamic> &tagToProps) override
{
// Does nothing.
// This delegate method is not currently used on iOS.
}
private:
void *scheduler_;
};
@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (std::vector<facebook::react::ProcessedColorStop>)getFixedColorStops:
(const std::vector<facebook::react::ColorStop> &)colorStops
gradientLineLength:(CGFloat)gradientLineLength;
// CAGradientLayer linear gradient squishes the non-square gradient to square gradient.
// This function fixes the "squished" effect.
// See https://stackoverflow.com/a/43176174 for more information.
@@ -153,75 +153,42 @@ static RadiusVector GetRadialGradientRadius(
+ (CALayer *)gradientLayerWithSize:(CGSize)size gradient:(const RadialGradient &)gradient
{
UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size];
UIImage *gradientImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext *_Nonnull rendererContext) {
CGContextRef context = rendererContext.CGContext;
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.type = kCAGradientLayerRadial;
CGPoint centerPoint = CGPointMake(size.width / 2.0, size.height / 2.0);
CGPoint centerPoint = CGPointMake(size.width / 2.0, size.height / 2.0);
if (gradient.position.top) {
centerPoint.y = gradient.position.top->resolve(size.height);
} else if (gradient.position.bottom) {
centerPoint.y = size.height - gradient.position.bottom->resolve(size.height);
}
if (gradient.position.top) {
centerPoint.y = gradient.position.top->resolve(size.height);
} else if (gradient.position.bottom) {
centerPoint.y = size.height - gradient.position.bottom->resolve(size.height);
}
if (gradient.position.left) {
centerPoint.x = gradient.position.left->resolve(size.width);
} else if (gradient.position.right) {
centerPoint.x = size.width - gradient.position.right->resolve(size.width);
}
if (gradient.position.left) {
centerPoint.x = gradient.position.left->resolve(size.width);
} else if (gradient.position.right) {
centerPoint.x = size.width - gradient.position.right->resolve(size.width);
}
bool isCircle = (gradient.shape == RadialGradientShape::Circle);
auto [radiusX, radiusY] =
GetRadialGradientRadius(isCircle, gradient.size, centerPoint.x, centerPoint.y, size.width, size.height);
const auto gradientLineLength = std::max(radiusX, radiusY);
const auto colorStops = [RCTGradientUtils getFixedColorStops:gradient.colorStops
gradientLineLength:gradientLineLength];
gradientLayer.startPoint = CGPointMake(centerPoint.x / size.width, centerPoint.y / size.height);
// endpoint.x is horizontal length and endpoint.y is vertical length
gradientLayer.endPoint = CGPointMake(
gradientLayer.startPoint.x + radiusX / size.width, gradientLayer.startPoint.y + radiusY / size.height);
bool isCircle = (gradient.shape == RadialGradientShape::Circle);
auto [radiusX, radiusY] =
GetRadialGradientRadius(isCircle, gradient.size, centerPoint.x, centerPoint.y, size.width, size.height);
NSMutableArray<id> *colors = [NSMutableArray array];
NSMutableArray<NSNumber *> *locations = [NSMutableArray array];
for (const auto &colorStop : colorStops) {
[colors addObject:(id)RCTUIColorFromSharedColor(colorStop.color).CGColor];
[locations addObject:@(std::max(std::min(colorStop.position.value(), 1.0), 0.0))];
}
CGFloat scale = 1.0;
if (radiusX != radiusY && gradient.shape != RadialGradientShape::Circle) {
scale = radiusX / radiusY;
CGContextSaveGState(context);
// Scale the context to make the circular gradient appear elliptical
CGContextTranslateCTM(context, centerPoint.x, centerPoint.y);
CGContextScaleCTM(context, 1.0, 1.0 / scale);
CGContextTranslateCTM(context, -centerPoint.x, -centerPoint.y);
radiusX = std::max(radiusX, radiusY * scale);
}
const auto colorStops = [RCTGradientUtils getFixedColorStops:gradient.colorStops gradientLineLength:radiusX];
NSMutableArray *colors = [NSMutableArray array];
CGFloat locations[colorStops.size()];
for (size_t i = 0; i < colorStops.size(); ++i) {
const auto &colorStop = colorStops[i];
CGColorRef cgColor = RCTCreateCGColorRefFromSharedColor(colorStop.color);
[colors addObject:(__bridge id)cgColor];
locations[i] = std::max(std::min(colorStop.position.value(), 1.0), 0.0);
}
CGGradientRef cgGradient = CGGradientCreateWithColors(NULL, (__bridge CFArrayRef)colors, locations);
CGContextDrawRadialGradient(
context,
cgGradient,
centerPoint,
0,
centerPoint,
radiusX,
kCGGradientDrawsBeforeStartLocation | kCGGradientDrawsAfterEndLocation);
// Restore the context state if we scaled it
if (radiusX != radiusY && gradient.shape != RadialGradientShape::Circle) {
CGContextRestoreGState(context);
}
for (id color in colors) {
CGColorRelease((__bridge CGColorRef)color);
}
CGGradientRelease(cgGradient);
}];
CALayer *gradientLayer = [CALayer layer];
gradientLayer.contents = (__bridge id)gradientImage.CGImage;
gradientLayer.colors = colors;
gradientLayer.locations = locations;
return gradientLayer;
}
@@ -35,7 +35,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "FBReactNativeSpec/**/*.{c,h,m,mm,cpp}"
s.source_files = podspec_sources("FBReactNativeSpec/**/*.{c,h,m,mm,cpp}", "FBReactNativeSpec/**/*.{h}")
s.exclude_files = "FBReactNativeSpec/react/renderer/components",
s.compiler_flags = new_arch_flags
s.header_dir = 'FBReactNativeSpec'
@@ -63,7 +63,7 @@ Pod::Spec.new do |s|
add_rn_third_party_dependencies(s)
s.subspec "components" do |ss|
ss.source_files = "FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{m,mm,cpp,h}"
ss.source_files = podspec_sources("FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{m,mm,cpp,h}", "FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{h}")
ss.header_dir = "react/renderer/components/FBReactNativeSpec"
add_dependency(ss, "React-featureflags")
@@ -42,7 +42,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "Fabric/**/*.{c,h,m,mm,S,cpp}"
s.source_files = podspec_sources("Fabric/**/*.{c,h,m,mm,S,cpp}", "Fabric/**/*.{h}")
s.exclude_files = "**/tests/*",
"**/android/*",
s.compiler_flags = new_arch_flags
@@ -99,7 +99,7 @@ Pod::Spec.new do |s|
add_rn_third_party_dependencies(s)
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = "Tests/**/*.{mm}"
test_spec.source_files = podspec_sources("Tests/**/*.{mm}", "")
test_spec.framework = "XCTest"
end
end
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
s.author = "Meta Platforms, Inc. and its affiliates"
s.platforms = min_supported_versions
s.source = source
s.source_files = "*.{h,mm}"
s.source_files = podspec_sources("*.{h,mm}", "*.h")
s.compiler_flags = new_arch_flags
s.header_dir = header_dir
s.module_name = module_name
@@ -3659,6 +3659,7 @@ public class com/facebook/react/uimanager/ReactAccessibilityDelegate : androidx/
public static final field TOP_ACCESSIBILITY_ACTION_EVENT Ljava/lang/String;
public static final field sActionIdMap Ljava/util/HashMap;
public fun <init> (Landroid/view/View;ZI)V
public fun cleanUp ()V
public static fun createNodeInfoFromView (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;
public fun getAccessibilityNodeProvider (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeProviderCompat;
protected fun getHostView ()Landroid/view/View;
@@ -4339,20 +4340,20 @@ public abstract interface class com/facebook/react/uimanager/UIImplementation$La
public abstract fun onLayoutUpdated (Lcom/facebook/react/uimanager/ReactShadowNode;)V
}
public class com/facebook/react/uimanager/UIManagerHelper {
public final class com/facebook/react/uimanager/UIManagerHelper {
public static final field INSTANCE Lcom/facebook/react/uimanager/UIManagerHelper;
public static final field PADDING_BOTTOM_INDEX I
public static final field PADDING_END_INDEX I
public static final field PADDING_START_INDEX I
public static final field PADDING_TOP_INDEX I
public fun <init> ()V
public static fun getDefaultTextInputPadding (Landroid/content/Context;)[F
public static fun getEventDispatcher (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/uimanager/events/EventDispatcher;
public static fun getEventDispatcherForReactTag (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/uimanager/events/EventDispatcher;
public static fun getReactContext (Landroid/view/View;)Lcom/facebook/react/bridge/ReactContext;
public static fun getSurfaceId (Landroid/content/Context;)I
public static fun getSurfaceId (Landroid/view/View;)I
public static fun getUIManager (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/bridge/UIManager;
public static fun getUIManagerForReactTag (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/bridge/UIManager;
public static final fun getDefaultTextInputPadding (Landroid/content/Context;)[F
public static final fun getEventDispatcher (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/uimanager/events/EventDispatcher;
public static final fun getEventDispatcherForReactTag (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/uimanager/events/EventDispatcher;
public static final fun getReactContext (Landroid/view/View;)Lcom/facebook/react/bridge/ReactContext;
public static final fun getSurfaceId (Landroid/content/Context;)I
public static final fun getSurfaceId (Landroid/view/View;)I
public static final fun getUIManager (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/bridge/UIManager;
public static final fun getUIManagerForReactTag (Lcom/facebook/react/bridge/ReactContext;I)Lcom/facebook/react/bridge/UIManager;
}
public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/bridge/ReactContextBaseJavaModule, com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/bridge/OnBatchCompleteListener, com/facebook/react/bridge/UIManager {
@@ -4866,20 +4867,6 @@ public abstract interface class com/facebook/react/uimanager/events/EventDispatc
public abstract fun removeListener (Lcom/facebook/react/uimanager/events/EventDispatcherListener;)V
}
public class com/facebook/react/uimanager/events/EventDispatcherImpl : com/facebook/react/bridge/LifecycleEventListener, com/facebook/react/uimanager/events/EventDispatcher {
public fun <init> (Lcom/facebook/react/bridge/ReactApplicationContext;)V
public fun addBatchEventDispatchedListener (Lcom/facebook/react/uimanager/events/BatchEventDispatchedListener;)V
public fun addListener (Lcom/facebook/react/uimanager/events/EventDispatcherListener;)V
public fun dispatchAllEvents ()V
public fun dispatchEvent (Lcom/facebook/react/uimanager/events/Event;)V
public fun onCatalystInstanceDestroyed ()V
public fun onHostDestroy ()V
public fun onHostPause ()V
public fun onHostResume ()V
public fun removeBatchEventDispatchedListener (Lcom/facebook/react/uimanager/events/BatchEventDispatchedListener;)V
public fun removeListener (Lcom/facebook/react/uimanager/events/EventDispatcherListener;)V
}
public abstract interface class com/facebook/react/uimanager/events/EventDispatcherListener {
public abstract fun onEventDispatch (Lcom/facebook/react/uimanager/events/Event;)V
}
@@ -5303,6 +5290,7 @@ public class com/facebook/react/viewmanagers/VirtualViewManagerDelegate : com/fa
public abstract interface class com/facebook/react/viewmanagers/VirtualViewManagerInterface : com/facebook/react/uimanager/ViewManagerWithGeneratedInterface {
public abstract fun setInitialHidden (Landroid/view/View;Z)V
public abstract fun setRenderState (Landroid/view/View;I)V
}
public final class com/facebook/react/views/drawer/ReactDrawerLayout : androidx/drawerlayout/widget/DrawerLayout {
@@ -37,15 +37,15 @@ public class MemoryPressureRouter(context: Context) : ComponentCallbacks2 {
listeners.remove(listener)
}
override public fun onTrimMemory(level: Int) {
public override fun onTrimMemory(level: Int) {
dispatchMemoryPressure(level)
}
override public fun onConfigurationChanged(newConfig: Configuration): Unit = Unit
public override fun onConfigurationChanged(newConfig: Configuration): Unit = Unit
@Deprecated(
"onLowMemory is deprecated, use onTrimMemory instead.", ReplaceWith("onTrimMemory(level)"))
override public fun onLowMemory(): Unit = Unit
public override fun onLowMemory(): Unit = Unit
private fun dispatchMemoryPressure(level: Int) {
for (listener in listeners) {
@@ -111,7 +111,8 @@ public open class ReactDelegate {
public fun onHostResume() {
if (activity !is DefaultHardwareBackBtnHandler) {
throw ClassCastException("Host Activity does not implement DefaultHardwareBackBtnHandler")
throw ClassCastException(
"Host Activity `${activity.javaClass.simpleName}` does not implement DefaultHardwareBackBtnHandler")
}
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
@@ -80,7 +80,7 @@ import kotlin.concurrent.Volatile
*/
@OptIn(UnstableReactNativeAPI::class)
@ReactModule(name = NativeAnimatedModuleSpec.NAME)
public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
NativeAnimatedModuleSpec(reactContext), LifecycleEventListener, UIManagerListener {
// For `queueAndExecuteBatchedOperations`
@@ -163,12 +163,13 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
// Due to a race condition, we manually "carry-over" a polled item from previous batch
// instead of peeking the queue itself for consistency.
// TODO(T112522554): Clean up the queue access
val peekedOperation = peekedOperation
if (peekedOperation != null) {
if (checkNotNull(peekedOperation).batchNumber > maxBatchNumber) {
if (peekedOperation.batchNumber > maxBatchNumber) {
break
}
operations.add(checkNotNull(peekedOperation))
peekedOperation = null
operations.add(peekedOperation)
this.peekedOperation = null
}
val polledOperation =
@@ -179,7 +180,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (polledOperation.batchNumber > maxBatchNumber) {
// Because the operation is already retrieved from the queue, there's no way of placing it
// back as the head element, so we remember it manually here
peekedOperation = polledOperation
this.peekedOperation = polledOperation
break
}
operations.add(polledOperation)
@@ -189,8 +190,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
}
}
private val animatedFrameCallback: GuardedFrameCallback
private val reactChoreographer: ReactChoreographer? = ReactChoreographer.getInstance()
private val reactChoreographer: ReactChoreographer = ReactChoreographer.getInstance()
private val operations = ConcurrentOperationQueue()
private val preOperations = ConcurrentOperationQueue()
@@ -205,7 +205,6 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
private var initializedForFabric = false
private var initializedForNonFabric = false
private var enqueuedAnimationOnFrame = false
@UIManagerType private var uiManagerType = UIManagerType.LEGACY
private var numFabricAnimations = 0
@@ -302,8 +301,8 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
}
}
checkNotNull(preOperations).executeBatch(batchNumber, nodesManager)
checkNotNull(operations).executeBatch(batchNumber, nodesManager)
preOperations.executeBatch(batchNumber, nodesManager)
operations.executeBatch(batchNumber, nodesManager)
}
// For non-FabricUIManager only
@@ -322,11 +321,9 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
// might be stripped out.
val frameNo = currentBatchNumber++
val preOperationsUIBlock = UIBlock {
checkNotNull(preOperations).executeBatch(frameNo, nodesManager)
}
val preOperationsUIBlock = UIBlock { preOperations.executeBatch(frameNo, nodesManager) }
val operationsUIBlock = UIBlock { checkNotNull(operations).executeBatch(frameNo, nodesManager) }
val operationsUIBlock = UIBlock { operations.executeBatch(frameNo, nodesManager) }
assert(uiManager is UIManagerModule)
val uiManagerModule = uiManager as UIManagerModule
@@ -366,41 +363,34 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
nodesManagerRef.set(nodesManager)
}
init {
animatedFrameCallback =
object : GuardedFrameCallback(checkNotNull(reactContext)) {
override fun doFrameGuarded(frameTimeNanos: Long) {
try {
enqueuedAnimationOnFrame = false
val nodesManager = nodesManager
if (nodesManager?.hasActiveAnimations() == true) {
nodesManager.runUpdates(frameTimeNanos)
}
// This is very unlikely to ever be hit.
if (nodesManager == null || reactChoreographer == null) {
return
}
enqueueFrameCallback()
} catch (ex: Exception) {
throw RuntimeException(ex)
private var enqueuedAnimationOnFrame = false
private val animatedFrameCallback =
object : GuardedFrameCallback(reactContext) {
override fun doFrameGuarded(frameTimeNanos: Long) {
try {
enqueuedAnimationOnFrame = false
val nodesManager = nodesManager ?: return
if (nodesManager.hasActiveAnimations()) {
nodesManager.runUpdates(frameTimeNanos)
}
enqueueFrameCallback()
} catch (ex: Exception) {
throw RuntimeException(ex)
}
}
}
}
private fun clearFrameCallback() {
checkNotNull(reactChoreographer)
.removeFrameCallback(
ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE, animatedFrameCallback)
reactChoreographer.removeFrameCallback(
ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE, animatedFrameCallback)
enqueuedAnimationOnFrame = false
}
private fun enqueueFrameCallback() {
if (!enqueuedAnimationOnFrame) {
checkNotNull(reactChoreographer)
.postFrameCallback(
ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE, animatedFrameCallback)
reactChoreographer.postFrameCallback(
ReactChoreographer.CallbackType.NATIVE_ANIMATED_MODULE, animatedFrameCallback)
enqueuedAnimationOnFrame = true
}
}
@@ -431,8 +421,9 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
}
// Subscribe to UIManager (Fabric or non-Fabric) lifecycle events if we haven't yet
if (if (uiManagerType == UIManagerType.FABRIC) initializedForFabric
else initializedForNonFabric) {
val initialized =
if (uiManagerType == UIManagerType.FABRIC) initializedForFabric else initializedForNonFabric
if (initialized) {
return
}
@@ -494,16 +485,14 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
override fun createAnimatedNode(tagDouble: Double, config: ReadableMap) {
val tag = tagDouble.toInt()
if (ANIMATED_MODULE_DEBUG) {
FLog.d(NAME, "queue createAnimatedNode: ${tag} config: ${config.toHashMap().toString()}")
FLog.d(NAME, "queue createAnimatedNode: $tag config: ${config.toHashMap()}")
}
addOperation(
object : UIThreadOperation() {
override fun execute(animatedNodesManager: NativeAnimatedNodesManager) {
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute createAnimatedNode: ${tag} config: ${config.toHashMap().toString()}"))
FLog.d(NAME, ("execute createAnimatedNode: $tag config: ${config.toHashMap()}"))
}
animatedNodesManager.createAnimatedNode(tag, config)
}
@@ -513,17 +502,14 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
override fun updateAnimatedNodeConfig(tagDouble: Double, config: ReadableMap) {
val tag = tagDouble.toInt()
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME, "queue updateAnimatedNodeConfig: ${tag} config: ${config.toHashMap().toString()}")
FLog.d(NAME, "queue updateAnimatedNodeConfig: $tag config: ${config.toHashMap()}")
}
addOperation(
object : UIThreadOperation() {
override fun execute(animatedNodesManager: NativeAnimatedNodesManager) {
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute updateAnimatedNodeConfig: ${tag} config: ${config.toHashMap().toString()}"))
FLog.d(NAME, ("execute updateAnimatedNodeConfig: $tag config: ${config.toHashMap()}"))
}
animatedNodesManager.updateAnimatedNodeConfig(tag, config)
}
@@ -714,7 +700,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute connectAnimatedNodes: parent: ${parentNodeTag} child: ${childNodeTag}"))
("execute connectAnimatedNodes: parent: $parentNodeTag child: $childNodeTag"))
}
animatedNodesManager.connectAnimatedNodes(parentNodeTag, childNodeTag)
}
@@ -734,7 +720,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute disconnectAnimatedNodes: parent: ${parentNodeTag} child: ${childNodeTag}"))
("execute disconnectAnimatedNodes: parent: $parentNodeTag child: $childNodeTag"))
}
animatedNodesManager.disconnectAnimatedNodes(parentNodeTag, childNodeTag)
}
@@ -747,7 +733,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("queue connectAnimatedNodeToView: animatedNodeTag: ${animatedNodeTag} viewTag: ${viewTag}"))
("queue connectAnimatedNodeToView: animatedNodeTag: $animatedNodeTag viewTag: $viewTag"))
}
initializeLifecycleEventListenersForViewTag(viewTag)
@@ -758,7 +744,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute connectAnimatedNodeToView: animatedNodeTag: ${animatedNodeTag} viewTag: ${viewTag}"))
("execute connectAnimatedNodeToView: animatedNodeTag: $animatedNodeTag viewTag: $viewTag"))
}
animatedNodesManager.connectAnimatedNodeToView(animatedNodeTag, viewTag)
}
@@ -783,7 +769,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute disconnectAnimatedNodeFromView: ${animatedNodeTag} viewTag: ${viewTag}"))
("execute disconnectAnimatedNodeFromView: $animatedNodeTag viewTag: $viewTag"))
}
animatedNodesManager.disconnectAnimatedNodeFromView(animatedNodeTag, viewTag)
}
@@ -816,7 +802,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("queue addAnimatedEventToView: ${viewTag} eventName: ${eventName} eventMapping: ${eventMapping.toHashMap().toString()}"))
("queue addAnimatedEventToView: $viewTag eventName: $eventName eventMapping: ${eventMapping.toHashMap()}"))
}
initializeLifecycleEventListenersForViewTag(viewTag)
@@ -827,7 +813,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute addAnimatedEventToView: ${viewTag} eventName: ${eventName} eventMapping: ${eventMapping.toHashMap().toString()}"))
("execute addAnimatedEventToView: $viewTag eventName: $eventName eventMapping: ${eventMapping.toHashMap()}"))
}
animatedNodesManager.addAnimatedEventToView(viewTag, eventName, eventMapping)
}
@@ -844,7 +830,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("queue removeAnimatedEventFromView: viewTag: ${viewTag} eventName: ${eventName} animatedValueTag: ${animatedValueTag}"))
("queue removeAnimatedEventFromView: viewTag: $viewTag eventName: $eventName animatedValueTag: $animatedValueTag"))
}
decrementInFlightAnimationsForViewTag(viewTag)
@@ -855,7 +841,7 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext?) :
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
("execute removeAnimatedEventFromView: viewTag: ${viewTag} eventName: ${eventName} animatedValueTag: ${animatedValueTag}"))
("execute removeAnimatedEventFromView: viewTag: $viewTag eventName: $eventName animatedValueTag: $animatedValueTag"))
}
animatedNodesManager.removeAnimatedEventFromView(viewTag, eventName, animatedValueTag)
}
@@ -381,7 +381,7 @@ public class NativeAnimatedNodesManager(
("connectAnimatedNodeToView: Animated node connected to view [${viewTag}] should be of type ${PropsAnimatedNode::class.java.name}"))
}
checkNotNull(reactApplicationContext) {
("connectAnimatedNodeToView: Animated node could not be connected, no ReactApplicationContext: ${viewTag}")
("connectAnimatedNodeToView: Animated node could not be connected, no ReactApplicationContext: $viewTag")
}
val uiManager = UIManagerHelper.getUIManagerForReactTag(reactApplicationContext, viewTag)
@@ -389,7 +389,7 @@ public class NativeAnimatedNodesManager(
ReactSoftExceptionLogger.logSoftException(
TAG,
ReactNoCrashSoftException(
("connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: ${viewTag}")))
("connectAnimatedNodeToView: Animated node could not be connected to UIManager - uiManager disappeared for tag: $viewTag")))
return
}
@@ -751,7 +751,7 @@ public class NativeAnimatedNodesManager(
val reason = if (cyclesDetected > 0) ("cycles ($cyclesDetected)") else "disconnected regions"
val ex =
IllegalStateException(
("Looks like animated nodes graph has ${reason}, there are ${activeNodesCount} but toposort visited only ${updatedNodesCount}"))
("Looks like animated nodes graph has ${reason}, there are $activeNodesCount but toposort visited only $updatedNodesCount"))
if (eventListenerInitializedForFabric && cyclesDetected == 0) {
// TODO T71377544: investigate these SoftExceptions and see if we can remove entirely
// or fix the root cause
@@ -18,12 +18,12 @@ public open class BaseActivityEventListener : ActivityEventListener {
ReplaceWith("onActivityResult(activity, requestCode, resultCode, data)"))
public open fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent): Unit = Unit
override public fun onActivityResult(
public override fun onActivityResult(
activity: Activity,
requestCode: Int,
resultCode: Int,
data: Intent?
): Unit = Unit
override public fun onNewIntent(intent: Intent): Unit = Unit
public override fun onNewIntent(intent: Intent): Unit = Unit
}
@@ -25,7 +25,7 @@ protected constructor(private val exceptionHandler: JSExceptionHandler) :
protected constructor(reactContext: ReactContext) : this(reactContext.exceptionHandler)
@Deprecated("AsyncTask is deprecated.")
override protected final fun doInBackground(vararg params: Params): Void? {
protected final override fun doInBackground(vararg params: Params): Void? {
try {
doInBackgroundGuarded(*params)
} catch (e: RuntimeException) {
@@ -134,15 +134,14 @@ public class JavaOnlyArray : ReadableArray, WritableArray {
override fun toString(): String = backingList.toString()
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
} else if (other == null || javaClass != other.javaClass) {
return false
} else {
return backingList == (other as JavaOnlyArray).backingList
}
}
override fun equals(other: Any?): Boolean =
if (this === other) {
true
} else if (other == null || javaClass != other.javaClass) {
false
} else {
backingList == (other as JavaOnlyArray).backingList
}
override fun hashCode(): Int = backingList.hashCode()
}
@@ -1,25 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge;
import android.content.Context;
import com.facebook.infer.annotation.Nullsafe;
/**
* A context wrapper that always wraps Android Application {@link Context} and {@link
* CatalystInstance} by extending {@link ReactContext}
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public abstract class ReactApplicationContext extends ReactContext {
// We want to wrap ApplicationContext, since there is no easy way to verify that application
// context is passed as a param, we use {@link Context#getApplicationContext} to ensure that
// the context we're wrapping is in fact an application context.
public ReactApplicationContext(Context context) {
super(context.getApplicationContext());
}
}
@@ -0,0 +1,20 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.bridge
import android.content.Context
/**
* A context wrapper that always wraps Android Application [Context] and [CatalystInstance] by
* extending [ReactContext].
*/
public abstract class ReactApplicationContext(context: Context) :
// We want to wrap ApplicationContext, since there is no easy way to verify that application
// context is passed as a param, we use [Context.getApplicationContext] to ensure that
// the context we're wrapping is in fact an application context.
ReactContext(context.applicationContext)
@@ -79,10 +79,10 @@ public open class ReadableNativeMap protected constructor() : NativeMap(), Reada
private inline fun <reified T> getNullableValue(name: String, type: Class<T>): T? {
val res = getNullableValue(name)
if (res == null) {
return null
return if (res == null) {
null
} else {
return checkInstance(name, res, type)
checkInstance(name, res, type)
}
}
@@ -12,6 +12,7 @@ import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import java.util.concurrent.TimeUnit
import kotlin.math.abs
/** Listens for the user shaking their phone. Allocation-less once it starts listening. */
public class ShakeDetector
@@ -63,7 +64,7 @@ constructor(private val shakeListener: ShakeListener, private val minNumShakes:
* @return true if the magnitude of the force exceeds the minimum required amount of force. false
* otherwise.
*/
private fun atLeastRequiredForce(a: Float): Boolean = Math.abs(a) > REQUIRED_FORCE
private fun atLeastRequiredForce(a: Float): Boolean = abs(a) > REQUIRED_FORCE
/**
* Save data about last shake
@@ -465,9 +465,7 @@ public abstract class DevSupportManagerBase(
devOptionsDialog?.show()
val reactContext = currentReactContext
if (reactContext != null) {
reactContext.getJSModule(RCTNativeAppEventEmitter::class.java).emit("RCTDevMenuShown", null)
}
reactContext?.getJSModule(RCTNativeAppEventEmitter::class.java)?.emit("RCTDevMenuShown", null)
}
override fun onNewReactContextCreated(reactContext: ReactContext) {
@@ -76,7 +76,7 @@ internal class PackagerStatusCheck {
if (PACKAGER_OK_STATUS != bodyString) {
FLog.e(
ReactConstants.TAG,
"Got unexpected response from packager when requesting status: ${bodyString}")
"Got unexpected response from packager when requesting status: $bodyString")
callback.onPackagerStatusFetched(false)
return
}
@@ -37,11 +37,12 @@ internal class LongStreamingStats {
}
len++
if (len == 1) {
average = n.toDouble()
} else {
average = (average / (len / (len - 1))) + (n / len)
}
average =
if (len == 1) {
n.toDouble()
} else {
(average / (len / (len - 1))) + (n / len)
}
max = (if (n > max) n else max)
}
@@ -21,6 +21,7 @@ import androidx.collection.SparseArrayCompat;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.react.bridge.GuardedRunnable;
import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.ReadableArray;
@@ -189,57 +190,55 @@ public class SurfaceMountingManager {
mTagToViewState.put(mSurfaceId, new ViewState(mSurfaceId, rootView, mRootViewManager, true));
Runnable runnable =
() -> {
// The CPU has ticked since `addRootView` was called, so the surface could technically
// have already stopped here.
if (isStopped()) {
return;
new GuardedRunnable(Assertions.assertNotNull(mThemedReactContext)) {
@Override
public void runGuarded() {
// The CPU has ticked since `addRootView` was called, so the surface could technically
// have already stopped here.
if (isStopped()) {
return;
}
if (rootView.getId() == mSurfaceId) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalViewOperationException(
"Race condition in addRootView detected. Trying to set an id of ["
+ mSurfaceId
+ "] on the RootView, but that id has already been set. "));
} else if (rootView.getId() != View.NO_ID) {
FLog.e(
TAG,
"Trying to add RootTag to RootView that already has a tag: existing tag: [%d] new"
+ " tag: [%d]",
rootView.getId(),
mSurfaceId);
// This behavior can not be guaranteed in hybrid apps that have a native android layer
// over which reactRootViews are added and the native views need to have ids on them
// in order to work. Hence this can cause unnecessary crashes at runtime for hybrid
// apps. So converting this to a soft exception such that pure react-native devs can
// still see the warning while hybrid apps continue to run without crashes
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalViewOperationException(
"Trying to add a root view with an explicit id already set. React Native uses"
+ " the id field to track react tags and will overwrite this field. If"
+ " that is fine, explicitly overwrite the id field to View.NO_ID before"
+ " calling addRootView."));
}
rootView.setId(mSurfaceId);
if (rootView instanceof ReactRoot) {
((ReactRoot) rootView).setRootViewTag(mSurfaceId);
}
executeMountItemsOnViewAttach();
// By doing this after `executeMountItemsOnViewAttach`, we ensure that any operations
// scheduled while processing this queue are also added to the queue, instead of being
// processed immediately through the queue in `MountItemDispatcher`.
mRootViewAttached = true;
}
if (rootView.getId() == mSurfaceId) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalViewOperationException(
"Race condition in addRootView detected. Trying to set an id of ["
+ mSurfaceId
+ "] on the RootView, but that id has already been set. "));
} else if (rootView.getId() != View.NO_ID) {
FLog.e(
TAG,
"Trying to add RootTag to RootView that already has a tag: existing tag: [%d] new"
+ " tag: [%d]",
rootView.getId(),
mSurfaceId);
// This behavior can not be guaranteed in hybrid apps that have a native android layer
// over
// which reactRootViews are added and the native views need to have ids on them in order
// to
// work.
// Hence this can cause unnecessary crashes at runtime for hybrid apps.
// So converting this to a soft exception such that pure react-native devs can still see
// the
// warning while hybrid apps continue to run without crashes
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalViewOperationException(
"Trying to add a root view with an explicit id already set. React Native uses"
+ " the id field to track react tags and will overwrite this field. If that"
+ " is fine, explicitly overwrite the id field to View.NO_ID before calling"
+ " addRootView."));
}
rootView.setId(mSurfaceId);
if (rootView instanceof ReactRoot) {
((ReactRoot) rootView).setRootViewTag(mSurfaceId);
}
executeMountItemsOnViewAttach();
// By doing this after `executeMountItemsOnViewAttach`, we ensure
// that any operations scheduled while processing this queue are
// also added to the queue, instead of being processed immediately
// through the queue in `MountItemDispatcher`.
mRootViewAttached = true;
};
if (UiThreadUtil.isOnUiThread()) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<dee97293bfeab942c9cd0ba8622a5f86>>
* @generated SignedSource<<442cbf571b5654c5d322ca1b5542db7d>>
*/
/**
@@ -258,6 +258,18 @@ public object ReactNativeFeatureFlags {
@JvmStatic
public fun enableVirtualViewDebugFeatures(): Boolean = accessor.enableVirtualViewDebugFeatures()
/**
* Enables reading render state when dispatching VirtualView events.
*/
@JvmStatic
public fun enableVirtualViewRenderState(): Boolean = accessor.enableVirtualViewRenderState()
/**
* Enables window focus detection for prioritizing VirtualView events.
*/
@JvmStatic
public fun enableVirtualViewWindowFocusDetection(): Boolean = accessor.enableVirtualViewWindowFocusDetection()
/**
* Uses the default event priority instead of the discreet event priority by default when dispatching events from Fabric to React.
*/
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<c46464d2d10ac0c8a6b7869ae5b3cd2b>>
* @generated SignedSource<<166a7cc18f83861c6c4d7f96a55c5843>>
*/
/**
@@ -58,6 +58,8 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
private var enableViewRecyclingForTextCache: Boolean? = null
private var enableViewRecyclingForViewCache: Boolean? = null
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
private var enableVirtualViewRenderStateCache: Boolean? = null
private var enableVirtualViewWindowFocusDetectionCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fuseboxEnabledReleaseCache: Boolean? = null
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
@@ -415,6 +417,24 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
return cached
}
override fun enableVirtualViewRenderState(): Boolean {
var cached = enableVirtualViewRenderStateCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableVirtualViewRenderState()
enableVirtualViewRenderStateCache = cached
}
return cached
}
override fun enableVirtualViewWindowFocusDetection(): Boolean {
var cached = enableVirtualViewWindowFocusDetectionCache
if (cached == null) {
cached = ReactNativeFeatureFlagsCxxInterop.enableVirtualViewWindowFocusDetection()
enableVirtualViewWindowFocusDetectionCache = cached
}
return cached
}
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<62c548a9bfbf777a40b1b9e9d52b1de2>>
* @generated SignedSource<<27e8fa8139901c1decaba5bfcbced221>>
*/
/**
@@ -104,6 +104,10 @@ public object ReactNativeFeatureFlagsCxxInterop {
@DoNotStrip @JvmStatic public external fun enableVirtualViewDebugFeatures(): Boolean
@DoNotStrip @JvmStatic public external fun enableVirtualViewRenderState(): Boolean
@DoNotStrip @JvmStatic public external fun enableVirtualViewWindowFocusDetection(): Boolean
@DoNotStrip @JvmStatic public external fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
@DoNotStrip @JvmStatic public external fun fuseboxEnabledRelease(): Boolean
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<de8775978e15479830fb215c6f15b144>>
* @generated SignedSource<<5efae3bf30e8acf69f0682372c39f7b2>>
*/
/**
@@ -99,6 +99,10 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
override fun enableVirtualViewDebugFeatures(): Boolean = false
override fun enableVirtualViewRenderState(): Boolean = false
override fun enableVirtualViewWindowFocusDetection(): Boolean = false
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean = false
override fun fuseboxEnabledRelease(): Boolean = false
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<220b0cff47d2eadddf8a36646852d619>>
* @generated SignedSource<<498e9a51a9a0d0c0c4eb69c84bb33dd1>>
*/
/**
@@ -62,6 +62,8 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
private var enableViewRecyclingForTextCache: Boolean? = null
private var enableViewRecyclingForViewCache: Boolean? = null
private var enableVirtualViewDebugFeaturesCache: Boolean? = null
private var enableVirtualViewRenderStateCache: Boolean? = null
private var enableVirtualViewWindowFocusDetectionCache: Boolean? = null
private var fixMappingOfEventPrioritiesBetweenFabricAndReactCache: Boolean? = null
private var fuseboxEnabledReleaseCache: Boolean? = null
private var fuseboxNetworkInspectionEnabledCache: Boolean? = null
@@ -457,6 +459,26 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
return cached
}
override fun enableVirtualViewRenderState(): Boolean {
var cached = enableVirtualViewRenderStateCache
if (cached == null) {
cached = currentProvider.enableVirtualViewRenderState()
accessedFeatureFlags.add("enableVirtualViewRenderState")
enableVirtualViewRenderStateCache = cached
}
return cached
}
override fun enableVirtualViewWindowFocusDetection(): Boolean {
var cached = enableVirtualViewWindowFocusDetectionCache
if (cached == null) {
cached = currentProvider.enableVirtualViewWindowFocusDetection()
accessedFeatureFlags.add("enableVirtualViewWindowFocusDetection")
enableVirtualViewWindowFocusDetectionCache = cached
}
return cached
}
override fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean {
var cached = fixMappingOfEventPrioritiesBetweenFabricAndReactCache
if (cached == null) {
@@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated SignedSource<<d2ab95a5f7bf0dfc52428a90bee2fc10>>
* @generated SignedSource<<fce6841e89beec5be32b76fc0941ef95>>
*/
/**
@@ -99,6 +99,10 @@ public interface ReactNativeFeatureFlagsProvider {
@DoNotStrip public fun enableVirtualViewDebugFeatures(): Boolean
@DoNotStrip public fun enableVirtualViewRenderState(): Boolean
@DoNotStrip public fun enableVirtualViewWindowFocusDetection(): Boolean
@DoNotStrip public fun fixMappingOfEventPrioritiesBetweenFabricAndReact(): Boolean
@DoNotStrip public fun fuseboxEnabledRelease(): Boolean
@@ -121,14 +121,13 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
}
private val isInvertColorsEnabledValue: Boolean
get() {
try {
return Settings.Secure.getInt(
contentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) == 1
} catch (e: Settings.SettingNotFoundException) {
return false
}
}
get() =
try {
Settings.Secure.getInt(
contentResolver, Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED) == 1
} catch (e: Settings.SettingNotFoundException) {
false
}
private val isGrayscaleEnabledValue: Boolean
get() {
@@ -181,10 +180,8 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
val isReduceMotionEnabled = isReduceMotionEnabledValue
if (reduceMotionEnabled != isReduceMotionEnabled) {
reduceMotionEnabled = isReduceMotionEnabled
val reactApplicationContext = getReactApplicationContextIfActiveOrWarn()
if (reactApplicationContext != null) {
reactApplicationContext.emitDeviceEvent(REDUCE_MOTION_EVENT_NAME, reduceMotionEnabled)
}
getReactApplicationContextIfActiveOrWarn()
?.emitDeviceEvent(REDUCE_MOTION_EVENT_NAME, reduceMotionEnabled)
}
}
@@ -192,10 +189,8 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
val isInvertColorsEnabled = isInvertColorsEnabledValue
if (invertColorsEnabled != isInvertColorsEnabled) {
invertColorsEnabled = isInvertColorsEnabled
val reactApplicationContext = getReactApplicationContextIfActiveOrWarn()
if (reactApplicationContext != null) {
reactApplicationContext.emitDeviceEvent(INVERT_COLOR_EVENT_NAME, invertColorsEnabled)
}
getReactApplicationContextIfActiveOrWarn()
?.emitDeviceEvent(INVERT_COLOR_EVENT_NAME, invertColorsEnabled)
}
}
@@ -203,13 +198,11 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
val isHighTextContrastEnabled = isHighTextContrastEnabledValue
if (highTextContrastEnabled != isHighTextContrastEnabled) {
highTextContrastEnabled = isHighTextContrastEnabled
val reactApplicationContext = getReactApplicationContextIfActiveOrWarn()
if (reactApplicationContext != null) {
reactApplicationContext.emitDeviceEvent(
HIGH_TEXT_CONTRAST_EVENT_NAME,
highTextContrastEnabled,
)
}
getReactApplicationContextIfActiveOrWarn()
?.emitDeviceEvent(
HIGH_TEXT_CONTRAST_EVENT_NAME,
highTextContrastEnabled,
)
}
}
@@ -239,10 +232,8 @@ internal class AccessibilityInfoModule(context: ReactApplicationContext) :
val isGrayscaleModeEnabled = isGrayscaleEnabledValue
if (grayscaleModeEnabled != isGrayscaleModeEnabled) {
grayscaleModeEnabled = isGrayscaleModeEnabled
val reactApplicationContext = getReactApplicationContextIfActiveOrWarn()
if (reactApplicationContext != null) {
reactApplicationContext.emitDeviceEvent(GRAYSCALE_MODE_EVENT_NAME, grayscaleModeEnabled)
}
getReactApplicationContextIfActiveOrWarn()
?.emitDeviceEvent(GRAYSCALE_MODE_EVENT_NAME, grayscaleModeEnabled)
}
}
@@ -9,6 +9,7 @@ package com.facebook.react.modules.clipboard
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import com.facebook.fbreact.specs.NativeClipboardSpec
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
@@ -20,8 +21,7 @@ internal class ClipboardModule(context: ReactApplicationContext) : NativeClipboa
private val clipboardService: ClipboardManager
get() =
getReactApplicationContext().getSystemService(ReactApplicationContext.CLIPBOARD_SERVICE)
as ClipboardManager
getReactApplicationContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
override fun getString(promise: Promise) {
try {
@@ -108,7 +108,7 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
* @param url the URL to open
*/
override fun openURL(url: String?, promise: Promise) {
if (url == null || url.isEmpty()) {
if (url.isNullOrEmpty()) {
promise.reject(JSApplicationIllegalArgumentException("Invalid URL: $url"))
return
}
@@ -131,7 +131,7 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
* @param promise a promise that is always resolved with a boolean argument
*/
override fun canOpenURL(url: String?, promise: Promise) {
if (url == null || url.isEmpty()) {
if (url.isNullOrEmpty()) {
promise.reject(JSApplicationIllegalArgumentException("Invalid URL: $url"))
return
}
@@ -189,7 +189,7 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
* @param extras An array of extras [{ String, String | Number | Boolean }]
*/
override fun sendIntent(action: String?, extras: ReadableArray?, promise: Promise) {
if (action == null || action.isEmpty()) {
if (action.isNullOrEmpty()) {
promise.reject(JSApplicationIllegalArgumentException("Invalid Action: $action."))
return
}
@@ -214,7 +214,6 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
ReadableType.String -> {
intent.putExtra(name, map.getString(EXTRA_MAP_KEY_FOR_VALUE))
}
ReadableType.Number -> {
// We cannot know from JS if is an Integer or Double
// See: https://github.com/facebook/react-native/issues/4141
@@ -222,11 +221,9 @@ public open class IntentModule(reactContext: ReactApplicationContext) :
val number = map.getDouble(EXTRA_MAP_KEY_FOR_VALUE)
intent.putExtra(name, number)
}
ReadableType.Boolean -> {
intent.putExtra(name, map.getBoolean(EXTRA_MAP_KEY_FOR_VALUE))
}
else -> {
promise.reject(
JSApplicationIllegalArgumentException("Extra type for $name not supported."))
@@ -62,14 +62,14 @@ internal class ProgressiveStringDecoder(charset: Charset) {
}
val hasRemainder = decoded && remainderLength > 0
if (hasRemainder) {
remainder =
remainder =
if (hasRemainder) {
ByteArray(remainderLength).apply {
System.arraycopy(decodeData, length - remainderLength, this, 0, remainderLength)
}
} else {
remainder = null
}
} else {
null
}
if (!decoded) {
FLog.w(ReactConstants.TAG, "failed to decode string from byte array")
@@ -80,7 +80,7 @@ public class PermissionsModule(reactContext: ReactApplicationContext?) :
object : Callback {
override operator fun invoke(vararg args: Any?) {
val results = args[0] as IntArray
if (results.size > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
if (results.isNotEmpty() && results[0] == PackageManager.PERMISSION_GRANTED) {
promise.resolve(GRANTED)
} else {
val callbackActivity = args[1] as PermissionAwareActivity
@@ -131,7 +131,7 @@ public class WebSocketModule(context: ReactApplicationContext) :
protocolsValue.append(",")
}
}
if (protocolsValue.length > 0) {
if (protocolsValue.isNotEmpty()) {
protocolsValue.replace(protocolsValue.length - 1, protocolsValue.length, "")
builder.addHeader("Sec-WebSocket-Protocol", protocolsValue.toString())
}
@@ -26,6 +26,7 @@ import com.facebook.react.uimanager.JSTouchDispatcher
import com.facebook.react.uimanager.common.UIManagerType
import com.facebook.systrace.Systrace
import java.util.Objects
import kotlin.math.max
/**
* A view created by [com.facebook.react.interfaces.fabric.ReactSurface] that's responsible for
@@ -55,7 +56,7 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa
for (i in 0 until childCount) {
val child = getChildAt(i)
val childSize = (child.left + child.measuredWidth + child.paddingLeft + child.paddingRight)
width = Math.max(width, childSize)
width = max(width, childSize)
}
} else {
width = MeasureSpec.getSize(widthMeasureSpec)
@@ -65,7 +66,7 @@ public class ReactSurfaceView(context: Context?, private val surface: ReactSurfa
for (i in 0 until childCount) {
val child = getChildAt(i)
val childSize = (child.top + child.measuredHeight + child.paddingTop + child.paddingBottom)
height = Math.max(height, childSize)
height = max(height, childSize)
}
} else {
height = MeasureSpec.getSize(heightMeasureSpec)
@@ -19,6 +19,7 @@ import android.view.accessibility.AccessibilityEvent;
import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.view.AccessibilityDelegateCompat;
import androidx.core.view.ViewCompat;
import com.facebook.common.logging.FLog;
import com.facebook.react.R;
@@ -186,6 +187,16 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
if (focusChangeListener instanceof BaseVMFocusChangeListener) {
((BaseVMFocusChangeListener) focusChangeListener).detach(view);
}
AccessibilityDelegateCompat axDelegate = ViewCompat.getAccessibilityDelegate(view);
if (axDelegate instanceof ReactAccessibilityDelegate) {
((ReactAccessibilityDelegate) axDelegate).cleanUp();
}
if (view instanceof ViewGroup) {
((ViewGroup) view).setOnHierarchyChangeListener(null);
}
}
// Currently, layout listener is only attached when transform or transformOrigin is set.
@@ -8,6 +8,12 @@
package com.facebook.react.uimanager
import com.facebook.infer.annotation.Assertions
import kotlin.math.abs
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
import kotlin.math.tan
/**
* Provides helper methods for converting transform operations into a matrix and then into a list of
@@ -19,7 +25,7 @@ public object MatrixMathHelper {
private fun isZero(d: Double): Boolean {
return if (java.lang.Double.isNaN(d)) {
false
} else Math.abs(d) < EPSILON
} else abs(d) < EPSILON
}
@JvmStatic
@@ -181,12 +187,11 @@ public object MatrixMathHelper {
// Now, get the rotations out
// Based on: http://nghiaho.com/?page_id=846
val conv = 180 / Math.PI
rotationDegrees[0] = roundTo3Places(-Math.atan2(row[2][1], row[2][2]) * conv)
rotationDegrees[0] = roundTo3Places(-atan2(row[2][1], row[2][2]) * conv)
rotationDegrees[1] =
roundTo3Places(
-Math.atan2(-row[2][0], Math.sqrt(row[2][1] * row[2][1] + row[2][2] * row[2][2])) *
conv)
rotationDegrees[2] = roundTo3Places(-Math.atan2(row[1][0], row[0][0]) * conv)
-atan2(-row[2][0], sqrt(row[2][1] * row[2][1] + row[2][2] * row[2][2])) * conv)
rotationDegrees[2] = roundTo3Places(-atan2(row[1][0], row[0][0]) * conv)
}
@JvmStatic
@@ -322,7 +327,7 @@ public object MatrixMathHelper {
/** From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js */
@JvmStatic
public fun v3Length(a: DoubleArray): Double {
return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])
return sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])
}
/** Based on: https://code.google.com/p/webgl-mjs/source/browse/mjs.js */
@@ -437,37 +442,37 @@ public object MatrixMathHelper {
@JvmStatic
public fun applySkewX(m: DoubleArray, radians: Double) {
m[4] = Math.tan(radians)
m[4] = tan(radians)
}
@JvmStatic
public fun applySkewY(m: DoubleArray, radians: Double) {
m[1] = Math.tan(radians)
m[1] = tan(radians)
}
@JvmStatic
public fun applyRotateX(m: DoubleArray, radians: Double) {
m[5] = Math.cos(radians)
m[6] = Math.sin(radians)
m[9] = -Math.sin(radians)
m[10] = Math.cos(radians)
m[5] = cos(radians)
m[6] = sin(radians)
m[9] = -sin(radians)
m[10] = cos(radians)
}
@JvmStatic
public fun applyRotateY(m: DoubleArray, radians: Double) {
m[0] = Math.cos(radians)
m[2] = -Math.sin(radians)
m[8] = Math.sin(radians)
m[10] = Math.cos(radians)
m[0] = cos(radians)
m[2] = -sin(radians)
m[8] = sin(radians)
m[10] = cos(radians)
}
// http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix
@JvmStatic
public fun applyRotateZ(m: DoubleArray, radians: Double) {
m[0] = Math.cos(radians)
m[1] = Math.sin(radians)
m[4] = -Math.sin(radians)
m[5] = Math.cos(radians)
m[0] = cos(radians)
m[1] = sin(radians)
m[4] = -sin(radians)
m[5] = cos(radians)
}
public open class MatrixDecompositionContext {
@@ -29,13 +29,12 @@ public enum class PointerEvents {
public companion object {
@JvmStatic
public fun parsePointerEvents(pointerEventsStr: String?): PointerEvents {
if (pointerEventsStr == null) {
return AUTO
} else {
return PointerEvents.valueOf(pointerEventsStr.uppercase(Locale.US).replace("-", "_"))
}
}
public fun parsePointerEvents(pointerEventsStr: String?): PointerEvents =
if (pointerEventsStr == null) {
AUTO
} else {
PointerEvents.valueOf(pointerEventsStr.uppercase(Locale.US).replace("-", "_"))
}
@JvmStatic
public fun canBeTouchTarget(pointerEvents: PointerEvents): Boolean {
@@ -16,6 +16,7 @@ import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityManager;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -72,6 +73,10 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
private Handler mHandler;
private final HashMap<Integer, String> mAccessibilityActionsMap;
@Nullable
private AccessibilityManager.AccessibilityStateChangeListener accessibilityStateChangeListener =
null;
@Nullable View mAccessibilityLabelledBy;
static {
@@ -256,10 +261,29 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
super.onInitializeAccessibilityNodeInfo(host, info);
// If we set an accessibility order then all the focusing logic should go through our custom
// virtual view tree hierarchy and ignore the default path
ReadableArray axOrderIds = (ReadableArray) mView.getTag(R.id.accessibility_order);
if (axOrderIds != null && axOrderIds.size() != 0) {
info.setContentDescription("");
info.setFocusable(false);
AccessibilityManager am =
(AccessibilityManager) host.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (accessibilityStateChangeListener == null && am != null) {
AccessibilityManager.AccessibilityStateChangeListener newAccessibilityStateChangeListener =
enabled -> {
if (!enabled) {
ReactAxOrderHelper.restoreSubtreeFocusability(host);
host.setTag(R.id.accessibility_order_dirty, true);
}
};
am.addAccessibilityStateChangeListener(newAccessibilityStateChangeListener);
accessibilityStateChangeListener = newAccessibilityStateChangeListener;
}
Boolean isAxOrderDirty = (Boolean) mView.getTag(R.id.accessibility_order_dirty);
if (isAxOrderDirty != null && isAxOrderDirty) {
@@ -278,7 +302,6 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
return;
}
super.onInitializeAccessibilityNodeInfo(host, info);
populateAccessibilityNodeInfo(host, info);
}
@@ -1098,4 +1121,17 @@ public class ReactAccessibilityDelegate extends ExploreByTouchHelper {
}
}
}
// In case a view with accessibilityOrder is unmounted we need a way to clean up the listener on
// this delegate
public void cleanUp() {
if (accessibilityStateChangeListener != null) {
AccessibilityManager am =
(AccessibilityManager) mView.getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
if (am != null) {
am.removeAccessibilityStateChangeListener(accessibilityStateChangeListener);
}
accessibilityStateChangeListener = null;
}
}
}
@@ -10,7 +10,6 @@ package com.facebook.react.uimanager
import android.graphics.Rect
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.facebook.react.R
import com.facebook.react.bridge.ReadableArray
@@ -76,10 +75,6 @@ private object ReactAxOrderHelper {
}
}
if (!isIncluded && !isContained && parent != view && view !is TextView) {
view.importantForAccessibility = View.IMPORTANT_FOR_ACCESSIBILITY_NO
}
// Don't traverse the children of a nested accessibility order
if (view is ViewGroup) {
val axChildren: ArrayList<View> = getAxChildren(view)
@@ -100,6 +95,13 @@ private object ReactAxOrderHelper {
}
}
}
if (!isIncluded && !isContained && parent != view) {
if (view.getTag(R.id.original_focusability) == null) {
view.setTag(R.id.original_focusability, view.isFocusable)
}
view.isFocusable = false
}
}
traverseAndBuildAxOrder(
@@ -159,4 +161,21 @@ private object ReactAxOrderHelper {
}
return axChildren
}
@JvmStatic
public fun restoreSubtreeFocusability(view: View) {
val originalFocusability = view.getTag(R.id.original_focusability)
if (originalFocusability is Boolean) {
view.isFocusable = originalFocusability
}
if (view is ViewGroup) {
for (i in 0 until view.childCount) {
val child = view.getChildAt(i)
if (child != null) {
restoreSubtreeFocusability(child)
}
}
}
}
}
@@ -32,7 +32,7 @@ public interface ReactClippingViewGroup {
*/
public fun updateClippingRect()
public fun updateClippingRect(excludedView: Set<Int>?)
public fun updateClippingRect(excludedViews: Set<Int>?)
/**
* Get rectangular bounds to which view is currently clipped to. Called only on views that has set
@@ -1,235 +0,0 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.uimanager;
import static com.facebook.react.uimanager.common.UIManagerType.FABRIC;
import static com.facebook.react.uimanager.common.ViewUtil.getUIManagerType;
import android.content.Context;
import android.content.ContextWrapper;
import android.view.View;
import android.widget.EditText;
import androidx.annotation.Nullable;
import androidx.core.view.ViewCompat;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.bridge.ReactNoCrashSoftException;
import com.facebook.react.bridge.ReactSoftExceptionLogger;
import com.facebook.react.bridge.UIManager;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.common.build.ReactBuildConfig;
import com.facebook.react.uimanager.common.UIManagerType;
import com.facebook.react.uimanager.events.EventDispatcher;
import com.facebook.react.uimanager.events.EventDispatcherProvider;
/** Helper class for {@link UIManager}. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class UIManagerHelper {
private static final String TAG = "UIManagerHelper";
public static final int PADDING_START_INDEX = 0;
public static final int PADDING_END_INDEX = 1;
public static final int PADDING_TOP_INDEX = 2;
public static final int PADDING_BOTTOM_INDEX = 3;
/**
* @return a {@link UIManager} that can handle the react tag received by parameter.
*/
@Nullable
public static UIManager getUIManagerForReactTag(ReactContext context, int reactTag) {
return getUIManager(context, getUIManagerType(reactTag));
}
/**
* @return a {@link UIManager} that can handle the react tag received by parameter.
*/
@Nullable
public static UIManager getUIManager(ReactContext context, @UIManagerType int uiManagerType) {
return getUIManager(context, uiManagerType, true);
}
@Nullable
private static UIManager getUIManager(
ReactContext context,
@UIManagerType int uiManagerType,
boolean returnNullIfCatalystIsInactive) {
if (ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE || context.isBridgeless()) {
@Nullable UIManager uiManager = context.getFabricUIManager();
if (uiManager == null) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"Cannot get UIManager because the instance hasn't been initialized yet."));
return null;
}
return uiManager;
}
// The following code is compiled-out when `context.isBridgeless() == true &&
// ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE == true ` because:
// - BridgelessReactContext.isBridgeless() is set to true statically
// - BridgeReactContext is compiled-out when UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE == true
//
// To detect a potential regression we add the following assertion ERROR
LegacyArchitectureLogger.assertLegacyArchitecture(
"UIManagerHelper.getUIManager(context, uiManagerType)", LegacyArchitectureLogLevel.ERROR);
if (!context.hasCatalystInstance()) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"Cannot get UIManager because the context doesn't contain a CatalystInstance."));
return null;
}
// TODO T60461551: add tests to verify emission of events when the ReactContext is being turn
// down.
if (!context.hasActiveReactInstance()) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"Cannot get UIManager because the context doesn't contain an active"
+ " CatalystInstance."));
if (returnNullIfCatalystIsInactive) {
return null;
}
}
CatalystInstance catalystInstance = context.getCatalystInstance();
try {
return uiManagerType == FABRIC
? context.getFabricUIManager()
: catalystInstance.getNativeModule(UIManagerModule.class);
} catch (IllegalArgumentException ex) {
// TODO T67518514 Clean this up once we migrate everything over to bridgeless mode
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"Cannot get UIManager for UIManagerType: " + uiManagerType));
return catalystInstance.getNativeModule(UIManagerModule.class);
}
}
/**
* @return the {@link EventDispatcher} that handles events for the reactTag received as a
* parameter.
*/
@Nullable
public static EventDispatcher getEventDispatcherForReactTag(ReactContext context, int reactTag) {
EventDispatcher eventDispatcher = getEventDispatcher(context, getUIManagerType(reactTag));
if (eventDispatcher == null) {
ReactSoftExceptionLogger.logSoftException(
TAG, new IllegalStateException("Cannot get EventDispatcher for reactTag " + reactTag));
}
return eventDispatcher;
}
/**
* @return the {@link EventDispatcher} that handles events for the {@link UIManagerType} received
* as a parameter.
*/
@Nullable
public static EventDispatcher getEventDispatcher(
ReactContext context, @UIManagerType int uiManagerType) {
// TODO T67518514 Clean this up once we migrate everything over to bridgeless mode
if (context.isBridgeless()) {
if (context instanceof ThemedReactContext) {
context = ((ThemedReactContext) context).getReactApplicationContext();
}
return ((EventDispatcherProvider) context).getEventDispatcher();
}
UIManager uiManager = getUIManager(context, uiManagerType, false);
if (uiManager == null) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new ReactNoCrashSoftException(
"Unable to find UIManager for UIManagerType " + uiManagerType));
return null;
}
EventDispatcher eventDispatcher = (EventDispatcher) uiManager.getEventDispatcher();
if (eventDispatcher == null) {
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalStateException(
"Cannot get EventDispatcher for UIManagerType " + uiManagerType));
}
return eventDispatcher;
}
/**
* @return The {@link ReactContext} associated to the {@link View} received as a parameter.
* <p>We can't rely that the method View.getContext() will return the same context that was
* passed as a parameter during the construction of the View.
* <p>For example the AppCompatEditText class wraps the context received as a parameter in the
* constructor of the View into a TintContextWrapper object. See:
* https://android.googlesource.com/platform/frameworks/support/+/dd55716/v7/appcompat/src/android/support/v7/widget/AppCompatEditText.java#55
*/
public static ReactContext getReactContext(View view) {
Context context = view.getContext();
if (!(context instanceof ReactContext) && context instanceof ContextWrapper) {
context = ((ContextWrapper) context).getBaseContext();
}
return (ReactContext) context;
}
/**
* @return Gets the surfaceId for the {@link ThemedReactContext} associated with a View, if
* possible, and then call getSurfaceId on it. See above (getReactContext) for additional
* context.
* <p>For RootViews, the root's rootViewTag is returned
* <p>Returns -1 for non-Fabric views
*/
public static int getSurfaceId(View view) {
if (view instanceof ReactRoot) {
ReactRoot rootView = (ReactRoot) view;
return rootView.getUIManagerType() == UIManagerType.FABRIC ? rootView.getRootViewTag() : -1;
}
int reactTag = view.getId();
// In non-Fabric we don't have (or use) SurfaceId
if (getUIManagerType(reactTag) == UIManagerType.LEGACY) {
return -1;
}
Context context = view.getContext();
if (!(context instanceof ThemedReactContext) && context instanceof ContextWrapper) {
context = ((ContextWrapper) context).getBaseContext();
}
int surfaceId = getSurfaceId(context);
if (surfaceId == -1) {
// All Fabric-managed Views (should) have a ThemedReactContext attached.
ReactSoftExceptionLogger.logSoftException(
TAG,
new IllegalStateException(
"Fabric View [" + reactTag + "] does not have SurfaceId associated with it"));
}
return surfaceId;
}
public static int getSurfaceId(Context context) {
if (context instanceof ThemedReactContext) {
return ((ThemedReactContext) context).getSurfaceId();
}
return -1;
}
/**
* @return the default padding used by Android EditText's. This method returns the padding in an
* array to avoid extra classloading during hot-path of RN Android.
*/
public static float[] getDefaultTextInputPadding(Context context) {
EditText editText = new EditText(context);
float[] padding = new float[4];
padding[PADDING_START_INDEX] = PixelUtil.toDIPFromPixel(ViewCompat.getPaddingStart(editText));
padding[PADDING_END_INDEX] = PixelUtil.toDIPFromPixel(ViewCompat.getPaddingEnd(editText));
padding[PADDING_TOP_INDEX] = PixelUtil.toDIPFromPixel(editText.getPaddingTop());
padding[PADDING_BOTTOM_INDEX] = PixelUtil.toDIPFromPixel(editText.getPaddingBottom());
return padding;
}
}

Some files were not shown because too many files have changed in this diff Show More