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

17559 Коммитов

Автор SHA1 Сообщение Дата
Dan Abramov e6d32d8a49 Register the bundle regardless of whether Fast Refresh is on
Summary:
We want to move to a world where Fast Refresh is on by default. As a first step, we can register the bundle early. This means we'll start receiving hot updates via the socket even if Fast Refresh is off. We'll just be ignoring those.

Anecdotally people with Fast Refresh on have had good experience even with invasive changes like branch switches. So this seems like a good way to test the waters further. It's also a prerequisite to unlocking a nicer experience where you can turn it on anytime and "catch up" on the changes you've missed. (That's out of scope of this diff.)

Reviewed By: cpojer

Differential Revision: D16344019

fbshipit-source-id: 6e5f8278909810b32c80e0af010251c876e4313b
2019-07-18 11:11:29 -07:00
Dan Abramov 295affc8ab Refactor the socket client API
Summary:
Two changes:

1. `disable` -> `close` to better match what's happening.

2. `enable` is inlined in the constructor because it's always called right after the constructor.

Reviewed By: rickhanlonii

Differential Revision: D16340009

fbshipit-source-id: 38a906b1ab3f5b39a57d2598ba400a2f03903951
2019-07-18 11:11:29 -07:00
Jan Kassens c13e5d0b43 fix jest's test.table flow type
Summary:
The current flow type disallows passing in an `Array<string>` since the current
type signature would allow just to append to the `Array`, `$ReadOnlyArray`
doesn't allow writing.

@public

Reviewed By: jstejada

Differential Revision: D16354977

fbshipit-source-id: a83c1227c1a15225487ac8672818d8b319dce32f
2019-07-18 09:38:47 -07:00
Moti Zilberman 5029195d22 Test ReactFiberErrorDialog in terms of NativeExceptionsManager
Summary:
https://github.com/facebook/react-native/pull/25671 added a shallow unit test for `ReactFiberErrorDialog`, mocking out the (JS) `ExceptionsManager` module. This rewrites that test in terms of `NativeExceptionsManager` instead, so the integration with `ExceptionsManager` is also tested.

Also adds tests for the behaviour of the `framesToPop` and `jsEngine` extended error fields, and for passing a frozen error object (seeing as we potentially mutate the error).

Reviewed By: rickhanlonii

Differential Revision: D16330341

fbshipit-source-id: 0b514d1c8f193a114748739ec31ddb4e06e4d2fd
2019-07-18 07:50:39 -07:00
Samuel Susla c914dfb8d3 Fix missing base64 images
Summary:
I discovered failing snapshot tests (T47222928, T47222859). They fail because `<Image>` doesn't work with base64 anymore.

There are two problems that are causing this.

1st is on iOS https://fburl.com/pw246vgw where if the image has 1 frame count, nothing is displayed.

2nd is in https://fburl.com/3im0u38r where if image is not within assets, we don't display it.

Reviewed By: shergin

Differential Revision: D16334151

fbshipit-source-id: 1ea8ef676b7207834ba63f4264e6ef2f05f24b96
2019-07-18 07:21:25 -07:00
Sidharth Guglani 86b671fdbc using enum struct for LayoutPassReason and LayoutType
Summary: Using enum struct for using enums in form ENUM_NAME::ENUM_VALUE for better code readablility

Reviewed By: davidaurelio

Differential Revision: D16356562

fbshipit-source-id: cbe7adadad78eb5d0756c44679c0e102b7d31ec6
2019-07-18 07:05:09 -07:00
Uladzislau Paulovich 45a4bec60c yoga | Fix error about implicit conversion to bit-field
Summary:
`YGStyle` puts Yoga enums (which are signed integers by default) into bitfields: https://fburl.com/7fowlunu

Mixing signed values and bit-fields can be error-prone and it also fails to build on Windows with `clang-cl` due to `-Wbitfield-constant-conversion` warning being treated as error:

```
stderr: In file included from xplat\yoga\yoga\YGLayout.cpp:8:
In file included from xplat\yoga\yoga/Utils.h:8:
In file included from xplat\yoga\yoga/YGNode.h:13:
xplat\yoga\yoga/YGStyle.h(110,9): error: implicit truncation from 'YGAlign' to bit-field changes value from 4 to -4 [-Werror,-Wbitfield-constant-conversion]
        alignItems_(YGAlignStretch),
```

This diff fixes the problem by making all enums unsigned integers. This change can be problematic only if values of the enums are serialized somewhere. CC: David Aurelio

Reviewed By: davidaurelio

Differential Revision: D16336729

fbshipit-source-id: ee4dabd7bd1ee429e644bd322b375ec2694cc742
2019-07-18 06:20:35 -07:00
David Aurelio 341b509437 Include headers in `fbjni/`, too (#25711)
Summary:
Adds headers in `fb/include/fbjni` to `//ReactAndroid/src/main/jni/first-party/fb:jni`, as these are needed by Yoga now

Fixes compilation of Yoga, after Yoga upgraded its internal copy of *fbjni* and changed header include paths.

## Changelog

[Android] [Fixed] - Fixes compilation of Yoga
Pull Request resolved: https://github.com/facebook/react-native/pull/25711

Test Plan:
```
$ buck build //ReactAndroid/src/main/jni/first-party/yogajni:jni
Invalidating internal cached state: Watchman failed to start. This may cause slower builds.
Parsing buck files: finished in 0.5 sec
Building: finished in 2.2 sec (100%) 8/8 jobs, 8 updated
  Total time: 2.9 sec
```

Reviewed By: SidharthGuglani

Differential Revision: D16357020

Pulled By: davidaurelio

fbshipit-source-id: 4a97c0d35ebf65412a661ae291b3110bcfba6467
2019-07-18 05:27:22 -07:00
Sidharth Guglani 87aca7ed74 Pass reason for measure pass along with measurecallbackend event (#566)
Summary:
Pull Request resolved: https://github.com/facebook/litho/pull/566

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

Pass reason for each measure callback to the flipper plugin

Reviewed By: davidaurelio

Differential Revision: D16221771

fbshipit-source-id: 2e72e1ebb3c7e633d189e7a7a81d655ac9531e51
2019-07-18 05:21:15 -07:00
Dominique d'Argent b07bbab392 Remove markerNote from JS bindings
Summary: This diff removes the unused `markerNote` method from QPL.

Differential Revision: D16331769

fbshipit-source-id: c35006af03d6129dc690cfd05bc1bc1c4a0856ba
2019-07-18 03:52:44 -07:00
Michał Pierzchała fafe5ee072 - Bump CLI to ^2.6.0 (#25666)
Summary:
Bumps CLI to the latest, including automatic jetifier, prettierrc in template and more: https://github.com/react-native-community/cli/compare/v2.2.0...v2.6.0

## Changelog

[Internal] [Changed] - Bump CLI to ^2.6.0
Pull Request resolved: https://github.com/facebook/react-native/pull/25666

Test Plan: CI passes

Differential Revision: D16279319

Pulled By: cpojer

fbshipit-source-id: d84e2e69a310ac3ef5722c22a17b12926a073097
2019-07-18 03:21:28 -07:00
Christoph Nakazawa d974793b59 Add a loading bar when loading split bundles
Summary:
This adds a loading indicator when loading split bundles so that users get a visual indicator about what is going on.

Note that I am currently trying to get the dynamic message that shows the number of modules and percentage to work but it appears that the JavaScript networking client (XMLHttpRequest + RCTNetwork) are not set up to deal with multipart responses in the same way as our native multipart handlers are. I'd like to put this in place now and polish it later if it's possible to fix the issue (I spent all afternoon yesterday trying to make multipart messages work and failed :( ).

Reviewed By: gaearon

Differential Revision: D16281531

fbshipit-source-id: 84e53d7f25642398ed51d8f552919880b8090897
2019-07-18 03:06:49 -07:00
Christoph Nakazawa ba8f88d1ab Rename HMRLoadingView to LoadingView
Summary:
This view will be re-used for bundle splitting so I'm changing the name to be more generic as it can be used for informing users of any loading activity.

I also cleaned up the files a bit from a class to just an object.

Reviewed By: gaearon

Differential Revision: D16281367

fbshipit-source-id: 5c2ee7790d29ccba473bd6e90737d2f0581e6291
2019-07-18 03:06:49 -07:00
Christoph Nakazawa 93bebf146f Switch HMR connection to register bundle entry points via a message
Summary:
This diff builds on the previous ones and changes the setup process from using the WebSocket URL to using a message that is sent after the connection is established. It also exposes a function on the HMRClient that allows registering more bundles, which I will make use of in the next (and hopefully final :D ) diff.

I was initially planning on using structured data, like `{bundleName, platform}` but decided to keep using URLs as that is the format used throughout Metro. In fact, when we parse the options from the URL, we need to re-encode the input URL to create the `sourceMapUrl`. I thought it doesn't make sense to write more code to send structured data over the connection only to re-construct a URL on the server manually.

Finally, I also slightly modified the "Internal Bundler" error that is shown in a RedBox (now used by the websocket connection if an invalid message is received). I removed the "internal" wording from the message and I'm actually attaching the failure message to the error instead of directing users to the Terminal.

Reviewed By: gaearon

Differential Revision: D16162729

fbshipit-source-id: 977fde5f6c2f1c14efb4fd99ed30a6bf95a3b13e
2019-07-18 03:06:48 -07:00
David Vacca c8ec2ae60c Delete method MountingManager.removeRootView
Summary:
The method MountingManager.removeRootView is not used anymore D16275118, I'm deleting from MountingManager

motivation: cleanup as I'm fixing other bugs in Fabric

Reviewed By: ejanzer

Differential Revision: D16350582

fbshipit-source-id: 488cf2aa2feda78e6660a854af5da2718f9905de
2019-07-17 18:21:22 -07:00
Riley Dulin c24387e45c Use UTF-8 instead of ASCII for setting object properties from folly::dynamic
Summary:
Based on Hermes Issue: https://github.com/facebook/hermes/issues/47
It was not actually a bug in Hermes, but a bug in JSI, assuming that all string property names from
`folly::dynamic` are ASCII.

Now we'll be more intentional and directly state `forUtf8` rather than the implicit ASCII encoding.

Reviewed By: mhorowitz

Differential Revision: D16347857

fbshipit-source-id: 6bcfbf9f918dc0a7a485b88a1b537d6c2dd322cc
2019-07-17 17:05:47 -07:00
Riley Dulin 96be82e3f9 clang-format everything
Summary: Ran clang-format on all of JSI.

Reviewed By: mhorowitz

Differential Revision: D16347858

fbshipit-source-id: 004afde1944f60a2c0989a7c38d5b3c58587f1cb
2019-07-17 17:05:46 -07:00
Valentin Shergin b0273bbe70 Fabric: Reimplementation of `stubViewTreeFromShadowNode`
Summary:
`stubViewTreeFromShadowNode` was implemented without using `calculateShadowViewMutations` (aka Diffing algorithm).
The problem is that we use `stubViewTreeFromShadowNode` to test the diffing, so it was not fully correct to use the algorithm to test itself.

Reviewed By: JoshuaGross

Differential Revision: D16342526

fbshipit-source-id: 2674245ed5ec71309fe5d362779a33d8dd31dc7b
2019-07-17 14:22:02 -07:00
Valentin Shergin 27b1558400 Fabric: Debug printing for StubView
Summary: That's extremly helpful for debugging, it allows to see the generated view structure (as diffing sees it).

Reviewed By: JoshuaGross

Differential Revision: D16342528

fbshipit-source-id: bc303d5cab992e517b7cf29962d7c1232e8aeec7
2019-07-17 14:22:02 -07:00
Valentin Shergin 66d7b83b52 Fabric: Fixed debug printing bug in ShadowView
Summary:
1. The check is now correct.
2. Now we call that "Invalid", not "Empty" because this case is invalid indeed.

Reviewed By: JoshuaGross

Differential Revision: D16342527

fbshipit-source-id: 433f6c5759d2d0756d55acb057b5639a8eab2e5d
2019-07-17 14:22:01 -07:00
Valentin Shergin 27ac090e1c Fabric: Implemented StubViewTree::getRootStubView()
Summary:
Trivial.
Before that we didn't have a way to get a root node from a Tree object.
It's useful during debugging (and some coming changes use that).

Reviewed By: mdvacca

Differential Revision: D16342529

fbshipit-source-id: 27c7516f3b3fccc8d8b25d4d2748006f7958ae41
2019-07-17 14:22:01 -07:00
Spencer Ahrens 1e45a41dc2 dev error for excessive pending callbacks
Summary:
We've seen some crashes from exceeding property limits (>200k) from storing callbacks, which is insane since callbacks should be called and cleaned up right away in most cases. Browsing around I never see more than about 50 pending callbacks when firing off a whole much of animations and measures and stuff.

In order to track down the leak, I added some code in `__DEV__` to provide more info - hopefully some developers will hit it and report the issue. Unfortunately it's not easy to get any useful information in prod because we strip all the useful debug info, but if this continues to be a problem we could try capturing that info in prod as well (and maybe other info, too).

Reviewed By: PeteTheHeat

Differential Revision: D16267702

fbshipit-source-id: 8185bb8ff0d646b307c98238616950086b1a608f
2019-07-17 14:15:54 -07:00
Spencer Ahrens 8dcee62be9 Use `Map`s instead of `Object`s for `MessageQueue` callbacks
Summary:
This lead to exceeding the Object property count limit in Hermes:
```
Unhandled JS Exception: Property storage can't accommodate 254464 properties, js engine: hermes
```

Reviewed By: PeteTheHeat

Differential Revision: D16212572

fbshipit-source-id: 8fcedb55ebd1f8b289ec759ea1ad4e81cf903dfd
2019-07-17 14:15:54 -07:00
Chris Blappert 87e02702a9 Remove some hacks to UIManager
Reviewed By: yungsters

Differential Revision: D15582614

fbshipit-source-id: 3de26eddcec47bba402b6dd44de3699c2af7862d
2019-07-17 12:30:37 -07:00
Guilherme Iscaro b432b8f13b Properly set borderRadius on Android (#25626)
Summary:
In order to properly set the view's borderRadius the inner*RadiusX/inner*RadiusY should not
be used, since their values are obtained via the following formula:

int innerTopLeftRadiusX = Math.max(topLeftRadius - borderWidth.left, 0);

If topLeftRadius and borderWidth.left have the same value innerTopLeftRadiusX will
be zero and it will cause the top left radius to never be set since
"(innerTopLeftRadiusX > 0 ? extraRadiusForOutline : 0)" will evaluate to zero.
In order to prevent this issue the condition will only consider topLeftRadius, topRightRadius, and etc.

I took a closer look to see if this fix does not causes a regression in https://github.com/facebook/react-native/issues/22511

## Changelog

[Android] [FIX] - Correctly set the border radius on android
Pull Request resolved: https://github.com/facebook/react-native/pull/25626

Test Plan:
Using the following code and Android certify that the border radius is correctly applied.
```javascript
import React from "react";
import { ScrollView, StyleSheet, Text, View } from "react-native";

export default class App extends React.Component<Props> {
  render() {
    return (
      <ScrollView style={styles.container}>
        <View style={styles.box1}>
          <Text>borderWidth: 2</Text>
          <Text>borderRadius: 2</Text>
        </View>
        <View style={styles.box2}>
          <Text>borderWidth: 2</Text>
          <Text>borderRadius: 2.000001</Text>
        </View>
        <View style={styles.box3}>
          <Text>borderWidth: 5</Text>
          <Text>borderRadius: 5</Text>
        </View>
        <View style={styles.box4}>
          <Text>borderWidth: 5</Text>
          <Text>borderRadius: 5.000001</Text>
        </View>
        <View style={styles.box5}>
          <Text>borderWidth: 10</Text>
          <Text>borderRadius: 10</Text>
        </View>
        <View style={styles.box6}>
          <Text>borderWidth: 10</Text>
          <Text>borderRadius: 11</Text>
        </View>
        <View style={styles.box7}>
          <Text>borderWidth: 10</Text>
          <Text>borderRadius: 5</Text>
        </View>
        <Text>Testing if this does not cause a regression in https://github.com/facebook/react-native/issues/22511</Text>
        <View style={{
          margin: 10,
          backgroundColor: 'red',
          width: 100,
          height: 100,
          borderWidth: 5,
          borderBottomLeftRadius: 15,
        }} />
        <View style={{
          margin: 10,
          backgroundColor: 'green',
          borderWidth: 5,
          width: 100,
          height: 100,
        }} />
      </ScrollView>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  },
  box1: {
    margin: 10,
    height: 100,
    borderRadius: 2,
    borderWidth: 2,
    borderColor: "#000000"
  },
  box2: {
    margin: 10,
    height: 100,
    borderRadius: 2.000001,
    borderWidth: 2,
    borderColor: "#000000"
  },
  box3: {
    margin: 10,
    height: 100,
    borderRadius: 5,
    borderWidth: 5,
    borderColor: "#000000"
  },
  box4: {
    margin: 10,
    height: 100,
    borderRadius: 5.000001,
    borderWidth: 5,
    borderColor: "#000000"
  },
  box5: {
    margin: 10,
    height: 100,
    borderRadius: 10,
    borderWidth: 10,
    borderColor: "#000000"
  },
  box6: {
    margin: 10,
    height: 100,
    borderRadius: 11,
    borderWidth: 10,
    borderColor: "#000000"
  },
  box7: {
    margin: 10,
    height: 100,
    borderRadius: 5,
    borderWidth: 10,
    borderColor: "#000000"
  }
});

```

### Without the fix

![not-working](https://user-images.githubusercontent.com/984610/61164801-e1dc6580-a4ee-11e9-91f3-6ca2fab7c461.gif)

### With the fix

![fixed](https://user-images.githubusercontent.com/984610/61164794-db4dee00-a4ee-11e9-88d7-367c29c785ec.gif)

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

Reviewed By: osdnk

Differential Revision: D16243602

Pulled By: mdvacca

fbshipit-source-id: 1e16572fdf6936aa19c3d4c01ff6434028652942
2019-07-17 12:22:53 -07:00
Valentin Shergin f003b931b4 Fabric: Workaround in ScrollView that communicates the fact that the view was unmounted
Summary:
See the comment in the code.
As part of proper fix of it, we also should remove a line in RCTScrollView that nulls the delegate.

Reviewed By: mdvacca

Differential Revision: D16296050

fbshipit-source-id: 54a4c6c60de4bd97c5cfb44652b5dc26852c540c
2019-07-17 11:20:52 -07:00
Valentin Shergin 509667e25a Fabric: Implementation of `ScrollView.contentInset`
Summary: Trivial.

Reviewed By: mdvacca

Differential Revision: D16296051

fbshipit-source-id: 2ab16cf94cbd14d6389a4cd8d9c68567fc5ee82c
2019-07-17 11:20:52 -07:00
Valentin Shergin bf38cf1be9 Fabric: Additional checks for _eventEmitter being null in ScrollView
Summary:
I finally convinced that we need to add this everywhere.
iOS internals can call those methods at any moment (which is happening in coming diffs), so we cannot predict `_eventEmitter` being not null.

Reviewed By: mdvacca

Differential Revision: D16296052

fbshipit-source-id: 34447c2b5af4117d75930d68593d60bace119bbd
2019-07-17 11:20:51 -07:00
Emily Janzer 5f8c129f19 Remove unused removeRootView() method from FabricUIManager
Summary:
FabricUIManager.removeRootView() isn't currently used, removing it from the UIManager interface.

It looks like this is called from JS in paper renderers, but not Fabric, so we should be good to delete it.

Reviewed By: shergin, mdvacca

Differential Revision: D16275118

fbshipit-source-id: b8f3ae1dc7574ce17d8cc9e7fee72ef5dcc9b323
2019-07-17 11:05:33 -07:00
Sidharth Guglani a43615a38a remove YGMarker code
Summary: Removes code for now unused marker based approach

Reviewed By: davidaurelio

Differential Revision: D16048800

fbshipit-source-id: 228e0e906252782ee0bed543728b666d1f9cc854
2019-07-17 08:12:00 -07:00
Sidharth Guglani fb855f60ba move YGMarkerMeasure and YGMarkerBaselineFn to event based system
Summary: Using yoga event listener for adding systrace sections for measure and baseline events

Reviewed By: davidaurelio

Differential Revision: D16048795

fbshipit-source-id: 3c2161328250184929ed1a3357b8c42ec8ca2e29
2019-07-17 08:12:00 -07:00
David Aurelio e4186e92dd Upgrade fbjni
Summary:
Upgrades Yoga’s copy of *fbjni* to the latest version.

This will enable us

- to move from `finalize()` to `PhantomReference` to deallocate native memory, with the potential of making GC more efficient.
- to remove the internal dependency to *libfb,* allowing apps without an own dependency to ship less code

Reviewed By: passy

Differential Revision: D16220924

fbshipit-source-id: e8233fe2b5403946ff51f43cb6def558ded52fda
2019-07-17 06:57:24 -07:00
Dan Abramov 4037f08b72 Always connect the socket at start
Summary:
Previously, Fast Refresh socket was initialized lazily. This changes it to be initialized eagerly, even if Fast Refresh is off.

This makes it easier to reason about different states the app can be in. It also lets us later change the code to stash away updates even when Fast Refresh is off — and apply them when you turn it on. (That's out of scope of this diff).

This change should not be user observable. Even if setting up the socket fails, the error is saved, and should only be shown once you turn it on. (AFAIK, D16286232 fixes the last error that was shown unconditionally.)

Reviewed By: rickhanlonii

Differential Revision: D16287232

fbshipit-source-id: a88f9c9f72847074876087da46e19dffa4eb82eb
2019-07-17 06:29:25 -07:00
Dan Abramov 93aab84699 Remove the escape hatch
Summary: I originally added `forceFullRefresh` as an escape hatch in case Fast Refresh is too unreliable. In practice we haven't seen any major issues with it. Since this option is already very obscure, I'm just removing it.

Reviewed By: shergin

Differential Revision: D16286632

fbshipit-source-id: c3dc44cffd459912e194e273acf868f3380c64cc
2019-07-17 06:29:25 -07:00
Dan Abramov 8e6f2f289b Don't redbox on startup if Metro is not running
Summary:
This fixes a problem that occurs when:

1. You run an Android app with Fast Refresh on
2. Kill the app
3. Start the app again

We used to redbox (on Android only). This is probably because we are missing some check on the native side, and we try to enable the socket anyway.

We could potentially fix this on the native side. But also, there's no good reason why this code needs to ever throw an error if Fast Refresh is disabled.

So I'm unifying it with the existing code path for other Fast Refresh errors. They are ignored when it's off, shown as yellowboxes when it's on, and shown as redboxes if you intentionally try to turn it off and on again.

I'm also adding core to prevent logging more than one Fast Refresh warning. Since they're not super actionable and usually indicate the same problem (e.g. Metro not running). The earliest one wins.

Reviewed By: rickhanlonii

Differential Revision: D16286232

fbshipit-source-id: bf3960f11c767a2352b1282d46950e4ba9e5031d
2019-07-17 06:29:25 -07:00
Dan Abramov e9640aeeb2 Downgrade symbolication warning to a log
Summary: These warnings are both noisy and unactionable to product developers when you disconnect a Metro server. You also see them *after* the redbox is closed anyway, so you kind of already know if symbolication didn't work. So I'm downgrading it to a simple log.

Reviewed By: motiz88

Differential Revision: D16285591

fbshipit-source-id: c0e4c9168f66f4573404aa336ab889e4e9da0c22
2019-07-17 06:29:25 -07:00
Michał Osadnik 247fc6774f Accept all types for objects' and arrays' elements
Summary:
Previously we accepted only very limited set of types for schema parser. However, in many cases we want to provide more specific typings e.g. accept enum or touple.

Currently, we don't take any advantages for codegen from specifying type of elements for object or array. All of them fallback to the same cpp code.

That's why I decided not to throw exception if types of arrays' and objects' elements are different than currently supported. Then I want to fallback to `undefined`.

Reviewed By: rickhanlonii

Differential Revision: D16325028

fbshipit-source-id: 3d7990ca0207c31f0ed522e7316a9cb17b6b1bcb
2019-07-17 06:21:51 -07:00
Michał Osadnik 7a62e7e333 Fix types for DialogManagerAndroid
Summary: We doesn;t support `onError: (string) => void,` is codegen so I change it to `onError: (error: string) => void,`

Reviewed By: TheSavior

Differential Revision: D16284628

fbshipit-source-id: a80a5da54823c827aa0bbe1f1f99613a35605489
2019-07-17 06:21:50 -07:00
Michał Osadnik a70a8d0e75 Add support for stringish in codegen for modules
Summary: Currently codegen for components supposts stringish. I add it also for components. It fallbacks to StringTypeAnnotation (like in codegen for components).

Reviewed By: rickhanlonii

Differential Revision: D16284381

fbshipit-source-id: 8f03cb79d7e2e1dabbdf4f9353d18dd1daf739fd
2019-07-17 06:21:50 -07:00
Michał Osadnik d1931344b0 Fix support for objects' types defined in file
Summary: By my mistake previosly it was not poossible to return object defined somewhere in file or return promise containing that object. I changed it to consider value which might be takes from `types` object.

Reviewed By: rickhanlonii

Differential Revision: D16283800

fbshipit-source-id: e9b0ad85b921022732ea0a11db9b58115e87aaa5
2019-07-17 06:21:49 -07:00
Michał Osadnik 6c7f3afee2 change flow union type in NativeUIManager.js to any
Summary: Union type is not supported by codegen and doen not have any impact on generated cpp code so I feel we may get rid of this only one case in favor of any.

Reviewed By: TheSavior

Differential Revision: D16283000

fbshipit-source-id: 210a8fbb7c191031e887d66e28dca048006ce00f
2019-07-17 06:21:49 -07:00
Michał Osadnik 28b282e5c7 Change callback in clearCookies and sendRequest from RCTNetworking to returning void
Summary: Currently callback has type `callback: (result: boolean) => mixed` what is pointless (and breaks codegen), because value returning flow callback doesn't have any impact.

Reviewed By: RSNara

Differential Revision: D16282852

fbshipit-source-id: fe1036f17bff307ac91b280727eaa5bf81febd35
2019-07-17 06:21:49 -07:00
Michał Osadnik ae840287e6 Temporarily get rid of not nullable boolean and number checks
Summary: NativeUIManager and NativeAnimatedModule are using nullable args. I believe we may teporarly don't care about that

Reviewed By: RSNara

Differential Revision: D16282683

fbshipit-source-id: 8071a9446c0e1e437391db17c16f82e131094c81
2019-07-17 06:21:48 -07:00
Michał Osadnik b4ac9ddcd5 Allow key of objects to be nullable
Summary: In this diff I handle the case where the key of an object may be nullable. To do that, I added a nullable param to the schema.

Reviewed By: rickhanlonii

Differential Revision: D16282081

fbshipit-source-id: cb7668d754e2ff30aef22df582351a512c988016
2019-07-17 06:21:48 -07:00
Michał Osadnik 6e73304401 Follow up e2e testing mechanism with real tests (#25680)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/25680

This diff's adding real e2e tests for skeleton added in previous diff.

It verifies many cases for codegen, which should generate cpp code.

Reviewed By: rickhanlonii

Differential Revision: D16279810

fbshipit-source-id: 4441dd0ed4d95476e4071fbd654ebfb8a47ecbfc
2019-07-17 06:21:48 -07:00
Michał Osadnik d6722477c4 Add e2e tests skeleton for generated cpp code (#25673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/25673

This diff add e2e code generator validation. I added proper buck rule which compiles cpp code and test if it really compiles.

While testing I faced few minor issues:

- `getBool` and `getNumber` shouldn't have `rt` param.

- Generators now start considering whole module name instead of sliced part of their name.

- Fixed import structure in generated cpp.

- renamed `jsireact` to `ReactCommon` following D16231697

Reviewed By: rickhanlonii

Differential Revision: D16221277

fbshipit-source-id: aff4011ad52dd5e16546ffdb709d6a751ebfaced
2019-07-17 06:21:48 -07:00
Emily Janzer 83969c26fb Decouple GuardedRunnable + friends from ReactContext
Summary:
Step 1 in removing the dependency on ReactContext from GuardedRunnable and other related classes. These are extensively by native modules and view managers, so in order to remove the bridge dependency from those modules we'll need to first decouple these classes from ReactContext. It turns out they only need ReactContext for its handleException method, which delegates out to product code. For backwards compatibility I'm exposing another NativeModuleExceptionManager in ReactContext that simply wraps its handleException method (since this interface already does everything we need).

I figured I'd keep around an extra constructor that still uses ReactContext for now instead of trying to migrate everything over at once.

Reviewed By: makovkastar

Differential Revision: D16270995

fbshipit-source-id: c9a8714bea7ac2a98e78234a0bae49140c00980d
2019-07-16 14:05:19 -07:00
Moti Zilberman 3a825c0360 Introduce NativeExceptionsManager.reportException API
Summary:
@public

`reportException` is a new method on `NativeExceptionsManager` that is designed to allow more structured and flexible JS error reporting. `reportFatalException` and `reportSoftException` are now deprecated.

In addition to all the usual exception fields, `reportException` also accepts an `extraData` property which the JS exception handler can populate with arbitrary JSON-serialisable data (here: the raw stack trace, the current JS engine, and the number of frames popped off the call stack by the exception handler). The contents of `extraData` get attached as JSON to the `JavascriptException` instance (or just logged, in the case of `console.error`).

This change is backwards compatible in two senses:
1. We have a JS fallback that uses `reportFatalException` and `reportSoftException` if the new native method is unavailable.
2. We have a Java fallback that implements `reportFatalException` and `reportSoftException` in terms of `reportException`.

Naturally, both fallbacks mentioned above discard `extraData`.

NOTE: The current implementation is Android-only; for the time being, iOS will continue to use the JS fallback.

While we're in `ExceptionsManager.js`, this also changes `dismissRedbox()` to be optional (which it is, since it's Android-only); existing call sites already guard it with a null check so this requires no other changes.

Reviewed By: mmmulani

Differential Revision: D16133080

fbshipit-source-id: d0b209d58da40b736df63155bbea232e94ce635c
2019-07-16 09:38:03 -07:00
Moti Zilberman 6fb1690de1 Introduce HasJavascriptExceptionMetadata interface
Summary:
@public

Introduces `HasJavascriptExceptionMetadata`, a thin interface to be implemented by all RN (Android) exception classes that represent JavaScript errors (primarily `JavascriptException` and any subclasses).

Also adds a builder-style API for setting the `extraDataAsJson` field on `JavascriptException` instances.

Reviewed By: abhinavbatra

Differential Revision: D16090574

fbshipit-source-id: 427a0d371f1cb4e6fe2e62a91db7857a191fdb8c
2019-07-16 09:38:03 -07:00
Michał Osadnik f7695e0183 Harden the Flow parser to handle more AST formats for commands and props
Summary:
This diff allows for parsing more flexible AST format.

Reusing logic used for methods, I add similar support for props and commands in components. Now it's possible to define separated type for props and commands in another part of the file.

Also, extracted this method to another file for reusing purposes.

Added tests.

Reviewed By: rickhanlonii

Differential Revision: D16221445

fbshipit-source-id: 21553bf5ade66588dd7dc0320d25333260b0ada9
2019-07-16 07:32:35 -07:00