Commit Graph

55 Commits

Author SHA1 Message Date
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
Vitali Zaidman
8fba154b66 Fix source mapping for codegenNativeCommands (#46452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/46452

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

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

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

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

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

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

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

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

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

Reviewed By: robhogan, huntie

Differential Revision: D62443699

fbshipit-source-id: 522b4382736a8fed93a1bc687a78d6885fe7c9d5
2024-09-16 05:22:38 -07:00
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
Alex Hunt
ebf1a7b79b Bump packages for next major release (#45015)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/45015

Set package versions to `0.76.0-main` (`0.75-stable` branch was cut).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D58687399

fbshipit-source-id: 27ed987e4557705845d57d64e7547cddbd982a03
2024-06-26 07:59:49 -07:00
Blake Friedman
a380ea55fb Summary: minor fix found in nightly logs from Publish NPM job (#43519)
Summary:
Minor fix to package.json which newer version of npm warn about when publishing, after running `npm pkg fix -ws` on the workspace.

{F1470070110}

## Changelog: [Internal] npm pkg fix -ws

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

Test Plan: eyescloseddog

Reviewed By: cortinico

Differential Revision: D55012872

Pulled By: blakef

fbshipit-source-id: ff3c63a3eefaf56d369219a3d4b32d44d6d842c9
2024-03-18 08:29:10 -07:00
Alex Hunt
f57be12977 Bump packages for next major release (#43132)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43132

Command run:

```
node scripts/releases/set-version 0.75.0-main --skip-react-native-version
```

Changelog: [Internal]

Reviewed By: lunaleaps, cipolleschi

Differential Revision: D54006327

fbshipit-source-id: 7afe9e7ca3020faf399fdba2221fab8a102c56c7
2024-03-04 07:54:37 -08:00
Luna Wei
b5e08e80d9 Remove * dependencies on @react-native (#42081)
Summary:
See https://github.com/facebook/react-native/issues/41929 for an issue on multiple monorepo packages being installed. The reason is that `*` resolves to whatever is tagged `latest` on npm.

We still need to fix the fact that our monorepo publish script will update the latest tag everytime we publish. For now, we should remove these from `main` and we will also update this in the 0.73 release branch.

I've left the two peer dependencies on `react-native` to keep at `*`.
```
virtualized-lists/package.json
30:    "react-native": "*"

rn-tester/package.json
32:    "react-native": "*"
```

As a peer-dependency this won't be a problem in terms of installing a second `react-native`. I thought about updating these to `nightly`, but that would install multiple nightly react-natives as the tag will be updated with each nightly release. I think for now this is fine and something we can revisit.

Things left to do
[ ] Fix monorepo publish script to not update `--latest`
[ ] Remove ^ dependencies on monorepo packages: https://github.com/facebook/react-native/pull/41958
[ ] Re-evaluate how we bump and align monorepo packages when we cut a release branch. I forget if we manually update this when we cut or if there is a script. We may want to change the script and have `main` dependencies point to some fake version like `1000.0.0` and only update these on nightly publishes. Regardless, this will need some discussion.

## Changelog:

[GENERAL] [CHANGED] - Be explicit about what monorepo versions we are using

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

Test Plan: N/A

Reviewed By: cortinico, cipolleschi

Differential Revision: D52435234

Pulled By: lunaleaps

fbshipit-source-id: 67da029d2b637e3997c12c21fe2a9ab9bc344399
2023-12-28 09:54:00 -08:00
Moti Zilberman
d6e0bc714a Enable lint/sort-imports everywhere (#41334)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41334

TSIA.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51025812

fbshipit-source-id: e10d437be775a6b80946483aa96460f34927f870
2023-11-06 12:59:38 -08:00
George Zahariev
9c135eb928 Update scripts to support AsExpressions
Summary:
Update various scripts to support AsExpressions, found by looking for scripts currently handling `TypeCastExpression`

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D50822952

fbshipit-source-id: c88c04a507d94ddbc6458a68fd36509463e91953
2023-11-02 14:09:03 -07:00
Gijs Weterings
d4ad19c969 Revert D49370200: Migrate codegen to shared build setup, remove package build pre-step from RNTester
Differential Revision:
D49370200

Original commit changeset: 992913155169

Original Phabricator Diff: D49370200

fbshipit-source-id: e8232c97c22065fb54ac940ee2351b2155eb51e0
2023-10-23 12:00:54 -07:00
Alex Hunt
4db31a3110 Migrate codegen to shared build setup, remove package build pre-step from RNTester (#39540)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39540

This simplifies the use of Codegen when creating dev builds of `rn-tester` in the monorepo. It now runs from source for this internal scenario, and this package is now built using the shared monorepo build setup.

Changes:
- Migrate `packages/react-native-codegen` to the shared `yarn build` setup.
    - Update package to use `"exports"` field and wrap entry point modules with `babel-register` (NOTE: This is only required for each entry point internally used in the monorepo).
- Fixup small Flow syntax quirks that fail under `hermes-parser`.
- Remove `BuildCodegenCLITask` task from Android build.
- Remove Codegen `build.sh` call from iOS build, use `require.resolve` for `combine-js-to-schema-cli.js` entry point.

Externally significant FYIs:
- `react-native/codegen` is converted to use the `"exports"` field — it should export all `.js` files, as before.
- `codegenPath` is now ignored and marked as deprecated on `ReactExtensions.kt`.

NOTE: TypeScript auto-generation is not yet enabled on this package, since it uses CommonJS `module.exports` syntax (unsupported by `flow-api-translator`).

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D49370200

fbshipit-source-id: 992913155169912ea1a3cb24cb26efbd3f783058
2023-10-23 08:32:33 -07:00
Dmitry Rykun
02957718d7 SVC Codegen: Handle TSAsExpression when looking for the codegen declaration (#40860)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/40860

This diff adds support for the `AS` expression in TS sources. The following codegen declaration should work now:
```
export default codegenNativeComponent<NativeProps>(
  'MyComponentView',
) as HostComponent<NativeProps>;
```
Changelog: [General][Added] - Handle TSAsExpression when looking for the codegen declaration

Reviewed By: shwanton

Differential Revision: D50225241

fbshipit-source-id: 247a3d341d742b548e82318d0fa21dff9884d2bd
2023-10-12 11:24:16 -07:00
Alex Hunt
f40bb9331c Bump package versions for next major (#39764)
Summary:
#publish-packages-to-npm

Bump all package versions to `0.74.0` (next major release) for `main`, following instructions at https://reactnative.dev/contributing/release-branch-cut-and-rc0#12-bump-minor-version-of-all-monorepo-packages-in-main.

```sh
yarn bump-all-updated-packages --release-branch-cutoff
```

Changelog: [Internal]

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

Test Plan: —

Reviewed By: robhogan

Differential Revision: D49871039

Pulled By: huntie

fbshipit-source-id: f4df6efeae4d8a9209e7aae7b9e6fea3d15793b5
2023-10-11 08:36:23 -07:00
Arushi Kesarwani
2eb25cbdbe Update Node.js to v18 in all RN packages (#37791)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37791

## Bump minimum Node JS version to 18 via `react-native/package.json#engines`

In https://github.com/facebook/react-native/pull/35443 we bumped up the node version from 16 to 18.

Node 16 [ends maintenance releases on 2023-09-11](https://nodejs.org/en/blog/announcements/nodejs16-eol/), and bumping this minimum will allow other associated Node JS tools (CLI, Metro, Jest) to reduce their support burden.

This follows up by formally making Node 18 the minimum supported version.

**Docs PR:**
https://github.com/facebook/react-native-website/pull/3748

**Changelog:**
[General][Breaking] Bump minimum Node JS version to 18

Reviewed By: cortinico, NickGerleman

Differential Revision: D46583997

fbshipit-source-id: 1f31e2f205ac8b09494c2a7d3b73b9f36eff221b
2023-06-22 09:53:21 -07:00
Pranav Yadav
14316bd635 Add missing READMEs & Update package.json in all RN packages (#37090)
Summary:
This diff adds _missing_ README files for all public RN packages.

#### Changes:
For all public RN packages:
- Add _Missing_ READMEs

Update package.json in all RN packages to add:
- Issues, Bugs urls
- Keywords and Homepage urls to respective pkgs

## Changelog:

[GENERAL][ADDED] - Add missing README files for all public RN packages.
[GENERAL][CHANGED] - Update package.json in all RN packages to add required fields.

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

Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_

Reviewed By: cortinico

Differential Revision: D45390861

Pulled By: hoxyq

fbshipit-source-id: 524a92de56a7cb553573d9f54ccf40a998dfd35f
2023-04-28 04:26:20 -07:00
Pranav Yadav
a58dea1e9e Update Node.js to v16 in all RN packages (#37073)
Summary:
**NOTE**: This is a **BREAKING** change.
TLDR; Enforce minimum Node.js v16 in all RN packages.

This diff **Updates Node.js to v16** across all RN packages.

#### Context:

- For RN development and new project created; bump to node 16 was in https://github.com/facebook/react-native/pull/36217
- Recently `react-native-windows` also; updated node to v16, https://github.com/microsoft/react-native-windows/pull/11500

#### Changes:

- [BREAKING] Update Node.js to v16 across all RN packages under 'packages/' dir

## Changelog:

[GENERAL][BREAKING] - Update Node.js to v16 in all RN packages

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

Test Plan: - `yarn lint && yarn flow && yarn test-ci` --> _should be green_

Reviewed By: cipolleschi

Differential Revision: D45306108

Pulled By: jacdebug

fbshipit-source-id: e3ba7d0151b86a6a0a3d63fb29c2bd887e1ac1e7
2023-04-26 08:24:06 -07:00
Nicola Corti
50553f4e81
Re-sync repo after ShipIt change - Removal of BUCK files (#36955) 2023-04-19 12:12:04 +01:00
Ruslan Lesiutin
8a18b53bcd bump packages for 0.73 (#36556)
Summary:
Changelog: [Internal]

Publishing to check CI if bumping and aligning in the same commit will work, since these new versions are not available on npm yet, but maybe our new monorepo setup will resolve this

**Adding back `react-native/virtualized-lists` as a workspace to `xplat/js` so that it won't be resolved from npm**

#publish-packages-to-npm

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

Reviewed By: cipolleschi

Differential Revision: D44255353

Pulled By: hoxyq

fbshipit-source-id: 21372487d6e9c0b2382b7cd9af835beed46b8ce1
2023-03-30 15:55:58 -07:00
Nicola Corti
b0863e1239 Bumping all the changes we have on main (#36355)
Summary:
This will publish several changes we have pending on main, specifically changes to React Native Gradle Plugin which are needed to unblock nightlies.

#publish-packages-to-npm

## Changelog

[INTERNAL] - Bumping all the changes we have on main

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

Test Plan: n/a

Reviewed By: hoxyq

Differential Revision: D43733634

Pulled By: cortinico

fbshipit-source-id: 9c041f7557cd8e494dfc942ae89e13e55353bb48
2023-03-02 07:11:43 -08:00
Luna Wei
d504fb4145 Revert ESM imports
Summary:
Changelog: [Internal] - Remove all imports back to CJS for changelog in 0.72

We are reverting these imports as it may regress perf as we don't have a recommended inlining solution for ES modules at the current time.

Reviewed By: NickGerleman

Differential Revision: D43630911

fbshipit-source-id: ff3bb80009f327c4d51dad21f2cd287ce46d5964
2023-02-28 10:23:36 -08:00
Nicola Corti
e42dd1593d bump package versions (#36184)
Summary:
We do have a lot of changes on `main` to ship to nightlies. This change bump all the packages with pending changes.

## Changelog

[INTERNAL] [CHANGED] - [ci][monorepo] bump package versions

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

Test Plan: Will rely on CI run.

Reviewed By: hoxyq

Differential Revision: D43363981

Pulled By: cortinico

fbshipit-source-id: eba5152dbe007eb3fad43f9088d145b3741fd94e
2023-02-17 06:19:37 -08:00
MaeIg
462815001b Extract parseString and parseModuleFixture functions in typescript and flow parsers (#35928)
Summary:
This PR aims to extract parseString and parseModuleFixture functions into the typescript and flow parsers. This task was proposed in https://github.com/facebook/react-native/issues/35158 and helps https://github.com/facebook/react-native/issues/34872.

## Changelog

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

Pick one each for the category and type tags:

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

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Extract parseString and parseModuleFixture functions in typescript and flow parsers

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

Test Plan:
yarn test:
<img width="386" alt="image" src="https://user-images.githubusercontent.com/40902940/213889984-f0cadaff-4472-42d6-b55b-4901023aad1e.png">

yarn flow:
<img width="166" alt="image" src="https://user-images.githubusercontent.com/40902940/213889974-21ac2483-2731-4cb1-a2b5-195d98619649.png">

yarn lint:
<img width="514" alt="image" src="https://user-images.githubusercontent.com/40902940/213889980-090af354-346f-4a9c-90bc-7006899f0819.png">

Reviewed By: jacdebug

Differential Revision: D42673866

Pulled By: cipolleschi

fbshipit-source-id: f1b5f8a7b3944e7e8223b25c0fb9bf4e8b512aa7
2023-01-25 12:38:52 -08:00
Luna Wei
0aece02cb0 ESM requireNativeComponent
Summary: Changelog: [General][Changed] - ESM requireNativeComponent

Reviewed By: yungsters

Differential Revision: D42200329

fbshipit-source-id: f1120f06362dc25e48551b3f2421bbda7b68c571
2023-01-03 18:09:06 -08:00
Nicola Corti
3ab6274f0d Bump further patch packages to unblock nightly as they have unreleased changes on main
Summary:
There are other 3 packages which have unreleased changes on main:
```
babel-plugin-codegen/
eslint-plugin-specs/
eslint-config-react-native-community/
```
I'm bumping them in order to be able to publish them to NPM.

Changelog:
[Internal] [Changed] - Bump further patch packages to unblock nightly as they have unreleased changes on main

Reviewed By: hoxyq

Differential Revision: D41874749

fbshipit-source-id: 0b8cd69cab6fcb116f2635c964490927f4fb20be
2022-12-10 04:03:11 -08:00
Rob Hogan
3e19c97646 Bump remaining build-time Babel deps
Summary:
Update `babel/*` dependencies specifying `^7.x.y` where `x > 0` to the latest available semver minor, and corresponding superficial snapshot updates reflecting a small decrease in JS bundle size.

 - `babel/core` to `^7.20.0`
 - `babel/parser` to `^7.20.0`
 - `babel/preset-env` to `^7.20.0`
 - `babel/traverse` to `^7.20.0`
 - `babel/cli` to `^7.19.0`
 - `babel/eslint-parser` to `^7.19.0`
 - `babel/preset-flow` to `^7.18.0`
 - `babel/preset-syntax-flow` to `^7.18.0`
 - Deduplicate / refresh others to take in patch updates

Changelog: [Internal] Bump Babel dependencies to latest 7.x

Reviewed By: JoeyMou

Differential Revision: D41449678

fbshipit-source-id: f04fe837a7961c4e2dde45fed59fcd138c2f8723
2022-11-30 19:16:23 -08:00
Rob Hogan
16343f5e1b Update @babel/generator to ^7.20.0, update snapshots (whitespace changes)
Summary:
Update `babel/generator` to the latest, which is a semver-minor update within the pre-existing range.

I'm separating this out for ease of review because it brings some noisy snapshot changes, including more granular source maps and fewer empty lines in generated output. The majority of this is a result of https://github.com/babel/babel/pull/14980 (`>=7.19.4`).

This and the previous diff clear the way for a general Babel update, which is currently blocking a perf-boosting Metro PR https://github.com/facebook/metro/pull/854.

Changelog: [Internal] Bump `babel/generator dependency` to `^7.20.0`

Reviewed By: motiz88

Differential Revision: D41438635

fbshipit-source-id: d56853169be22a2197ad53d6320ec6c1faf6b2a7
2022-11-29 13:25:48 -08:00
shivenmian
b7a85b59b5 chore: renamed react-native-codegen to @react-native/codegen (#34804)
Summary:
Renamed react-native-codegen package to react-native/codegen and updated references, without changing the folder name; part of RFC480 (https://github.com/facebook/react-native/issues/34692). Follow-up from https://github.com/facebook/react-native/pull/34578

## Changelog

[General] [Changed] - Renamed react-native-codegen package to react-native/codegen and updated references

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Reviewed By: cortinico

Differential Revision: D39883584

Pulled By: hoxyq

fbshipit-source-id: 0ef384b75c6edd248b31e37b8f05f64b4d39ca6f
2022-11-28 08:28:51 -08:00
Dmitry Rykun
d62b0b463b Bump dependency versions to 0.72.0 after the branch cut
Summary:
Changelog
[General][Changed] - Bump dependency versions to 0.72.0 after the branch cut.

Reviewed By: cipolleschi

Differential Revision: D41079762

fbshipit-source-id: 83e912c4eaf969c1673ccc5fa854646efa99fa4a
2022-11-07 06:57:35 -08:00
Dmitry Rykun
8183aac0b1 Bump dependency versions before the branch cut 0.71.0
Summary: Changelog: [General][Changed] - Bump dependency versions.

Reviewed By: cipolleschi

Differential Revision: D40991336

fbshipit-source-id: 71c8edbeb274d095403b2f17e60f217d16fe01c0
2022-11-03 17:28:26 -07:00
Tim Yung
908571de2f RN: Fix Existing Lint Warnings
Summary:
Fixes all existing lint warnings in React Native.

Changelog:
[Internal]

Reviewed By: christophpurrer

Differential Revision: D39831224

fbshipit-source-id: 6ad3fc3fc7dbb9c24cdb4ff4a99639bad27c1901
2022-09-27 09:22:58 -07:00
Rujin Cao
b2ac528156 @emails -> @oncall (remaining ones)
Differential Revision: D39536169

fbshipit-source-id: 6c8d6787328eefecd23f3498b14a6d9ff750a670
2022-09-15 15:54:10 -07:00
Rubén Norte
4d04b1d4c8 Remove last direct references to utilities in Paper from react-native
Summary:
Changelog: [internal]

This replaces all direct references to the `ReactNative` module (which is the Paper renderer) to `RendererProxy` which would select between Paper and Fabric correctly.

The implementation of these functions is exactly the same right now.

As per the removal of the fix for T55744311 in `ScrollView`, I verified this doesn't cause any issues in the screen where it failed before.

Reviewed By: javache

Differential Revision: D39270691

fbshipit-source-id: 03882748fe4b754b9a2c5e9d4c4f003b94ed49ef
2022-09-08 11:12:06 -07:00
Ramanpreet Nara
4f6929bb3c Bump @react-native/babel-plugin-codegen to v0.71.0
Summary:
## Change
This align react-native/babel-plugin-codegen version to RN version: 0.71.0

## Motivation
We just introduced TypeScript support in this babel plugin via D39136171 (df0b6900ec). This version bump will allow us to enable the static ViewConfig codegen in TypeScript React Native libraries, like React Native SVG. See PR: https://github.com/react-native-svg/react-native-svg/pull/1847

Changelog: [General] Bump react-native/babel-plugin-codegen to v0.71.0

Created from CodeHub with https://fburl.com/edit-in-codehub

Reviewed By: cortinico

Differential Revision: D39172735

fbshipit-source-id: 1d1b2c073dd6d76160979ac3c281e85f6eb4c87a
2022-09-07 04:12:38 -07:00
Ramanpreet Nara
df0b6900ec Enable SVC codegen in TypeScript Spec files
Summary:
## Context
babel-plugin-codegen:
1. Looks at HostComponent spec files (i.e: *NativeComponent.js files).
2. It runs the Static ViewConfig codegen (i.e: GenerateViewConfigJs.js)
3. It replaces codegenNativeComponent with NativeComponentRegistry.get.

**Before**

[react-native-svg/src/fabric/CircleNativeComponent.ts](https://github.com/react-native-svg/react-native-svg/pull/1847/files#diff-676990c4b50b85e2530021bed11f83744fb646c8ffcc769fd5d982eac1b97e98R9-R55)
```
interface SvgNodeCommonProps {
  name?: string;
  opacity?: WithDefault<Float, 1.0>;
  matrix?: ReadonlyArray<Float>;
  // transform?: ____TransformStyle_Internal, // CATransform3D, custom handling
  mask?: string;
  markerStart?: string;
  markerMid?: string;
  markerEnd?: string;
  clipPath?: string;
  clipRule?: WithDefault<Int32, 0>;
  responsible?: boolean;
  display?: string;
}

type ColorStruct = Readonly<{
  type?: WithDefault<Int32, -1>;
  value?: ColorValue;
  brushRef?: string;
}>;

interface SvgRenderableCommonProps {
  fill?: ColorStruct;
  fillOpacity?: WithDefault<Float, 1.0>;
  fillRule?: WithDefault<Int32, 1>;
  stroke?: ColorStruct;
  strokeOpacity?: WithDefault<Float, 1.0>;
  strokeWidth?: WithDefault<string, '1'>;
  strokeLinecap?: WithDefault<Int32, 0>;
  strokeLinejoin?: WithDefault<Int32, 0>;
  strokeDasharray?: ReadonlyArray<string>;
  strokeDashoffset?: Float;
  strokeMiterlimit?: Float;
  vectorEffect?: WithDefault<Int32, 0>;
  propList?: ReadonlyArray<string>;
}

interface NativeProps
  extends ViewProps,
    SvgNodeCommonProps,
    SvgRenderableCommonProps {
  cx?: string;
  cy?: string;
  r?: string;
}

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

**After**
```
var __INTERNAL_VIEW_CONFIG = {
  uiViewClassName: "RNSVGCircle",
  validAttributes: {
    name: true,
    opacity: true,
    matrix: true,
    mask: true,
    markerStart: true,
    markerMid: true,
    markerEnd: true,
    clipPath: true,
    clipRule: true,
    responsible: true,
    display: true,
    fill: true,
    fillOpacity: true,
    fillRule: true,
    stroke: true,
    strokeOpacity: true,
    strokeWidth: true,
    strokeLinecap: true,
    strokeLinejoin: true,
    strokeDasharray: true,
    strokeDashoffset: true,
    strokeMiterlimit: true,
    vectorEffect: true,
    propList: true,
    cx: true,
    cy: true,
    r: true,
  },
};
exports.__INTERNAL_VIEW_CONFIG = __INTERNAL_VIEW_CONFIG;
var _default = NativeComponentRegistry.get(nativeComponentName, function () {
  return __INTERNAL_VIEW_CONFIG;
});
exports.default = _default;

```

## Changes
This babel plugin only worked with Flow HostComponent spec files. After this change, it'll start to work with TypeScript files as well.

## Motivation
Once published, this update will allow us to make react-native-svg static ViewConfigs-compatible.

For usage, see this GitHub commit: [feat: try to add babel plugin](80fe687747)

Changelog: [General][Added] Make babel-plugin-codegen work for TypeScript Spec files

Reviewed By: cipolleschi

Differential Revision: D39136171

fbshipit-source-id: d89d35b591577e7626ce46a9c8e73b4d7ac7f227
2022-08-30 15:15:31 -07:00
Janic Duplessis
ae756647c9 Fix babel-plugin-codegen crash when export init is null (#33387)
Summary:
It is possible that `init` is null when using the following code.

```js
export var a;
```

The typescript compiler actually generates something like this for enums so a lot of third party libraries triggered this issue.

For example in expo-apple-authentication/build/AppleAuthentication.types.js

```js
export var AppleAuthenticationScope;
(function (AppleAuthenticationScope) {
    AppleAuthenticationScope[AppleAuthenticationScope["FULL_NAME"] = 0] = "FULL_NAME";
    AppleAuthenticationScope[AppleAuthenticationScope["EMAIL"] = 1] = "EMAIL";
})(AppleAuthenticationScope || (AppleAuthenticationScope = {}));
```

This simply adds a null check.

## Changelog

[General] [Fixed] - Fix babel-plugin-codegen crash when export init is null

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

Test Plan: Tested that this fixed the crash in an app.

Reviewed By: javache

Differential Revision: D34687271

Pulled By: philIip

fbshipit-source-id: 7a7e0fe1bb6a7a21a5b442af26b221a263d4173d
2022-03-11 23:24:22 -08:00
Ramanpreet Nara
971ba5c26b Re-introduce {eventName}: true ViewConfig ValidAttributes in Static ViewConfigs
Summary:
# Problem
I removed the {eventName}: true entries from ViewConfigs validAttributes in D33303950 (ca5aaa7663). These entries were iOS-only. I removed them to achieve platform-consistency in native ViewConfigs.

This change broke the onLayout event for all React Native components. So, I reverted D33303950 (ca5aaa7663) for native ViewConfigs server-side. But I never got around to reverting D33303950 (ca5aaa7663) for static ViewConfigs.

# Changes
This diff reverts D33303950 (ca5aaa7663) for Static ViewConfigs, with server-side gating.

Now, these {eventName}: true ViewConfig validAttribute will be inserted into all view configs (static and native) **by default**.

Calling RCTDisableViewConfigEventValidAttributes(YES) on iOS will remove {eventName}: true ViewConfig ValidAttributes entries from Static ViewConfigs. (Previously, this method only removed the entries from native ViewConfigs).

https://www.internalfb.com/code/fbsource/[6615b0675bdf]/fbobjc/Apps/Wilde/FBReactModule2/FBReactModuleAPI/FBReactModuleAPI/Exported/FBReactModule.mm?lines=344

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D33933403

fbshipit-source-id: 17823ed99f97d7851f04e5cdab9c95667df13253
2022-02-08 19:11:08 -08:00
Paige Sun
63605323b0 2/4 Fix RNHostListComponentListRoute to validate SVCs with NVCs
Summary: Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D33715385

fbshipit-source-id: d8d31e92dd934648f8431a508a78e2813c462f8f
2022-01-25 15:23:46 -08:00
Ramanpreet Nara
ca5aaa7663 Remove {eventName}: true from ViewConfig validAttributes
Summary:
For every direct and bubbling event, RCTComponentData (iOS-only) creates a {eventName}: true entry in the component's ViewConfig validAttributes. This entry is unnecessary, and creates a discrepancy between ViewConfigs on iOS vs Android.

This diff removes this entry for all events to:
1. Reduce bloat in native ViewConfigs
2. Create consistency betweeen Android and iOS.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D33303950

fbshipit-source-id: 870c8a2a6d41156ac89bd8554eb09f292bb6108e
2022-01-06 19:09:53 -08:00
Andres Suarez
8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Sota Ogo
2098c89502 Add babel-plugin-codegen to babel.config.js for fabric (#32756)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32756

Changelog: [internal] Add babel-plugin-codegen to babel.config.js for the new architecture support.

Reviewed By: motiz88

Differential Revision: D33053216

fbshipit-source-id: 97a1fd9c64972ac4831461b1b62d3a83aa3207cb
2021-12-14 19:28:41 -08:00
Sota Ogo
09b69036c0 Fallback to use lib when src doesn't exist.
Summary:
Changelog: [Internal] babel-plugin-codegen.js to fallback to use lib instead of src.

The bubel plugin uses react-native-codegen/src but it's not compatible when react-native-codegen is installed as a separate dependency (which is the case for OSS).

Reviewed By: cortinico

Differential Revision: D32908846

fbshipit-source-id: 1d3e3a3485e94e2f051e220d76dd2dbcdd8070a8
2021-12-07 12:34:50 -08:00
Tim Yung
77ecc7ede1 JS: Format with Prettier v2.4.1 [3/n]
Summary:
Changelog:
[General][Internal]

Reviewed By: zertosh

Differential Revision: D31883447

fbshipit-source-id: cbbf85e4bf935096d242336f41bf0cc5d6f92359
2021-11-02 22:14:16 -07:00
Moti Zilberman
268efb1022 Use deep require instead of Haste for NativeComponentRegistry
Summary:
Changelog: [Internal]

Some environments that use codegen don't have Haste enabled, breaking the `require('NativeComponentRegistry')` call in generated view configs. Here we change it to reference an explicit path relative to `react-native`.

Reviewed By: JoshuaGross

Differential Revision: D31166063

fbshipit-source-id: cebc23d0d95b5cde76d0f8473eabc03ca82a862e
2021-09-27 13:47:28 -07:00
Moti Zilberman
8db946ade8 Pass configFile: false to Babel parser
Summary:
Changelog: [Internal]

Disables implicit `babel.config.js` lookup in a `parse()` call that does not need any user-specified config.

Reviewed By: javache

Differential Revision: D30396331

fbshipit-source-id: 9b07c361eae53cdffc6a76ba30f1146a7af65a10
2021-08-19 07:03:41 -07:00
Micha Reiser
58a0f9b4e2 Upgrade babel from 7.12.3 -> 7.14.1
Summary:
Changelog:

[General] [Changed] Upgrade Babel from 7.12.3 to 7.14.1

Reviewed By: motiz88

Differential Revision: D27851184

fbshipit-source-id: 59326332d1d188f163cdb034556eea7808824360
2021-05-13 02:48:09 -07:00
Ramanpreet Nara
daefa526ad Clean up babel-plugin-codegen snapshot tests
Summary:
Forgot to delete these snapshot tests in D25915169 (e67fc7cada). They are no longer necessary, because we're deleting the JS TurboModule codegen.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D25920310

fbshipit-source-id: 66f6fa3fcba5b53210798a204e4f76e4595b3f25
2021-01-15 11:59:38 -08:00
Ramanpreet Nara
e67fc7cada Stop inlining the TurboModule schema in NativeModule specs
Summary:
See title.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D25915169

fbshipit-source-id: 9a5ab08b11fb0d5e9eb47b4a4c579dcff1e60e92
2021-01-14 19:14:23 -08:00
Danny van Velzen
fc1ddb6128 Fix typo of TurobModule to TurboModule (#30723)
Summary:
Fix typo in a code comment of babel codegen: TurobModule -> TurboModule
This was discovered in the PR [https://github.com/facebook/react-native/issues/6832](https://github.com/microsoft/react-native-windows/pull/6832) when [microsoft/react-native-windows](https://github.com/microsoft/react-native-windows) ingested latest react-native bits..

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Fixed] - Fix a typo in a code comment.

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

Test Plan: None, change is in a comment and most of the scripts like lint-ci don't work on windows.

Reviewed By: shergin

Differential Revision: D25884872

Pulled By: sammy-SC

fbshipit-source-id: 49dfc25d220aa9bc4f7de61c664837b193ae25e5
2021-01-13 08:22:40 -08:00
Evan Gilbert
f52e3b3e8b Workaround for react-native-web failing to build
Summary:
There is partially compiled TurboModule code in [NativeAnimatedModule](https://fburl.com/diffusion/g91a70ng) that fails to build with:
`"File neither contains a module declaration, nor a component declaration. For module declarations, please make sure your file has an InterfaceDeclaration extending TurboModule. For component declarations, please make sure your file has a default export calling the codegenNativeComponent<Props>(...) macro"`

This diff removes react-native-web from the TurboModules logic while we work on a cleaner solution, tracked in T80868008

msdkland[metro]
Changelog: [Internal]

Reviewed By: cpojer, RSNara

Differential Revision: D25325163

fbshipit-source-id: 346abf52660073f976b0f978cbfbfc8402f4b3ee
2020-12-08 17:45:28 -08:00