Commit Graph

38536 Commits

Author SHA1 Message Date
Rubén Norte 631d4dea25 Migrate Web Performance API tests to Flow (#45875)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45875

Changelog: [internal]

Just adopting Flow in all tests in `react-native/src/private` :)

Reviewed By: rshest

Differential Revision: D60654714

fbshipit-source-id: 34a9ae618fbd254044e2faf801adccc12fc0e244
2024-08-02 10:19:49 -07:00
Rubén Norte ed63646fc2 Move ErrorHandlers to react-native/src/private (#45876)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45876

Changelog: [internal]

Reviewed By: dmytrorykun

Differential Revision: D60597776

fbshipit-source-id: 1093aee0f2b84312b55a2b0c22e2b1576c60e26e
2024-08-02 10:19:49 -07:00
Rubén Norte e14b5f1d6f Move default export of PerformanceObserver to named export (#45874)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45874

Changelog: [internal]

Move default export of `PerformanceObserver` to named export.

Reviewed By: sammy-SC

Differential Revision: D60597779

fbshipit-source-id: 39f82c1903aa32a5318b112cbb03b63e4e6d2fc0
2024-08-02 10:19:49 -07:00
Nicola Corti 52fc64c602 Unbreak build_android by not depending on PreferenceManager from androidx (#45872)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45872

build_android is currently broken, this should fix it.

Changelog:
[Internal] [Changed] - Unbreak build_android by not depending on PreferenceManager from androidx

Reviewed By: cipolleschi, hezi

Differential Revision: D60652912

fbshipit-source-id: a089609c6643c40c95919fdc882a89406f6ce871
2024-08-02 09:14:01 -07:00
Ruslan Shestopalyuk 51278d3f30 Migrate UIManager interface to Kotlin (#44589)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44589

## Changelog:
[Internal] -

As in the title.

Reviewed By: tdn120

Differential Revision: D57434432

fbshipit-source-id: ce2504d5a27a9e8dd8d8d02b052b6cf9414491ab
2024-08-02 07:10:36 -07:00
Ruslan Shestopalyuk de73e44569 Migrate Promise interface to Kotlin (#44587)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44587

# Changelog:
[Internal] -

As in the title, moving towards migrating all the interfaces in react.bridge.

Reviewed By: tdn120

Differential Revision: D57433401

fbshipit-source-id: 35581d27d6d093edb1cc59b245e6468758825f68
2024-08-02 06:38:55 -07:00
Antony M. Kithinzi 491c3e9d76 chore: migrate GenerateCodegenArtifactsTaskTest to assertj (#45845)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

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

Pick one each for the category and type tags:

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

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

[INTERNAL] [CHANGED] - Migrated `packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt` to assertj.

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: hezi

Differential Revision: D60597025

Pulled By: cortinico

fbshipit-source-id: 4228b958c7b9e1506640b9ff217f098e2626ea81
2024-08-02 04:08:08 -07:00
Omar Bafagih ea78d68906 Migrate PackagerConnectionSettings.java to Kotlin (#45800)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45800

convert PackagerConnectionSettings.java to PackagerConnectionSettings.kt

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D60296462

fbshipit-source-id: 77a4ef164cd3405c3b7c85ecb301ae6e1d965e57
2024-08-01 14:28:57 -07:00
Ruslan Shestopalyuk c8a1da4c9e Migrate JavaTimerManager to Kotlin (#45820)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45820

# Changelog:
[Internal] -

As in the title.

Reviewed By: mdvacca

Differential Revision: D60449157

fbshipit-source-id: c3c8ae9bcc270d421ee71deef0159477206c6ca3
2024-08-01 14:03:13 -07:00
Nicola Corti 9679756682 Re-apply Use BackgroundStyleApplicator in View setters on ReactImageView.kt
Summary:
This re-applies D60495100 after I've fixed the history for `ReactImageView`.

bypass-github-export-checks

Changelog:
[Internal] [Changed] - Re-apply Use BackgroundStyleApplicator in View setters on ReactImageView.kt

Reviewed By: NickGerleman

Differential Revision: D60578453

fbshipit-source-id: 995f5e54ea6ca3161935e8b7814df390d827a463
2024-08-01 13:31:06 -07:00
Nicola Corti fd231c5eaf Convert com.facebook.react.views.image to Kotlin
Summary:
This converts the 3 remaining files inside `com.facebook.react.views.image` to Kotlin

bypass-github-export-checks

Changelog:
[Internal] [Changed] - Convert com.facebook.react.views.image to Kotlin

Reviewed By: NickGerleman

Differential Revision: D60578452

fbshipit-source-id: 6a5951f1f74561c1c45fe697e7cfc68fcec92412
2024-08-01 13:31:06 -07:00
Nicola Corti 6393a3cd78 Back out "Convert com.facebook.react.views.image to Kotlin"
Summary:
bypass-github-export-checks

Changelog:
[Internal] [Changed] - Back out "[RN][Android] Convert com.facebook.react.views.image to Kotlin"

Original commit changeset: 72450d37969b

Original Phabricator Diff: D60170084

Reviewed By: sammy-SC, rshest

Differential Revision: D60578451

fbshipit-source-id: b6c57eaf1e3cceff43b10680f6b9abf53cbf8605
2024-08-01 13:31:06 -07:00
Nick Gerleman 5f14963da0 Breaking: Set "enableBackgroundStyleApplicator" by default (#45866)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45866

This turns on enableBackgroundStyleApplicator() by default, which will get us more screenshot tests over existing apps, and let us add new screenshot tests for box-shadow against stock RNTester.

This is a breaking change, for the small number of libraries which use CSSBackgroundDrawable/ReactViewBackgroundDrawable off of a view directly, for setting or accessing styles (this was already unreliably), along with libraries which read `mBorderRadius` from views using reflection. This is more or less confined to Reanimated, react-native-navigation, and one internal library.

Users who want to access or mutate background styles should use the public `BackgroundStyleApplicator` instead.

Changelog:
[Android][Breaking] - Set "enableBackgroundStyleApplicator" by default

Reviewed By: joevilches

Differential Revision: D60365677

fbshipit-source-id: aab8588b27c1125920adb257406c53dadb356767
2024-08-01 12:06:40 -07:00
Abdelhafidh Belalia 48669af562 Android: Fix uploading GIF URI (#45826)
Summary:
In Android, when constructing a multipart body for a file and that file source is a uri (base64-encoded) we do the following:
1. Decode the base64 string into bytes
2. Create a bitmap object
3. Compress the bitmap object as PNG into new bytes

The process does an unnecessary work (bytes -> bitmap -> bytes) and creates unexpected results e.g. a GIF file will be converted into PNG when uploaded. This PR removes the unnecessary steps (2 and 3).

## Changelog:

[ANDROID] [FIXED] - Fix uploading GIF URI

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

Test Plan:
1. Upload a GIF; use URI (base64-encoded)
2. Verify that the uploaded file is a GIF

```js
const formData = new FormData();
formData.append('photo', {
  uri: GIFURI,
  type: 'image/gif',
  name: 'photo.gif',
});

fetch(UPLOAD_URL,
{
    body: formData,
    method: "POST",
}):
```

| Before | After |
|:------:|:-----:|
|   <video src="https://github.com/user-attachments/assets/6ce4769a-8fa5-4d00-8066-9a1911608632" />     |  <video src="https://github.com/user-attachments/assets/76a29d14-ce9d-48cd-94d0-7591064a5b1b" />      |

Reviewed By: cortinico

Differential Revision: D60515478

Pulled By: tdn120

fbshipit-source-id: d6ad1c42631c184c3dcdf3a956641e25d0c1b926
2024-08-01 12:04:42 -07:00
Jorge Cabiedes Acosta 54a6438eaa Fix default imageSource on Filters example (#45799)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45799

No idea how I missed this but I don't think `defaultProps` is a thing in React Native? So the images were not showing

Changelog: [internal]

Reviewed By: joevilches

Differential Revision: D60392853

fbshipit-source-id: 27280033fb719340a809053d6ca98ac3f178c8c3
2024-08-01 10:38:53 -07:00
Nishan bd0aedc8c3 feat: linear gradient android (#45433)
Summary:
- Adds `background` prop that supports CSS's linear gradient. Later this can be extended to support various other gradients and possibly CSS's background image (less motivation as better solutions exists for image)
- Extended `CSSBackgroundDrawable` to draw Linear Gradient shader while preserving the border style support.
- Style supports JS object to specify `LinearGradient`, so it can support Animated libraries.

## Changelog:
[ANDROID] [ADDED] - linear gradient

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

Pick one each for the category and type tags:

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

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

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

Test Plan:
- Check out `processBackground-test.js` for supported syntax testcases.
- Checkout examples added in `LinearGradientExample.js`

Although the PR is tested well but open to any changes/feedback on the approach taken.

iOS PR - https://github.com/facebook/react-native/pull/45433. Separated the PRs to keep it easier to review. Both PRs can be reviewed individually.

Reviewed By: joevilches

Differential Revision: D60493360

Pulled By: NickGerleman

fbshipit-source-id: 762929c4fe16d87cbbd9ebe83ecce96a9e13192c
2024-08-01 09:38:51 -07:00
Ruslan Shestopalyuk 6483a28b3a Convert modules/core/ReactChoreographer to Kotlin (#45811)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45811

# Changelog:
[Internal] -

Converts both ReactChoreographer.java and ChoreographerCompat.java to Kotlin.

Reviewed By: mdvacca

Differential Revision: D60445731

fbshipit-source-id: 597c9f2ea1a89ee13a210a4b3e172ea239297ae7
2024-08-01 06:59:40 -07:00
Ruslan Shestopalyuk c30ee464eb Kotlinify AnimationDriver (#45836)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45836

# Changelog:
[Internal] -

As in the title.

Reviewed By: cortinico

Differential Revision: D60502487

fbshipit-source-id: 003f2eade8f8425636b2023397ec29545175b487
2024-08-01 03:52:44 -07:00
Nick Gerleman fdfa0b17bb Enable BackgroundStyleApplicator and boxShadow for View (#45832)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45832

The main one! This allows box-shadow to be used in View, and uses BackgroundStyleApplicator (if flag is enabled) for background management.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D60491176

fbshipit-source-id: c068b1dc971253f1303de5bae62e42a9eceb0de6
2024-07-31 23:49:48 -07:00
Nick Gerleman 087193c98e Add missing invalidate() to setOverflow() (#45835)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45835

`ReactViewBackgroundManager` will do this for us (and otherwise doesn't do anything draw related), but this will be removed when BackgroundStyleApplicator is rolled out, and not all callers use `ReactViewBackgroundManager`.

Changelog:
[Android][Fixed]

Reviewed By: philIip

Differential Revision: D60489756

fbshipit-source-id: 37cfc2b90af057bc142ad95b93e32941edb17ca5
2024-07-31 23:49:48 -07:00
Nick Gerleman 7047b7eaeb BackgroundStyleApplicator and boxShadow in TextInput (#45831)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45831

Like the previous diffs, but for TextInput!

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D60489444

fbshipit-source-id: 13edc2fada0ef55a84916e6bdff151e4f8a16d34
2024-07-31 23:49:48 -07:00
Nick Gerleman f26027e3c0 BackgroundStyleApplicator and boxShadow in Text (#45830)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45830

Like the previous diffs, but for Text!

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D60488060

fbshipit-source-id: 9ce89f65f44df75a83f86f14d2cbdfbf96f32a7c
2024-07-31 23:49:48 -07:00
Nick Gerleman 5d1a3bd07b Use BackgroundStyleApplicator in View setters (#45834)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45834

These are very rarely called, outside of directly by the view manager, but they are still public, so we should make these work off the same composite drawable as the view managers (eventually BasrViewManager).

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D60495100

fbshipit-source-id: 90f51870dd9929d1f3657d8f5368ef46216c8544
2024-07-31 23:49:48 -07:00
Nick Gerleman b988e1cb58 Handle resetting boxShadow prop (#45829)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45829

`ReadableArray` here should be nullable, according to https://reactnative.dev/docs/next/native-components-android#3-expose-view-property-setters-using-reactprop-or-reactpropgroup-annotation

Filter is doing this correctly already.

That form will be used to reset state, back to no box shadows.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D60465486

fbshipit-source-id: b8024ad02a0eabc0da8dfca141d51387983cc031
2024-07-31 23:49:48 -07:00
Nick Gerleman 92dca53702 Add borderStartWidth and borderEndWidth support (#45854)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45854

Right now these border widths are incorporated into Yoga layout, but view manager never responds to it.

This adds the props supported by <View> to text, still missing many others. The underlying functions are aware of the spacing type,

I plan to fix this more thoroughly, across the different edges, properties, and different components, after we remove the legacy background stack, and all of these can live in a single place on BaseViewManager.

Changelog:
[Android][Fixed] - Add borderStartWidth and borderEndWidth support

Reviewed By: necolas

Differential Revision: D60560343

fbshipit-source-id: 8e1ebaa087e0728b5758850239c41aeae5d619a9
2024-07-31 22:32:23 -07:00
Kyle Rosenberg 8d6ec66b48 Update AccessibilityInfo mocks to return promises (#45825)
Summary:
Many `AccessibilityInfo` functions (`isReduceMotionEnabled`, `isBoldTextEnabled`, etc.) return promises, but the mocked versions of them in jest/setup.js aren't returning promises.

All of these functions live in [packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js](https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js), where you can verify their return types are Promises.

When using `react-native/jest-preset` and running tests that utilize one of these functions, you'll get an error:
```
AccessibilityInfo.isReduceMotionEnabled().then() is not a function
```

https://github.com/facebook/react-native/pull/29381 was opened in 2020 but closed after becoming stale. My PR is nearly identical but covers additional Promise-returning functions that have been added to `AccessibilityInfo` since then.

## Changelog:

[GENERAL] [FIXED] - Update the react-native/jest-preset mock of AccessibilityInfo to better match its API

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

Test Plan:
I've tested by making the change locally in my project's `node_modules/react-native/jest/setup.js` file and confirming that I no longer get an error when running this test:
```
it("should pass", async () => {
  await AccessibilityInfo.isReduceMotionEnabled().then(enabled => {
    expect(enabled).toBe(false);
  });
});
```

Before:
```
TypeError: Cannot read properties of undefined (reading 'then')

  16 |
  17 |   it.only("should pass", async () => {
> 18 |     await AccessibilityInfo.isReduceMotionEnabled().then(enabled => {
     |                                                    ^
  19 |       expect(enabled).toBe(false);
  20 |     });
  21 |   });
```

After: No type error, and test passes.

Reviewed By: robhogan

Differential Revision: D60519836

Pulled By: tdn120

fbshipit-source-id: 24fc77b0f9693e131686a0a45b81fbd33ff65f01
2024-07-31 12:35:41 -07:00
Thomas Nardone 2f651c8783 Convert common.ShakeDetector (#45744)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45744

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D60311462

fbshipit-source-id: 142649a18b365b0954dd138c895030fad4780ed1
2024-07-31 11:28:07 -07:00
Thomas Nardone 2962d69b67 Convert Convert ReactBuildConfig, ClearableSynchronizedPool, DebugServerException (#45680)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45680

Changelog:
[Internal] [Changed] - Convert ReactBuildConfig, ClearableSynchronizedPool, DebugServerException to Kotlin

Reviewed By: rshest

Differential Revision: D60246428

fbshipit-source-id: de4584b84c18972b31370530b2ab4b2f9ab38b4a
2024-07-31 11:28:07 -07:00
Thomas Nardone 5812ee1969 Convert common.futures.SimpleSettableFuture (#45677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45677

Changelog:
[Internal] [Changed] - Convert com.facebook.react.common.futures.SimpleSettableFuture to Kotlin

Reviewed By: rshest

Differential Revision: D60237075

fbshipit-source-id: e8a94fa3bb5d09da85b13d86b55a020d42a770cd
2024-07-31 11:28:07 -07:00
Thomas Nardone fbfb430b3b Convert common/assets/ReactFontManager.java (#45668)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45668

Changelog:
[Internal] [Changed] - Convert com.facebook.react.common.assets.ReactFontManager to Kotlin

Reviewed By: cortinico

Differential Revision: D60188666

fbshipit-source-id: 17ca6f162545e9185e1e0a24d8ebacf6cb49a064
2024-07-31 11:28:07 -07:00
Alan Lee 34e3a6cc88 provide default implementation for ReactHostDelegate.handleInstanceException() (#45521)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45521

[ReactHostDelegate.handleInstanceException()](https://github.com/facebook/react-native/blob/a6f5e5adebed3d9da411f99548e2d8ce96636e16/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt#L48) is a no-op so providing a default implementation for this.
As a simplified solution, just throw a `RuntimeException` (on non-debug bulid) in this case. Below is the justification.

1) We may want to consider using `ExceptionsManagerModule` TurboModule in OSS to report the exception but current implementation  just [throws JavaScriptException](https://github.com/facebook/react-native/blob/a6f5e5adebed3d9da411f99548e2d8ce96636e16/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java#L67) when it is fatal

2) If the exception happens during ReactInstance initialization then we may not have Turbo Module initialized and may not be able to access it. While we might want to fix how this works in longer term but for now just throw an Exception and let the app handle it.

3) In debug build, `DevSupportManager` is called before `handleInstanceException()` which would display a RedBox so don't throw when it is a debug build.

So it seems to best for now to just throw an exception so it can be handled by the app than silently ignoring it.

Changelog:
[Android][Added] - provide default implementation for ReactHostDelegate.handleInstanceException()

Reviewed By: javache

Differential Revision: D59847543

fbshipit-source-id: 0dd3c7688d13d159dfceb8defc8d0250273ef2ff
2024-07-31 11:23:34 -07:00
omer-ayhan 84de32b2d7 chore: ☂️ Migrate BundleHermesCTaskTest.kt to AssertJ (#45806)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:
[INTERNAL] [CHANGED] - Migrate `BundleHermesCTaskTest.kt` to AssertJ testing library

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

Pick one each for the category and type tags:

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

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

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: mdvacca

Differential Revision: D60522760

Pulled By: cortinico

fbshipit-source-id: f7847143d182b29e1bbbba738a0ddae9bf3ee59c
2024-07-31 11:08:30 -07:00
Bogusz Kaszowski 2b39e6307e chore: migrate PrepareJSCTaskTest to assertj (#45842)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:

[ANDROID] [CHANGED] - Migrated `packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PrepareJSCTaskTest.kt` to assertj.

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: mdvacca, arushikesarwani94

Differential Revision: D60519806

Pulled By: cortinico

fbshipit-source-id: 04e6a35ecafcb08e6935599d863ab62180383ac4
2024-07-31 11:01:18 -07:00
Joe Vilches acb634bc96 Fix case where certain spreads break box shadow logic (#45746)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45746

Once the spread was past a certain value, it could break some of this logic by creating a null rect or negative size. This just makes it so that in those cases, inset will be a 0x0 clear region rect and outset will be nothing

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60317780

fbshipit-source-id: 021bf41d71ae69809076b4f5e6413d04cd878372
2024-07-31 10:13:20 -07:00
Joe Vilches 49a7a7d58b Get inset box shadow to play nicely with borders (#45681)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45681

This diff fixes 2 related issues that arise when we add a border to the view with box shadow

1) The shadow fills the padding box and not the border box. To fix this we just need to subtract the edge insets (border width) from both the shadow size and the clear region size. We also need to change the clipping area to clip anything outside the padding box
2) The corner radius of the clear region is based on the corner insets, so border radius - border width

The first change required a bit of thinking on my part to remember what bits of the crazy arithmetic here needed to change. So I refactored a bit:

* The general theme now is that all of the rects are derived from one another, and make use of CGRectOffset and CGRectInset to make their necessary adjustments.
* We introduce `shadowFrame` which is just the frame of the shadow area - agnostic of things like blur padding and offscreen shenanigans. So its the size of the layer insetted by the border widths.
* From this we can derive our 2 offscreen rects. The `shadowCastingRect` outsets the shadow frame by the blurRadius, while the `clearRegionRect` insets by spread distance. We then use `CGRectOffset` to push it offscreen. We save this offset so we can use it later to get the CG shadow back in place (since this is all originally derived from `shadowFrame`.
* There is now a single place that dictates the size of the shadow (`shadowFrame`), and a single place that dictates the offset to push our rects offscreen. The necessary change to trace padding box and not content box therefore just needs to change `shadowFrame` as opposed to 4 other spots.
* Additionally, when we offset, we do not need to worry about things like spread and blur, since `CGRectInset` takes care of that along with the size

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60201959

fbshipit-source-id: 4ecf0e0db8ce9d54f08e89adec94d50eb19a26a3
2024-07-31 10:13:20 -07:00
Joe Vilches 4fef34e1fd Don't call cornerRadiiForBoxShadow if we don't have to (#45679)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45679

`cornerRadiiForBoxShadow(cornerRadii, 0)` no-ops since there is no spread, and it returns the same type as it takes as an input, so there is no point for this complexity

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60203620

fbshipit-source-id: c1f86ce6e8fef07365ab57caa3e906f1601a0c2b
2024-07-31 10:13:20 -07:00
Joe Vilches e6ef47aff8 Simplify some clipping logic for inset shadows (#45678)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45678

This doesn't need to be an explicit path, its just tracing out a rect. CG has a method for that

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D60202842

fbshipit-source-id: 61faa21e57b1341c3b96961f12503eb4a7f3020b
2024-07-31 10:13:20 -07:00
Ruslan Shestopalyuk 71b5f04986 HeadlessJsTaskSupportModule.java->.kt (#45816)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45816

# Changelog:
[Internal] -

As in the title.

Reviewed By: cortinico, mdvacca

Differential Revision: D60446972

fbshipit-source-id: 318f091b0ee697ac241d73e309bd13ae2ffdbe19
2024-07-31 10:00:22 -07:00
Ruslan Shestopalyuk 395f46c847 Convert ExceptionManagerModule to Kotlin (#45812)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45812

# Changelog:
[Internal] -

As in the title.

Reviewed By: mdvacca

Differential Revision: D60446630

fbshipit-source-id: 9d27e13735c7d2ae6f1d0e3259ef962513665050
2024-07-31 10:00:22 -07:00
Ruslan Shestopalyuk 3735cb3d4f modules/core/TimingModule to Kotlin (#45815)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45815

# Changelog:
[Internal] -

As in the title.

Reviewed By: alanleedev

Differential Revision: D60446859

fbshipit-source-id: 0ca52c59e2bbaa18c751f4459afac811e9c89703
2024-07-31 08:38:18 -07:00
Ruslan Shestopalyuk 6742af4a9d DeviceEventManagerModule.java->.kt (#45811)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45811

# Changelog:
[Internal] -

Converts both ReactChoreographer.java and ChoreographerCompat.java to Kotlin.

Reviewed By: alanleedev

Differential Revision: D60446332

fbshipit-source-id: b762dfcd53bb781483c8a1df19faa0c6a0065f11
2024-07-31 08:38:18 -07:00
Samuel Susla 53d2f8e8d6 do a bounds check in TouchTargetHelper (#45824)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45824

changelog: [internal]

add a bounds check to prevent crash in TouchTargetHelper.

as it turns out, firstReactAncestor may be bigger than the size of pathAccumulator.

Reviewed By: christophpurrer

Differential Revision: D60449741

fbshipit-source-id: 4e981d06877e26d278c4567beebebd82262f60d0
2024-07-31 07:46:22 -07:00
Rubén Norte c3dbebff5a Force accesses to ReactFabric to always go through proxy (#45822)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45822

Changelog: [internal]

## Context

`react-native/Libraries/Renderer/shims/ReactFabric` is the default module to load the RN renderer and loading it has side-effects (among other things it sets `global.RN$stopSurface`.

We introduced a proxy module (`RendererProxy`) so we could use dependency injection to overwrite the renderer module with a custom implementation (the original goal was to be able to use a renderer version that didn't pull paper and only used Fabric).

Unfortunately, using both the proxy and the module directly in some places leads to race conditions setting `global.RN$stopSurface`, which causes some screens to be rendered with one renderer and unmounted/disposed with a different one (because we accessed `ReactFabric` later and set `RN$stopSurface` from a different renderer implementation). When this happens, the unmount request in the other renderer is a no-op because no surface was renderer in it.  This leads to surfaces not being disposed.

## Changes

This modifies the proxy to add additional functions and modifies all other modules in the package to make sure that all the accesses to the renderer go through the proxy.

Reviewed By: sammy-SC

Differential Revision: D60452544

fbshipit-source-id: 1b17a95ed9b1c529718f22983dde1f00f1b2adae
2024-07-31 07:02:16 -07:00
Ruslan Shestopalyuk f8f85be8b5 Migrate react/modules/fresco to Kotlin (#45750)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45750

# Changelog:
[Internal] -

This migrates the whole module of `react/modules/fresco` from Java to Kotlin.

Reviewed By: defHLT

Differential Revision: D60334554

fbshipit-source-id: b66695215b82495253aa2ac78b33c64c703347af
2024-07-31 06:52:50 -07:00
omer-ayhan 575ab78625 chore: ☂️ Migrate GenerateCodegenSchemaTaskTest.kt to AssertJ (#45807)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:
[INTERNAL] [CHANGED] - Migrate `GenerateCodegenSchemaTaskTest.kt` to AssertJ testing library

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

Pick one each for the category and type tags:

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

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

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: andrewdacenko

Differential Revision: D60509334

Pulled By: cortinico

fbshipit-source-id: 0702958f0c9d03994b0c9a6a1c743f5db84e5703
2024-07-31 04:53:18 -07:00
omer-ayhan 9cd3c57840 chore: ☂️ Migrate PreparePrefabHeadersTaskTest.kt to AssertJ (#45808)
Summary:
Issue: https://github.com/facebook/react-native/issues/45596

## Changelog:
[INTERNAL] [CHANGED] - Migrate `PreparePrefabHeadersTaskTest.kt` to AssertJ testing library

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

Pick one each for the category and type tags:

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

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

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

Test Plan: Run `./gradlew -p packages/gradle-plugin test`

Reviewed By: andrewdacenko

Differential Revision: D60509282

Pulled By: cortinico

fbshipit-source-id: 1b7d9f0c24bb0e8e573f685582c532a38e6b3b13
2024-07-31 04:45:02 -07:00
Nicola Corti 6484070ad7 Convert com.facebook.react.views.image to Kotlin (#45645)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45645

This converts the 3 remaining files inside `com.facebook.react.views.image` to Kotlin

Changelog:
[Internal] [Changed] - Convert com.facebook.react.views.image to Kotlin

Reviewed By: javache

Differential Revision: D60170084

fbshipit-source-id: 72450d37969b84e0d31d4902c0ef0d520419f7a9
2024-07-31 04:11:59 -07:00
Deepanshu.shukla d88dd14507 fix: onChangeText should be called only once if changed via js in a multiline textinput (#45401)
Summary:
Fixes [44566](https://github.com/facebook/react-native/issues/44566)

Issue was onChangeText was called 5-6 times if maxLength was set in a multiline component and TextInput Value was changed via state update.
`if (_maxLength) {
    NSInteger allowedLength = MAX(
        _maxLength.integerValue - (NSInteger)backedTextInputView.attributedText.string.length + (NSInteger)range.length,
        0);

    if (text.length > allowedLength) {
      // If we typed/pasted more than one character, limit the text inputted.
      if (text.length > 1) {
        if (allowedLength > 0) {
          // make sure unicode characters that are longer than 16 bits (such as emojis) are not cut off
          NSRange cutOffCharacterRange = [text rangeOfComposedCharacterSequenceAtIndex:allowedLength - 1];
          if (cutOffCharacterRange.location + cutOffCharacterRange.length > allowedLength) {
            // the character at the length limit takes more than 16bits, truncation should end at the character before
            allowedLength = cutOffCharacterRange.location;
          }
        }
        // Truncate the input string so the result is exactly maxLength
        NSString *limitedString = [text substringToIndex:allowedLength];
        NSMutableAttributedString *newAttributedText = [backedTextInputView.attributedText mutableCopy];
        // Apply text attributes if original input view doesn't have text.
        if (backedTextInputView.attributedText.length == 0) {
          newAttributedText = [[NSMutableAttributedString alloc]
              initWithString:[self.textAttributes applyTextAttributesToText:limitedString]
                  attributes:self.textAttributes.effectiveTextAttributes];
        } else {
          [newAttributedText replaceCharactersInRange:range withString:limitedString];
        }
        backedTextInputView.attributedText = newAttributedText;
        _predictedText = newAttributedText.string;

        // Collapse selection at end of insert to match normal paste behavior.
        UITextPosition *insertEnd = [backedTextInputView positionFromPosition:backedTextInputView.beginningOfDocument
                                                                       offset:(range.location + allowedLength)];
        [backedTextInputView setSelectedTextRange:[backedTextInputView textRangeFromPosition:insertEnd
                                                                                  toPosition:insertEnd]
                                   notifyDelegate:YES];

        [self textInputDidChange];
      }

      return nil; // Rejecting the change.
    }}`

This is the original code snippet.
It was happening because of wrong check of maxLength with text length `if (text.length > allowedLength)` this  should be
`(text.length > _maxLength.integerValue)`  and `if (allowedLength <= 0)`  we should not change the string and fire `textInputDidChange`

## Changelog:
[IOS] [FIXED] : Fixing maxLength check which was firing onChange multiple times

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

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

Test Plan:
Tested in Ios
Ran yarn test
<img width="1661" alt="Screenshot 2024-07-12 at 1 00 28 PM" src="https://github.com/user-attachments/assets/fbad94a8-9989-4252-ad7d-e507d4eafd9e">

Reviewed By: sammy-SC

Differential Revision: D59911745

Pulled By: cipolleschi

fbshipit-source-id: 67410ec50d6a2415e568e1685699bfed02fd0a27
2024-07-31 04:06:14 -07:00
Riccardo Cipolleschi f8c13f601d Declare onUserDrivenAnimationEnded on Old Arch (#45838)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45838

Some Internal tests in the old architecture were failing after landing [#45414](https://github.com/facebook/react-native/pull/45414) because the `RCTNativeAnimatedModule` in the old architecture was not declaring the event.

This change fixes it by declaring the event that is never fired in the Old Architecture as it is not needed.

## Changelog
[iOS][Added] - Declare the `onUserDrivenAnimationEnded` in the old Architecture

Reviewed By: sammy-SC

Differential Revision: D60507812

fbshipit-source-id: eb12563c6551204bcf98f3a2001e1efcf84ef05e
2024-07-31 03:47:33 -07:00
Arushi Kesarwani a5b84b9258 Migrate enableViewRecycling to ReactNativeFeatureFlags (#45654)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45654

Migrate enableViewRecycling to ReactNativeFeatureFlags

changelog: [internal] internal

Reviewed By: mdvacca

Differential Revision: D60153238

fbshipit-source-id: 14980174cb21833e35e107dc4cf52867cd0a5f8e
2024-07-31 00:14:55 -07:00