Commit Graph

34421 Commits

Author SHA1 Message Date
Peter Abbondanzo dc5535cf88 Improve documentation for AssetSourceResolver (#48532)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48532

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D67942309

fbshipit-source-id: 0f3901bfcd58863adf6dc8466bb5d587438e0d2c
2025-01-08 14:54:17 -08:00
Peter Abbondanzo 6feb90bb29 Replace custom XmlFormat with Fresco built-in (#48533)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48533

Replaces the custom `XmlFormat` introduced in https://github.com/facebook/react-native/pull/46711 with the built-in support from Fresco. Fresco utilizes a very similar approach to load binary XML files and offers the XML format as part of its built-in `DefaultImageFormats`

Changelog:
[Android][Changed] - Replaced custom XML decoder with Fresco's built-in decoder

Reviewed By: NickGerleman

Differential Revision: D66553842

fbshipit-source-id: 096e60140f893d461be1cdb48e250749e58bbb4c
2025-01-08 14:54:17 -08:00
Peter Abbondanzo 819b5c2c8d Bump Fresco to 3.6.0 (#48542)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48542

Updates Fresco from 3.5.0 to 3.6.0. Picks up a few new features and bug fixes for XML drawables, including a required fix that [automatically supplies the XML drawable factory to Fresco's PipelineDraweeControllerBuilder](https://github.com/facebook/fresco/commit/e6b052610aab461601cfabc00f7240758a415878). Without this change, we cannot switch from RN's custom XmlFormat to Fresco's built-in format

Changelog:
[Android][Changed] - Update Fresco to 3.6.0

Reviewed By: NickGerleman, rshest

Differential Revision: D67950225

fbshipit-source-id: 9afd87565a5f069493c9c5ef87977cbd6d7cf3d4
2025-01-08 14:54:17 -08:00
Peter Abbondanzo 218815959b xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewAccessibilityDelegate.java (#48530)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48530

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D67912326

fbshipit-source-id: b03be79dfbf3bf8d92b11eb6228ecc36282b29cf
2025-01-08 14:46:01 -08:00
David Vacca 843588ffe5 Refactor PointerEvents strings as constants (#48537)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48537

Refactor PointerEvents strings as constants

changelog: [internal] internal

Reviewed By: shwanton

Differential Revision: D67924567

fbshipit-source-id: 7d9976d293cef3eeedbbb72abd20d8f877b768d0
2025-01-08 11:37:47 -08:00
David Vacca e4ec22de9d Delete POSITION_SPACING_TYPES from ViewProps (#48536)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48536

POSITION_SPACING_TYPES is not being used, let's delete it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67924569

fbshipit-source-id: 6cc4b0537032f4a4b54dbd728ca52ba216fd6cee
2025-01-08 11:37:47 -08:00
David Vacca c17e6ce0f0 Delete ON_LAYOUT constant (#48535)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48535

ON_LAYOUT is not being used, lets delete it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67924570

fbshipit-source-id: b5522317c943c07f8617508c0345b18a6f31ce7e
2025-01-08 11:37:47 -08:00
David Vacca 98b413416c Delete unused constants in ViewProps (#48534)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48534

IS_ATTACHMENT is unused, let's delete it

changelog: [internal] internal

Reviewed By: christophpurrer

Differential Revision: D67924566

fbshipit-source-id: 49718f4ce667abe919a314a853dbd7853bfe1292
2025-01-08 11:37:47 -08:00
Nick Gerleman f7a5db3c06 Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints (#48525)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48525

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

`TextMeasureCacheKey` hash and equality functions only incorporates the maximum width constraint. I'm guessing this was an attempt at an optimization, but it can lead to incorrect results in pretty trivial cases. E.g. if Yoga knows a definite size of `Text` in one dimension,  and measures via `YGMeasureModeExactly`, we can have a minimum size corresponding specific to the style in which the text was laid out.

Changelog:
[General][Fixed] - Fix TextMeasureCacheKey Throwing Out Some LayoutConstraints

Reviewed By: christophpurrer

Differential Revision: D67922414

fbshipit-source-id: 0ee0220059fc4e4645b1684c42a0587fe728bedd
2025-01-08 10:33:25 -08:00
Tim Yung 85e58f334e Prettier: Cleanup eslint-plugin-prettier Dependency (#48524)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48524

I've confirmed that we are no longer using `eslint-plugin-prettier` in Metro or React Native. This removes it from the package dependencies.

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D67920511

fbshipit-source-id: 9c8036ccfb94d974d344d861942c076dc2b70125
2025-01-08 09:42:59 -08:00
Tim Yung 6d67d6a7f6 Animated: Optimize onUserDrivenAnimationEnded Deopt (#48511)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48511

{D60499583} added a new`onUserDrivenAnimationEnded` listener that requires `AnimatedValue` instances to have up-to-date values reported by `onAnimatedValueUpdate` (if native driver is in use).

Previously, the only way to ensure `onAnimatedValueUpdate` events were always fired to update JavaScript values in `AnimatedValue` instance was to attach a listener — even an empty one. This is exactly what D60499583 did: it traverses `props` for `AnimatedNode` instances and attaches listeners to them.

However, this is really inefficient and makes the code extra convoluted. Instead, this diff changes `AnimatedValue` so that it always subscribes to changes in `__attach`, and then it cleans up the extraneous props traversal and "empty listener" logic.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D67872307

fbshipit-source-id: e7d7e486bbfd9ef03e2dd9f201089e2f68b2dbb2
2025-01-08 09:03:17 -08:00
Sam Zhou abf0384434 Deploy 0.258.1 to xplat
Summary: Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D67927891

fbshipit-source-id: ac9c7bd87e9f1e2fecdbd7141cd0e5c5a62c7ce6
2025-01-08 08:47:41 -08:00
Pieter De Baets a62230a54d Merge copies of GuardedFrameCallback (#48529)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48529

These classes are identical and we already have a dependency on :uimanager in fabric.

Looking at OSS, I found no usages of `fabric.GuardedFrameCallback`.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67913226

fbshipit-source-id: 97d7a9b45b877b98e9549c71135bd9b21386d78c
2025-01-08 07:40:32 -08:00
Peter Abbondanzo ec72af403c Mark string props as nullable in scrollview managers (#48520)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48520

Both `ReactScrollViewHelper.parseSnapToAlignment` and `ReactScrollViewHelper.parseOverScrollMode` accept a nullable string. This is a precursor to migrating these files to Kotlin (since they're already marked as nullsafe). The prop itself is a nullable string so this should be reflected in the native types as well

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D67911553

fbshipit-source-id: aabe55c2dc65a933b170d76b89f62f25493ab0ee
2025-01-07 15:13:34 -08:00
Oskar Kwaśniewski 8b0af4542e fix(iOS): enable/disable keyboard shortcuts only on iOS (#48518)
Summary:
This PR guards code that enables/disables keyboard shortcuts only on iOS (iPadOS included).

![CleanShot 2025-01-07 at 14 49 36@2x](https://github.com/user-attachments/assets/cba4e19c-5a52-4874-94cf-a3e18112c8a3)

## Changelog:

[IOS] [FIXED] - enable/disable keyboard shortcuts only on iOS

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

Test Plan: CI Green

Reviewed By: rshest

Differential Revision: D67900442

Pulled By: javache

fbshipit-source-id: 249a7c3124d02d2c30303d218e2b26e987ae1f0f
2025-01-07 13:21:19 -08:00
Tim Yung 38c46fe865 Animated: Lower onAnimatedValueUpdate to AnimatedValue (#48514)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48514

Currently, `AnimatedNode` implements logic to start listening to updates on the current native node if a listener is added.

However, the `startListeningToAnimatedNodeValue` native module method only supports native tags for instances of `AnimatedValue`, which is a subclass of `AnimatedNode`. In fact…

* On Android, [`startListeningToAnimatedNodeValue`](https://fburl.com/code/bdsl4sro) throws if the node is not an instance of `ValueAnimatedNode`.
* On iOS, [`startListeningToAnimatedNodeValue`](https://fburl.com/code/hlpk1rzk) does nothing if node is not an instance of `RCTValueAnimatedNode`.

As such, this refactors `AnimatedNode` to never manage this subscription for native nodes. Instead, the logic is moved into the `AnimatedValue` subclass, ensuring that we never accidentally try to `startListeningToAnimatedNodeValue` with non-`AnimatedValue` native tags.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D67884973

fbshipit-source-id: 5601efd8c29104a991301eabd97ddb88fd03c4a3
2025-01-07 10:05:15 -08:00
Tim Yung d3c5f6d1df Animated: Add Missing super.__attach() Calls (#48513)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48513

While refactoring `Animated`, I noticed that many subclasses of `AnimatedNode` override `__attach` without invoking the superclass method, even though we do this for `__detach`.

In order to minimize surprise (e.g. if someone were to add logic into `AnimatedNode.prototype.__attach`), this diff updates all method overrides to invoke `super.__attach()`.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D67884975

fbshipit-source-id: f3a5456cf944d4d70ba1cfe7c44897c110e5fc7e
2025-01-07 10:05:15 -08:00
Pieter De Baets 3f6fc32a5c Fix nullability of ViewManagerDelegate
Summary:
Some of these parameters were incorrectly marked as nullable during the Kotlin migration

Changelog: [Internal]

Reviewed By: tdn120

Differential Revision: D67091825

fbshipit-source-id: c660164e41ba7d47f1d1d3dc28a01b79b7c8cb03
2025-01-07 09:52:55 -08:00
Rob Hogan 7a58f1f5bf Add changelog for 0.77.0-rc.6 (#48508)
Summary:
Changelog for 0.77.0-rc.6

## Changelog:

[Internal]

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

Test Plan: N/A

Reviewed By: christophpurrer

Differential Revision: D67866154

Pulled By: robhogan

fbshipit-source-id: a64f2aa83abe31bbc8d9e1a2ac47e00bba55c389
2025-01-07 08:45:34 -08:00
Pieter De Baets afd77d52ed Rename SurfaceRegistryBinding to AppRegistryBinding (#48337)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48337

`SurfaceRegistryBinding` refers to a forked `SurfaceRegistry` we had for a while in bridgeless but which was merged back into `AppRegistry`. Align the native name as well to make it explicit that all this class does is call into `AppRegistry`.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67342499

fbshipit-source-id: 797d8080611cb2576a2052999c2bf46d2eea9f72
2025-01-07 07:40:40 -08:00
Pieter De Baets dbb75e36dc Always use AppRegistry globals in SurfaceRegistryBinding (#48336)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48336

`RN$AppRegistry` and `RN$stopSurface` are always set on the init path, regardless of bridgeless or not, so we can remove the fallback path and cleanup this code.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67342498

fbshipit-source-id: db47e52fee5075f11258364d82474579d2bb21f4
2025-01-07 07:40:40 -08:00
Pieter De Baets 65bda54232 Remove getInspectorDataForInstance (#48335)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48335

This API was never adopted or implemented on iOS, and is not compatible with bridgeless.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D67342500

fbshipit-source-id: a6740514d0347c0f497e1aa2f850328cc4607d24
2025-01-07 07:40:40 -08:00
Alex Hunt eda29f0a56 Remove legacy InspectorPackagerConnection (#48506)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48506

Cleanup after the original experiment removal in D57730921, and having launched Fusebox for a full release cycle.

- This was previously opened as D58017460 and reverted in D58132473 ([see comment](https://www.internalfb.com/diff/D58017460?transaction_fbid=980942997022731)).

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D67858259

fbshipit-source-id: f4b29247dd4c310cc1f6b6f45688756d7b925a5e
2025-01-07 05:48:00 -08:00
Blake Friedman a8cf53fcd1 Add messaging to phabricator (#48470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48470

This introduces:
- `validate_rn_cpp_api`: run a shell script that fails if the user changes the C++ API.  Importantly it produces an artifact with details to share with the user: `message`.
- `message` has to be extracted from `stdout`, which **get_user_message** does if the `validate_rn_cpp_api` action is not successful (**warning**).
- The then users `comment_to_signalhub` to share this as a warning to the user (until we're confident this entire stack is very stable, at which time we'll block).

The provides 2 classes of warning:
1. vanilla you've change the API,
2. you've change the API and haven't included the correct changelog.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D67776215

fbshipit-source-id: 4ac7451c8ecef62ba968710ec41804ba42153976
2025-01-07 03:41:42 -08:00
Parsa Nasirimehr d22dbb5c51 chore(Android): Migrate Hermes Instruments to Kotlin (#48378)
Summary:
Time to migrate some of Hermes's instruments. I see that HermesMemoryDumper(`react/hermes/instrumentation/HermesMemoryDumper.h`) implements the interface on C++, ~but not sure if i need to update the `getId` call to just `id` (same with `getInternalStorage`) or if the interop between Kotlin and Java applies to these things as well. cortinico Any thoughts on your side would be appreciated.
HermesSamplingProfiler just became an object, since it was a singleton and a static anyway.
Here is what HermesMemoryDumper.h looks like:
<img width="1840" alt="Screenshot 2024-12-24 at 10 03 00" src="https://github.com/user-attachments/assets/d18e378a-9b23-47a9-83c9-402d29aeaa5f" />~
*Updated*: I ended up making them match the function signature on Cxx, because even if it does have that implicit behavior, doesn't feel right to tap into it like this.

## Changelog:

[INTERNAL] [FIXED] - Migrate HermesMemoryDumper and HermesSamplingProfiler to Kotlin

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

Test Plan:
`/gradlew test`:
<img width="1840" alt="Screenshot 2024-12-24 at 09 54 29" src="https://github.com/user-attachments/assets/1b23fb6f-9da8-42e4-a348-7da868df77c1" />

Reviewed By: cortinico

Differential Revision: D67657481

Pulled By: philIip

fbshipit-source-id: 4fb5e003789d51d464d0cca5800704ea51324b69
2025-01-07 00:49:59 -08:00
generatedunixname89002005232357 cd40e4e387 Revert D67868219 (#48512)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48512

This diff reverts D67868219
Breaking OTA Compatibility Check https://fburl.com/onedetection/m0hqsvjp

[General][Changed] - Revert: Mark intersectionRect required in NativeIntersectionObserverEntry to reflect native logic.

Reviewed By: lunaleaps

Differential Revision: D67882016

fbshipit-source-id: 8cff299ee823f8ef06fe96667e832b68be45666d
2025-01-06 22:28:51 -08:00
Christoph Purrer 65c6a0a941 Add getSurfaceProps helper method to SurfaceManager (#48487)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48487

[Changelog] [Internal] - Add getSurfaceProps helper method to SurfaceManager

When reload a reactHost we need to know which surface properties have been applied when starting the surface. This adds a utility function for that.

Reviewed By: rshest

Differential Revision: D67822459

fbshipit-source-id: 6d1f182514ed6e7ae8e31d3e1ca052c93bac2843
2025-01-06 21:49:49 -08:00
Christoph Purrer 44525aaf8b Add isSurfaceRunning / getRunningSurfaces util functions to SurfaceManager (#48484)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48484

[Changelog] [Internal] - Add isSurfaceRunning / getRunningSurfaces util functions to SurfaceManager

This exposes convience getter methods to data already stored in SurfaceManager

Reviewed By: rshest

Differential Revision: D67814092

fbshipit-source-id: af5e9df3b380d5efc0c11627a0d9a56796526639
2025-01-06 18:51:46 -08:00
Eli White 25c673e357 Fixing schema types for component command params of Arrays (#48476)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48476

Command param array types were generating invalid schemas due to untyped parser code. The invalid schemas occurred for any alias type, including custom objects and basics like Int32. This was also inconsistent between Flow and TypeScript.

We already had one component utilizing this issue, so this just codifies that support into the schema so it reflects reality. This is only a partial solution. The more full solution would be to fully encode the custom types in the schemas like we do for Native Modules.

# More Information:

Tl;dr, DebuggingOverlay is abusing a FlowFixMe in codegen commands.

## The problem:

The [CodegenSchema](https://www.internalfb.com/code/fbsource/[d3ab2f79b377]/xplat/js/react-native-github/packages/react-native-codegen/src/CodegenSchema.js?lines=220) should be the source of truth for anything that can be in the schema. If something is in the schema that isn't allowed by the types, that's a bug. We have a bug. I'm adding compat-check support for components and it's blowing up on prod schemas because DebuggingOverlay causes an invalid schema.

## The details:

Support for Arrays as arguments in commands was added to the Codegen in D51866557. [Code Pointer](https://fburl.com/code/8yy1rm0p)

The intention appears to be to support arrays of primitives. There is a TODO for supporting complex types.

```
interface NativeCommands {
  +addOverlays: (
    viewRef: React.ElementRef<NativeType>,
    overlayColorsReadOnly: $ReadOnlyArray<string>,
  )
}
```

This support was added to TypeScript in D52046165 where it types the allowed Array arguments to be only

```
{
    readonly type: 'ArrayTypeAnnotation';
    readonly elementType:
    | Int32TypeAnnotation
    | DoubleTypeAnnotation
    | FloatTypeAnnotation
    | BooleanTypeAnnotation
    | StringTypeAnnotation
  };
```

However, because the Parsers are treating the input type as `any`, it isn't safe to pass through an input value into the schema as Flow won't catch mismatches.

The Flow parser just passes it through:

```
{
    type: 'ArrayTypeAnnotation',
    elementType: {
    // TODO: T172453752 support complex type annotation for array element
    type: paramValue.typeParameters.params[0].type,
}
```

Whereas the TypeScript parser has the more correct behavior of validating the inputs and returning specific outputs. Unfortunately, the return type is also typed here as $FlowFixMe, losing most of the benefits.

```
function getPrimitiveTypeAnnotation(type: string): $FlowFixMe {
  switch (type) {
    case 'Int32':
      return {
        type: 'Int32TypeAnnotation',
      };
    case 'Double':
      return {
        type: 'DoubleTypeAnnotation',
      };
    case 'Float':
      return {
        type: 'FloatTypeAnnotation',
      };
    case 'TSBooleanKeyword':
      return {
        type: 'BooleanTypeAnnotation',
      };
    case 'Stringish':
    case 'TSStringKeyword':
      return {
        type: 'StringTypeAnnotation',
      };
    default:
      throw new Error(`Unknown primitive type "${type}"`);
  }
}
```

[DebuggingOverlay](https://fburl.com/code/zfe3ipq7) is abusing this gap in the Flow parser by sticking an Array of Objects in.

```
export type ElementRectangle = {
  x: number,
  y: number,
  width: number,
  height: number,
};

...
  +highlightElements: (
    viewRef: React.ElementRef<DebuggingOverlayNativeComponentType>,
    elements: $ReadOnlyArray<ElementRectangle>,
  ) => void;
...
```

This isn't allowed in the schema, but it seems to fall through the holes of the flow parser and generators.

The resulting schema from Flow is this. Note the GenericTypeAnnotation which isn't allowed to be in the schema.

```
{
    "name": "highlightElements",
    "optional": false,
    "typeAnnotation": {
    "type": "FunctionTypeAnnotation",
    "params": [
        {
            "name": "elements",
            "optional": false,
            "typeAnnotation": {
                "type": "ArrayTypeAnnotation",
                "elementType": {
                    "type": "GenericTypeAnnotation"
                }
            }
        }
    ],
    "returnTypeAnnotation": {
        "type": "VoidTypeAnnotation"
    }
},
```

The TypeScript parser fails with `Error: Unsupported type annotation: GenericTypeAnnotation`.

The generators don't seem to check beyond the ArrayTypeAnnotation so they fall through to generating generic arrays.

```
// ios
elements:(const NSArray *)elements

// android
ReadableArray locations
```

## So how do I fix this?

I think there are a couple of different options here. The key problem is that the Schema types need to represent reality of what can be in the schema.

1. We revert DebuggingOverlay to not use features that aren't supported (I assume nobody would be happy with this, but the change shouldn't have been made in the first place)
2. **(This is the approach taken in this diff)** We add MixedTypeAnnotation to the allowed types in Command arrays and have it generate that and add official support for that to the TypeScript parser as well. That is probably the quickest and easiest approach. It leaves the same type unsafety we have today on the native side.
3. NativeModules seem to have a lot more complex type safety here. They persist the alias type in the schema so that the CompatCheck can check them on changes. And then in C++ they generate structs and RCTConvert functions although for Java and ObjC it looks like they just use the same untyped native code. The matching approach here would be to add `aliasMap` and the whole data to the schema for commands, use that for the compat check, and still generate the same unsafe native code.

```
export type ObjectAlias = {|
  x: number,
  y: number,
|};

export interface Spec extends TurboModule {
  +getAlias: (a: ObjectAlias) => string;
}
```

stores the ObjectAlias in the schema

```
{
  "aliasMap": {
    "ObjectAlias": {
      "type": "ObjectTypeAnnotation",
      "properties": [
        {
          "name": "x",
          "optional": false,
          "typeAnnotation": {
            "type": "NumberTypeAnnotation"
          }
        },
        {
          "name": "y",
          "optional": false,
          "typeAnnotation": {
            "type": "NumberTypeAnnotation"
          }
        },
      ]
    }
  },
  "spec": {
    "methods": [
      {
        "name": "getAlias",
        "optional": false,
        "typeAnnotation": {
          "type": "FunctionTypeAnnotation",
          "returnTypeAnnotation": {
            "type": "StringTypeAnnotation"
          },
          "params": [
            {
              "name": "a",
              "optional": false,
              "typeAnnotation": {
                "type": "TypeAliasTypeAnnotation",
                "name": "ObjectAlias"
              }
            }
          ]
        }
      }
    ]
  }
}
```

and then generates the appropriate structs on the native side and generates [this](https://www.internalfb.com/code/fbsource/[d3ab2f79b377]/xplat/js/react-native-github/packages/react-native-codegen/src/generators/modules/__tests__/__snapshots__/GenerateModuleHObjCpp-test.js.snap?lines=818)

```

Reviewed By: hoxyq

Differential Revision: D67806838

fbshipit-source-id: 31f20455c816fdb6b1a86f8f9d0f6f7d0a452754
2025-01-06 18:42:37 -08:00
Eli White c748b44183 Add command type to CompleteTypeAnnotation (#48475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48475

This will be needed for the compat-check.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D67806831

fbshipit-source-id: b660c9557cafbfa2e713e85a0fd2bdc9edabf537
2025-01-06 18:42:37 -08:00
Eli White 825492b199 Separate component array types and command array types (#48474)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48474

The previous definition said that you could put prop types into commands, which definitely isn't allowed.

For example, the schema would have allowed `WithDefault` types.

```
interface NativeCommands {
  +methodInt: (viewRef: React.ElementRef<NativeType>, a: WithDefault<string, 'hi'>) => void;
}
```

This change separates out the things that are allowed in commands from what's allowed in props.

Commands should be very similar to what's allowed in native modules, but it isn't exact enough to be able to merge those.

## Changelog:
[General][Breaking] - Codegen: Separate component array types and command array types

Reviewed By: cipolleschi

Differential Revision: D67806818

fbshipit-source-id: 58e504fe2e2e5efa612e836b18af22a167e7ae2f
2025-01-06 18:42:37 -08:00
Eli White c91cfd1ec1 Simplify CompleteTypeAnnotation (#48473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48473

This is such a simpler approach lol.

I'll need this later for when I want to pass in arrays or objects of these types to the compat check

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D67806812

fbshipit-source-id: 5cc361815fea901098d2931ba78293693ecc0a35
2025-01-06 18:42:37 -08:00
Eli White 02c6790842 Make CompleteType contain module and component reserved names (#48477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48477

Over the years of copying and moving and renaming types through CodegenSchema, this type ended up in the Command params, although the Command parser doesn't allow it.

I made this change to a fixture:

{F1974104959}

and got this error

```
 FAIL  xplat/js/react-native-github/packages/react-native-codegen/src/parsers/flow/components/__tests__/component-parser-test.js
  ● RN Codegen Flow Parser › can generate fixture COMMANDS_DEFINED_WITH_ALL_TYPES

    Unsupported param type for method "scrollTo", param "speed". Found UnionTypeAnnotation

      127 |       default:
      128 |         (type: empty);
    > 129 |         throw new Error(
          |               ^
      130 |           `Unsupported param type for method "${name}", param "${paramName}". Found ${type}`,
      131 |         );
      132 |     }
```

Also, a default value for enum an argument of a Command doesn't make sense anyways.

Commands should probably have support for enums and string literal unions, but that's out of scope here.

Still need to add to this vec\concat on www: https://www.internalfb.com/code/www/[ebfa58f888a6064e17879934d447f59bcc2b6951]/flib/intern/sandcastle/react_native/ota_steps/SandcastleOTACompatibilityCheckReportingStep.php?lines=62

Changelog: [internal]

Reviewed By: cipolleschi

Differential Revision: D67806808

fbshipit-source-id: f0f31cca30abbf61f569933ea7c49cf6bfd18a3f
2025-01-06 18:42:37 -08:00
Christoph Purrer c8552519b3 Make SurfaceManager const correct (#48485)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48485

[Changelog] [Internal] - Make SurfaceManager const correct

This marks methods which don't modify member props as `const` and others as non `const`.

The current API signature is misleading as `const` methods do alter `mutable` members

Reviewed By: rshest

Differential Revision: D67820439

fbshipit-source-id: 6a991bd7ccbd464c2390e33e0c29b136892d65e0
2025-01-06 14:41:39 -08:00
Luna Wei 8681fc2ab2 Remove optionality of intersectionRect
Summary:
Changelog:
[General][Changed] - Mark `intersectionRect` required in `NativeIntersectionObserverEntry` to reflect native logic.

Reviewed By: rubennorte

Differential Revision: D67868219

fbshipit-source-id: cdc15908c0cf687b13d1424a59ee1e2383811ab3
2025-01-06 13:30:10 -08:00
Christoph Purrer 3744349ed7 Add RuntimeSchedulerKey constant for RuntimeScheduler lookup (#48486)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48486

[Changelog] [Internal] - Add RuntimeSchedulerKey constant for RuntimeScheduler lookup

Similar to https://github.com/facebook/react-native/pull/48127 this adds a contant to avoid typos when inserting or retrieving the RuntimeScheduler

Reviewed By: rshest

Differential Revision: D67822346

fbshipit-source-id: af982c6d4b875ffde06aae8e953c4892754a074b
2025-01-06 11:23:04 -08:00
Christoph Purrer c4edfe7323 Remove startEmptySurface from SurfaceManager (#48479)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48479

[Changelog] [Internal] - Remove startEmptySurface from SurfaceManager

Most of the logic deleted here does not seem to be needed as the core functionality is in:

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/renderer/scheduler/SurfaceHandler.cpp#L88-L96

And this code path can be reached both via
- `startSurface` (by passing in an empty `moduleModule` OR
- `startEmptySurface`

Reviewed By: shwanton, rubennorte

Differential Revision: D67805569

fbshipit-source-id: e3d06dcaa637996498a6cb52b5c1b98f740326ce
2025-01-06 10:32:16 -08:00
Mykhailo Kravchenko 0154372b93 feat: Manage keyboard shortcuts visibility of TextInput (#47671)
Summary:
**iOS** does offer a native property for **UITextField** called `inputAssistantItem`. According to the [documentation](https://developer.apple.com/documentation/uikit/uitextinputassistantitem), we can hide the **"shortcuts"** by setting the `leadingBarButtonGroups` and `trailingBarButtonGroups` properties to empty arrays.

I propose adding a new property for **TextInput** in **React Native**, which would set these native properties to empty arrays. This new property could be called `disableInputAssistant` or `disableKeyboardShortcuts` and would be a `boolean`.

Developers can manage this behavior (the redo & undo buttons and suggestions pop-up hiding) after applying these native props.

https://github.com/react-native-community/discussions-and-proposals/discussions/830

## Changelog:

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

Pick one each for the category and type tags:

[IOS] [ADDED] - [TextInput] Integrate a new property - `disableKeyboardShortcuts`. It can disable the keyboard shortcuts on iPads.

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

[IOS] [ADDED] - [TextInput] Integrate a new property - `disableKeyboardShortcuts`. It can disable the keyboard shortcuts on iPads.

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

Test Plan:
Manual
1. Open TextInput examples.
2. Scroll down and reach the "Keyboard shortcuts" section.
3. Test each case.

Note: **TextInput** behaves the same as now when the new prop is not passed or is `false`.

https://github.com/user-attachments/assets/5e814516-9e6c-4495-9d46-8175425c4456

Reviewed By: javache

Differential Revision: D67451609

Pulled By: cipolleschi

fbshipit-source-id: 59ba3a5cc1644ed176420f82dc98232d88341c6e
2025-01-06 09:54:29 -08:00
zhongwuzw a3dfc4984d Fabric: Added ScrollEndDragEvent for scrollEndDrag event (#48319)
Summary:
Fixes https://github.com/facebook/react-native/issues/42533 .

## Changelog:

[IOS] [FIXED] -  Fabric: Added ScrollEndDragEvent for scrollEndDrag event

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

Test Plan: Repro please see https://github.com/facebook/react-native/issues/42533 .

Reviewed By: javache

Differential Revision: D67517912

Pulled By: cipolleschi

fbshipit-source-id: aa1caebfb690d09a207b3ebce382eceb520009e5
2025-01-06 08:44:23 -08:00
Rubén Norte cb308bdc5e Add benchmark for host component class variants (#48450)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48450

Changelog: [internal]

This implements a basic benchmark to compare `ReactFabricHostComponent` and `ReactNativeElement` (legacy and DOM implementations for native component instances).

Reviewed By: rshest

Differential Revision: D66698546

fbshipit-source-id: dd4bde833e5c9eb32c79a52d06f3c360fb012e23
2025-01-06 07:10:28 -08:00
Rubén Norte ff7c550a86 Run benchmarks in test mode when not specifying verification functions in CI (#48451)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48451

Changelog: [internal]

Modifies the execution of benchmarks in CI to run benchmarks in test mode when they don't define a `verify` method.

If a benchmark uses `verify`, the test is meant to make sure that the benchmark doesn't regress in CI. If it doesn't, then running the benchmark on CI doesn't provide much value. In that case, we run a single iteration of each test case just to make sure things don't break over time.

Reviewed By: rshest

Differential Revision: D67637754

fbshipit-source-id: 33b78a9c809386cf2e040314b0427de6a53da3e3
2025-01-06 07:10:28 -08:00
Rubén Norte 3795f0fb66 Add API to run benchmarks in Fantom (#48452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48452

Changelog: [internal]

Implements a basic API to run benchmarks with Fantom (using `tinybench` under the hood):

```
import {benchmark} from 'react-native/fantom';

benchmark
  .suite('Suite name', {
    // options
  })
  .add(
    'Test name',
    () => {
      // code to benchmark
    },
    {
      beforeAll: () => {},
      beforeEach: () => {},
      afterEach: () => {},
      afterAll: () => {},
    },
  )
  .verify(results => {
    // check results and throw an error if the expectations fail
  });
```

Features:
* Print benchmark results in the console as a table.
* It opts into optimized builds automatically
* Verifies that optimized build is used (unless manually opting out of the check via `disableOptimizedBuildCheck`).
* Supports verification of results (making expectations and making the test fail if the benchmark doesn't meet some expectations).

Reviewed By: rshest

Differential Revision: D66926183

fbshipit-source-id: 61cfa7689ea7684eb870fbbc815b8d236a1871e6
2025-01-06 07:10:28 -08:00
Rubén Norte 96205dd78e Add tinybench to run benchmarks in Fantom (#48453)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48453

Changelog: [internal]

Adds tinybench 3.1.0 (which has support for sync execution) and defined Flow types for the package.

Reviewed By: dmytrorykun

Differential Revision: D66698545

fbshipit-source-id: faf44add74e5711ac0d50794ce3360eedc45f0a5
2025-01-06 07:10:28 -08:00
Rubén Norte bc3072eafc Implement native module to measure CPU time (#48454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48454

Changelog: [internal]

This implements a native module for Fantom to provide information about the CPU time used by the current process. This will be used by Fantom as the clock to run benchmarks more accurately.

It provides 2 implementations:
1. One based on `clock_gettime` with `CLOCK_THREAD_CPUTIME_ID` that's available on Linux. This provides the CPU time for the current process with decent precision (tens of nanoseconds).
2. A fallback implementation that uses a monotonic clock (not actually CPU time).

We can add a MacOS equivalent in a following diff.

Reviewed By: rshest

Differential Revision: D67596312

fbshipit-source-id: dd712c0171aa998ddbb6fed9187b3c467cd5417d
2025-01-06 07:10:28 -08:00
Alex Hunt eee2866508 Fix InspectorFlags debug default, clean up legacy Buck opt in (#48504)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48504

Following D67857739, fixes accidental change where the removed `ReactNativeFeatureFlags` flag read was not replaced with `true`. This temporarily disabled Fusebox on `main`, where not configured via other build flags.

{F1974195736}

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D67857739

fbshipit-source-id: 2a6fb2e6733035245e7ad959c7d3c650a9fde994
2025-01-06 07:02:22 -08:00
Mateo Guzmán b477cfa0ba Add AppStateModule Android unit tests (#48492)
Summary:
Currently the `AppStateModule` doesn't have any unit tests in the Android implementation. This should make it safer for future changes or refactors.

## Changelog:

[INTERNAL] - Add `AppStateModule` Android unit tests

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

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

Reviewed By: cipolleschi

Differential Revision: D67857498

Pulled By: cortinico

fbshipit-source-id: f90ced1cf02ac12a3438495b425ce7931decf19a
2025-01-06 06:49:27 -08:00
Kræn Hansen 7a85b91125 Fix ruby unit tests (#48498)
Summary:
As a prerequisite of enabling running unit tests on CI again, this PR suggests changes needed to the Ruby unit tests.

I've added comments on the code below, justifying changes where I deem a justification might be needed.

For use internally, I suggest accessing the folly_config and boost_config directly via the `Helpers` class instead of the `get_folly_config` and `get_boost_config` because these global functions are defined in `react_native_pods` which would be result in circular requires. An alternative would be to move these global functions to a separate file.

## Changelog:

[INTERNAL] [FIXED] - Fix Ruby unit tests.

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

Test Plan:
- `cd packages/react-native`
- `./scripts/run_ruby_tests.sh`

Reviewed By: rshest

Differential Revision: D67852809

Pulled By: cipolleschi

fbshipit-source-id: 54d8bd708a9e3fd9aef3569ac89ec6ddcd244437
2025-01-06 02:31:42 -08:00
Ruslan Shestopalyuk 5ce07386e1 Convert FabricEventDispatcher (#48491)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48491

# Changelog:
[Internal] -

As in the title.

Reviewed By: christophpurrer

Differential Revision: D67825655

fbshipit-source-id: e94431ae6978332c0566ab0a500e1a85f1ad9a7d
2025-01-06 01:46:46 -08:00
Ruslan Shestopalyuk a9d86be3a4 Migrate EventDispatcher interface to Kotlin (#48445)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48445

# Changelog:
[Internal] -

As in the title.

Reviewed By: christophpurrer

Differential Revision: D67760373

fbshipit-source-id: 6360ed5b488ec47bdd2e4d0357d0d06e8e42f614
2025-01-06 01:46:46 -08:00
Ruslan Shestopalyuk d470f39d8a Migrate RCTEventEmitter to Kotlin (#48467)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48467

# Changelog:
[Internal] -

As in the title.

Reviewed By: christophpurrer

Differential Revision: D67793304

fbshipit-source-id: 39bbdebf8434ad57bab3e1d309915a8132033f5b
2025-01-06 01:46:46 -08:00