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

21263 Коммитов

Автор SHA1 Сообщение Дата
Sam Goldman dd35bf534c Deploy Flow v0.135.0
Summary: Changelog: [Internal]

Reviewed By: mroch

Differential Revision: D24040584

fbshipit-source-id: 106caa00cadd6930685c0030ad74685c64572ba9
2020-09-30 23:33:59 -07:00
Joshua Gross 8b7fd37b42 Log View hierarchy if removeViewAt crashes
Summary:
If removeViewAt crashes, log the children of the parent view, and all of the parent's ancestors.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24019515

fbshipit-source-id: c5b1ca0948ebc47f2648e161770affa8542ca5dd
2020-09-30 22:40:26 -07:00
Frieder Bluemle 553fb8b28d Update Android Gradle plugin to 4.0.1 (#29013)
Summary:
This is a major version update that needs to be tested thoroughly.

Android Studio 4.0.1 is now available in the stable channel

https://androidstudio.googleblog.com/2020/05/android-studio-40-available-in-stable.html
https://developer.android.com/studio/releases/gradle-plugin#4.0.1

## Changelog

[Android] [Changed] - Update Android Gradle plugin to 4.0.1

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

Test Plan:
Build project

Closes https://github.com/facebook/react-native/issues/29044

Reviewed By: shergin

Differential Revision: D24041233

Pulled By: fkgozali

fbshipit-source-id: 68ef0f313aa773866e65796e323ed0f19f41f834
2020-09-30 22:16:54 -07:00
Valentin Shergin c42183817d Fixed incorrect assert in RCTScrollViewComponentView
Summary:
This diff removes an incorrect assert and replaces it with a debug-only verification phase that compares "what we want" with "what we get".

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: PeteTheHeat

Differential Revision: D23983123

fbshipit-source-id: 03a628b4f8baa1f5fe4b55354b7c943e38b5e537
2020-09-30 19:24:18 -07:00
Kevin Gozali 18f7abae07 Android: removed Robolectric 4.3.1 Buck configuration
Summary:
It was recently upgraded to 4.4, so we don't need the 4.3.1 anymore.

Changelog: [Android][Removed] Removed Robolectric 4.3.1 setup

Reviewed By: jselbo

Differential Revision: D24030822

fbshipit-source-id: 09b3c577d32028723e7bbc02f13459a7ae69b749
2020-09-30 17:08:10 -07:00
simek 8a31dfe567 chore: update RNTester example link in PanResponder comment (#30051)
Summary:
This PR fixes a small leftover after the RNTester migration to the monorepo package - an invalid link in the `PanResponder` comment.

Refs:
* https://github.com/facebook/react-native/issues/29567
* facebook/react-native-website#2177 (the similar correction was a part of merged PR in the RN docs)

## 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] PanResponder: correct example link in comment

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

Test Plan: N/A

Reviewed By: fkgozali

Differential Revision: D24025065

Pulled By: hramos

fbshipit-source-id: 190486e458fb8e83a35fa2d3c62f4483f3a4334d
2020-09-30 14:36:59 -07:00
Héctor Ramos 7054e58de4 iOS: fix ios-configure-glog.sh syntax issue
Summary:
A `cat` to file was removed accidentally, preventing the configuration script from executing successfully as part of a `pod install`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24024824

fbshipit-source-id: 94af0c6e663320bfac04ee8f6fb37bd4bdc379a4
2020-09-30 13:27:02 -07:00
Riley Dulin 8c77f7060c Remove idx package from inspector msggen
Summary:
This was causing a crash in babel:
```
$ babel src --out-dir bin --source-maps
Error: Cannot find module 'babel-plugin-idx' from
'~/fbsource/xplat/js/react-native-github/ReactCommon/hermes/inspector/tools/msggen'
- If you want to resolve "idx", use "module:idx" {
  code: 'MODULE_NOT_FOUND'
}
```
It didn't appear that this module was used, so I deleted it.

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D23993272

fbshipit-source-id: dd34f0fc652cb27c87c891ca37d0eba66a19a6cf
2020-09-30 12:08:49 -07:00
Samuel Susla 0544568d86 Drop old state updates
Summary:
Changelog: [internal]

Components can update state multiple times before the state update queue is flushed. This causes unnecessary layout/diff and mount passes. To solve this, drop stale state updates inside `stateUpdateQueue_ ` for specific `ShadowNodeFamily`.

Delivering stale status updates is redundant. Let's take SafeAreaView as an example. It schedules 5-6 state updates before `stateUpdateQueue_` is flushed. That's unnecessary work blocking JS thread. We only care about the latest state update. Same for TextInput and other components using state updates.

Reviewed By: JoshuaGross

Differential Revision: D23987707

fbshipit-source-id: 2e3f92cc93af61d78ac564aa40aef165af64b8c1
2020-09-30 08:36:06 -07:00
Joshua Selbo d373a8d88c Fix React Native Robolectric 4.4 deps (#30073)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/30073

Changelog: [Android][Added] - Test infra: Robolectric 4.3.1 -> 4.4 upgrade

Reviewed By: fkgozali

Differential Revision: D24009953

fbshipit-source-id: 70549187f4af0abd2ea10f6725eecadbaef7281b
2020-09-29 22:51:46 -07:00
Héctor Ramos c92e767435 TurboModule iOS: Remove module filters
Summary:
These native modules are now filtered downstream in `combine-js-to-schema-cli.js`.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D24003572

fbshipit-source-id: d858dbf4a4b6d522ed528f9c2262f37243317160
2020-09-29 21:48:08 -07:00
Joshua Selbo 5bb54c90bd Upgrade Robolectric from 4.3.1 -> 4.4
Summary: Changelog: [Internal]

Reviewed By: jiawei-lyu

Differential Revision: D23718455

fbshipit-source-id: 39c684722db1269e2179cf9680cb728be1171afb
2020-09-29 18:46:06 -07:00
Kevin Gozali 1d89ef87b6 TurboModule: exclude NativeSampleTurboModule in the schema
Summary:
The sample module is meant for demo only, but it lives alongside other core modules in react-native repo.

For now, exclude it in the Flow-type parsing, just like `NativeUIManager.js`

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24005108

fbshipit-source-id: 9ef524bfe2778dd983c94d1701f9ce49da5e0a68
2020-09-29 18:41:14 -07:00
Kevin Gozali 94b198cfd5 TurboModule Android: install SampleTurboModule and the playground to RNTester
Summary:
This compiles SampleTurboModule into RNTester Android. It also adds the NativeModule playground to show case TurboModule system to RNTester examples, just like in iOS.

{F337854369}

Changelog: [Android][TurboModule] Added TurboModule example to RNTester when `USE_CODEGEN` is set

Reviewed By: hramos

Differential Revision: D24004711

fbshipit-source-id: b682dd51fa998ee2e60f8d6ffd8c39220d13a7fe
2020-09-29 18:41:14 -07:00
Kevin Gozali b9a1ea9e9e TurboModule Android: move SampleTurboModule impl and spec to OSS
Summary:
This is the Java/JNI impl of the NativeSampleTurboModule.js, just like on iOS. The files here are supposed to be generated by the react-native-codegen, but they are checked in to the repo for easier build integration with RNTester.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23985746

fbshipit-source-id: 46340d778f3d964efe5b538d15ebe0f2cab04862
2020-09-29 18:41:14 -07:00
Kevin Gozali b931bd33fe TurboModule Android: properly set up RNTester ndkBuild and cleanup dependencies
Summary:
Before RNTester compilation starts, it needs to wait for :ReactAndroid NDK build to finish, so that it knows where to find the exported .so files. This tells the `preBuild` task to depends on `:ReactAndroid:prepareReactNdkLibs` task. The .so files are now copied over to the local project build dir, instead of depending on :ReactAndroid's build dir.

For cleanup, the reverse ordering is needed: before `clean` removed our temp dir to store the copied .so files, make sure the ndkBuild cleanup tasks execute beforehand.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23982989

fbshipit-source-id: 955d7c9bccb5855b6b066fca89764df2ede89f63
2020-09-29 18:41:14 -07:00
Joshua Gross ca51dc6288 Fix mutation sorting function
Summary:
The sorting function currently forms a partial ordering, not a total ordering. This can cause problems with certain sequences of immediate or conflicting mutations, leading to UI corruption or crashes.

Changelog: [Internal]

Reviewed By: shergin

Differential Revision: D24002668

fbshipit-source-id: edc9b4c1e3104897cb0c5fd6da563ec43d800494
2020-09-29 16:37:56 -07:00
Tommy Nguyen 521b16730d Align multi-line TextInput onSubmitEditing behavior (#29177)
Summary:
Aligns behavior to be consistent with Android and the [documentation](https://reactnative.dev/docs/textinput#bluronsubmit). `onSubmitEditing` should not be called when `blurOnSubmit=false`.

## Changelog

[iOS] [Fixed] - Align multi-line TextInput onSubmitEditing behavior

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

Test Plan: ![textinput-blur-align](https://user-images.githubusercontent.com/4123478/85121116-85b4b200-b224-11ea-86c5-065e9e6d22ba.gif)

Reviewed By: shergin

Differential Revision: D22488870

Pulled By: hramos

fbshipit-source-id: 2dec3a55da6384389a8358896ef1fbfd806d0304
2020-09-29 15:57:52 -07:00
Ramanpreet Nara 6e6443afd0 Remove header_namespace from module codegen target
Summary:
Making this change because I see this error when compiling Internationalization
```
➜  fbsource buck build //xplat/js/RKJSModules/Libraries/Internationalization:generated_objcpp_modules-InternationalizationApple
buck-out/gen/33fbdb84/xplat/js/RKJSModules/Libraries/Internationalization/generate_module_mm-Internationalization/FBReactNativeInternationalizationSpec-generated.mm:15:9: fatal error: 'FBReactNativeInternationalizationSpec.h' file not found
#import "FBReactNativeInternationalizationSpec.h"
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Command failed with exit code 1.

command: [/Applications/Xcode_11.6.0_fb.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++, @/Users/ramanpreet/fbsource/buck-out/bin/33fbdb84/xplat/js/RKJSModules/Libraries/Internationalization/generated_objcpp_modules-InternationalizationApple#compile-FBReactNativeInternationalizationSpec-generated.mm.o...
```

Since the header namespace is "FBReactNativeInternationalizationSpec", we can only import the header file via "FBReactNativeInternationalizationSpec/FBReactNativeInternationalizationSpec.h", according to this buck documentation: https://buck.build/rule/cxx_library.html#headers. Not entirely sure how this target compiled before.

The legacy codegen buck target also set the header namespace to "": https://fburl.com/diffusion/3p85qhf9.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23978436

fbshipit-source-id: c9cd7c710edf94df6df10778f8603870f92275a7
2020-09-29 14:39:42 -07:00
Ramanpreet Nara 6d6e04619f Fix ObjC++ structs and method mapping
Summary:
Adjust generated ObjC++ code to resolve a few build time and run time errors:

* Suppress CONSTANTS struct implementations
* Use type alias name as struct name when serializing arguments that involve a type alias
* Use actual number of arguments for a method when generating method map.

With these changes in place, RNTester can be built and run using the code that is generated by the new codegen.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23926500

fbshipit-source-id: 88fcbb795fd71dc8155eb26348db943975e13e84
2020-09-29 14:39:41 -07:00
Ramanpreet Nara 97d3e85c29 Fix ObjC++ module generator output
Summary:
* Removed extraneous closing brace.
* Fixed static method signature, replacing double colon with an underscore (`static facebook::jsi::Value __hostFunction_Native${moduleName}SpecJSI::${methodName}()` -> `static facebook::jsi::Value __hostFunction_Native${moduleName}SpecJSI_${methodName}()`).
* Wrap `getConstants` selector name with `selector()`.
* Pass through `getConstants` and `constantsToExport` to allow de-duping of `getConstants` method in generator output.

Note that the FBReactNativeSpec that is output by the generator still has some issues that need to be addressed before it can be used.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23910505

fbshipit-source-id: 37d884885b8878f38d40637377c2a74a728c3a13
2020-09-29 14:39:41 -07:00
Ramanpreet Nara 1b3dc1d9e3 Fix GenerateModuleJniCpp
Summary:
Just updated the generator to work with the new RN Codegen Flow Parser types.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23667253

fbshipit-source-id: ef94e75287d37dfd7b80f61455a1bfa34bddeb28
2020-09-29 14:39:41 -07:00
Ramanpreet Nara cedd628fc3 Fix GenerateModuleJniH
Summary:
Just updated the generator to work with the new RN Codegen Flow Parser types.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23667250

fbshipit-source-id: f36b5418101c40331964d1f9ede7c6bd7924383d
2020-09-29 14:39:41 -07:00
Ramanpreet Nara 560ac1a9fa Fix GenerateModuleJavaSpec
Summary:
Just updated the generator to work with the new RN Codegen Flow Parser types.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23667255

fbshipit-source-id: 40b7747aad89f6d5bbb9f42d59a4df9633060c66
2020-09-29 14:39:41 -07:00
Ramanpreet Nara 4ab7cc236a Fix GenerateModuleH
Summary:
Just updated the generator to work with the new RN Codegen Flow Parser types.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23667252

fbshipit-source-id: 34404a478ddd67446d82b5f98e1051300064e95c
2020-09-29 14:39:41 -07:00
Ramanpreet Nara c0408b56fc Fix GenerateModuleCpp
Summary:
Just updating this generator to understand the new RN Codegen Module parser flow types.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23667254

fbshipit-source-id: 558dd7ac5b4541edf40248b8ab8bb50d31fa8624
2020-09-29 14:39:40 -07:00
Ramanpreet Nara 1ac1255d63 E2E snapshot test ObjC++ generator
Summary:
NativeModule specs exist under `react-native-github/packages/react-native-codegen/src/__tests__/modules/fixtures`. `GenerateModuleObjCpp-test.js` runs the RN Codegen on those NativeModule specs, and saves the output inside a snapshot. For convenience, the folowing command runs the legacy codegen on the fixtures:

```
buck build fbsource//xplat/js/react-native-github/packages/react-native-codegen/src/__tests__/modules:RNCodegenModuleFixtures-flow-types-ios --show-output
```

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23637708

fbshipit-source-id: 3319f319515eca42b4499682313fea6e0bdc2a06
2020-09-29 14:39:40 -07:00
Ramanpreet Nara c267b8de72 Rewrite ObjC++ module generator
Summary:
## Misc. Improvements

* We now have 95%+ flow coverage in all generator files. Henceforth, we can make changes to these files with more confidence, and trust flow to catch more errors. This should also improve the DevX of working on these files.
* Better templates: Instead of doing string replace with RegExps, we instead use functions and leverage JS template literals to generate our code. A few benefits: (1) data dependencies of templates are clearly visible, and statically checked by flow, (2) the templates are more readable in VSCode.
* Merged the GenerateModuleHObjCpp.js and GenerateModuleMm.js generators. They can share a lot of logic, so it's not a good idea to keep them separate.
* The ObjC++ module generator no longer generates “dead” structs (i.e structs that aren’t used by type-safety infra). In fact, it explicitly only supports the types in our Wiki. (I know this wasn’t the case with the legacy codegen, because we were generating native code for enums in the legacy codegen). This is a mixed bag. The test to verify correctness will be more difficult to write. However, keeping structs in the codegen needlessly complicates the parsers + generators, and creates technical debt for us to clean up later.

## Abstractions
- **StructCollector:** As we serialize NativeModule methods, when we detect an ObjectTypeAnnotation in the return type of `getConstants()` or inside a method param, we must create a Struct JS object for it. When we detect a type-alias (also in the same locations), we must look up that type-alias and create a Struct from its RHS. A Struct is basically an ObjectTypeAnnotation with a context (i.e: used in getConstants() vs as a method param), that cannot contain other ObjectTypeAnnotations.
- **serializeMethod.js** Given a NativeModule method type annotation, output the protocol method, JS return type, selector, a record of which params were structs, and which structs. Basically, this is all the information necessary to generate the declaration and implementation codegen for a partiular NativeModule method.
- **serializeStruct/*.js**: After creating all these Structs, we need to loop over all of them, and tranform them into ObjC++ code.
  - **serializeStruct.js**: Depending on the struct context, calls either `serializeRegularStruct.js` or `serializeConstantsStruct.js`. Both of these files have the same layout/abstractions. They look very similar.
- **serializeModule.js:** Outputs RCTCxxConvert categories for transforming `NSDictionary *` into C++ structs. Outputs ObjCTurboModule subclass.

## Algorithm
```
for spec in NativeModuleSpecs
  structCollector = new StructCollector
  resolveAlias = (aliasName) => nullthrows(spec.aliases[aliasName])

  methodDatas = []
  for method in methods(spec)
    methodData.push(serializeMethod(method, structCollector, resolveAlias))
  end

  structs = structCollector.getStructs()

  output generateImplCodegen(methodDatas, structs)
  output generateHeaderCodegen(methodDatas, structs)
end
```

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23633940

fbshipit-source-id: 7c29f458b65434f4865ef1993061b0f0dc7d04ce
2020-09-29 14:39:40 -07:00
Ramanpreet Nara c300193853 Create utilities for module generators
Summary:
There are two operations we do in every NativeModule generator:
- We convert the `SchemaType` into a map of NativeModule schemas
- If the type-annotation is a TypeAliasTypeAnnotation, we resolve it by doing a lookup on the NativeModuleAliasMap. This is usually followed by an invariant to assert that the lookup didn't fail.

Both procedures have been translated into utilities for use across our generators. I also deleted `getTypeAliasTypeAnnotation` which will no longer be used.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23667249

fbshipit-source-id: 4e34078980e2caa4daed77c38b1168bfc161c31c
2020-09-29 14:39:40 -07:00
Ramanpreet Nara 5f5ccfcb2c Update generator fixtures to comply with Schema flow types
Summary:
In diffs below, we made several changes to the NativeModule schema. This diff just ensures that the input to our generator snapshot tests, which are module schemas, are valid.

Changelog: [Internal]

Reviewed By: TheSavior

Differential Revision: D23633942

fbshipit-source-id: 444ccd60f6ec76e348a8e54b946260464ff3aeee
2020-09-29 14:39:40 -07:00
Ramanpreet Nara 91a7da087b Refactor: Make NativeModuleArrayTypeAnnotation elementType customizable
Summary:
In the future, we'll use `NativeModuleArrayTypeAnnotation` inside JS struct objects. Structs cannot contain `ObjectTypeAnnotations` anywhere. Therefore, we need the elementType of `NativeModuuleArrayTypeAnnotation`'s elementType customizable.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23645210

fbshipit-source-id: 97abb993d59536ebd68ec08b18ce7f2801c68a2d
2020-09-29 14:39:39 -07:00
Ramanpreet Nara 4927de6011 Rename GenericPromiseTypeAnnotation to PromiseTypeAnnotation
Summary:
We have first class support for Promises in our codegen. So, it's more appropriate to just call this PromiseTypeAnnotation, as opposed to GenericPromiseTypeAnnotation.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23645209

fbshipit-source-id: bfc0b909750e221e18be33acf197f342a2918aa9
2020-09-29 14:39:39 -07:00
Ramanpreet Nara 92a6722bf2 Refactor: Make NativeModuleAliasMap $ReadOnly
Summary:
We were using `$ReadOnly<NativeModuleAliasMap>` everywhere, so I figured we'd just make the type itself `$ReadOnly`.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23645207

fbshipit-source-id: 4e018d5768f4fcfd00492def7d840a5054cb2b73
2020-09-29 14:39:39 -07:00
Ramanpreet Nara 2e0fb69365 Refactor: Introduce Required<T> generic type
Summary:
This diff introduces a `Required<T>` generic type in CodegenSchema. Why? NativeModule aliase RHSs are basically ObjectTypeAnnotations but they have `nullable` fixed to `false`. This generic type reduces duplication in the schema flow types.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23645208

fbshipit-source-id: da984f64fa17d8533a3ea74b132ce10aae9aa7ed
2020-09-29 14:39:39 -07:00
Ramanpreet Nara 1194a36efa Export module type annotations from CodegenSchema
Summary:
This diff has a few changes:
- All type annotations are now declared top-level, and exported from `CodegenSchema.js`.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D23616473

fbshipit-source-id: 1509c304305e56674bd76c44bc49f755dfeaa332
2020-09-29 14:39:39 -07:00
Ramanpreet Nara 572e1da889 Fix type alias nullability resolution in module parser
Summary:
Consider this case:

```
type Animal = ?{|
  name: string,
|};

type B = Animal

export interface Spec extends TurboModule {
  +greet: (animal: B) => void;
}
```

The generated output for this spec is:

```
namespace JS {
  namespace NativeSampleTurboModule {
    struct Animal {
      NSString *name() const;

      Animal(NSDictionary *const v) : _v(v) {}
    private:
      NSDictionary *_v;
    };
  }
}

protocol NativeSampleTurboModuleSpec <RCTBridgeModule, RCTTurboModule>
- (void)greet:(JS::NativeSampleTurboModule::Animal &)animal;
end
```

Observations:
  1. The codegen looks as though we wrote `+greet: (animal: ?Animal) => void;` as opposed to `+greet: (animal: B) => void;`
  2. The generated struct is called `Animal`, not `B`.

## After this diff
Whenever we detect a usage of a type alias, we recursively resolve it, keeping a track of whether the resolution will be nullable. In this example, we follow B to Animal, and then Animal to ?{|name: string|}.

Then, we:
  1. Replace the `B` in `+greet: (animal: B) => void;` with `?Animal`,
  2. Pretend that `Animal = {|name: string|}`.

Why do we make all type alias RHSs required?
 2. This design is simpler than managing nullability in both the type alias usage, and the type alias RHS.
 3. What does it mean for a C++ struct, which is what this type alias RHS will generate, to be nullable? ¯\_(ツ)_/¯. Nullability is a concept that only makes sense when talking about instances (i.e: usages) of the C++ structs. Hence, it's better to manage nullability within the actual TypeAliasTypeAnnotation nodes, and not the associated ObjectTypeAnnotations.

## Other Changes
- Whenever we use the `Animal` type-alias, the e2e jest tests validate that the type alias exists in the module schema.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23225934

fbshipit-source-id: 8316dea2ec6e2d50cad90e178963c6264044f7b7
2020-09-29 14:39:39 -07:00
Ramanpreet Nara aba4e87873 Add unit tests to validate module parser
Summary:
## Test Structure
- Parameter Parsing
  - For type in [optional, nullable, optional and nullable, required]:
    - Can parse Primitives
    - Can parse Object
    - Can parse Arrays
      - Can parse primitive element types
      - Can parse Object element types
      - Can parse Array element types
      - Can parse Reserved Type element types
      - Can parse Type alias element types
      - Can parse Object Literals
    - Can parse Function
    - Can parse Reserved Types (e.g: RootTag)
    - Can parse Type alias
    - Can parse Object Literals
      - For prop type in [optional, nullable, optional and nullable, required]:
        - Can parse primitive prop types
        - Can parse Object prop types
        - Can parse Array prop types
        - Can parse Reserved Type prop types
        - Can parse Type alias prop types
        - Can parse Object Literal prop types
- Return Parsing
  - For type in [nullable, required]:
    - Can parse Promises
    - Can parse Primitives
    - Can parse Object
    - Can parse Arrays
      - Can parse primitive element types
      - Can parse Object element types
      - Can parse Array element types
      - Can parse Reserved Type element types
      - Can parse Type alias element types
      - Can parse Object Literals
    - Can parse Function
    - Can parse Reserved Types (e.g: RootTag)
    - Can parse Type aliases
    - Can parse Object Literals
      - For prop type in [optional, nullable, optional and nullable, required]:
        - Can parse primitive prop types
        - Can parse Object prop types
        - Can parse Array prop types
        - Can parse Reserved Type prop types
        - Can parse Type alias prop types
        - Can parse Object Literal prop types

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23089925

fbshipit-source-id: 73c3b1ef33b402265c14f0ac9e364414a5d54dca
2020-09-29 14:39:38 -07:00
Ramanpreet Nara 2d19037041 Rewrite Flow module parser
Summary:
This diff:
1. Simplifies the NativeModule schema Flow types.
2. Simplifies the NativeModule Flow parser, to accomodate the modified schema, and to reduce code duplication.

**Notes:**
- If the parser detects an unrecognized type within the context of parsing an Array's element type, it'll omit the `elementType` property of the `ArrayTypeAnnotation`. Details: T72031674. **Rationale:** Basically, when an array element type is supported, we use it in our generators. When it's unsupported, we ignore it. In the unsupported case, there's no point in trying to parse the Array element type, which is why I decided to omit the `elementType` property. Ideally, our NativeModule specs would never use unsupported types, in any context. This would allow us to always parse and use the elementType. However, that seems like a it could be a hefty migration: we have > 400 specs. Since, this isn't a battle we need to fight right now, I left a TODO at the relevant lines instead.
- The legacy codegen would generate structs for each object literal type in the file. In this re-implementation of the parser, I only insert into the aliases array when we detect a usage of a type-alias to an ObjectLiteral type annotation. With this decision, we won't be able to generate these unnecessary structs. This is good because we get rid of dead code. It's bad because it might make our migration to this codegen bit more difficult.

[WARNING] This diff produces flow failures that will be addressed in subsequent diffs.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23201387

fbshipit-source-id: 55ce0df925a8bae0e7d5bb2a9b63167607eba461
2020-09-29 14:39:38 -07:00
Ramanpreet Nara f9ea52574e Cleanup buildMethodSchema and introduce nullable methods
Summary:
## Changes
- Started doing cleanup under `/parsers/flow/modules/methods.js`
- Rename `NativeModuleMethodTypeShape` -> `NativeModulePropertyShape`
- Moved optional property from `FunctionTypeAnnotation` to the `NativeModulePropertyShape`
- Introduced a nullable property inside what was once `FunctionTypeAnnotation`.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23146050

fbshipit-source-id: 2fe97bb9c0736242682133e4923131a54bbea54b
2020-09-29 14:39:38 -07:00
Ramanpreet Nara 747f493feb Colocate alias/method generation logic
Summary:
## Changes
- Generating the aliases was split over `parsers/flow/modules/index.js`, and `parsers/flow/modules/aliases.js`. I moved everything to the latter file.
- Generating methods was split over `parsers/flow/modules/index.js` and `parsers/flow/modules/methods.js`. I moved everything to the latter file.
- More type-safety

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D23143382

fbshipit-source-id: e11b76bee7917a7db37ae7f1af64da5f046c5d1e
2020-09-29 14:39:38 -07:00
Ramanpreet Nara 78057729ce Clean up parsers/flow/modules/index.js
Summary:
Changes:
- Adding type annotations, where possible
- Delete unnecessary functions

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23138227

fbshipit-source-id: b4b47492ddef49f496ed9fcb61ef1c000e3e8f18
2020-09-29 14:39:38 -07:00
Ramanpreet Nara 8c138baf4e Fix parser's buildSchema's return type
Summary:
`buildSchema` delegates to two other functions: `buildComponentSchema`, or `buildComponentSchema`. Both return have a return type of *required* `SchemaType`. Therefore, `buildSchema` can have a return type of `SchemaType`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23135499

fbshipit-source-id: f13db17549c93b965f372d9b68d06efc2a40c6cc
2020-09-29 14:39:37 -07:00
Ramanpreet Nara 22d6e04da1 Clean up Module/Component detection logic in Flow parser
Summary:
Just broke down getConfigType into two separate functions: `isModule` and `isComponent`.
- Cleaned up `isComponent`, to check for the the AST node types.
- Re-implemented `isModule`
- Improved error messages.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23121896

fbshipit-source-id: 3df2b2e334c4cea8eabe2e73ecb9f1f1217e7be4
2020-09-29 14:39:37 -07:00
Ramanpreet Nara 1435d654d7 Restructure getTypes function
Summary:
There are two types of types we care about:
- Type aliases
- Interface Declarations

These types can be exported.

I think we should build the types dictionary from only those types. Everything else should be ignored.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23120241

fbshipit-source-id: 9f023081d0f9c85b45407b180ae7c3e7391eb725
2020-09-29 14:39:37 -07:00
Ramanpreet Nara 5142e99437 Delete NativeModuleSchemaBuilderConfig type
Summary:
Unecessary, since `NativeModuleShape` is the exact same thing.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D23119784

fbshipit-source-id: 8c4aded88a97a80aa977c13cc27e32fbe68150aa
2020-09-29 14:39:37 -07:00
Ramanpreet Nara 341e05ff62 Allow NativeModule method return types to use type aliases
Summary:
We already support type-aliases in our NativeModule method params. This diff extends the support to NativeModule method returns.

**Note:** I need to see if I need to update the generators to handle this case. Will do that in this diff, after working through other higher priority stuff.

Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D22828839

fbshipit-source-id: cf5c756d3cacf067df217cdb6212946320a2d4be
2020-09-29 14:39:37 -07:00
Ramanpreet Nara ef145adb9d Split NativeImageStore into iOS and Android counterparts
Summary:
Split the two specs, so that that we don't have to use Flow unions in the merged spec.

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D23800841

fbshipit-source-id: 28b67578832ebd733bd080877e4ab763c013fded
2020-09-29 14:39:37 -07:00
Paige Sun a7c026e667 Remove unused Fabric image instrumentation
Summary:
Remove the older implementation of image instrumentation in Fabric by removing, RCTImageInstrumentationProxy, ImageInstrumentation from ImageRequest, and trackURLImageContentDidSetForRequest from RCTImageLoaderWithAttributionProtocol.

Changelog: [RN][Fabric][Image] Remove unused Fabric image instrumentation

Reviewed By: fkgozali

Differential Revision: D23990606

fbshipit-source-id: 004d04025d031af11377a73e5bfb64b1e0449962
2020-09-29 14:19:09 -07:00
Joshua Gross c06f765f7d Allow Java classes to hook into ScrollView scroll and layout events
Summary:
For advanced interop cases.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D23984345

fbshipit-source-id: f5c2a43a1bf5937f9974bcc5c66c36ec35e679c5
2020-09-29 13:19:11 -07:00
Samuel Susla 5ccb5f5b80 Fix dismissal animation of Modal Component
Summary:
Changelog: [Internal]

Fabric removes components bottom up (from leafs to the root).
This means that by the time Fabric hides Modal, it has no content and therefore it appears as if Modal disappears without Animation.

To fix this, we snapshot contents of the Modal before any of its contents are removed.

Reviewed By: shergin

Differential Revision: D23976244

fbshipit-source-id: 01c13b74e97f82816e8946fd9d1add1db10340b1
2020-09-29 06:44:25 -07:00