Commit Graph

38536 Commits

Author SHA1 Message Date
Oskar Kwaśniewski e98c221e5e fix: remove @available for RCTKeyWindow check (#46510)
Summary:
This PR removes `available` for `RCTKeyWindow` after minimum version bump to iOS 15 this check is not needed anymore.

## Changelog:

[IOS] [REMOVED] - remove available for RCTKeyWindow check

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

Test Plan: CI Green

Reviewed By: rshest

Differential Revision: D62752434

Pulled By: javache

fbshipit-source-id: 7b7745d4f27128cdb66053f7fa1cc234435eac31
2024-09-16 09:38:30 -07:00
shubhamguptadream11 4e1d7015c1 feat: add overlayColor prop to modal component for customisable background overlay (#46322)
Summary:
Solves these issues:
- https://github.com/facebook/react-native/issues/18398
- https://github.com/facebook/react-native/issues/12478

Solves this proposal: https://github.com/react-native-community/discussions-and-proposals/discussions/774

## 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
-->

[GENERAL] [ADDED] - added overlayColor prop to modal component for customisable background overlay

**Motivation:**
Currently, the React Native Modal component only allows the background to be set to either `transparent` or `white`. This limits the ability to dim the background or apply custom colors, which is essential for creating a more polished and user-friendly interface.

**Change Log:**

Modal Component Enhancements:

- Introduced a new optional prop `overlayColor` to the Modal component.
- Updated the background color logic to prioritize `overlayColor` when transparent is `false`.
- Ensured backward compatibility by defaulting to `white` when `overlayColor` is not provided.

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

Test Plan:
- Test the changes on both iOS and Android devices/emulators to ensure consistent behavior.
- Added example in **rn-tester** app

**Sample screenshot with custom overlayColor passed as 'red'.**

![simulator_screenshot_4F112217-7AD5-4030-8A18-6260AD32988A](https://github.com/user-attachments/assets/52f16ef2-874b-487c-908b-1aa2a1b8fafb)

Reviewed By: cipolleschi

Differential Revision: D62201559

Pulled By: alanleedev

fbshipit-source-id: e990d7f18f5edf61f0107026ea899c5f22d47bfd
2024-09-16 09:29:00 -07:00
Rubén Norte b4c41ec768 Clean up "fixIncorrectScrollViewStateUpdateOnAndroid" feature flag (#46506)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46506

Changelog: [Android][Fixed] Fixed incorrect scroll event/position for scroll views when doing a smooth scroll animation.

We tested this in production and the fix is safe to land.

Reviewed By: rshest

Differential Revision: D62738925

fbshipit-source-id: e1198dac76cf850dfa76a5cee1ef205d5b367d19
2024-09-16 09:22:41 -07:00
Samuel Susla 8da5924b57 add std::move when adding task to taskQueue (#46511)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46511

changelog: [internal]

task is not used after this line of code. Let's avoid copy shared_ptr's copy constructor.

Reviewed By: rubennorte

Differential Revision: D62751612

fbshipit-source-id: 92b0da44972b200870ef66f3a8482fbde55052ac
2024-09-16 09:16:56 -07:00
Saad Najmi 8ac80e39ea Revert "feat: build codegen on postinstall (#46227)" (#46420)
Summary:
This reverts commit 0cb97f0261.

Revert this commit that adds a `post install` script for a couple of reasons:

1. (EDIT: This turns out to be unrelated) The `postinstall` script causes `yarn install` to fail on React Native macOS, where we use Yarn 4. I'm not entirely sure why, but I probably won't debug it for the rest of the reasons.
2. `postinstall` scripts (at least inside Microsoft) are viewed as a security risk. Any package in your dependency tree can get compromised, add the phase, and run arbitrary code. This has happened in the past with React Native past if I recall correctly. As such, we disable `postinstall` scripts in many of our repos (including `rnx-kit` and `react-native-test-app`).
3. The issue this is trying to solve is to help newcomers avoid a stale cache when they switch branches in the React Native monorepo and only run `yarn install`. I think it would be sufficient to add some documentation somewhere that it is expected one runs `yarn && yarn build` to use this repo locally? That's a fairly common practice in monorepos, at least ones inside Microsoft.

## Changelog:

[INTERNAL] [SECURITY] - Remove post install script phase in the React Native monorepo

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

Test Plan: CI should pass

Reviewed By: christophpurrer, robhogan, cortinico, rshest

Differential Revision: D62755022

Pulled By: huntie

fbshipit-source-id: bf94ed33e3e451ea337ef7a6984f7ba964d0b212
2024-09-16 09:14:54 -07:00
Alex Hunt 8f1c227721 Add missing babel-jest dependency to react-native package (#46462)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46462

While adding D62583337, I noticed that `react-native` doesn't specify `babel-jest` as a dependency, despite referencing it in the included `jest-preset.js` — instead this would need to be installed by the template/project.

If we want to change this in future, we should consider a separate `react-native/jest-preset` package. However, I strongly believe this is the right location for this dependency: installing `react-native` = all parts of it work.

(Note that in the React Native monorepo, we are using `dependencies` for both dev and runtime deps in packages.)

Changelog: [Internal]

allow-executable-binary

## allow-executable-binary: Bypassed as this is a managed JavaScript dependency that is pre-existing in other parts of the codebase

Reviewed By: robhogan

Differential Revision: D62583665

fbshipit-source-id: 8bbcc8736e2740e45793d7b7e225ccfd1ca7f898
2024-09-16 08:25:12 -07:00
Alex Hunt 38a490574c Switch to Hermes parser in Jest preset (#46465)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46465

Resolves https://github.com/facebook/react-native/issues/46355.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: robhogan

Differential Revision: D62583337

fbshipit-source-id: 64813d84c2a6395be8ef4f138398834ddae6e54b
2024-09-16 08:25:12 -07:00
Riccardo Cipolleschi 74d9a4c38c Add changelog for 0.76.0-rc.0 (#46419)
Summary:
This PR adds the Changelg for 0.76.0-rc.0

## Changelog:
[Internal] - Add changelog for 0.76.0-rc.0

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

Test Plan: N/A

Reviewed By: christophpurrer

Differential Revision: D62443133

Pulled By: cipolleschi

fbshipit-source-id: 814d1de8b90de819c60e3962430132544539bdd7
2024-09-16 07:58:00 -07:00
Pascoal Júnior 14e0d0dffb Add support for new iOS text content type cellular EID and cellular IMEI (#46378)
Summary:
Support for new iOS text content type to autofill cellular EID or cellular IMEI:
- https://developer.apple.com/documentation/uikit/uitextcontenttypecellulareid?language=objc
- https://developer.apple.com/documentation/uikit/uitextcontenttypecellularimei?language=objc

## 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
-->
[IOS] [ADDED] - new text content type cellular EID and cellular IMEI

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

Test Plan:
JavaScript Tests - yarn test [PASSED]
- No errors related with the changes

Flow - yarn flow && yarn lint [PASSED]
- No errors related with the changes

iOS Tests - ./scripts/objc-test.sh test [PASSED]
- No errors related with the changes

Build RNTester [PASSED]
- No errors related with the changes
- Proof:
<img width="838" alt="Screenshot 2024-09-07 at 12 06 48" src="https://github.com/user-attachments/assets/836a71f2-8adb-428f-b98d-8b84f71e93d6">
<img width="806" alt="Screenshot 2024-09-07 at 12 07 29" src="https://github.com/user-attachments/assets/7b33b919-3b29-4846-b6a2-3427dbbc2869">
<img width="1221" alt="Screenshot 2024-09-07 at 12 13 02" src="https://github.com/user-attachments/assets/58b369e9-5281-4a6b-9663-1cbd77439510">

![Simulator Screenshot - iPhone 15 Pro - 2024-09-07 at 12 06 36](https://github.com/user-attachments/assets/9411c9d9-0b93-4f47-b21c-cbd95810f4c7)
Note: Since the test was done using an iOS simulator the autofill suggestion won't appear for the cellularEID or cellularIMEI

Reviewed By: cortinico

Differential Revision: D62386126

Pulled By: cipolleschi

fbshipit-source-id: 50da572650b796d0426a15f0c06fd0c52a8247f5
2024-09-16 07:27:01 -07:00
Samuel Susla 1ac3b890d8 add support for multiple calls to Linking.getInitialURL (#46502)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46502

changelog: [internal]

At the moment, Linking module has undocumented restriction that if you call it twice when Android Activity is not available, it will return with an error.

This is unnecessary and can be handled more sensibly.

Reviewed By: javache, yungsters

Differential Revision: D62708123

fbshipit-source-id: 79a6beb70e834e631f7bedaf6a64076b050a7daa
2024-09-16 06:45:53 -07:00
Samuel Susla b63ec30614 fix race condition in IntentModule.mInitialURLListener (#46499)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46499

changelog: [internal]

IntentModule.mInitialURLListener is accessed and mutated on three different threads and is missing synchronisation.

1. In [waitForActivityAndGetInitialURL](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java#L83) it is accessed and mutated from thread mqt_v_native.
2.  In [LifecycleEventListener](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java#L97) it is mutated from the main thread.

3. In [invalidate](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java#L44) it is read and mutated on a another thread.

Reviewed By: javache

Differential Revision: D62698183

fbshipit-source-id: b437928c4d5d9b9d20bcad601805b2f7f402b33c
2024-09-16 06:45:53 -07:00
Riccardo Cipolleschi 20b141508b Add TS types for Codegen (#46484)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46484

We recently realized that we don't have TS types for Codegen.
These are needed to let our users use these types when writing Specs in TS

## Changelog
[General][Added] - Add CodegenTypes for TS

Reviewed By: christophpurrer

Differential Revision: D62644516

fbshipit-source-id: 92bb7e8998d31806f6eb63319fb6d406fcd65ad8
2024-09-16 06:28:33 -07:00
Oskar Kwaśniewski 52718b530e feat: stub RCTStatusBarManager for non iOS Apple platforms (#45896)
Summary:
Following one of my previous PRs: https://github.com/facebook/react-native/pull/45176 I'm adding same conditionals to another module.

StatusBar API is supported on this platforms:

| Platform  | Support |
| ------------- | ------------- |
| macOS |    |
| tvOS |    |
| visionOS |    |
| iOS/iPadOS |    |

## 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] [ADDED] - Conditionals for iOS only code in RCTStatusBarManager.mm

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

Test Plan: CI Green / Make sure everything works as before

Reviewed By: cortinico

Differential Revision: D62579943

Pulled By: cipolleschi

fbshipit-source-id: 0c198c7732d253993638d825ca83be076bb09b90
2024-09-16 05:56:40 -07:00
Vitali Zaidman 8fba154b66 Fix source mapping for codegenNativeCommands (#46452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46452

`babel-plugin-codegen` transforms `codegenNativeComponent`s by expending it with a whole set of many commands (~40 lines) that don't have a good equivalent on the source file.

Currently these lines are pointing to random parts of the due to a bug that causes the source maps to be incorrect and confusing.

Instead, I point all these generated lines of code to the default export as the only line that can represent them.

This way, if an error is thrown from that generated code it would point to that export.

If the users are confused by how it works, there's a comment in the function that is used in the default export in these that explains it:
```
// If this function runs then that means the view configs were not
// generated at build time using `GenerateViewConfigJs.js`. Thus
// we need to `requireNativeComponent` to get the view configs from view managers.
// `requireNativeComponent` is not available in Bridgeless mode.
// e.g. This function runs at runtime if `codegenNativeComponent` was not called
// from a file suffixed with NativeComponent.js.
function codegenNativeComponent<Props>(
  componentName: string,
  options?: Options,
): NativeComponentType<Props> {
```

The transformation is from all the types and exports after the imports:
[`MyNativeViewNativeComponent` for example](https://github.com/facebook/react-native/blob/773a02ad5d3cc38e0f5837b42ba9a5e05a206bf9/packages/rn-tester/NativeComponentExample/js/MyNativeViewNativeComponent.js#L4)
Which is roughly (ignoring all typing):
```
// types and exports
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
  supportedCommands: [
    'callNativeMethodToChangeBackgroundColor',
    'callNativeMethodToAddOverlays',
    'callNativeMethodToRemoveOverlays',
    'fireLagacyStyleEvent',
  ],
});

export default (codegenNativeComponent<NativeProps>(
  'RNTMyNativeView',
): MyNativeViewType);

```
to roughly:
```
  var React = require('react');
  var nativeComponentName = 'RNTMyNativeView';
  var __INTERNAL_VIEW_CONFIG = {
    uiViewClassName: 'RNTMyNativeView',
    bubblingEventTypes: {
      topIntArrayChanged: { /* */ },
      topAlternativeLegacyName: { /* */ },
    },
    validAttributes: {
      opacity: true,
      values: true,
      ...require('ViewConfigIgnore').ConditionallyIgnoredEventHandlers({
        onIntArrayChanged: true,
        onLegacyStyleEvent: true
      })
    }
  };
  var _default = require('NativeComponentRegistry').get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
  var Commands = {
    callNativeMethodToChangeBackgroundColor(ref, color) {
      require('RendererProxy').dispatchCommand(ref, "callNativeMethodToChangeBackgroundColor", [color]);
    },
    callNativeMethodToAddOverlays(ref, overlayColors) {
     require('RendererProxy').dispatchCommand(ref, "callNativeMethodToAddOverlays", [overlayColors]);
    },
    callNativeMethodToRemoveOverlays(ref) {
      require('RendererProxy').dispatchCommand(ref, "callNativeMethodToRemoveOverlays", []);
    },
    fireLagacyStyleEvent(ref) {
     require('RendererProxy').dispatchCommand(ref, "fireLagacyStyleEvent", []);
    }
  };
  exports.default = _default;
  exports.__INTERNAL_VIEW_CONFIG = __INTERNAL_VIEW_CONFIG;
  exports.Commands = Commands;
```

Changelog: [Fix] Fixed source maps in Native Components JS files that use codegenNativeComponent

Reviewed By: robhogan, huntie

Differential Revision: D62443699

fbshipit-source-id: 522b4382736a8fed93a1bc687a78d6885fe7c9d5
2024-09-16 05:22:38 -07:00
Rodolfo Gomez Sirimarco b4532adad4 Fix Headless Crash Tried to finish non-existent task with id (#46497)
Summary:
Sometimes a headless task tries to finish, but it doesn’t exist, which causes an exception.
No one knows how to reliably reproduce it, as it could be a race condition. However, if you attempt to remove a task that has already been removed, it shouldn’t cause an issue since you're trying to remove something that’s already gone (which is exactly what you want).

Fixes:
 - https://github.com/facebook/react-native/issues/46496
 - https://github.com/facebook/react-native/issues/33883
 - https://github.com/facebook/react-native/issues/27597
 - https://github.com/transistorsoft/react-native-background-fetch/issues/202
 - https://github.com/transistorsoft/react-native-background-fetch/issues/369
 - https://github.com/transistorsoft/react-native-background-geolocation/issues/2096
 - https://github.com/jpush/jpush-react-native/issues/78

## Stacktrace:
```
Fatal Exception: java.lang.AssertionError: Tried to finish non-existent task with id 28.
  at com.facebook.infer.annotation.Assertions.assertCondition(Assertions.java:88)
  at com.facebook.react.jstasks.HeadlessJsTaskContext.finishTask(HeadlessJsTaskContext.java:179)
  at com.facebook.react.jstasks.HeadlessJsTaskContext$3.run(HeadlessJsTaskContext.java:217)
  at android.os.Handler.handleCallback(Handler.java:958)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loopOnce(Looper.java:257)
  at android.os.Looper.loop(Looper.java:368)
  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:233)
  at java.lang.Thread.run(Thread.java:1012)
```

## Screenshot

https://github.com/user-attachments/assets/101f0f53-95c9-40ec-a59d-22d6d474b457

## Changelog:

[ANDROID] [FIXED] - Fix Headless Crash `Tried to finish non-existent task with id`

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

Test Plan:
I created an example where I attempt to remove a task that doesn’t exist.

Example: https://github.com/RodolfoGS/react-native-fix-non-existent-task

### How to reproduce using the example above:
1. `git clone git@github.com:RodolfoGS/react-native-fix-non-existent-task.git`
2. `cd react-native-fix-non-existent-task`
3. `npm install`
4. `npm run android`
5. Notice the crash

### Steps to create the example from scratch and reproduce the crash:
1. `npx react-native-community/cli@latest init AwesomeProject`
2. `cd AwesomeProject`
3. Add call to finishTask to reproduce the crash (https://github.com/RodolfoGS/react-native-fix-non-existent-task/commit/6fe3c1388a58b9ffdcca5f9c6f00a4f2fea725ea)
4. `npm run android`
5. Notice the crash

Reviewed By: javache

Differential Revision: D62738059

Pulled By: rshest

fbshipit-source-id: 3232dc76ba8a069279c2b741d62372537a3f9140
2024-09-16 04:29:47 -07:00
David Vacca 6dbbbe33fd Delete pre-allocated views that were never mounted on the screen (#46473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46473

This diff extends the renderer of react native to ensure that pre-allocated views that were never mounted on the screen are deleted as soon as the shadow node is deleted from JS

This feature is controlled by the ReactNativeFeatureFlag: enableDeletionOfUnmountedViews

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D62559190

fbshipit-source-id: 1af6785fc57256d12750db64489c9ecc6cf98c9d
2024-09-16 04:16:36 -07:00
Sam Zhou 68a92aa312 Replace React.Ref with React.RefSetter in react-native (#46488)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46488

React.Ref includes string | number to support legacy string ref, which will be killed in React 19. Therefore, the type is deprecated in Flow. This diff changes the type to use React.RefSetter instead.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62649800

fbshipit-source-id: 81bcfbb052e2039b23829dac8de242bfb0fdca3a
2024-09-15 20:22:44 -07:00
Tim Yung 7bd4a54968 Animated: Restore AnimatedNode.prototype.toJSON (#46498)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46498

Looks like this is still necessary because we still run into this error when using the Components tab when using React DevTools:

> TypeError: cyclical structure in JSON object

This effectively reverts https://github.com/facebook/react-native/pull/46382.

Changelog:
[General][Changed] - AnimatedNode (and its subclasses) once again implement `toJSON()`.

Reviewed By: javache

Differential Revision: D62690380

fbshipit-source-id: d5b7c1d156b49838abefe48a7d7b61471cc3488a
2024-09-14 22:21:27 -07:00
Kevin Gozali 7d621f5eb7 Android: check SafeAreaView component existence before exporting (#46500)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46500

We're in the process of adding the required native component to all apps we maintain.
Until that is fully completed, fall back to using View if the native component
doesn't exist.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D62701331

fbshipit-source-id: d26c946af3a68231d0714e89d5e41be311399036
2024-09-14 20:20:34 -07:00
Tim Yung afb40e9f2a Animated: Alias onUpdateRef Type Argument (#46469)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46469

This causes VS Code to syntax highlight incorrectly, so let's use a type alias to workaround that limitation.

Changelog:
[Internal]

Reviewed By: tyao1

Differential Revision: D62595120

fbshipit-source-id: 97fc3caded51190a7840de91025eeb71c6290be8
2024-09-13 20:10:18 -07:00
Melissa Liu 6bcaa09749 evenly distribute adjustment between top and bottom
Summary:
Before we were dividing proportionally and were noticing some truncation at the bottom. It seems that the truncation was disproportionately because of the way the metrics are calculated. Through guess and check, dividing equally between top and bottom seems to yield better results... 🤡

Changelog: [internal]

Reviewed By: NickGerleman, xunrongl

Differential Revision: D62665295

fbshipit-source-id: b1589c75251d68eaf75e32598ee84fbac457ae4a
2024-09-13 17:50:10 -07:00
Jorge Cabiedes Acosta 17faac4170 Implement outline properties on Android (#46284)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46284

This diff adds:

`outline-width`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-width
`outline-color`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-color
`outline-style`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-style
`outline-offset`: https://developer.mozilla.org/en-US/docs/Web/CSS/outline-offset

Using `BackgroundStyleApplicator`

Changelog: [Android] [Added] - Outline properties `outline-width`, `outline-color`, `outline-style` & `outline-offset`

Reviewed By: NickGerleman

Differential Revision: D61293868

fbshipit-source-id: d8787bbf1560cf46b92ad039afde9c1e7ab669da
2024-09-13 17:26:37 -07:00
Rubén Norte 40aaeb7181 Improve FlatList estimates for items not yet laid out (#46487)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46487

Changelog: [General][Fixed] Fixed accuracy of FlatList estimations to determine what elements are visible in the rendering window.

This fixes a bug in FlatList where it thinks that some elements are visible in the rendering window, when they're not. Specifically, if a cell hasn't been laid out yet, it ignores all the information it already has on the ones that had, and estimates its position and offset based on the estimated size of the cells. In this case, if the first element has a larger offset because the list has a header, that offset is ignored in this case.

One observed result of this is that in a list where there's a header and a single cell that occupy the whole rendering window, FlatList thinks it needs to pre-render an additional element because the header is ignored.

Reviewed By: NickGerleman

Differential Revision: D62649060

fbshipit-source-id: 437bae79916707ca1d08784190508a9f7e36688e
2024-09-13 16:18:33 -07:00
David Vacca 70188fe222 Introduce ReactNativeFeatureFlag enableDeletionOfUnmountedViews (#46467)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46467

This diff introduces a new feature flag called ReactNativeFeatureFlag.enableDeletionOfUnmountedViews, which will ensure that pre-allocated views that were never mounted on the screen are deleted as soon as the shadow node is deleted from JS

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D62559188

fbshipit-source-id: 61f19a6dd38536de9f70fecc2937793681036f68
2024-09-13 13:46:12 -07:00
Jorge Cabiedes Acosta 6f84b63d64 Rename DropShadowPrimitive to DropShadowValue (#46476)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46476

Keep the type naming consistent with examples like `DimensionValue`, `ColorValue`, etc.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62614579

fbshipit-source-id: 824ea9af17487a4459e8f39d9374e2e00452db43
2024-09-13 12:35:57 -07:00
Jorge Cabiedes Acosta eaff327e0d Rename BoxShadowPrimitive to BoxShadowValue (#46485)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46485

Keep the type naming consistent with examples like `DimensionValue`, `ColorValue`, etc.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62614444

fbshipit-source-id: 3ff66d3f52623b6fb7bd8d31d2910aa255ae8a31
2024-09-13 12:35:57 -07:00
Nick Gerleman 2d6c59e1d4 Unhide new arch layout props (#46478)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46478

These are all supported in the new arch (default as of 0.76), across all platforms. but were previously hidden from types, and undocumented.

I will make a pick request for this change, and we should then add these to documentation.

Changelog:
[General][Added] - Unhide new arch layout props

Reviewed By: cortinico

Differential Revision: D62616897

fbshipit-source-id: f6c2e71785284e667824a76918ccf2724adc4e98
2024-09-13 12:04:52 -07:00
Nicola Corti f3a969f38d Do not print Bridgeless Mode is enabled on console anymore. (#46486)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46486

We probably don't need this extra log anymore as this information is already avaialbe from the start application log.

Changelog:
[General] [Changed] - Do not print Bridgeless Mode is enabled on console anymore

Reviewed By: fkgozali

Differential Revision: D62639866

fbshipit-source-id: 720bb1446a1e1be71bf27830fe4156ae64a1586f
2024-09-13 11:50:32 -07:00
Nicola Corti 4d814f20af Back out "Remove some Tasks overhead" (#46483)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46483

Original commit changeset: 631d741bd2ec

This is breaking the RedBox on React Native 0.76 on Android when not connected to Metro.

Original Phabricator Diff: D62213722

Changelog:
[Internal] [Changed] - Back out "[react-native] Remove some Tasks overhead"

Reviewed By: cipolleschi

Differential Revision: D62644614

fbshipit-source-id: a092614da78bef65546c2539a3ebc9bff5e807b2
2024-09-13 11:35:24 -07:00
Nicola Corti d7884a6bb8 RNGP - Sanitize the output of the config command (#46482)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46482

Fixes https://github.com/facebook/react-native/issues/46443
Fixes https://github.com/facebook/react-native/issues/46134

I'm sanitizing the output of the `config` command + I've added some more logging in case of failure.

Changelog:
[Android] [Fixed] - RNGP - Sanitize the output of the config command

Reviewed By: cipolleschi

Differential Revision: D62641979

fbshipit-source-id: c13d27a42beeb7a973c1802e7204631d49d3d09b
2024-09-13 10:42:20 -07:00
Oskar Kwaśniewski 3cbaddbc16 fix(iOS): fallback to old path when dynamic resolve fails (#46432)
Summary:
This PR is a follow-up after https://github.com/facebook/react-native/issues/46181 this change makes sure that if the `require.resolve` fails we still fall back to the old behavior.

The `require.resolve` was failing for local builds of OOT platforms (because in OOT platforms mono repo `react-native` is renamed to `react-native-platform-name`)

## Changelog:

[IOS] [FIXED] - Fallback to old resolve mechanism when node require fails to resolve react native path

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

Test Plan: CI Green

Reviewed By: christophpurrer

Differential Revision: D62577183

Pulled By: cipolleschi

fbshipit-source-id: d62d9c2a5eee3546a81d2aad52b7f73763315b18
2024-09-13 09:44:19 -07:00
Riccardo Cipolleschi 11a2ab1cc5 Fix some basic warning while building (#46463)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46463

We had some basic warnings emitted by React Native components due to unused parameters or missing documentations.

This change fixes some of those

## Changelog:
[Internal] - Fix some build warnings

Reviewed By: NickGerleman

Differential Revision: D62583790

fbshipit-source-id: 329acc67ce64c00757a8568460ee68b85a62b6e9
2024-09-13 08:19:55 -07:00
Riccardo Cipolleschi 62d4768984 Inhibit warning in 3p libraries (#46464)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46464

React Native uses some 3P libraries that are emitting some warnings for which we can't do anything about.

This change suppress those warnings.

## Changelog:
[Internal] - Suppress 3p warnings

Reviewed By: cortinico

Differential Revision: D62582960

fbshipit-source-id: 79e8c28725177f5f47359da86f865e770dcf7c7b
2024-09-13 08:19:55 -07:00
Riccardo Cipolleschi f529fe4876 Exclude dSYM from the archive (#46472)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46472

Currently, we are building the Debug symbols (dSYM) for hermes dSYM but we are not shipping them with the xcframework.
This is correct, because Debug symbols can increase the size of Hermes thus enalrging the iOS IPA and increasing the download time when installing pods.

We distribute the dSYM separatedly, in case users needs to symbolicate Hermes stack traces.

However the path to the dSYM still appears in the Info.plist of the universal XCFramework and this can cause issues when submitting an app to apple.

This change should remove those lines from the universal framework.

It fixes https://github.com/facebook/react-native/issues/35863

## Changelog
[Internal] - Remove dSYM path from Info.plist

Reviewed By: cortinico

Differential Revision: D62603425

fbshipit-source-id: 038ec3d6b056a3d6f5585c8125d0430f56f11bb9
2024-09-13 08:16:19 -07:00
Riccardo Cipolleschi de39a204c3 Fix SVC Validator for Box Shadow and filter (#46454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46454

The SVC Validator have no idea on how to process a simple NSArray *.

With this change, we are creating two named types for the NSArray:
* BoxShadowArray
* FilterArray
To create unique types that we can reference in JS.

We are then enhancing the `getProcessor` function to return the proper processor when those types are found in the NativeViewConfig

## Changelog:
[iOS][Fixed] - Fixed warnings when validating SVC

## Facebook:
This change is OTA safe: even when we ship the JS before the native code, the new cases in the switch will be never hit, similarly to the situation we have right now.

As soon as the native code is shipped, the new cases will start get hit and the wrning will disappear

Reviewed By: NickGerleman

Differential Revision: D62574612

fbshipit-source-id: d173bf5534ee5e436f23a4bc6e2fb25e72a4b06d
2024-09-13 08:10:10 -07:00
Riccardo Cipolleschi fad4a0783b Fix Basic SVC for RNTester iOS (#46439)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46439

The SVC for some components on iOS got out of sync.
This was creating warnings in the React Native DevTools and it was affecting the release of 0.76.

With this change, I updated the manually written SVC so that we don't have warnings anymore.

We still have to fix the `boxShadow` and `filter`. This will happen in a later change.

## Changelog
[iOS][Fixed] - Solved SVC warnings for RNTester

Reviewed By: NickGerleman

Differential Revision: D62501704

fbshipit-source-id: 3c02f7615c3511a97eba73a2ddaa713d2e4e30f0
2024-09-13 08:10:10 -07:00
Robert Pasiński f3fee67c54 fix: AppRegistry not callable from Native in bridgeless (#46480)
Summary:
AppRegistry was not treated as a Callable Module in bridgeless mode. This is breaking headless tasks on Android.

Fixes:

 - https://github.com/facebook/react-native/issues/46050

## Changelog:

[ANDROID] [FIXED] - Made AppRegistry callable from Native code in Bridgeless (fixes headless tasks)

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

Test Plan: Used repro from linked issue

Reviewed By: javache

Differential Revision: D62637486

Pulled By: cortinico

fbshipit-source-id: 756527003ac6d712e76c02c188e280d15c010068
2024-09-13 07:58:19 -07:00
shubhamguptadream11 b98b9f1fa7 fix(iOS): fire onMomentumScrollEnd when UIScrollView is removed from window (#46277)
Summary:
Solves this issue: https://github.com/facebook/react-native/issues/46276

## Changelog:

<!-- 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
-->

[IOS] [ADDED] - fire onMomentumScrollEnd when UIScrollView is removed from window

**Why the issue is happening?**
The `onMomentumScrollEnd` event is typically triggered by the `UIScrollView` delegate methods `scrollViewDidEndDecelerating` and `scrollViewDidEndScrollingAnimation`. However, if the scroll view is removed from the window while navigating away, these delegate methods are not called, resulting in the event not being dispatched.

This behaviour was particularly problematic in scenarios where a scroll view is in motion, and the user navigates away from the screen before the scrolling completes. In such cases, the `onMomentumScrollEnd` event would never fire, which further make scroll area un touchable or un responsive.

**What we changed?**
In the didMoveToWindow method, we added logic to handle the scenario where the UIScrollView is being removed from the window (i.e., when the component is unmounted or the user navigates away). Here’s a breakdown of the changes:

- **Added a Check for Scroll State:** We check if the UIScrollView was decelerating or had stopped tracking (_scrollView.isDecelerating || _scrollView.isTracking == NO).

- **Manually Triggered onMomentumScrollEnd:** If the scroll view was in motion and is being removed from the window, we manually trigger the `onMomentumScrollEnd` event to ensure that the final scroll state is captured.

**_I had fixed this issue on both Old and New arch._**

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

Test Plan:
Attaching a video with working solution:

https://github.com/user-attachments/assets/1a1f3765-3f11-46c3-af18-330c88478db8

Reviewed By: andrewdacenko

Differential Revision: D62374798

Pulled By: cipolleschi

fbshipit-source-id: 014be8d313bab0257459dc4e53f5b0386a39d5e0
2024-09-13 06:33:30 -07:00
Philip Su f8287e25e1 feat(scripts): Support multiple bundles in react-native-xcode.sh (#46339)
Summary:
This enables projects to have multiple bundles built during the Xcode bundling phase (e.g. for projects where you might have a PhoneScene and a CarPlayScene each with their own RootView and bundle, if you're using [react-native-carplay](https://github.com/birkir/react-native-carplay)).

## Changelog:
[IOS] [ADDED] - User-configurable BUNDLE_NAME when building bundles

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

Test Plan:
Built my project with the following Xcode "Bundle React Native code" build step:
```sh
set -e

export SOURCEMAP_FILE="$(pwd)/../main.jsbundle.map";
SOURCEMAP_FILE="$(pwd)/../main.jsbundle.map"

WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
REACT_NATIVE_XCODE="../node_modules/react-native/scripts/react-native-xcode.sh"

/bin/sh -c "BUNDLE_NAME=main $WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
/bin/sh -c "BUNDLE_NAME=carplay $WITH_ENVIRONMENT $REACT_NATIVE_XCODE"
```

Then launched the app with a modified `AppDelegate.swift` which loaded main.jsbundle into one RootView and carplay.bundle into another RootView.

Reviewed By: cortinico

Differential Revision: D62577314

Pulled By: cipolleschi

fbshipit-source-id: 22312ca144146da6c71a8533a1883e720aff1e85
2024-09-13 05:09:51 -07:00
Nicola Corti 2136c19944 Bump SoLoader to 0.12.1 and remove unnecessary extra manifest metadata. (#46461)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46461

This bumps SoLoader to 0.12.1 inside React Native and cleans up the extra
`com.facebook.soloader.enabled` metadata which are not necessary anymore.

Changelog:
[Internal] [Changed] - Bump SoLoader to 0.12.1 and remove unnecessary extra manifest metadata

Reviewed By: cipolleschi

Differential Revision: D62581188

fbshipit-source-id: ff990c0af1f0f51070037fcb4c7c13fbe6bae234
2024-09-13 03:51:58 -07:00
Phillip Pan a777a8937e delete partialBatchDidFlush (#46471)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46471

Changelog: [iOS][Breaking] Delete partialBatchDidFlush

this is an extremely old method on RCTBridgeModule similar to batchDidComplete that was special cased for UIManager. however, UIManager ended up deleting its implementation of partialBatchDidFlush. we had this janky logic that would iterate through all of the modules to call this partialBatchDidFlush when we really just wanted to do this for the UIManager. this logic is risky because the _moduleDataByID array is not thread safe.

i feel we can skip the deprecation cycle for this method, because i searched through GH and i did not find any callsites of this: https://github.com/search?q=partialBatchDidFlush&type=code&p=1.

Reviewed By: realsoelynn

Differential Revision: D62600722

fbshipit-source-id: d889bad54170a267e938b588e2fd6f558583a904
2024-09-12 22:57:11 -07:00
Phillip Pan 731bd95c43 do not iterate through moduleData array to handle UIManager batch completion (#46470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46470

Changelog: [iOS][Deprecated] - Deprecating RCTBridgeModule batchDidComplete and adding configuration to disable it

batchDidComplete is used for the UIManager to initiate a layout and mount after a callback has been initiated by the bridge. however, we iterate through the whole module array in order to get this single UIManager, which is unnecessary. this also increases risk of a crash because the module array is shared between threads.

Reviewed By: realsoelynn

Differential Revision: D62600034

fbshipit-source-id: 6c98df7d5ab282015181fb07764121693bcc141e
2024-09-12 22:57:11 -07:00
Tim Yung 1c7fd8baa8 Animated: Switch to useInsertionEffect (#46474)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46474

Changes `useAnimatedPropsLifecycle_passiveEffects` (the experimental lifecycle management in `useAnimatedProps`) to `useInsertionEffect` instead of `useEffect`. This has a few benefits:

1. Prevents any Activity detach and attach events from triggering Animated lifecycle work (which adds to effect mounting and unmounting time).
2. Fixes batching of native Animated operations across components. (Since we flush the operation queue in a passive effect, enqueueing operations in a passive effect causes weird interleaving of enqueuing and flushing.)
3. Enables animations to be started in layout effects.

Changelog:
[Internal]

Reviewed By: bvanderhoof

Differential Revision: D62602336

fbshipit-source-id: 3f6412387d87d4ea4135a29893135b4a64638809
2024-09-12 22:05:02 -07:00
Melissa Liu 5e288d0cd4 fix for bottom adjustment (#46475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46475

fm.top is negative, so we want to add in order to decrease the absolute value, but fm.bottom is positive, so we need to subtract instead here

Changelog: [internal]

Reviewed By: NickGerleman

Differential Revision: D62612192

fbshipit-source-id: fc942abcb5a1ddedd6547aca66a188736e4ec029
2024-09-12 19:17:23 -07:00
Eric Rozell bb3ec4d6c3 Add protected constructor to decouple ReactFragment lifecycle events from ReactHost (#46425)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46425

It's entirely plausible that one would want to run a ReactFragment that does not tear down the ReactHost when it is destroyed. This adds a protected constructor that can be used to disable host lifecycle events in a ReactFragment. When disabled, the `onDestroy` method of the ReactFragment simply stops the surface attached to it using `ReactDelegate.unloadApp`.

## Changelog

[Android][Added] Flag in ReactFragment to allow unmounting a surface without destroying ReactHost.

Reviewed By: philIip

Differential Revision: D62449779

fbshipit-source-id: a443ed004ced45e0adc95bd43b36d1b80f9f392f
2024-09-12 18:13:51 -07:00
Phillip Pan cf8d09b279 remove RCTRuntimeExecutor (#46466)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46466

We should use [BindingsInstaller](https://github.com/facebook/react-native/pull/44486?fbclid=IwZXh0bgNhZW0CMTEAAR0noV5FT4pi2z0saQhFy4q2bVLiu0bLUn0Aq0QPAWnycksVBuizmUYXdnc_aem_bS3_Q_CgUIljILgDtrHUhA) and [RCTCallInvoker](https://github.com/facebook/react-native/pull/44378?fbclid=IwZXh0bgNhZW0CMTEAAR3rjd8_Ak2CsQfs3k4o6k0F9uivwx-22llwl6TiCFl5c0FmcoW8PKaxNgs_aem_R3cJp9eKQsMte_03lfuBdQ) instead.

## Changelog:
[iOS][Breaking] - We deprecated RCTRuntimeExecutor in 0.76, so let's get rid of the code now.

Reviewed By: cipolleschi

Differential Revision: D62469005

fbshipit-source-id: 3ed033b08f52823bd42f8a57d5d6ab40e35d30f1
2024-09-12 14:57:58 -07:00
Eric Rozell 38593c440e Add unloadApp method to ReactDelegate (#46424)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46424

It's not isomorphic for `ReactDelegate` to have a `loadApp` method to initialize a surface, but only allow unloading of a surface by calling `onHostDestroy`, which also destroys the ReactHost. This change adds an `unloadApp` method to `ReactDelegate` so it can be used in, e.g., `ReactFragment` to stop a surface without tearing down the host.

## Changelog

[Android][Added] ReactDelegate `unloadApp` methods for unmounting surfaces without destroying ReactHost

Reviewed By: mdvacca

Differential Revision: D62448543

fbshipit-source-id: e99b880f48e857935ee856c37b881bcc8bd22ad0
2024-09-12 14:34:46 -07:00
Eric Rozell cbddcfc691 ReactRootView is Nullable in ReactDelegate (#46440)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46440

ReactDelegate does not properly annotate the ReactRootView field as Nullable. This fixes that.

## Changelog

[Android][Fixed] Use appropriate Nullable attribute for ReactRootView field in ReactDelegate

Reviewed By: philIip

Differential Revision: D62514424

fbshipit-source-id: e9f10899007dfe794aa081717f5a5aa7d0038181
2024-09-12 14:34:46 -07:00
Joe Vilches 93b608d130 Make it so that aspect ratio behaves like auto if it is 0 or inf (#46428)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46428

X-link: https://github.com/facebook/yoga/pull/1696

We do not validate the aspect ratio to ensure it is non zero and non inf in a lot of places. Per the spec, these values should act like auto. There is no auto keyword, but it is the default so I just set the style to a default FloatOptional in this case

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D62473161

fbshipit-source-id: 6857de819538a7a87ce0a652e99f5a49992921ae
2024-09-12 14:28:33 -07:00
Nicola Corti d7c1e5b989 Unblock RNTester instacrashing due to SoLoader not being enabled (#46459)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46459

After the SoLoader 0.12.0 bump I've noticed RNTester is instacrashing due to us not having enabled it
explicitely in the Manifest:

Changelog:
[Internal] [Changed] - Unblock RNTester instacrashing due to SoLoader not being enabled

Reviewed By: cipolleschi

Differential Revision: D62580751

fbshipit-source-id: 3b291e7f82daf1a6bd61bc9588c2d49a389801ef
2024-09-12 14:16:33 -07:00