Граф коммитов

21338 Коммитов

Автор SHA1 Сообщение Дата
Tomoaki Imai 53f55001af Fix App Bundle/Release build missing index.android.bundle with gradle plugin 4.1.0+/gradle 6.5 (#30177)
Summary:
- This fix resolves https://github.com/facebook/react-native/issues/29398
- After updating gradle to 6.5+ and android gradle plugin to 4.1.0+(which is recommended in the latest Android Studio 4.1), Running `:app:assembleRelease` or `:app:bundleRelease` will not contain `index.android.bundle` in Apk/AAB. It will be included when the command executed twice.
<img width="949" alt="Screen Shot 2020-10-17 at 11 32 43 PM" src="https://user-images.githubusercontent.com/6277118/96360808-38165c00-10d5-11eb-8b6e-f098517a24c7.png">

- This is caused by the task ordering update introduced in gradle plugin 4.1.0+/gradle 6.5. `mergeResources` task runs before `currentAssetsCopyTask`(copying the bundle asset file to intermediate output directory) which causes generated Apk/AAB not including the bundle file.
- The fix ensures mergeResources task runs after currentAssetsCopyTask

## Changelog

[Android] [Fixed] - Fix App Bundle/Release build missing index.android.bundle with gradle plugin 4.1.0/gradle 6.5

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

Test Plan:
- Reproducible repository https://github.com/tomoima525/android_build_test_rn
  -  This project is generated with `create-react-native-app` and updated Gradle version to 6.5 and com.android.tools.build:gradle plugin to 4.1
- Run `./gradlew clean :app:assembleRelease` and `./gradlew clean :app:bundleRelease` => reproduces the issue
- After adding the fix above and run `./gradlew clean :app:assembleRelease` and `./gradlew clean :app:bundleRelease` => The issue is resolved

- Also confirmed the build works properly with android gradle plugin `3.5.3` and `gradle 6.2`(the default value of `create-react-native-app`)

Reviewed By: fkgozali

Differential Revision: D24551605

Pulled By: cpojer

fbshipit-source-id: b0effe2c6ea682748af185061af951e2f2bce722
2020-10-26 16:06:33 -07:00
Samuel Susla 41c788a2b4 Make sure opacity and transform are applied in native animation
Summary:
Changelog: [internal]

Problem:

`props.transform` gets out of sync with `self.layer.transform`.

To avoid writing out value of transform matrix, in the follow example I will only consider identity matrix and non-identity matrix. It is sufficient to demonstrate the point.

1. View is reused with transform being something besides identity. This causes `props.transform` and `self.layer.transform` to be non-identity.
2. View is taken from pool and animated with transform set to non-identity.
3. React JS props arrive and set `view.props` to identity but `self.layer.transform` stays unchanged because it is managed by native animation. This is the point where `props.transform` and `self.layer.transform` get out of sync.
4. Native animation wants to set transform to identity to finish the animation. But inside `[RCTViewComponentView updateProps:oldProps:]` `self.layer.transform` does not get set because current `view.props` is already identity.

Solution:
After native animation layer calls `[RCTViewComponentView updateProps:oldProps:]`, verify that values were set. If they weren't, set them directly without depending on `[RCTViewComponentView updateProps:oldProps:]`.

Reviewed By: JoshuaGross

Differential Revision: D24538442

fbshipit-source-id: ba8c59c5c9bb751306118bd1c7f0ccd9d0fb7fba
2020-10-26 15:39:24 -07:00
Joshua Gross 4b58038515 Log stack trace when unmountReactApplication is called in Fabric
Summary:
Sometimes stopSurface crashes when unmountReactApplication is called under Fabric; knowing the stack trace up to this point might assist in debugging.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D24532027

fbshipit-source-id: f350e77fb1a2de52eb146b449f1d2f6e960fa017
2020-10-26 12:33:31 -07:00
Héctor Ramos 6f78e16c01 iOS: Build react-native-codegen as part of RNTester pod install
Summary:
Ensure the react-native-codegen package is built before the codegen is invoked during RNTester's pod install.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24515852

fbshipit-source-id: eeb1237f601d83a79a5274261c374bb5fc5689eb
2020-10-26 11:31:08 -07:00
Samuel Susla 6b16f2e7a7 Add throttling mechanism to background executor
Summary:
Changelog: [internal]

Background executor performs unnecessary operations when second `completeRoot` message from React arrives before first `completeRoot` was finished. This produces unnecessary `ShadowViewMutations`.

Mechanism:
Everytime `completeRoot` is received, before the call is dispatched on the background queue, `completeRootEventCounter_DO_NOT_USE_` is incremented.
Inside `ShadowTree::tryCommit` we check if the value has been incremented to determine if another `completeRoot` is queued.

Reviewed By: JoshuaGross

Differential Revision: D24419160

fbshipit-source-id: 11e19026feca01db6c8981b093a691a6b58a006f
2020-10-26 05:04:53 -07:00
Kevin Gozali 2a634f452c Codegen BUCK: moved generate-test.sh to be general-purpose generate-all CLI
Summary:
This moves the test script that generates **all outputs using all generators** to a dedicated "generate-all" CLI. This allows us to use it via Buck, at FB and OSS.
Also renamed the target to be more specific: "rn_codegen" => "generate_all_from_schema"

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24513995

fbshipit-source-id: 8435d3d065718eb1309c1c61fe28fb592787311a
2020-10-24 14:02:47 -07:00
Samuel Susla e75a0dc265 Force scroll event inside scrollViewDidEndScrollingAnimation and scrollTo
Summary:
Changelog: [internal]

`onScroll` event needs to be fired when scroll view ends the scrolling animation and when scrollTo is called.
This is how Paper does it and client code might depend on it.

Reviewed By: JoshuaGross

Differential Revision: D24527189

fbshipit-source-id: bdec099f16b3d8c97686975a1f769db4d2c0d832
2020-10-24 12:02:08 -07:00
Samuel Susla 1d1cbc93c2 Prevent ScrollTo view command from scrolling outside of content view
Summary:
Changelog: [internal]

ScrollTo command needs to clamp the value in order to not scroll out of content view of scroll view. Paper does the same thing.

Reviewed By: JoshuaGross

Differential Revision: D24526992

fbshipit-source-id: 47c48ecb01f4ae40791306016dd7847079263128
2020-10-24 12:02:07 -07:00
Joshua Gross 46eb3ec474 Disable `childrenDrawingOrder` of ReactViewGroup in Fabric
Summary:
Fabric should be inserting Views into the hierarchy in the correct order based on z-index already, so there should be no reason to enable this mechanism.

At best it's a perf pessimisation and at worst it could be causing consistency issues or crashing (TBD). Most likely this is a noop.

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24512203

fbshipit-source-id: b9336240ef8506742bcbd8d08fc8b830f82cdfe2
2020-10-24 07:22:16 -07:00
Ramanpreet Nara a68754f9b2 Disallow non-string literals in TurboModuleRegistry calls
Summary:
Our NativeModule spec parser parses the TurboModuleRegistry.get<Spec>(...) calls to figure out what the name of the NativeModule is. The parser assumes the argument is a string literal. Therefore, we should lint to validate this case.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24500412

fbshipit-source-id: 5aa5e9255db5a2e0cd86d6dd96e6787caa673fc4
2020-10-24 03:45:03 -07:00
Ramanpreet Nara 008596d42f Disallow more than one TurboModuleRegistry calls in NativeModule specs
Summary:
TurboModule specs should have exactly one TurboModuleRegistry.get or TurboModuleRegistry.getEnforcing call. When a JS file contains more than one call into TurboModuleRegistry, this lint rule will report an error on all calls.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24499286

fbshipit-source-id: 2c47185165a2a81c4b7b7ad9a7b8458e9aa8c018
2020-10-24 03:45:03 -07:00
Ramanpreet Nara ad5802cf91 Make RN Modules ESLint rule call into NativeModule spec parser
Summary:
This diff guts the React Native Modules ESLint rule, and makes it instead call into the NativeModule spec parser. After calling into the parser, the lint rule loops over all collected errors, and reports them.

## Benefits
- There is now one source of truth of what is a "correct" NativeModule spec: The NativeModule spec parser.
- Every change we make to the NativeModule spec parser will reflect in the lint rule. We have a number of changes planned for the NativeModule parser that will change what it means for a NativeModule spec to be correct. These changes now won't have to be duplicated in the ESLint rule.
- The linter will *never* show any false positive errors. If there's an error in the linter, you *need* to fix it. Otherwise, the codegen *will* fail. This is huge. Previously, people were used to ignoring the linter, because it over-reported errors. This behavior won't slide after this stack lands.

NOTE: This will run the NativeModules parser on all our NativeModule specs. We may have to check the specs, or the parser. Therefore, this could take some time to land.

## How does the lint rule work now?
In every JavaScript file, the ESLint rule looks for `CallExpression` AST Nodes. Once it detects a `CallExpression` that corresponds to a `TurboModuleRegistry.get` or `TurboModuleRegistry.getEnforcing`  it:
  1. Marks the file as a TurboModule spec
  2. Validates the `CallExpression` to verify that it is called with the <Spec> type parameters (i.e: like this: TurboModuleRegistry.get<Spec>(...)).

When we're done the visition for the JavaScript file (i.e: in `Program:exit`), if the JavaScript file was a TurboModule spec:
1. Report a lint error if the filename doesn't start with Native.
2. We parse the source using flow-parser, and run the NativeModule spec parser on it. We capture all ParserErrors and report them via ESLint.

## When can I start using this lint rule in VSCode?
I made the ESLint VSCode plugin use flow-node in D24454702. It'll take 3-4 weeks for this change to be shipped to everyone's VSCode. After the update, the linter will automatically start working in VSCode. Until then, we'll only get feedback on Sandcastle/Landcastle for lint rule violations.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24379783

fbshipit-source-id: 222778d8a84d7010eb7b3ad71b34a7fe1f52e509
2020-10-24 03:45:03 -07:00
Joshua Gross 2ff1d4c041 Fix NativeAnimated queueing
Summary:
I believe the old method of queueing these operations for Fabric is causing crashes because "connectNode" is on a separate JS queue from setting up nodes.

In hindsight, this seems silly. We must ensure that nodes are created before they're connected, and we weren't doing that?

Using a single queue is conceptually simpler, should be easier to reason about, and should fix some crashes.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24521951

fbshipit-source-id: f6c38ac0023faa28414063d8b96daf32ba95524d
2020-10-24 00:02:21 -07:00
Joshua Gross 81c184dce1 Followup to D24379607, update minsdk
Summary:
Followup to D24379607 (a17ff44adc), update target SDK scattered throughout code

Changelog: [Internal]

Reviewed By: ejanzer

Differential Revision: D24510634

fbshipit-source-id: 356e172027e48db498253dcb15373007f42db292
2020-10-23 19:50:08 -07:00
Joshua Gross d527e03842 Add some diagnostics to aid in debugging ReactViewGroup.dispatchDraw crashes
Summary:
I want to see if the child count changes before/after this method execute; that would help pinpoint the cause of these crashes.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D24510064

fbshipit-source-id: 11b4baf15bc5e0beb23d65546605b378d84d1b20
2020-10-23 19:46:15 -07:00
Paige Sun edb6fa7979 Synchronize RCTImageLoader loaders initialization
Summary:
The method `imageURLLoaderForURL` can be called from multiple threads. This adds a mutex to make sure that _loaders is initialized with a non-nil value only once.

We'll only lock this mutex at one point in time as long as `_loadersProvider()` gives a value, so the mutex doesn't affect performance.

Changelog: [iOS][Fixed] Synchronize RCTImageLoader loaders initialization

Reviewed By: fkgozali

Differential Revision: D24513083

fbshipit-source-id: b89ef8a82729eda508162b01f7fdaa8a291f40d0
2020-10-23 19:12:53 -07:00
Héctor Ramos 0d1f93c317 Bump Node LTS to 14, and Node PrevLTS to 12. (#30237)
Summary:
On October 27, 2020, Node 14 will enter active LTS status, and Node 12 will enter maintenance LTS status at the end of November.

With these upcoming dates in mind, I am bumping the Circle CI NodeLTS executor to use Node 14, and the NodePrevLTS executor to use Node 12.

With these changes, Node 12 will be hereto considered the minimum supported version.

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

[Changed] [JavaScript] - Bump minimum Node version to 12 LTS

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

Test Plan: Circle CI

Reviewed By: PeteTheHeat

Differential Revision: D24513133

Pulled By: hramos

fbshipit-source-id: 2651d954d546e5f7c9e40b54ef3ee976ad9b2d5e
2020-10-23 17:39:24 -07:00
Héctor Ramos ca00173fea Fix test_docker: Confirm envinfo package install during Docker container setup (#30235)
Summary:
With the release of Node 15 on October 20, 2020, the `nvm i node` command started installing Node 15 by default during the Docker setup step on Circle CI. This version of Node now requires user interaction down in `npx envinfo@latest` during the same step.

With these changes, we ensure we automatically accept the installation of any necessary packages.

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

[CATEGORY] - Internal

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

Test Plan: Circle CI.

Reviewed By: fkgozali

Differential Revision: D24510043

Pulled By: hramos

fbshipit-source-id: bce72fd8ea8b0a4df501f75e48984eca0b10a090
2020-10-23 12:44:29 -07:00
Rubén Norte 74fc285c58 Allow specifying custom timestamps in performance logger spans
Summary: Changelog: [internal] Allow specifying custom timestamps in {start/stop}Timestamp in performance loggers

Reviewed By: lunaleaps

Differential Revision: D24474631

fbshipit-source-id: 48d8e69af8ba79ef1638cd5d03bac33af84f7881
2020-10-23 07:14:59 -07:00
Rubén Norte 5c498e3d6b Migrate createPerformanceLogger to ESM and export getCurrentTimestamp
Summary: Changelog: [internal]

Reviewed By: lunaleaps

Differential Revision: D24476172

fbshipit-source-id: 5afa58935a6a3a8e1d2d0d0bb8b3b28840fc17f4
2020-10-23 07:14:59 -07:00
Oleksandr Melnykov d238da71aa Do not crash when ScrollView snapToOffsets is empty
Summary:
The value of the `ScrollView.snapToOffsets` property can be an empty array (most likely an issue in the product code), which will crash the app. This diff adds a check to prevent crashing in this scenario and falling back to the default snap behaviour.

Changelog:
[Android][Fixed] - Do not crash when ScrollView snapToOffsets is empty

Reviewed By: sammy-SC

Differential Revision: D24502365

fbshipit-source-id: c63b8e3b8f2fb323ebd6c962ee628015934d8e11
2020-10-23 05:10:54 -07:00
Samuel Susla 6eed1e4f80 Remove iOS gating to fix sticky header
Summary:
Changelog: [internal]

The comment talks about jankiness which isn't there anymore.
Not setting translateY breaks Fabric's measure infra.

Reviewed By: JoshuaGross

Differential Revision: D24482016

fbshipit-source-id: 8188caa5bee5b8d2b1e686b289f5fd1ccc9e4a65
2020-10-23 04:22:31 -07:00
Samuel Susla 3a5eedffff Remove noexcept from TelemetryController
Summary:
Changelog: [internal]

There are two exceptions inside `TelemetryController::pullTransaction`:
- Empty Optional cannot be unwrapped
- mutex lock failed: Invalid argument

By marking this method `noexcept`, stack trace is lost and it makes it more difficult to track down the issue.

What does compiler do if a method is marked `noexcept`?

```
void f() noexcept {
    try {
        // do work
    }
    catch (...) {
        std::terminate(); // This is the std::terminate() we are seeing in stack traces.
    }
}
```

Removing noexcept specifier might give us more information about the exception.

Reviewed By: JoshuaGross

Differential Revision: D24477861

fbshipit-source-id: 80f26e9ab160a5330c2848b89a01d60bfc0a4611
2020-10-23 02:34:04 -07:00
Tim Yung a911efaecd Text: Refine Exported Flow Type
Summary:
Refines the exported type of `Text` so that it is more accurate.

Instead of `HostComponent<TextProps>` (which is not exactly accurate), we use the recently introduced types: `NativText` and `NativeVirtualText`.

Changelog:
[Changed][General] - Refined Flow type for `Text` component.

Reviewed By: nadiia

Differential Revision: D24486720

fbshipit-source-id: fad114fd14335933ebc2f7430d7b8b7838b6b523
2020-10-22 20:01:39 -07:00
Liang Liu afb926abb1 Sort index.js by alphabetical order and add category comments. (#30217)
Summary:
As of right now, index.js contains a big blob of imports that are mostly in alphabetical order, with a few exceptions. In addition, the imports aren't separated by Components / API / Plugins, so comments were added for ease of future maintainability.

## Changelog

[Internal] [Changed] - Reordered imports into alphabetical order and added comments to divide imports into sections (components, apis, plugins, prop types)

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

Test Plan:
This change did not change the codebase. Building rn-tester still works.

rickhanlonii

Reviewed By: cpojer

Differential Revision: D24490715

Pulled By: rickhanlonii

fbshipit-source-id: 7340395c8e10833b700dcfe8e83ab4a66b79e47b
2020-10-22 19:58:11 -07:00
Janic Duplessis a28dd38909 Use default for hermes es6 proxy enabled (#30142)
Summary:
Proxy is now enabled by default in hermes 0.7 (https://github.com/facebook/hermes/releases/tag/v0.7.0). However we currently disable it because of the config we pass.

This removes the config so proxy is now enabled.

## Changelog

[Android] [Changed] - Use default for hermes es6 proxy enabled

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

Test Plan: Tested that proxy is now enabled (typeof Proxy !== 'undefined') with hermes 0.7.

Reviewed By: cpojer

Differential Revision: D24494182

Pulled By: mhorowitz

fbshipit-source-id: 7f8a506e2c436f2f1611e183ca22d33dc763643c
2020-10-22 18:57:33 -07:00
Janic Duplessis 3a41f69f9c Make sure js bundle still exists at bundle-output path (#30149)
Summary:
Since changes to support hermes on iOS the js bundled is moved away from the location where it is generated when calling metro. This causes issues with the RN sentry integration since it relies on intercepting this path to find the bundle file after running react-native-xcode.sh. Seems kind of like a hacky way to get the bundle location, but let's avoid breaking it.

https://github.com/getsentry/sentry-cli/blob/master/src/commands/react_native_xcode.rs

## Changelog

[iOS] [Fixed] - Make sure js bundle still exists at bundle-output path

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

Test Plan:
Checked that the bundle file exists both at bundle-output path and in the .app.
Checked that the sentry release script works.

Reviewed By: cpojer

Differential Revision: D24480115

Pulled By: appden

fbshipit-source-id: c01c80d47ed54319f97063ec635c021552a95c22
2020-10-22 17:55:55 -07:00
Samuel Susla bfbd841f38 Remove redundant property from ImageRequest
Summary:
Changelog: [internal]

`moved_`, introduced in D8526571 (979ea2094e), no longer servers its purpose.
Let's remove it.

Reviewed By: JoshuaGross

Differential Revision: D24475715

fbshipit-source-id: 162d1fc4ed3d4a67885d8f140904dd80763dcaa0
2020-10-22 17:52:30 -07:00
Kevin Gozali 16044b3c2a Codegen Buck: fork schema generator target for FB vs OSS via rn_codegen_cli()
Summary:
Introduced a helper macro `rn_codegen_cli()` that defines ":write_to_json" and ":rn_codegen" targets differently based on the environment. When run at FB, it uses FB-specific setup. When run in OSS as a standalone repo, we use `yarn install` and `yarn run build` directly, then use `node` to run the output CLI.

This way, the same target can be used in both environments on other Buck targets.

Motivation: we need this to define rn_codegen_modules() to use codegen to produce Java TurboModule specs, that can be built by CircleCI (we build ReactAndroid via Buck as well). That way we can finally removed the checked-in .java spec files.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24442468

fbshipit-source-id: b1e5fce275100cfe3a1b3ae6d61c1c6d4b25651b
2020-10-22 17:09:30 -07:00
Kevin Gozali 7cfc7d65f7 Codegen: Make react-native-codegen BUCK deps OSS-compatible
Summary:
Added a few FB vs OSS polyfills:
* react_native_root_target() to refer to the root FB react-native-github/ dir or repo dir in OSS
* react_native_xplat_synced_target() for anything xplat
* a few others

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D24437245

fbshipit-source-id: ee290a87a98a8e9be67b102a96f2faac2a2cb92b
2020-10-22 17:09:29 -07:00
Joshua Gross f8eaab4fdc Workaround for T76236115 and swallow crash while using TextEdit
Summary:
There's a crash for a small number of users that looks like it is happening when cutting the text via a context menu, or deleting content near the end.

This is only happening because we cache the Spannable and it detects changes due to the cache mechanism itself. I'm making a minor change that will hopefully result
in Spannables being copied instead of the same Spannable instances being used for display on the View and measurement; and also swallowing this error, since it should
not be considered as a fatal, unrecoverable error for now. Hopefully we can delete entirely in the future.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24430622

fbshipit-source-id: 495458b3d85733e46a7e62b5c954b7cb6b00470b
2020-10-22 13:53:19 -07:00
Samuel Susla ae418b83c0 Fix crash when blurring image
Summary:
Changelog: [internal]

Copy `blurRadius` into a variable instead of accessing it through a reference which might not exist when the block is dispatched.

Reviewed By: cpojer

Differential Revision: D24472850

fbshipit-source-id: 936ef671255ae0e825e1d2dfda9649824b63d297
2020-10-22 01:48:55 -07:00
Marc Horowitz a8c90e6af4 Make conversions between folly::dynamic and JSI non-recursive
Summary:
Changelog:
[General][Fixed] - Fix handling of very deeply nested data across the bridge

fixes facebook/hermes#339

Reviewed By: sammy-SC

Differential Revision: D24182938

fbshipit-source-id: b674283a112b98cc63f20e436c538e3789ddf6dd
2020-10-21 20:54:55 -07:00
Héctor Ramos 9218e0c2e6 iOS: Generate FBReactNativeSpec ObjC++ files at build time
Summary:
Removes the generated FBReactNativeSpec files from source control.

## Generating FBReactNativeSpec files

The files will be generated automatically by CocoaPods when the `RNTesterPods` Xcode workspace is generated:

```
cd packages/rn-tester
pod install
```

The spec files can be re-generated by invoking the script directly:
```
./scripts/generate-native-modules-specs.sh
```

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D24261167

fbshipit-source-id: acb7ac856e5e519932e4f587f79e24f49cd84a91
2020-10-21 20:47:09 -07:00
Samuel Susla 5333ad8a61 Add unit tests for RCTComponentViewRegistry
Summary:
Changelog: [internal]

Adds unit tests for `RCTComponentViewRegistry`.

Reviewed By: shergin

Differential Revision: D24391419

fbshipit-source-id: e8adb641361c3e1394f652a1819f196d2402f493
2020-10-21 10:49:43 -07:00
Ramanpreet Nara 5b270e0243 Version bump to 0.0.5
Summary:
Just published react-native-codegen to npm. This diff bumps the version in package.json

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24433252

fbshipit-source-id: 35327b11ca4db270f207b6f778dabf86dd7dcb4c
2020-10-20 23:43:00 -07:00
Keith Melmon b5de89755d add testID, helps tests find items in the list (#30138)
Summary:
This change adds a testID to each item in the RNTester list.  This helps Appium find items in the list for automated tests.  The change was added in react-native-windows as part of end-to-end test infrastructure changes.    See https://github.com/microsoft/react-native-windows/pull/5555

We'd like to remove this forked file, upstreaming this change will enable us to do that.

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

[General] [Changed] - add testID to items in RNTester test list, helps test automation tools find the items

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

Test Plan: Change is currently running in react-native-windows CI loop.

Reviewed By: cpojer

Differential Revision: D24434352

Pulled By: appden

fbshipit-source-id: 998916d8fe4e4e4cd6ac764baabb9fd5f2e312c7
2020-10-20 17:29:13 -07:00
Joshua Gross 49f10fd2e5 Remove code for API level 20 and below
Summary:
We've deprecated API 20 and below. This is just a cleanup to remove code that assumes API level <21.

Changelog: [Android][Deprecated] Deprecate support of Android API levels 19 and 20.

Reviewed By: fkgozali

Differential Revision: D24380233

fbshipit-source-id: d8f98d7cb19446a60ba36137f1f9290e35f27c02
2020-10-20 17:00:47 -07:00
Joshua Gross a17ff44adc Upgrade minsdkversion of RN OSS template to API level 21
Summary:
This diff updates the minsdkversion of RN OSS template to API level 21.

Changelog: [Android][Deprecated] Deprecate support of Android API levels 19 and 20. The new minSDK version will be 21+ moving forward.

Reviewed By: fkgozali

Differential Revision: D24379607

fbshipit-source-id: 6801cdcd363065807cdc11006bd94217f914fac7
2020-10-20 17:00:47 -07:00
Samuel Susla 36b0f7d19b Fix controller <TextInput> on iOS when inputting in Chinese/japanese
Summary:
Changelog: [internal]

Solution copied over from 892212bad2 (diff-0874427511e8753d0037472fffbe6d7ee014d831e254d4b3c12ffb1dd8ce27c9)

Reviewed By: JoshuaGross

Differential Revision: D24429166

fbshipit-source-id: 3c0588ac774041a9fd6d1b6685d94c5658f754b2
2020-10-20 15:56:56 -07:00
Kevin Gozali eca9d9772c Codegen: Make BUCK & DEFS.bzl OSS friendly
Summary:
This makes the build configuration compatible with OSS Buck (but doesn't provide the complete capability).

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24414408

fbshipit-source-id: 4632933b8659389543ed72ae7c11c63d86bb3dce
2020-10-20 14:11:46 -07:00
Kevin Gozali 82c95fadc1 Codegen (FB): define internal BUCK targets for Android + JNI
Summary:
`rn_codegen_modules()` now defines 2 additional Android targets:
* the rn_android_library()
* the C++ library for JNI files

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24411783

fbshipit-source-id: 5ee4550dc313041f87e133397f266279b3eec6ee
2020-10-20 14:11:45 -07:00
Kevin Gozali 13d9927a48 Codegen: separate Android/Cxx/iOS modules codegen outputs
Summary:
For now, separate the definition of `modules` generator per platform to avoid file output collision. Additionally:
* For Android, produce files under java/ (plus nested subdirs based on packageName) and jni/ (for C++ files) - JavaPoet version already does it
* Allow configuring packageName for Android - JavaPoet version has this
* Avoid tmp directory dance in the CLI script, given the proper modules separation

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24410864

fbshipit-source-id: 9bd6bc1d65bec037bfca32ec478f3af50d72e927
2020-10-20 14:11:45 -07:00
Héctor Ramos d03c0f965e Generate FBReactNativeSpec ObjC++ source files using CocoaPods
Summary:
Move FBReactNativeSpec codegen invocation to shared `react_native_pods.rb` script and trigger codegen to run as part of `pod install` in both RNTester as well as React Native for iOS projects.

These files need to be generated before CocoaPods generates the Pods project, so the codegen is invoked as part of a `pre_install` hook during `pod install`.

The codegen hook can now take optional paths to allow it to run within different contexts (as part of a `react-native` repo checkout with access to the codegen source, or as part of a React Native iOS project that depends on the `react-native-codegen` npm package).

## Motivation

The FBReactNativeSpec ObjC++ source files (FBReactNativeSpec.h and FBReactNativeSpec-generated.mm) can be generated on demand from the native module specs in `Libraries/` using `react-native-codegen`. They can therefore be removed from the repository, but before we do so, we must ensure they get generated when a React Native iOS workspace is created or updated.

Invoking the codegen as part of the `pod install` step that creates a React Native iOS Xcode workspace ensures the specs are available in the following scenarios:
* Whenever a new React Native iOS project is created. The `react-native init` command invokes `pod install`.
* Whenever a React Native iOS project is upgraded. The `react-native upgrade` command invokes `pod install` as well.
* For contributors to the open source project running the RNTester application, the codegen will be invoked when the RNTester workspace is generated by CocoaPods using `pod install` in `packages/rn-tester`.

In any other case, the codegen can still be invoked directly via `scripts/generate-native-modules-specs.sh`.

> **Note:**
> The codegen will only process native modules in React Native's own Libraries directory.

Changelog:
[iOS][Changed] - Generate FBReactNativeSpec ObjC++ source files using CocoaPods.

Reviewed By: fkgozali

Differential Revision: D24348111

fbshipit-source-id: d62ae5c6f8ce6358bf96a2801c3cdb3d94dd868d
2020-10-20 13:17:00 -07:00
Hugo Cuvillier 403d6f4401 Migrate remaining call sites to `CKOverlayLayoutComponent` to Builder
Summary:
Ditto

Changelog: [Internal]

Reviewed By: aCorrado

Differential Revision: D24395872

fbshipit-source-id: 38260ed7ce154036d8e40493cfe81506cf3054e8
2020-10-20 05:58:21 -07:00
Joshua Gross ca4bac5534 EZ: Fix debug mode NPE in non-Fabric
Summary:
Fixes a NPE in debug mode. This will only impact developers who have explicitly turned this debug flag on, so it's a very low-pri fix.

Changelog: [Internal]

Reviewed By: makovkastar

Differential Revision: D24410825

fbshipit-source-id: 08c8a0c6d0e0fb7c132725ad6af9460b91a7edf3
2020-10-20 05:20:26 -07:00
Ramanpreet Nara 9c1f0c697d Make NativeModule spec parser collect all parsing errors
Summary:
## Rationale
Previously, the NativeModule spec parser would throw an error the first time it encountered an invalid Flow type. While this is ideal from a parsing standpoint, from a linting standpoint, however, we may want to display all errors that make the NativeModule spec invalid.

## Changes
This diff extends the NativeModule spec parser to collect all parsing errors in an array. In the codegen, if after building the schema, any parsing errors were detected, we throw the first one. In the ESLint rule, if after building the schema, any parsing errors were detected, the plan is to display them all.

## Notes
- All ParserErrors keep a track of the invalid AST Node
- When a Parsing error occurs, the Parser tries its best to continue parsing the rest of the source. For function parameters, it'll move on to the next param. For object proroperties, it'll move to the next property. It'll form a half-baked schema in the process, when a parsing error occurs. However, higher up in the stack, we have a check that discards the half-baked schema, if any ParsingErrors were collected.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24379511

fbshipit-source-id: 1989433da9b356b9ad5d9dcf901b429f585803c2
2020-10-19 21:59:29 -07:00
Ramanpreet Nara 2f438b03d7 Make buildModuleSchema and buildComponentSchema operate on Program AST nodes
Summary:
## Why
We want to reuse these functions inside the ESLint rule. Therefore, it's better to make them accept the AST node object, as opposed to a custom type defined in codegen.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24379512

fbshipit-source-id: 9f7378fc6c5f48cce34da109f5a7c017332b302a
2020-10-19 21:59:29 -07:00
Ramanpreet Nara 33789ba0ea GenerateModuleCpp: Replace string replace with string templates
Summary:
## Benefits:
- Improved Readability
- Improved type-safety with templates

Changelog: [Internal]

Differential Revision: D24386276

fbshipit-source-id: d5913122221960c06c5256af10ace1d2f7a60b49
2020-10-19 21:59:29 -07:00
Ramanpreet Nara de32fd2539 GenerateModuleH: Replace string replace with string templates
Summary:
## Benefits:
- Improved Readability
- Improved type-safety with templates

Changelog: [Internal]

Differential Revision: D24386278

fbshipit-source-id: b6cfa9fe17e1f7c54f4d541fd19281bf9a6c6796
2020-10-19 21:59:29 -07:00