Commit Graph

33947 Commits

Author SHA1 Message Date
Rubén Norte
9f604dbd43 Watch changes in C++ files (#47871)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47871

Changelog: [internal]

No need to keep going back to save test files when we change C++ files and need to re-run tests :)

Reviewed By: javache

Differential Revision: D66293212

fbshipit-source-id: dc232e1d3f7f8ae1578e894ce14bd21ccf3c8ade
2024-11-21 03:58:36 -08:00
Rubén Norte
92a476661c Add flag to force running tests in optimized mode (#47870)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47870

Changelog: [internal]

This flag allows us to run optimized mode by using the right buck modes for the Fantom CLI, using minified + dev in Metro and building bytecode using Buck as well.

It's disabled by default but in the future we can enable it based on the configuration in the test file (e.g.: if it's a benchmark) or we can run tests in both modes by default to catch problems caused by the differences between environments.

Reviewed By: rshest

Differential Revision: D66292709

fbshipit-source-id: d25294b739ff6a67507990241784b838d5b30dcd
2024-11-21 03:58:36 -08:00
Abdelhafidh Belalia
550b0c0ed1 TextLayout: take full width if text wrapped (#47435)
Summary:
### Problem
The calculated width for a multiline text is based on the longest line. However it does not account for text that wraps.

**Example** if numberOfLines=1 and the text wraps

```
+---------------------------+
This is a long text that
will wrap
+---------------------------+
```

The TextView will render
```
+---------------------------+
This is a long text t...
+---------------------------+
```

because the `calculatedWidth` took the width of the first line.

Also see https://github.com/facebook/react-native/pull/41770#issuecomment-2453611554 for additional context.

### Solution

If the text wraps, take the whole width.

```
+---------------------------+
This is a long text that w...
+---------------------------+
```

Fixes https://github.com/facebook/react-native/issues/39722
Fixes https://github.com/facebook/yoga/issues/1730

## Changelog:

[GENERAL] [FIXED] - Fix text not taking full width

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

Test Plan:
```tsx
        <Text
          numberOfLines={1}
          style={{
            backgroundColor: 'red',
            alignSelf: 'flex-start',
            color: 'white',
            fontSize: 34,
          }}>
          {'This is a long text that will wrap.'}
        </Text>
        <Text
          numberOfLines={3}
          style={{
            backgroundColor: 'red',
            alignSelf: 'flex-start',
            color: 'white',
            fontSize: 34,
          }}>
          {
            '1\n\ntest\nThis is a long text that will wrap.This is a long text that will wrap.This is a long text that will wrap.\n'
          }
        </Text>
        <Text
          numberOfLines={3}
          style={{
            backgroundColor: 'red',
            alignSelf: 'flex-start',
            color: 'white',
            fontSize: 34,
          }}>
          {
            '1\n\nThis is a long text that will wrap.This is a long text that will wrap.This is a long text that will wrap.\n'
          }
        </Text>
```
1. Verify that the first and third text take full width
2. Verify that the second text does not take full width

| Before | After |
|:------:|:-----:|
|   <img width="480" alt="Screenshot 2024-11-05 at 9 00 24 PM" src="https://github.com/user-attachments/assets/b8d765c0-f4b1-42c6-afc7-75862c52612a">     |    <img width="480" alt="Screenshot 2024-11-05 at 9 01 49 PM" src="https://github.com/user-attachments/assets/f1534c14-a56a-4d44-8edc-4d9f75166cb2">   |

Reviewed By: NickGerleman

Differential Revision: D65521732

Pulled By: realsoelynn

fbshipit-source-id: 0bb0bb306445e73e8b24ff4c02921739d15ee07e
2024-11-21 03:16:30 -08:00
Dmitry Rykun
105ad855d9 Fix ViewConfig validation error after merging defaultSrc into defaultSource for RCTImageView (#47754)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47754

The `./resolveAssetSource` processor was added to the `defaultSource` prop in the `RCTImageView` static view config in D65819218.
To match this in native view config, we're adding the `customType = "ImageSource"` hint to the view config infra, so it knows to assign correct processor to the native view config in runtime.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D66228921

fbshipit-source-id: d0e0cd9e2f5cc0ba5b3a7002f7ade3f45305a2ac
2024-11-21 03:12:21 -08:00
Riccardo Cipolleschi
880dea858e Bump Podfile.lock for Folly (#47868)
Summary:
RNTester jobs are failing because we bumped folly to the recent version but we didn't update the podfile.lock

## Changelog:
[Internal] - Bump Podfile.lock to new Folly version

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

Test Plan: GHA

Reviewed By: robhogan

Differential Revision: D66292931

Pulled By: cipolleschi

fbshipit-source-id: 19cbe1321d2891135aa9777823e9dff2916b16dc
2024-11-21 02:33:29 -08:00
Riccardo Cipolleschi
0eb9472c69 Allow downgrading CMake to build hermesc on Windows (#47867)
Summary:
CI is failing to build HermesC on windows due to a version mismatch of the CMake already installed

## Changelog:
[Internal] - Fix Windows CI for HermesC

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

Test Plan: GHA

Reviewed By: robhogan

Differential Revision: D66292617

Pulled By: cipolleschi

fbshipit-source-id: 5e8f4f45e33fbdd9ff163b4e8a09cb98d4366dc7
2024-11-21 02:20:30 -08:00
David Vacca
ac0dbe1ea2 Migrate ReactClippingProhibitedView to Kotlin (#47752)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47752

Migrate ReactClippingProhibitedView to Kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D66217071

fbshipit-source-id: e7559db5c3f2795b78f51c3bd5a3f521eb54b70d
2024-11-20 23:08:03 -08:00
David Vacca
a2523a24c7 Migrate ReactCompoundView to kotlin (#47748)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47748

Migrate ReactCompoundView to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D66217094

fbshipit-source-id: 238c20c907880f4251c9b5926ad486cfff55a3b0
2024-11-20 23:08:03 -08:00
Jakub Piasecki
aa53bde21b Fix the nodes' owners not being updated when display: contents is used (#47733)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47733

In https://github.com/facebook/yoga/pull/1729 I moved the cleanup of `display: contents` nodes to happen before all the early returns, but that change also made it be called **before** `cloneChildrenIfNeeded`. It actually needs to be called after `cloneChildrenIfNeeded` to make sure that children of `display: contents` nodes are properly owned.

It also needs to be called in every short-path, so it's being called in four places in this PR. Please let me know whether it's ok or not.

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

Reviewed By: NickGerleman

Differential Revision: D65953902

Pulled By: zeyap

fbshipit-source-id: 0b18a5651f19c23564f5b3aa2a50833426e9ca5f
2024-11-20 20:01:50 -08:00
phuccvx12
73a2be1243 Fix: Correct Layout Behavior for Combined align-content and align-items (#47732)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47732

This pull request addresses the issue where combining align-content and align-items properties resulted in incorrect layout behavior in Yoga version 3.1.0, as reported in [Issue https://github.com/facebook/yoga/issues/1739](https://github.com/facebook/yoga/issues/1739).

# Changes Made:

Alignment Logic Update: Modified the alignment calculations to ensure that the combination of align-content and align-items properties produces the expected layout, consistent with CSS Flexbox standards and previous Yoga versions.

Test Cases Added: Introduced new test cases to cover scenarios involving various combinations of align-content and align-items properties to prevent future regressions.

# Testing:

All existing tests pass successfully.

New test cases confirm that the layout behaves as expected when align-content and align-items are used together.

# Impact:

This fix ensures that layouts using both align-content and align-items properties render correctly, aligning with the behavior observed in Yoga version 1.19.0 and standard web browsers.

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

Reviewed By: joevilches

Differential Revision: D65953882

Pulled By: zeyap

fbshipit-source-id: 7e12a21b1d442b35c3f3536cad32dc4b82130d15
2024-11-20 19:59:42 -08:00
David Vacca
17502dd743 Migrate ReactCompoundViewGroup to kotlin (#47751)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47751

Migrate ReactCompoundViewGroup to kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D66217251

fbshipit-source-id: b24b4ed984670e18256dda758bfa1d783badd536
2024-11-20 18:51:34 -08:00
Nishan
221d1eceda fix: start and end points linear gradient algorithm (#47003)
Summary:
- Current implementation does not follow CSS spec for rectangle boxes with corner angles. It is using non spec compliant algorithm to calculate start and end points. This PR follows the spec compliant algorithm to implement and makes sure Web, iOS and Android gradients are identical with corner angles.
- Also, currently it is using `CAGradientLayer` which does not support spec compliant start and end points i.e. start and end point can be outside of rectangle bounds. This leads to inconsistent gradients on iOS for corner angles compared to web and android. So this PR replaces it with `CGGradient`.
- I have also moved some files to make it easier to add more background image types in future.

## Changelog:

[GENERAL] [FIXED] - Linear gradient start and end point algorithm.

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

Test Plan:
- Added multiple gradient example which should be identical in all platforms (Web, iOS and Android) and tested thoroughly on all platforms. I think some visual test cases can help here.
- I have referred to [blink's](https://github.com/chromium/chromium/blob/main/third_party/blink/renderer/core/css/css_gradient_value.cc) implementation.

## Aside

Took a while to understand the [spec](https://www.w3.org/TR/css-images-3/#corner-gradient-example), but felt great after getting it. Gradients should be 100% identical on all platforms now. Sorry i missed testing cornered angles + rectangles earlier and I found out it is inconsistent on platforms just this weekend  😅

<img width="1389" alt="Screenshot 2024-10-14 at 12 24 45 AM" src="https://github.com/user-attachments/assets/2f61eb87-502b-4b8c-88f3-d8a3cca9a7a3">

Reviewed By: joevilches

Differential Revision: D64497127

Pulled By: jorge-cab

fbshipit-source-id: 2647176ae2ee74b6c71f9061465b07dccdabcfc1
2024-11-20 17:17:52 -08:00
Joe Vilches
6d8fd49832 Remove trivial private api calls in YogaLayoutableShadowNode.cpp (#47735)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47735

We are trying to remove or minimize private header usage in YogaLayoutableShadowNode.cpp and YogaLayoutableShadowNode.h. There are a few "trivial" ones, meaning some private call maps 1:1 to an existing public API, so I just opt to use that instead

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66131948

fbshipit-source-id: 7068021513703d1c142d3c298f4804e4e8b81ee2
2024-11-20 17:06:01 -08:00
Tom Van Laerhoven
13780126d3 Fix generated EventEmitter code for nested objects in arrays. (#47514)
Summary:
This PR fixes the code for generating EventEmitter C++ code in case nested objects in arrays are used.

```typescript
export interface NativeProps extends ViewProps {
  onEvent: DirectEventHandler<
    Readonly<{
      payloadArray: Readonly<
        {
          obj: Readonly<{ str: string }>
        }[]
      >
    }>
  >;
}

export default codegenNativeComponent<NativeProps>('SomeComponent');
```

In this case the generated `EventEmitters.cpp` code would contain:

```c
obj.setProperty(runtime, "str", payloadArrayValue,obj.str);
```

while

```c
obj.setProperty(runtime, "str", payloadArrayValue.obj.str);
```

is expected.

## 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] [FIXED] - Codegen: Support nested objects in arrays

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

Test Plan: Tested with the reproduction case above to verify correct output.

Reviewed By: javache

Differential Revision: D65848670

Pulled By: elicwhite

fbshipit-source-id: 0021e87bc7213fff615465cab8554cc1a2159522
2024-11-20 16:25:34 -08:00
Andrei Marchenko
aafe696453 turn on by default optimization for memoization of virtualized list cells (#47724)
Summary:
Changelog: [General] [Changed] - Fix unnececary rerenders of VirtualizedListCells with strictMode={true}

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

Reviewed By: sammy-SC

Differential Revision: D66123469

fbshipit-source-id: 295e10add51bc1c319b8b8e3a9f4874c5e5a386d
2024-11-20 16:00:03 -08:00
Nick Gerleman
6e06a810f0 Fix possible NSRangeException when updating typing attributes in response to new text content (#47737)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47737

We may see an NSRangeException when setting new AttributedString content, where setting the AttributedString itself changes selection (before we mutate it later).

It seems like the selection here is not in a good state yet in regards to the AttributedString backing exposed (since we are reading it while modifying it). So let's fold the logic for updating typing attributes into the collection of ignored work from non-user-selection updates, since programatically setting an AttributedString will already trigger updating typing attributes.

I also added a nil check here, which is unrelated to the crash, but it seems like we should have it for safety...

Changelog:
[iOS][Fixed] - Fix possible NSRangeException when updating typing attributes in response to new text content

Reviewed By: cipolleschi

Differential Revision: D66202986

fbshipit-source-id: fded492b5022c5fef5b9563f93a57549d06a7020
2024-11-20 14:05:33 -08:00
Alan Lee
48ea6867a9 update targetSdk to 35 (#47738)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47738

- updating targetSdk to 35 for RN Android and helloworld
- **Note:** `tagetSdk` of RN Android does not have effect on the app's targetSdk. App can set `targetSdk` regardless of what RN targetSdk is. Updating the targetSdk just signals that RN Android has been tested with targetSdk 35 and apps can choose to support lower targetSdk as needed.

Changelog:
[Android][Changed] updating targetSdk to 35 (apps can still choose their own targetSdk regardless of RN version)

Reviewed By: NickGerleman

Differential Revision: D66209381

fbshipit-source-id: 2f26e8f605a383ff662e4b1d65611f186a7d7979
2024-11-20 11:06:31 -08:00
Alan Lee
7733c335eb Align HermesBadge to bottom to avoid overlap with status bar (#47734)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47734

- With forced edge-to-edge on Android 15 targetSdk 35, `HermesBadge` overlaps with the top status bar.
- Move the location of the HermesBadge to align with bottom of the header so we can avoid UI overlap with minimal changes to the template.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D66183918

fbshipit-source-id: 6e9eff337660a133349a2813e9ee033a8d2b749e
2024-11-20 11:06:31 -08:00
Alan Lee
de82b15b0d Remove NewAppScreen from public API test (#47707)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47707

NewAppScreen should be removed from public API test

Changelog: [Internal]

Reviewed By: cipolleschi, blakef

Differential Revision: D66165484

fbshipit-source-id: 2b72a874e443447a2b444921f25cec729bcb89c5
2024-11-20 11:06:31 -08:00
Riccardo Cipolleschi
102062fbc7 Extract RCTAppDependencyProvider in a separate pod (#47761)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47761

When breaking the last dependency, we created the `RCTApDependencyProvider` in the Codegen pod.

This is not an issue per sè. The problem comes in with the new template in Swift: ReactCodegen contains some headers with some C++ code that Swift can't really process.

That's why most libraries started failing in jobs like [this one](https://github.com/facebook/react-native/actions/runs/11906196751/job/33177904733): the template app was not able to load the `ReactCodegen` pod in the Swift app delegate.

Given that the app delegate only have to actually load the RCTAppDependencyProvider, I extracted that class in its own pod: ReactAppDependencyProvider.

The name of the pod does not follow the React-RCTXXX structure because that will create issues with the import statements and the `use_frameworks!`  use case.

> [!NOTE]
> We need to update the template and change the `import ReactCodegen` to `import ReactAppDependencyProvider`

## Changelog:
[iOS][Added] - Extract RCTAppDependencyProvider in the ReactAppDependencyProvider pod

Reviewed By: blakef

Differential Revision: D66241941

fbshipit-source-id: 6b888109c65d9560fff322ec84a16da78fbcd64b
2024-11-20 10:51:56 -08:00
Rubén Norte
105beed569 Fix bugs in MutationObserver (#47760)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47760

Changelog: [internal]

(this is internal because this API isn't enabled in OSS yet)

This fixes 2 bugs in `MutationObserver`:
1. Incorrectly reporting updates for the same node multiple times, if changes are observable by different targets in the same observer.
2. Incorrectly ignoring observations of subsequent targets in a given observer.

These were caught when migrating the unit tests for `MutationObserver` that were mocking Fabric to a Fantom integration test that uses the whole C++ infra.

Reviewed By: sammy-SC

Differential Revision: D66232571

fbshipit-source-id: b6e967ca4deaa1a69d35f14d4f921103fec2bbaf
2024-11-20 10:00:48 -08:00
Rubén Norte
43554b5a0f Expose NodeList and MutationRecord in global scope (#47759)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47759

Changelog: [internal]

These interfaces should be available in the global scope, so this exposes them in their setup modules.

Reviewed By: javache

Differential Revision: D66232574

fbshipit-source-id: 191c579ffce3fb8b4b454b5c5725661ff160a46f
2024-11-20 10:00:48 -08:00
Rubén Norte
b2f624d054 Add flag to print Fantom logs in Jest output (#47758)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47758

Changelog: [internal]

This helps with debugging when adding logs in native code. By default they're logged to stderr and not shown in the Jest output, but we can opt into getting them with this new flag.

Reviewed By: sammy-SC

Differential Revision: D66232572

fbshipit-source-id: d507fa4438ae46988fafc92123d0954ab3d27631
2024-11-20 10:00:48 -08:00
zhongwuzw
e573929d6c Fabric: Adjusts the weight according to the font name (#47742)
Summary:
Fixes another font weight issue mentioned in https://github.com/facebook/react-native/issues/47656#issuecomment-2486282496. We can get the weight from font name if user not specify weight.

esbenvb Is this work for you ?

## Changelog:

[IOS] [FIXED] - Fabric: Adjusts the weight according to the font name

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

Test Plan: Demo in https://github.com/facebook/react-native/issues/47656#issuecomment-2486282496.

Reviewed By: cipolleschi

Differential Revision: D66236128

Pulled By: javache

fbshipit-source-id: d325a7fee28681a1e95fa0341cb7a16fcd9918c0
2024-11-20 09:25:48 -08:00
Alex Hunt
01b40789ee Update build script to minimally support subpath patterns (#47673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47673

Update shared monorepo build script:
- Refactor entry point discovery and file iteration
- Add support for "exports" subpath patterns (skip considering as entry point with warning)

This is required for the incoming migration of `react-native-codegen` to this build setup (D51465053).

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D66121262

fbshipit-source-id: 0deb2c2b26de442ee348ef9de54a1fa144368b6f
2024-11-20 09:21:13 -08:00
Samuel Susla
d2723b8ed7 delete feature flag useSetNativePropsInNativeAnimationsInFabric
Summary: changelog: [internal]

Reviewed By: dmytrorykun

Differential Revision: D66230767

fbshipit-source-id: 8f133a313e42a5dc7136e88a3ce68835d420ced9
2024-11-20 07:25:56 -08:00
Rob Hogan
69400be4fc dev-middleware: Only rewrite hostnames if they match device connection hosts (#47685)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47685

Currently, we assume any URL with a hostname of `10.0.2.2` or `10.0.3.2` (device-relative) is eligible for rewriting to `localhost` (frontend-relative), because we assume the device is an Android emulator. We rewrite these URLs between device and dev machine so that the rewritten URLs are reachable from the dev machine.

This diff narrows this logic so that we'll only rewrite URLs where the hostname matches the pre-existing list *and* this matches the host the device is actually connected on, according to its headers from the original connection.

The main motivation for this change is to unblock removing assumptions about device-reachable vs server-reachable hosts. Later in the stack we'll drop the hardcoded listing of `10.0.2.2` etc in favour of identifying URLs that target the dev server, from whatever network.

There's also an edge case fix here that `10.0.2.2` etc might actually refer to a remote LAN server, and not be an Android emulator's alias for for an emulator host.

Changelog:
[General][Fixed] RN DevTools: Don't assume 10.0.2.2 is an alias for localhost unless it's used to establish a connection to the server

Reviewed By: huntie

Differential Revision: D66058704

fbshipit-source-id: bad28717b0c9b1ca43e2ea3391cef13f87892e6c
2024-11-20 06:56:21 -08:00
Dmitry Rykun
d658ff521d Add missing Android-only props to ImageProps (#47719)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47719

There is a subset of `ImageProps` that are used by Android but not used by iOS. They were missing in the `ImageProps.h`. It was fine when they were only consumed by the Android mounting layer. But it becomes a problem if we want to write some shared C++ code based on those props.
This diff adds those props to the corresponding C++ type.
This should have no practical effect for both platforms.
Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65426569

fbshipit-source-id: dc1c9fe4a6e0e62e62f84b9b249e1c7d253290f5
2024-11-20 06:34:35 -08:00
Simon Krueger
4dd8d3db57 Use folly::fileops qualified name lookup (#47608)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47608

This is a codemod. It was automatically generated and will be landed once it is approved and tests are passing in sandcastle.
You have been added as a reviewer by Sentinel or Butterfly.

Autodiff project: fileops2
Autodiff partition: xplat.js.react-native-github.packages.react-native.ReactCommon.cxxreact
Autodiff bookmark: ad.fileops2.xplat.js.react-native-github.packages.react-native.ReactCommon.cxxreact

This updates `open`, `close`, `read`, `write`, and `pipe` call sites to use
`folly::fileops` qualified name lookup.

This is the 2nd phase in a 3-phase change to remove folly's global definitions
of the posix functions that conflict with windows CRT.
The 1st phase created namespaces for folly's posix functions. The 2nd phase
updates callsites to use the qualified name of folly's  `open`, `close`,
`read`, `write`, and `pipe`  functions. The 3rd and final phase will remove
folly's globally defined posix functions and have windows CRT define them
again.

**What is the reason for this change?**
Folly's global definitions of posix functions on Windows causes `#include`
order issues if folly is not included first.

For example, when `gtest/gtest.h` is included before folly, gtest includes
`windows.h` and that declares `open`, `read`, and `chdir`, which creates
ambiguous references to folly's `open`, `read`, and `chdir`.

Another example is where posix functions go undeclared when
`folly/portability/windows.h` is included without other portability headers
(e.g., `folly/portability/unistd.h`). `folly/portability/windows.h` includes
`windows.h` in a way that only underscore versions of the posix functions are
available (e.g., `_open`, `_close`).

These issues create friction for windows development.

**Background: What is the purpose of `folly::portability::{fcntl,stdlib,sysstat,unistd}`?**
It is a portability layer to make posix functions available and behave
consistently across platforms. Some posix functions don't exist on windows
(e.g., `sysconf`). Some other posix functions, folly changes to adapt behavior
across platforms. For example, on windows folly defines `open`, `read`,
`write`, and `close` functions to work with sockets. Folly makes these
functions available in the global scope for convenience.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65855147

fbshipit-source-id: b06863330ca213b9d1bffe0ee85e0fbf1bc8a845
2024-11-20 06:27:34 -08:00
Rubén Norte
737045217b Implement expect().toEqual() (#47697)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47697

Changelog: [internal]

Implements `expect(received).toEqual(expected)` in Fantom tests.

Reviewed By: sammy-SC

Differential Revision: D66108539

fbshipit-source-id: 4e1d2405064900ec9859220fb6a28ec25a5176f3
2024-11-20 04:27:10 -08:00
Pieter De Baets
e80bdb88be Convert com.facebook.react.ReactPackageHelper to Kotlin (#47683)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47683

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D66131407

fbshipit-source-id: 73d637afea71a77140051efd8001d6ceebc32a43
2024-11-20 04:05:26 -08:00
Pieter De Baets
e0a5bbe309 Convert com.facebook.react.ViewManagerOnDemandReactPackage to Kotlin (#47682)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47682

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D66131124

fbshipit-source-id: aef75eba5fffb1e54c800a4351f8fcb5e1c8a6d4
2024-11-20 04:05:26 -08:00
Pieter De Baets
09b08aa4e0 Convert com.facebook.react.BaseReactPackage to Kotlin (#47679)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47679

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D66119659

fbshipit-source-id: d7917aa09edac6d5a8c07635d294de229723f0c9
2024-11-20 04:05:26 -08:00
Pieter De Baets
ba1bc639b8 Convert com.facebook.react.ReactPackage to Kotlin (#47677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47677

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D66123384

fbshipit-source-id: afac59b4b8f6a0fed9c2acd45176422aa1ffa85e
2024-11-20 04:05:26 -08:00
Dmitry Rykun
c2aa201b1e Fix C++ prop type for the Image.defaultSource (#47713)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47713

`defaultSource` is defined as a single `ImageSource` in docs (https://reactnative.dev/docs/next/image#defaultsource) but its type is a vector of `ImageSource`s in `ImageProps.h`.

This diff changes its C++ type to just `ImageSource`.

Technically, this is a breaking change, however I don't think folks should directly access `ImageProps` outside of `RCTImageComponentView.mm`
Moreover, this prop is actually not implemented in Fabric, so this change should have no practical effect.

Changelog: [Internal]

Facebook
T208171435 - [RN][Fabric][iOS] Implement defaultSource support for Image

Reviewed By: javache

Differential Revision: D65821570

fbshipit-source-id: 38139b0f8d6da495e82c4ef72c19af3db254ba6c
2024-11-20 03:58:20 -08:00
Nick Lefever
2944752a5d Enable RSNRS only on JS thread (#47637)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47637

Changelog: [Internal]

RSNRS does not support off JS thread layout due to current fiber tree corruption when syncing happens on more than one shadow tree at the same time. This diff guarantees that RSNRS will only be enabled on the JS thread, avoiding any state corruption.

Reviewed By: sammy-SC

Differential Revision: D64500893

fbshipit-source-id: aa20f54a0fcfa47534ae099e95307a692bd9fd0f
2024-11-20 00:37:21 -08:00
David Vacca
0eff2c5a22 Update javadoc for ReactHost.destroy() method (#47741)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47741

Update javadoc for ReactHost.destroy() method

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D66215193

fbshipit-source-id: 836c8383f5bb2ffd14b46e498be74b6ed79b4402
2024-11-19 22:28:00 -08:00
Nick Gerleman
e88974f199 Cleanup "setAndroidLayoutDirection" (#47736)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47736

This has been 100% enabled in production across all the apps for more than a month, after an experiment a long time ago, and we kinda depend on it now for correct border drawing in some cases. Let's clean it up!

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D66208418

fbshipit-source-id: 582a38bd84a2d085ba5c4aac4cd478680dd206cc
2024-11-19 21:42:01 -08:00
Joe Vilches
a865975ce3 Update some Justify tests following Chrome changes
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
X-link: https://github.com/facebook/yoga/pull/1746

Chrome made some changes for how overflowed row-reverse containers are laid out which was causing some issues on CI. I updated them here and skipped the new failing tests which we would want to followup on.

For LTR, the differences are seen below
|Before|After|
|--|
|{F1962694149} | {F1962694151}|

The extra space is now extending past the flex start edge vs flex end. RTL is the opposite. NickGerleman had deviated from the spec back in the day to match Chrome and it seems they made the adjustment recently. T208209388 is tracking the followup to align with the spec again. Basically, there is a notion of fallback alignment when certain justification/alignment values cannot actually apply. Right now we are falling back to flex start in all cases but we should fallback to start sometimes.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66138361

fbshipit-source-id: c46d2e9b0cd297069b9cc544e3bded995e4867a6
2024-11-19 15:43:04 -08:00
zhongwuzw
933356e2a6 Fabric: Fixes custom font of weight is not honored (#47691)
Summary:
Fixes https://github.com/facebook/react-native/issues/47656 .

## Changelog:

[IOS] [FIXED] - Fabric: Fixes custom font of weight is not honored

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

Test Plan: Demo in https://github.com/facebook/react-native/issues/47656

Reviewed By: cipolleschi

Differential Revision: D66174732

Pulled By: javache

fbshipit-source-id: 5e6a8c870d3a13283548c736aed73193f7976bfc
2024-11-19 14:06:20 -08:00
Joe Vilches
156454ef39 Potentially fix seg fault when replace YogaLayoutableShadowNodes (#47689)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47689

We were seeing some segfaults from trying to access `display_` in Yoga's `replaceChild` function. Some memory debugging helped identify this was a use-after-free error and NickGerleman suggested we try swapping these lines. Logic being the shared_ptr of YogaLayoutableShadowNode is replaced right before we go and replace its yoga node in the yoga tree. If this is the last shared_ptr holding this node we will delete this object and thus the yoga node with it. We do not need to do this first, so let's swap the lines.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D66142356

fbshipit-source-id: 8fd835346edc91e045ed2ee8945a95af21c47556
2024-11-19 13:17:35 -08:00
David Vacca
fa65b937f5 MigrateSurfaceDelegateFactory to Kotlin (#47688)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47688

MigrateSurfaceDelegateFactory to Kotlin

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D66133186

fbshipit-source-id: 3b53ab557dce6d099bb412f7be6c00ee81be40fc
2024-11-19 12:41:32 -08:00
David Vacca
c0eaa7f1be Make SurfaceDelegate and SurfaceDelegateFactory NullSafe (#47686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47686

Make SurfaceDelegate and SurfaceDelegateFactory NullSafe

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D66134454

fbshipit-source-id: 4364f29699ffee64304bd2ac2eeaec6fb6de9942
2024-11-19 12:41:32 -08:00
Jorge Cabiedes Acosta
61f01ade42 Optimize CompositeBackgroundDrawable (#47618)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47618

Its not optimal to reconstruct CompositeBackgroundDrawable everytime we add a layer to it.

With this change I'm adding an optimization to modify the underlying `LayerDrawable` in place instead of reconstructing everything. `LayerDrawable` has a pretty constrained API and some weirdish behaviors.

- `addLayer` - This API doesnt set the callback for the recently added layer so after adding the layer we also need to manually set the callback
- Mutating `LayerDrawable` in-place is not straightforward, I had to add a function that will figure out where each layer should be inserted
- `LayerDrawable` doesn't allow deleting an element which means that for this case in particular we do need to re-create `CompositeBackgroundDrawable`
- Newer Android versions allow `null` on `LayerDrawable` layers, but older versions do not, this implementation is mostly done this way to accommodate older versions. But also, even though newer versions can have `null` set on a layer `LayerDrawable` still doesn't handle it well and we get some bugs when removing and inserting a layer which the current implementation handles by not relying on null

This is all feature flagged. since it will only be enabled with the new drawables

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D65907786

fbshipit-source-id: c18b898ddfe58faa5b90714945ffcc82d471051d
2024-11-19 12:13:42 -08:00
Jorge Cabiedes Acosta
fd2ce35172 Change type of shadows from array to LayerDrawable (#46818)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46818

Before we were using lists which meant `CompositeBackgroundDrawable` had a `LayerDrawable` of variable length.

This meant that our layers were not consistent and made it hard to optimize `CompositeBackgroundDrawable` to not create a new instance every time we set a new Layer.

With this change `CompositeBackgroundDrawable` has a consistent amount of layers which will allow us to more easily mutate it and land the optimization present on D63287222

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D63798842

fbshipit-source-id: bf0b9ee91ff2083b89ca90ace4de00c71bf3153c
2024-11-19 12:13:42 -08:00
Dmitry Rykun
abeee154d5 Unify defaultSource and defaultSrc ImageProp (#47710)
Some checks are pending
Label closed PR as merged and leave a comment / comment-and-label (push) Waiting to run
Publish Bumped Packages / publish_bumped_packages (push) Waiting to run
Update node modules cache / update_node_modules_cache (push) Waiting to run
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47710

There is Android code that supports remapping `defaultSrc` -> `defaultSource` for `ImageNativeComponent`.
The docs reference this prop as `defaultSource`: https://reactnative.dev/docs/next/image#defaultsource
It is not referenced as `defaultSrc` anywhere. Let's unify it as `defaultSource` across both platforms.
Changelog: [Internal]

Reviewed By: javache

Differential Revision: D65819218

fbshipit-source-id: 0f468e2327ad07285a45e4c9f5e33d74da411c74
2024-11-19 11:21:22 -08:00
Samuel Susla
6f1cf004fa add expect().toBeNull() (#47716)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47716

changelog: [internal]

Add toBeNull check to Fantom.

Jest docs: https://jestjs.io/docs/expect#tobenull

Reviewed By: javache

Differential Revision: D66167811

fbshipit-source-id: 33b6cf362bcf1636f41b78dc6c84905b80be994e
2024-11-19 10:52:08 -08:00
Pieter De Baets
8fba7ebb5e Mark ReactPackage#getModule as stable (#47676)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47676

`getModule` is used by all modern ReactPackage base-classes to allow lazy loading of specific module and should be considered stable at this point.

Changelog: [Android][Added] Marked ReactPackage#getModule as stable.

Reviewed By: mdvacca

Differential Revision: D66127068

fbshipit-source-id: de447794435d267619430e3c0cbc65c6e1c614ba
2024-11-19 10:19:14 -08:00
Riccardo Cipolleschi
4c3112c8d8 Do not discard props when setNativeProps is used (#47669)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47669

When investigating [#47476](https://github.com/facebook/react-native/issues/47476), I found that the `secureTextInput` prop was not changing in the Mounting layer when changing it in JS.

I track down the problem to the `UIManager::cloneNode` method.
When we clone the node, we first merge the patch that arrives from React into the props controlled by setNativeProps, ignoring the patch's props that are controlled by React.

But then, we forgot to merge back the React's controlled property into the final props, effectively losing them.

This change adds an extra merging step, merging the props controlled with setNativeProps back into the patch of props controlled by React, and then using this new set of props as source of truth.

## Changelog:
[General][Fixed] - do not discard props in the patch when they are not null while using `useNativeProps`

Reviewed By: sammy-SC

Differential Revision: D65948574

fbshipit-source-id: db4f2b793f4a6348456933c95a151012252b8ebc
2024-11-19 09:54:27 -08:00
Alex Hunt
35ab62cca3 Substitute @pkgjs/parseargs for Node builtin (#47704)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47704

Now that we have a min requirement of Node 18.18 on `main`, drop dependency on this polyfill.

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D66162328

fbshipit-source-id: e8ab6669fe14ed177eccf4b861c01df4fb0d405a
2024-11-19 09:47:40 -08:00