Commit Graph

1004 Commits

Author SHA1 Message Date
Eli White b691122afc Share ArrayTypeAnnotation between components and modules (#48318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48318

These structures were the same, but the component side didn't use generics and just had duplicates. Making a base one to be shared.

I need to follow up to this and constrain the types that components allow.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D67371894

fbshipit-source-id: bb1a30fcd0efe6cc567b88bc6f11e7b385bd7c41
2025-01-02 13:20:02 -08:00
Eli White 4dac99cf6d Fix FlowFixMes in CodegenVersionDiffing (#48312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48312

I figured out how to fix these FlowFixMes

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D67313962

fbshipit-source-id: 21b109824411c1537f397aca45b7cdc2495f5e11
2024-12-17 20:23:24 -08:00
Eli White 949d229b5f Apply enum changes to new codegen version (#48000)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48000

Adding this type to CompleteTypes

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D65305755

fbshipit-source-id: 962297ba21b3b88f0117631fb4192c111e903fc6
2024-12-03 16:41:36 -08:00
Eli White fa8a25eb6b Make enum types annotation objects instead of literal strings and numbers (#47349)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47349

This is needed to be able to recurse into the literals and compare them.

I'm primarily unsure if there is a problem representing doubles/floats as numbers instead of strings though.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D65284058

fbshipit-source-id: b2de9ed5fb7f079a432c94aaea69027863879909
2024-12-02 14:32:35 -08:00
Eli White 96c2be8567 Don't store pretty printed json in schema
Summary: Changelog: [Internal]

Reviewed By: javache

Differential Revision: D66603960

fbshipit-source-id: 2d7844df76f168b99eb76bb19359ee71e953d0b2
2024-12-02 14:32:35 -08:00
Sam Zhou d86412dcc6 prepare for primitive literal changes (#47943)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47943

Changelog: [Internal]

Reviewed By: panagosg7

Differential Revision: D66461724

fbshipit-source-id: b526ed1617667b70337472f4dad4e19f152a266b
2024-11-26 00:07:32 -08:00
Alex Hunt 113337f269 Update hermes-parser and related packages in fbsource to 0.25.1 (#47573)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47573

Bump hermes-parser and related packages to [0.25.1](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D65816542

fbshipit-source-id: cb445eb77790fb2632d3bc318c6eb59f097b1518
2024-11-21 05:41:39 -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
Oskar Kwaśniewski 177bf4d043 feat: handle negative values in enums (#47452)
Summary:
This PR adds support for negative values in enums.

Currently when we try to use an enum with negative value:

```ts
enum MyEnum {
  ZERO = 0,
  POSITIVE = 1,
  NEGATIVE = -1,
}

export interface Spec extends TurboModule {
  useArg(arg: MyEnum): void;
}

export default TurboModuleRegistry.get<Spec>('Foo');
```

It will fail:

```
Enum values can not be mixed. They all must be either blank, number, or string values.
```

This is because negative values are parsed as `UnaryExpressions` which have `-` operator in front and value as argument.

With the new approach codegen properly generates enums with negative values.

## Changelog:

[GENERAL] [ADDED] - Codegen: Support negative values in enums

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

Test Plan: I've added tests to see if everything is working properly

Reviewed By: vzaidman

Differential Revision: D65887888

Pulled By: elicwhite

fbshipit-source-id: edb25f663dc58afa68c69cb84a47cfc67fc1f7e7
2024-11-13 12:20:16 -08:00
Sam Zhou f5d7df6672 Pre-suppress errors to prepare for flow typing changes
Summary: Changelog: [Internal]

Reviewed By: cyan33

Differential Revision: D65633359

fbshipit-source-id: 7aaee2cab2d61b61eb5e1317d6b4ce58b6191fb8
2024-11-08 08:39:06 -08:00
Eli White 35f0e1cca2 Fix CodegenSchema Enum type to not export array (#47324)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47324

I need to reference this type somewhere else, but not an array of the type.

Generally we prefer that all exported types are the object itself, and it used as a member type of arrays when used.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D65259014

fbshipit-source-id: 35fb5fe03a44bed61ad87337d0fc5c198744c0e9
2024-11-04 12:58:49 -08:00
Eli White dd472101b7 Add NumberLiteralTypeAnnotation support (#47323)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47323

This change adds support for number literals as a type.

The codegen already has parsing support for these types
```
  +passNumber: (arg: number) => void;
  +passString: (arg: string) => void;
  +passStringLiteral: (arg: 'A String Literal') => void;
```

This change now also supports
```
  +passNumberLiteral: (arg: 4) => void;
```

On the native side this is treated the same as `number`. It could be strengthened in the future.

This is a pre-requisite for number literal unions and enums.

Changelog: [Added] Codegen: Added support for Number literals in native module specs

Reviewed By: makovkastar

Differential Revision: D65249334

fbshipit-source-id: 98b051d2a6bd1ad5cc6473ac88acfcbe82bd5c7d
2024-11-04 12:58:49 -08:00
Eli White 3111473d57 Add test for native module returning enum (#47229)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47229

Adding a test case for an enum value in a fromNative position

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D65038107

fbshipit-source-id: ed323d9a8b226be3ff571c86fda617cabc17cdb9
2024-10-28 12:03:33 -07:00
Eli White 4c37431c7f Support new codegen schema for native modules (#47114)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47114

Export the EventEmitter annotation from the codegen

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D63995813

fbshipit-source-id: 0211c21d7813da03bf8b6680095e016a621c188b
2024-10-21 16:43:49 -07:00
Tim Yung c9ea05552f RN: Fix lint/sort-imports Errors (#47109)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47109

Fixes the `lint/sort-imports` errors that are now surfaced after fixing the lint configuration.

For a couple files, I added lint suppressions instead because the unsorted import ordering is important due to interleaved calls with side effects.

Changelog:
[Internal]

Reviewed By: GijsWeterings

Differential Revision: D64569485

fbshipit-source-id: 26415d792e2b9efe08c05d1436f723faae549882
2024-10-18 04:07:02 -07:00
Nick Gerleman 7fb3d830be Breaking: Remove BaseViewManagerInterface (#46809)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46809

BaseViewManagerInterface isn't adding much value right now. It was added in D16984121 to allow codegen generated ViewManager delegates to apply to view managers which derive from ViewMangager instead of BaseViewManager (if they did some cleverness, to make VM delegate apply to a no-op class, still implementing all of BaseViewManager's methods).

All of the cases where that was used have since been moved to `SimpleViewManager`, and `BaseViewManagerAdapter` (needed to wire this together) doesn't exist anymore, so it's not possible to take any advantage of this interface existing. We should remove it, since its existence  is a source of error (e.g. it was missing setters for `accessibilityValue` or those related to pointer events), and is more generally confusing for anyone adding to `BaseViewManager` in the future.

This is a breaking change, because there are some libraries which vendor a copy of generated ViewManagerDelegate when building against legacy arch to be able to share code normally generated at build time. That means these will need to be updated to maintain compatibility with RN versions of 0.77+ with new arch disabled. This will not effect compatibility of these libraries against the default new arch, and the updated delegate is still compatible with older RN version.

```
    sourceSets.main {
        java {
            if (!isNewArchitectureEnabled()) {
                srcDirs += [
                    "src/paper/java",
                ]
            }
        }
    }
```

1. `react-native-picker/picker`
2. `rnmapbox/maps`
3. `react-native-gesture-handler`
4. `react-native-screens`
5. `react-native-svg`
6. `react-native-safe-area-context`
7. `react-native-pdf`

Changelog:
[Android][Breaking] - Remove BaseViewManagerInterface

Reviewed By: cortinico

Differential Revision: D63819044

fbshipit-source-id: 7e4935c8e43706b168f0f599a6676e8abfa66937
2024-10-09 14:49:01 -07:00
Blake Friedman e4814b0d6d Add description to CLI arguments (#46890)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46890

Add details as this is discussed in the Turbo Native Modules documentation going out in 0.76:

```
Usage: combine-js-to-schema-cli.js <outfile> <file1> [<file2> ...]

Options:
      --help      Show help                                            [boolean]
      --version   Show version number                                  [boolean]
  -p, --platform  Platforms to generate schema for, this works on filenames:
                  <filename>[.<platform>].(js|tsx?)              [default: null]
  -e, --exclude   Regular expression to exclude files from schema generation
                                                                 [default: null]
```

## Changelog:
[General][Added] Add cli --help details to combine-js-toschema-cli.js

Reviewed By: dmytrorykun

Differential Revision: D64045337

fbshipit-source-id: a4b977da2cbb0198a5d43f17ca3466ebde21e9a9
2024-10-08 19:22:29 -07:00
Panos Vekris bed5323374 manually remove instances of '$TEMPORARY$string<>' (#46874)
Summary:
Remove instances of an unsound flow type

Changelog: [internal]

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

Reviewed By: SamChou19815

Differential Revision: D63991776

fbshipit-source-id: 1817b1287803d22195bf521e07b3027b86562f47
2024-10-07 19:18:14 -07:00
Eli White a669de1dd2 Parse string unions as StringLiteralUnionTypeAnnotation (#46845)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46845

Previously, the parser was throwing away the values of a string union when storing it in the schema. It would only store the union as

```
{
  type: 'UnionTypeAnnotation',
  memberType: 'StringTypeAnnotation'
}
```

We now track the string literals through the parser and store them in the schema:

```
{
  type: 'StringLiteralUnionTypeAnnotation',
  types: [
    {
      type: 'StringLiteralTypeAnnotation'
      value: 'light'
    },
    {
      type: 'StringLiteralTypeAnnotation'
      value: 'dark'
    },
  ],
}
```

We aren't changing the generators, those still just output "string". They could eventually be made smarter.

The value of this is that the compat checker can now error when the union changes.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D63917685

fbshipit-source-id: 34a10e1f1910d2935837a3659f66049fd4473134
2024-10-07 16:56:04 -07:00
Eli White d2f3f06826 Add support for StringLiteralTypeAnnotation (#46827)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46827

You can now define a native module that takes an argument that is a specific string literal:

Like this:
```
export interface Spec extends TurboModule {
  +passString: (arg: string) => void;
  +passStringLiteral: (arg: 'A String Literal') => void;
}
```

On the native side, this will still generate `string`, but the schema will now store the string literal, and it will be allowed in JS. This should allow more strict flow / typescript types for modules.

This will also allow the compatibility check to fail if the literal changes.

This is a step towards accepting a union of string literals.

Changelog: [General][Added] Codegen for Native Modules now supports string literals

Reviewed By: GijsWeterings

Differential Revision: D63872440

fbshipit-source-id: e54b97d34af4a3d1af51727db0777f26fb7b778c
2024-10-07 12:35:19 -07:00
Eli White 3af126b562 Add support for basic unions for native modules (#46747)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46747

You can now use unions in native modules.

Support for this pretty much existed, but one callsite was throwing for non-cpp modules which meant nobody could use this.

Previously, StructCollector would throw that this was not supported because it couldn't generate it for objc. Instead of generating something smart in the native code for each option, it just tells native to treat them like the base type (number, string, object).

Changelog: [General][Added] Codegen now supports Union Types in NativeModules

Reviewed By: GijsWeterings

Differential Revision: D63664505

fbshipit-source-id: 73278ed9cd64452173c5170aba44ced71181510f
2024-10-04 12:08:51 -07:00
Sam Zhou 94009f30e0 Update hermes-parser and related packages in fbsource to 0.24.0 (#46802)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46802

Bump hermes-parser and related packages to [0.24.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: javache

Differential Revision: D63797332

fbshipit-source-id: 98179d3cd777ff6824dfd10ceb7236a02dc6c9d6
2024-10-03 08:20:16 -07:00
Rubén Norte 4b82922ac5 Fix reported properties for native modules (#46788)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46788

Changelog: [internal]

This fixes the reported keys for C++ TurboModules:
```
import MyNativeCppModule from 'MyNativeCppModule';

Object.keys(MyNativeCppModule); // [] - expected
Object.keys(Object.getPrototypeOf(MyNativeCppModule)); // [] - NOT expected
```

Before, we were trying to read the properties from the method map in the public `TurboModule`, but in this implementation all the logic is actually in its delegate (also a `TurboModule` instance, yeah, confusing).

This fixes the issue by forwarding the call to the delegate that has the right information.

Reviewed By: javache

Differential Revision: D63761381

fbshipit-source-id: 90bd216efa0f60352c5ca341d210d83239c80dba
2024-10-02 12:25:06 -07:00
Pieter De Baets 5b5e150eaf Fix Cxx TurboModule methods not being cached (#46751)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46751

rubennorte noticed that some turbo module methods were not getting cached on the jsRepresentation as expected. This is caused by the react-native-codegen wrappers we generate overriding the `get` method and bypassing this caching layer. Instead they should be overriding `create` to lazily allocate new properties. To prevent this from re-occuring, I've made `get` final so no other overrides can happen.

## Changelog:

[General][Fixed] Properties for C++ TurboModules using codegen were not correctly cached
[General][Breaking] TurboModule::get is now a final method, override `create` to customize property lookup

Reviewed By: rubennorte

Differential Revision: D63665966

fbshipit-source-id: c614901c2f0d698147ec9ba36a4b592ed3d37652
2024-10-02 05:10:33 -07:00
Cedric van Putten 39c98fb8f8 fix(react-native-codegen): upgrade jscodeshift@17.0.0 to resolve outdated dependencies (#46724)
Summary:
This upgrades `jscodeshift` from `0.14.0` to `17.0.0`, to resolve unsupported babel dependencies when installing React Native. See https://github.com/expo/expo/issues/31613

## Changelog:

[GENERAL] [FIXED] - Upgrade Codegen dependency `jscodeshift@17.0.0` to resolve outdated dependencies

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

Test Plan:
To test it out yourself:

- `npx create-expo@latest ./test-codegen`
- `cd ./test-codegen`
- `npm why babel/plugin-proposal-nullish-coalescing-operator@7.18.6 | grep codegen` - [npm deprecation](https://www.npmjs.com/package/babel/plugin-proposal-nullish-coalescing-operator/v/7.18.6)
- `npm why babel/plugin-proposal-class-properties@7.18.6 | grep codegen` - [npm deprecation](https://www.npmjs.com/package/babel/plugin-proposal-class-properties/v/7.18.6)
- `npm why rimraf@2.6.3 | grep codegen` - [npm deprecation](https://www.npmjs.com/package/rimraf/v/2.6.3)
- `npm why babel/plugin-proposal-optional-chaining@7.21.0 | grep codegen` - [npm deprecation](https://www.npmjs.com/package/babel/plugin-proposal-optional-chaining/v/7.21.0)

> [!IMPORTANT]
> There are other dependencies that require an update, unfortunately there are no flow typings available (yet).
> - `npm why glob@7.2.3 | grep codegen` - [npm deprecation](https://www.npmjs.com/package/glob/v/7.2.3)

Reviewed By: cortinico

Differential Revision: D63629133

Pulled By: huntie

fbshipit-source-id: 3799e49677b8e5fd64841e6c7f855bde10e15072
2024-10-01 05:14:16 -07:00
Eli White 86cac68365 Promise annotations must specify their elementType (#46727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46727

It makes scripts operating on the schema complicated when the elementType might be there or might not. Let's make it required, but VoidTypeAnnotation if it's unknown.

Arguably we shouldn't allow it to be unknown at all, but that's out of scope here.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D63616703

fbshipit-source-id: 290586384b911928e55344aa522bd296f23a074c
2024-09-30 11:19:44 -07:00
Eli White ad380c011f Add test for Object with indexers (#46726)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46726

An object isn't allowed to have both an indexer and regular properties. Previously, the schema just wouldn't include the properties and would only include the indexer. Instead of failing silently and not generating the expected code, let's explicitly error out.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D63615090

fbshipit-source-id: a4c881b7a809f0b467509f7f7e2131be59ee274e
2024-09-30 11:19:44 -07:00
Eli White c658e87518 Add a test for an Alias to an Alias (#46725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46725

This covers types that deeply alias.

Changelog: [Internal]

Reviewed By: GijsWeterings

Differential Revision: D62926913

fbshipit-source-id: 2fea1900f1be2893230a949db6778c76afae0423
2024-09-30 11:19:44 -07:00
Eli White 6666df9fb8 Add a union of all the types (#46528)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46528

This is needed for a script that needs to switch over all possible type annotations in the codegen schema.

Reviewed By: GijsWeterings

Differential Revision: D62805189

fbshipit-source-id: 8fd113f4ad0b695b38e92b8d0fc45a991f597fb8
2024-09-17 13:20:04 -07:00
anirudh.bharti 7cdb87eb19 chore: replace mkdirp with mkdir fs (#46388)
Summary:
This pull request replaces the use of mkdirp with Node.js's built-in fs.mkdirSync({ recursive: true }) function, which is available in Node.js version 10.12.0 and above. This change reduces the number of external dependencies and simplifies the codebase by using the native capabilities of Node.js.

The motivation behind this change is to remove the unnecessary mkdirp dependency, as Node.js natively supports recursive directory creation since version 10.12.0. This streamlines the code and reduces the reliance on external libraries.

## Changelog:

[INTERNAL] [REMOVED] - Replaced mkdirp with fs.mkdirSync({ recursive: true }) in build scripts and codegen. Requires Node.js 10.12.0 and above.

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

Test Plan: I ran the build and codegen scripts locally with Node.js version 10.12.0 and above after replacing mkdirp, ensuring the scripts work as expected. No issues were encountered, and all processes, including directory creation and file handling, function correctly.

Reviewed By: cortinico

Differential Revision: D62852488

Pulled By: huntie

fbshipit-source-id: 76f44102a80b499521c156308d276a17d279ce38
2024-09-17 07:03:44 -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
Riccardo Cipolleschi 120558c0cd Bump main to 0.77
Summary:
This change bumps the React Native version in main to 0.77

bypass-github-export-checks

## Changelog:
[General][Changed] - Bump main to 0.77-main

## Facebook:
generated by running `js1 publish react-native 0.77.0-main`

Reviewed By: cortinico

Differential Revision: D62575939

fbshipit-source-id: 6d239fca2eed6cfe51f8c37f78d8dc8730c18b8c
2024-09-12 09:23:23 -07:00
Vitali Zaidman b37101486b update babel and fix tests accordingly (#46295)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46295

X-link: https://github.com/facebook/metro/pull/1343

Updated all **babel** packages in all `package.json` across the repo and ran `npx yarn-deduplicate yarn.lock --scopes babel`. Afterwards, fixed the following issues appearing as a result of that (squashed the following initially separate diffs to make this packages update work atomically):
### (D61336392) updated jest snapshot tests failing
### (D61336393) updated babel types and corrected typings accordingly
The latest babel 7 introduces the following features we need to adjust our types to:
* `JSXNamespacedName` is removed from valid `CallExpression` args ([PR](https://github.com/babel/babel/pull/16421))
  * `JSXNamespacedName` is used for namespaced XML properties in things like `<div namespace:name="value">`, but `fn(namespace:name)` doesn't make any sense.
* Dynamic imports are enabled behind a new flag `createImportExpressions` ([PR](https://github.com/babel/babel/pull/15682)), introducing calls such as `import(foo, options)`. These complicate the expected values passed to `import` to be more than just strings.
  * Since these are behind a flag that is not expected to be enabled, we can throw an error for now and whoever uses it can add a support to it if needed later.

### Added a new metro ENV ignore
`BROWSERSLIST_ROOT_PATH` is set to `""` explicitly in `xplat/js/BUCK`
and then ignored in
`js/tools/metro-buck-transform-worker/src/EnvVarAllowList.js`

Reviewed By: robhogan

Differential Revision: D61543660

fbshipit-source-id: abbcab72642cf6dc03eed5142eb78dbcc7f63a86
2024-09-05 07:11:17 -07:00
Eli White 84ec424e8a Remove superflous {type:string} from CodegenSchema (#46237)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46237

I can't find any uses of this, it's not referenced in any fixtures, and flow and typescript both pass without it.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D61892355

fbshipit-source-id: 8ebb4da3e104109c740d90c2495dbcc89d3978e5
2024-08-29 10:51:31 -07:00
Eli White a5363113f1 Fix NativeModuleEnumMembers type (#46222)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46222

This value was typed as always being a string, even though it  was containing both strings and numbers in the fixtures. This was because on this line https://fburl.com/code/9j7gh4av the input type is $FlowFixMe (from the source AST), which wasn't catching that it couldn't flow into just `string`.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D61830075

fbshipit-source-id: 0d5a0239d7c0209049184ca858a7ceb1ada02f79
2024-08-29 10:51:31 -07:00
Eli White 0b56ccab2a Array's with unparsable element type's are explicitly Any vs missing (#46221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46221

Previously the schema special cased unparseable elementType with elementType just being undefined. This causes issues for logic that requires recursively matching types. Instead of being implicit, this makes them explicitly an AnyTypeAnnotation

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D61825742

fbshipit-source-id: 47bf70d32d21647896d8f5319087378cc8ac8d4f
2024-08-29 10:51:31 -07:00
Eli White 851037d144 Dedupe trivial types between modules and components (#46220)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46220

We'll want to eventually combine the module and component capabilities more, but these are at least the trivially shared ones.

More work is required to merge the more complex object types.

This change also makes it more clear where capabilities are different between native modules and components

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D61740140

fbshipit-source-id: 9e7bf740cf6cd2431be8cad822ec69903dbbc71f
2024-08-26 17:34:40 -07:00
Nicola Corti 80c3aea48d Move libyoga.so and libturbomodulejsijni.so inside libreactnative.so (#46058)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46058

This moves other 2 libraries inside libreactnative.so

Changelog:
[Android] [Changed] - Move libyoga.so and libturbomodulejsijni.so inside libreactnative.so

Reviewed By: cipolleschi

Differential Revision: D61376499

fbshipit-source-id: 8780831491a5d57c4bb747fccf8a872ad30dc09e
2024-08-16 05:42:46 -07:00
Tommy Nguyen 3e084bc159 fix(react-native-codegen): scripts require yargs (#45994)
Summary:
Android fails to build in a pnpm monorepo setup because `yargs` cannot be found:

```
% yarn android
info Installing the app...

> Configure project :app
WARNING: The option setting 'android.jetifier.ignorelist=hermes-android' is experimental.
Signing config for 'release' build type not found; reusing debug config

> Task :react-native-webapis_web-storage:generateCodegenSchemaFromJavaScript FAILED
28 actionable tasks: 6 executed, 22 up-to-date

node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module 'yargs'
Require stack:
- /~/node_modules/.store/react-native-codegen-virtual-39ff8dcc54/package/lib/cli/combine/combine-js-to-schema-cli.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
```

## Changelog:

[GENERAL] [FIXED] - Fix codegen failing in a pnpm monorepo because of missing `yargs`

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

Test Plan: Tested in https://github.com/microsoft/rnx-kit/pull/3290

Reviewed By: dmytrorykun

Differential Revision: D61201420

Pulled By: cortinico

fbshipit-source-id: aac3704ae7f200db827b14c8362f83a5e66ad08e
2024-08-13 06:31:42 -07:00
Alex Hunt 115918780d Update hermes-parser and related packages in fbsource to 0.23.1 (#45782)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45782

Bump hermes-parser and related packages to [0.23.1](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

React Native specific changes: This removes all remaining syntax parsing exclude cases from `public-api-test` 🎉

Changelog: [Internal]

Differential Revision: D60375696

fbshipit-source-id: 35dbb17fe1b2b9bce7c7772e5735773ac50504e8
2024-08-07 12:41:47 -07:00
Nicola Corti 6ced6fe1b5 Move react_codegen_* + react_nativemodules_* libraries to static linking (#45639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45639

There is a circular dependency between libreactnative.so and libreact_codegen_rncore.so which I'm breaking here.

Changelog:
[Internal] [Changed] - Move react_codegen_* + react_nativemodules_* libraries to static linking

Reviewed By: cipolleschi

Differential Revision: D55799200

fbshipit-source-id: 53f814636f016a8c93f40b0456686228dfb46888
2024-07-26 07:00:32 -07:00
Nicola Corti 52de8c70f2 Move several libs from default App CMake setup to static linking (#43909)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43909

As we're moving towards a single `libreactnative.so` file, we need to remove several of our prefab targets. Here I'm cleaning up those that are not having an OnLoad.cpp file which needs to be loaded from SoLoader.

This is breaking for libraries using native dependencies via Prefab (i.e. search for `ReactAndroid::` in CMakeLists.txt files for your project).

If so, the CMakeLists.txt files should be updated as follows:

```diff
- ReactAndroid::react_render_debug
+ ReactAndroid::reactnative
```

This applies to every prefab dependencies (the example is just for `react_render_debug`

Changelog:
[General] [Breaking] - Remove several libs from default App CMake setup

Reviewed By: cipolleschi

Differential Revision: D55751683

fbshipit-source-id: 3aca7897852b5f323d60ede3c5036cae2f81e6c3
2024-07-26 07:00:32 -07:00
Alex Taylor (alta) cbdb4d78c0 Update hermes-parser and related packages in fbsource to 0.23.0 (#45504)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45504

Bump hermes-parser and related packages to [0.23.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: gkz

Differential Revision: D59881428

fbshipit-source-id: cf8d055b3a1078895fc16ec3da26981eabc22db7
2024-07-18 13:52:22 -07:00
Christoph Purrer 85dc2e393f Allow map type objects in Java/ObjC TM EventEmitter (#45271)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45271

Changelog: [Internal] Allow map type objects in Java/ObjC TM EventEmitter

Reviewed By: rshest

Differential Revision: D59360044

fbshipit-source-id: 6fce094586ed2ad55a0d83a8a83ff554e2ba000e
2024-07-05 12:37:47 -07:00
Nicola Corti c25246044f Migrate test_js to GHA (#45246)
Summary:
This migrates the `test_js` workflow to GHA

## Changelog:

[INTERNAL] - Migrate test_js to GHA

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

Test Plan: Will wait for CI

Reviewed By: javache

Differential Revision: D59270333

Pulled By: cortinico

fbshipit-source-id: e77eb9819e0819638c51e61b1e477ac04680a2f4
2024-07-02 05:17:33 -07:00
Christoph Purrer ad3df84668 Add EventEmitter Code-gen support for Java and ObjC Turbo Modules (#45119)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45119

## Changelog:

[iOS][Added] - Add EventEmitter Code-gen support for Java and ObjC Turbo Modules

Reviewed By: RSNara

Differential Revision: D58929417

fbshipit-source-id: 5208ba5ecb5882d47c3827c2aa8e3a54a3d7f2b6
2024-07-01 14:42:46 -07:00
Pieter De Baets 9d3052378a Revert D59107105: Merge newarchdefaults jni target into fabric and turbomodule targets
Differential Revision:
D59107105

Original commit changeset: fb3b25f3ce45

Original Phabricator Diff: D59107105

fbshipit-source-id: 2197d1deb79e7fc9b3ac7b0772225e13c23e0001
2024-07-01 12:47:24 -07:00
Pieter De Baets c68f35d444 Merge newarchdefaults jni target into fabric and turbomodule targets (#45207)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45207

These are their own shared library, and their own soloader-call, but they can easily be pulled into existing targets without causing excessive bloat.

Changelog: [Android][Removed] react_newarchdefaults is no longer a prefab, instead use fabricjni

Reviewed By: christophpurrer

Differential Revision: D59107105

fbshipit-source-id: fb3b25f3ce4511aa18126477f2beefe1292c6d09
2024-07-01 07:28:42 -07:00
Christoph Purrer ed5f558a6c Code-generate an optional base class to use for every NativeModule (#45113)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45113

## Changelog:

[iOS][Added] - Code-generate an optional base class to use for every NativeModule

Extend RN Code-gen to generate a NativeModule base class for each ObjC Turbo Modules.

Its usage is not mandatory now, but would become for future features to add

A practial first step would be to migrate

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.h#L157-L160

from the `protocol` to the default `interface` and then provide a default implementation for it

Reviewed By: RSNara

Differential Revision: D58907395

fbshipit-source-id: a6b0ef97a5c7f5bb0c53a4cb6fd83d2e55306953
2024-06-28 13:29:15 -07:00
Christoph Purrer 84a9f5e6c8 Add Java Turbo Module Event Emitter example (#44906)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44906

Shows a proof of concept how '*strongly typed Turbo Module scoped*' `EventEmitters` can be used in a Java Turbo Module.

## Changelog:

[Android] [Added] - Add Java Turbo Module Event Emitter example

Reviewed By: javache

Differential Revision: D57530807

fbshipit-source-id: 04261d8885760f0e3b3c8c1931e0d56a5d33a0df
2024-06-28 09:41:02 -07:00