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

629 Коммитов

Автор SHA1 Сообщение Дата
Ramanpreet Nara 6a9a76e420 Make RCTDevLoadingView TurboModule-compatible
Summary:
This is a redo of D16969764, with a few extensions.

## Changes
1. Move `RCTDevLoadingView.{h,m}` to `CoreModuels/RCTDevLoadingView.{h,mm}`
2. Extract ObjC API of `RCTDevLodingView` into `RCTDevLoadingViewProtocol` in `ReactInternal`.
3. Create API `RCTDevLoadingViewSetEnabled.h` in `ReactInternal` to enable/disable `RCTDevLoadingView`

Changelog:
[iOS][Added] - Make RCTDevLoadingView TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D18642554

fbshipit-source-id: 6b62e27e128d98254b7a6d018399ec1c06e274fc
2020-02-27 17:06:13 -08:00
Samuel Susla d33ead3f16 Fix matricesDiffer ignoring first value of matrix
Summary:
Changelog: [internal]

# Problem

Implementation of `matricesDiffer` was ignoring first element in the matrix, therefore two matrixes that were different were actually evaluated as same and React didn't pass value to native.

# Solution

Take first element in the matrix into account when comparing matrices.

Reviewed By: cpojer

Differential Revision: D20117210

fbshipit-source-id: 84c3b4e580da44bda4fc8bd8669318282ae9aa32
2020-02-27 05:43:02 -08:00
Eli White 6286270e4c Migrate TextInputState to take a ref instead of a reactTag
Summary:
Changelog:
[General][Breaking] Multiple deprecations and breaking changes to TextInputState. Use native component refs instead of react tags

Reviewed By: JoshuaGross

Differential Revision: D19458214

fbshipit-source-id: f67649657fa44b6c707a0ac91f07d2ceb433bc70
2020-02-19 15:28:59 -08:00
Rick Hanlon 96f19a3d89 Replace YellowBox references with LogBox
Summary:
This diff replaces some YellowBox references with LogBox so we can remove it.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D19948126

fbshipit-source-id: b26ad1b78d86a8290f7e08396e4a8314fef7a9f3
2020-02-18 07:51:46 -08:00
Adam Ernst bcc62a6d17 Clean up misc references to ComponentScript
Summary:
ComponentScript is defunct.

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: yungsters

Differential Revision: D19883555

fbshipit-source-id: 4459e42518468086489bb5d1470a38710423656a
2020-02-13 14:29:02 -08:00
Michel Weststrate ffb82cb2f0 Make sure exceptions and console.errors are send to metro
Summary: changelog: [General] `console.error` calls, and uncaught exceptions are now displayed in the Metro logs as well

Reviewed By: passy

Differential Revision: D19743075

fbshipit-source-id: a665a06cfc7854ae785af177af8f2478bb1d76b0
2020-02-12 08:27:04 -08:00
Yuanzhe Bian 484f62a71f Add hybrid scene tracker
Summary:
## This diff

- Add a hybird scene tracker that support both native navigation and js navigation
- It also has a filter that bypass loading routes and unrelated routes like log box
- The tracker can provide exactly what surface user is looking at

Changelog: [Internal]

Differential Revision: D19667699

fbshipit-source-id: 600efd05e68bf2702c6c2b1d794e720059f75f81
2020-02-03 18:46:38 -08:00
Peter Argany 0d968fd7dc Ignore deprecatedPropType in bridgeless mode
Summary:
This validate function uses the `UIManager.getViewManagerConfig` API to verify if props are supported. Bridgeless mode doesn't support UIManager APIs.

It seems like these `deprecatedPropType` will be removed eventually, so let's ignore it in bridgeless.

Changelog: [Internal] Ignore deprecatedPropType in bridgeless mode

Reviewed By: ejanzer

Differential Revision: D19603819

fbshipit-source-id: 2c744705be8821cc6a9d8daaac3e652987447e4d
2020-01-29 12:02:48 -08:00
Jesse Katsumata 5b8f4ef195 Clear some lint warnings (#27893)
Summary:
Applied linting for warnings that seemed trivial.

## Changelog

[Internal] [Fixed] - clear lint warnings
Pull Request resolved: https://github.com/facebook/react-native/pull/27893

Test Plan: yarn lint

Differential Revision: D19619569

Pulled By: cpojer

fbshipit-source-id: f9f02838c56e94abc1590686c8443c6c6e6f44ca
2020-01-29 04:36:28 -08:00
Eli White 4e31fbd39c Pressable: Update ReactTestTools to be able to tab on Pressable
Summary:
This was all yungsters idea. I blame him. :)

Switching Pressable to be a functional component presents a new challenge. ReactNativeTestTools can no longer find its instance because there is no instance Pressable uses forwardRef.

We need a way to both find a pressable, and then call the onPress callback if the pressable isn't also disabled.

So in DEV (and thus test) we add the pressable config to a secret key on a function passed onto View. The TestTools look for this key on this function, and then can call onPress.

Super hacky, but so is all of ReactNativeTestTools. We aren't proud of this.

Changelog:
[General][Changed]: Added support for Pressable to ReactNativeTestTools.tap

Reviewed By: yungsters

Differential Revision: D18849358

fbshipit-source-id: ea8880ceedfc04cda217ee17ba140475d003172c
2020-01-28 15:14:23 -08:00
Christoph Nakazawa 35c6bb9ac0 Only set dimensions if the window attributes change
Differential Revision: D19386339

fbshipit-source-id: b7f14c540ceec40cae0c4eb9fc93f2020a6ee16f
2020-01-13 23:26:14 -08:00
Christoph Nakazawa 02633fe522 Remove old JSC workarounds in HMRClient
Reviewed By: fkgozali

Differential Revision: D19297717

fbshipit-source-id: e85abe1c0d1b96cf21ae3a223ee65d92e6f88824
2020-01-07 16:53:15 -08:00
Christoph Nakazawa 022f9cc573 Force reload at split points when Metro restarts
Summary:
In https://fb.workplace.com/groups/rn.support/permalink/3132785890103338/?comment_id=3132873900094537 we identified that when Metro restarts but the app keeps the main bundle alive, the next request for a split bundle will always produce an invalid bundle. This is because we rely on module ids being stable while Metro is running and when Metro is restarted, those module ids will likely be assigned to different modules.

The fix applied here simply forces a full reload when downloading (registering) a new split bundle if the connection to Metro disappeared.

Another way to mitigate this is to use stable module ids. That's a more involved change in Metro that I'm not planning on making right now.

Changelog: [Internal]

Reviewed By: rickhanlonii

Differential Revision: D19235555

fbshipit-source-id: b8ff10590655952a2af1379bbf4e930f9eb95c1b
2019-12-26 22:31:40 -08:00
Jakub e2ec34deea Fix typo (#27579)
Summary:
Fixed typo (paramenter -> parameter) in `Libraries/Utilities/HMRClient.js`

## Changelog

[Internal] [Fixed] - Fixed typos in error messages
Pull Request resolved: https://github.com/facebook/react-native/pull/27579

Test Plan: N/A

Differential Revision: D19200542

Pulled By: hramos

fbshipit-source-id: 3e4e93f46a682f4606bf2f088d78b0d5edb55661
2019-12-20 13:25:16 -08:00
Ramanpreet Nara 048f88a33a Fix NativePlatformConstants
Summary:
When in debug mode, PlatformConstants doesn't have a `ServerHost` constant. This wasn't captured by `NativePlatformConstants`.

Changelog:
[Android][Fixed] - Make sure ServerHost is optional in NativePlatformConstants.js

Reviewed By: rickhanlonii

Differential Revision: D19091270

fbshipit-source-id: 4b3ac73a4ab6111b3e433ecca01cc769e8cdec6b
2019-12-18 08:22:09 -08:00
Ramanpreet Nara b42371da5a Fix NativeJSDevSupport.onSuccess
Summary:
`JSDevSupport.onSuccess` is called in `JSDevSupportModule.getJSHierarchy`:

```
const JSDevSupportModule = {
  getJSHierarchy: function(tag: number) {
    try {
      const {
        computeComponentStackForErrorReporting,
      } = ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
      const componentStack = computeComponentStackForErrorReporting(tag);
      if (!componentStack) {
        JSDevSupport.onFailure(
          JSDevSupport.ERROR_CODE_VIEW_NOT_FOUND,
          "Component stack doesn't exist for tag " + tag,
        );
      } else {
        JSDevSupport.onSuccess(componentStack);
      }
    } catch (e) {
      JSDevSupport.onFailure(JSDevSupport.ERROR_CODE_EXCEPTION, e.message);
    }
  },
};
```

If you look at the implementation of `computeComponentStackForErrorReporting`, it returns a `string`. The Java NativeModule also accepts a `String` for the argument to `JSDevSupport.onSuccess`. So, I've changed the `NativeJSDevSupport.onSuccess` method signature to match the native implementation (i.e: accept a string).

Changelog:
[General] [Fixed] - Correct argument types of NativeJSDevSupport.onSuccess

Reviewed By: fkgozali

Differential Revision: D18908306

fbshipit-source-id: 1c9a5c6fe5b3a81b25baed520e586ebf7e2514f8
2019-12-10 12:35:17 -08:00
Eli White e362470305 Convert easy files to flow strict-local
Summary:
This diff was generated by this script used by WWW
https://our.intern.facebook.com/intern/diffusion/WWW/browse/master/scripts/flow/upgrade_to_flow_strict_local.sh?lines=0

Changelog:
[Internal] Upgrade flow to flow strict-local

Reviewed By: zackargyle, rickhanlonii

Differential Revision: D18833630

fbshipit-source-id: e64d4e9a49a0db5e6bf70a0c489567862b578d7f
2019-12-05 16:06:46 -08:00
Eli White c24c8a039c Core files should depend on internals directly
Summary:
By depending on react-native, these files can't be flow strict until index.js is flow strict. By depending on the internals directly they can be flow strict as soon as their dependents are flow strict.

Changelog:
[Internal] Refactoring some core file imports to depend on internals directly

Reviewed By: zackargyle

Differential Revision: D18828324

fbshipit-source-id: 2a347c4e234a64edbb3e6f0ef6387ef1ce78badc
2019-12-05 13:33:58 -08:00
Tim Yung ebf7d75816 RN: New `TouchableWithoutFeedback`
Summary:
Launches a new implementation of `TouchableWithoutFeedback`.

It is implemented using `Pressability` and extends `React.Component`. Notably, `propTypes` no longer exist.

Changelog:
[General] [Changed] - TouchableWithoutFeedback overhauled as a class without propTypes.

Reviewed By: TheSavior

Differential Revision: D18715852

fbshipit-source-id: f2eb28e3b8500bfcd8db44fc6bdbc0476193723a
2019-11-27 07:48:38 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
2019-11-21 09:42:57 -08:00
Ramanpreet Nara 1ad0862363 Revert D16969764: Make RCTDevLoadingView TurboModule-compatible
Differential Revision:
D16969764

Original commit changeset: 47e6682eea3f

fbshipit-source-id: d95b76eb8e57bbaff840b3d85f3745b13d622ce0
2019-11-21 08:43:12 -08:00
Eli White 20a3bb52ce Convert component snapshot tests to a reusable helper
Summary:
These tests need to be consistent with every test so a helper makes more sense.

Changelog: [Internal]

Reviewed By: rickhanlonii

Differential Revision: D18500439

fbshipit-source-id: de535156d370102bad88e556ad3d2a0d5443e4e2
2019-11-20 18:09:30 -08:00
Ramanpreet Nara 294e31b7c2 Make RCTDevLoadingView TurboModule-compatible
Summary:
RCTDevLoadingView wasn't hooked up to the codegen. This diff makes RCTDevLoadingView type-safe and also makes it TurboModule-compatible.

Changelog:
[iOS][Added] - Make RCTDevLoadingView TurboModule-compatible

Reviewed By: PeteTheHeat

Differential Revision: D16969764

fbshipit-source-id: 47e6682eea3fc49d3f0448c636b5f616d5bce220
2019-11-20 11:20:12 -08:00
Rick Hanlon bdd1a675ba Dismiss all logs on fast refresh
Summary:
Based on feedback we're going to clear all logs on fast refresh 👍

Changelog: [Internal]

Reviewed By: gaearon

Differential Revision: D18614230

fbshipit-source-id: 119a09e8ffea9d86137583d8da435338833f910c
2019-11-20 08:50:49 -08:00
Eli White 8f601418ab Convert TextInput from NativeMethodsMixin to ES6 Class
Summary:
In order to make this more flow typed and modern we need to get it off of createReactClass. This change converts the class as is with no intended behavior changes to an ES6 class.

Changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D18443018

fbshipit-source-id: 831921976e9de8e965180cdefd1c4a154f04bfea
2019-11-15 14:02:41 -08:00
Rick Hanlon e9fd102c33 Remove "reload to reconnect" from the metro disconnected message
Summary:
Changes the Fast Refresh message for when metro disconnects to remove "Reload to reconnect.". The most common use case for this happening is when Metro is stopped, and reloading will not reconnect to a stopped metro server.

Long term we should reconnect to Metro automatically and then this message would be followed up with a "Reconnected to Metro" message, never needing a reload.

Changelog: [Internal]

Reviewed By: cpojer

Differential Revision: D18527705

fbshipit-source-id: 40768ce1089348b612e9d86638f07169d2a34b67
2019-11-15 06:18:30 -08:00
Rick Hanlon c54f5cf72a LogBox - Only dismiss syntax errors when the issue is fixed
Summary:
This change is not only more correct, it's also fixes the modal in the the next diff.

It's more accurate because in the previous location, the redbox dismissal was done as a hack in order to hide non-syntax errors so that the syntax error would be visible when it fired. This is unnecessary for LogBox because it always puts syntax errors on top of any other error.

The main motivation for changing this, however, is that this strategy is broken when switching to the Modal component because the Modal component does not work well with quickly unmounting and remounting. With the old strategy, the inspector would flicker and then collapse even though there was a syntax error.

Changelog: [Internal]

Reviewed By: cpojer, gaearon

Differential Revision: D18461431

fbshipit-source-id: e8ed83e3d2b002e5d45cc13dc9533ed841ed5cae
2019-11-14 12:06:35 -08:00
Kevin Gozali fb627dac6a TM JS: Revert to import from TurboModuleRegistry.js
Summary:
Changelog: [Internal]

Reverting the import to the previous local module style since importing from react-native seems to introduce some perf regression. We'll revisit this later in the future.

Reviewed By: yungsters

Differential Revision: D18383893

fbshipit-source-id: f11d46a4545768f39199fd6fd22fcf14905d0a74
2019-11-08 11:44:16 -08:00
Emily Janzer da39b07298 Add handwritten view config for RCTScrollView
Summary:
Adding a handwritten view config for RCTScrollView, to be used in DEV only (for now).

Changelog: [Internal]

Reviewed By: rickhanlonii

Differential Revision: D18263203

fbshipit-source-id: 975499f030c7caed9851bcde0be42c5058911ad5
2019-11-05 19:09:02 -08:00
Jordan Brown 93e58b2c96 Suppressions for 0.111
Summary:
still some generated files in www that need to land before we can release 0.111 here.

drop-conflicts

Changelog: [Internal]

(Note: this ignores all push blocking failures!)

Reviewed By: dsainati1

Differential Revision: D18278838

fbshipit-source-id: b20c3fefb3aab7c5fb614b33d846c7548184f49a
2019-11-05 17:36:23 -08:00
Jorge Bernal a6fc0898de Add support for native pseudo-OS to Platform.select (#26966)
Summary:
When you write platform-specific code using [file extensions](https://facebook.github.io/react-native/docs/platform-specific-code#platform-specific-extensions), you can specify `.ios.js`, `.android.js`, or the catch-all `.native.js` when you are sharing code with a web project.

This `native` shortcut is missing for the `Platform.select` method, and this PR is adding support for that.

## Changelog

[General] [Added] - Platform.select now supports native as an option.
Pull Request resolved: https://github.com/facebook/react-native/pull/26966

Test Plan: Added relevant passing unit tests for Platform module.

Differential Revision: D18323670

Pulled By: cpojer

fbshipit-source-id: 7524c1914beab4f86041dcf8e60875380ebf7e02
2019-11-05 05:39:20 -08:00
Kevin Gozali dd06f85bd0 TM JS: cleaned up TurboModuleRegistry types [2]
Summary:
Changelog: [Internal]

Moved the imports for `TurboModuleRegistry` and `TurboModule` from `react-native`. This was a jscodeshift with the script: P120688078

Reviewed By: yungsters

Differential Revision: D18262538

fbshipit-source-id: 48fac15229c897408928511c5ecbb42f17ec7b42
2019-11-04 18:51:05 -08:00
Samuel Susla b6a23d8793 Add excludedPlatform option to CodeSchema
Summary:
Currently we generate Java ViewManager interfaces and C++ classes for iOS regardless whether the component is supported on platform or it isn't. This adds an option to exclude either iOS to Android in order to avoid this.

Changelog: In codegen it is now possible to exclude one or the other platform

Reviewed By: rickhanlonii

Differential Revision: D18217185

fbshipit-source-id: 1c569b92c92a5b991c96b0abdff6b8ed395e449f
2019-11-04 04:36:55 -08:00
Rick Hanlon 62c79206ef Fast Refresh - Dismiss LogBox syntax errors
Summary:
This diff adds Fast Refresh support for dismissing LogBox syntax errors. We don't dismiss all errors because once a syntax error is fixed you'll still want to see the covered fatals, errors, and warnings.

If you actually full reload, then it falls back to the native redbox.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D18278889

fbshipit-source-id: f109ca1d6c34aa3eda6e434deca66f8ce5e02ce0
2019-11-01 16:08:49 -07:00
David Vacca 67a1743e20 Enable codegen ViewConfig in production
Summary:
This diff enables the codegen ViewConfig in production, which have been running in Dev mode for 4+ months withouth any issue

Changelog: [Internal]

Reviewed By: rickhanlonii, ejanzer

Differential Revision: D18218546

fbshipit-source-id: cc74a89db1b1f8d9770a0b7dacb2fbfa6fd3a2d7
2019-10-31 12:09:04 -07:00
Kevin Gozali f15309fa15 Appearance: stop caching colorScheme in JS
Summary:
At times, the OS updates the color scheme without any active listener on RN side, e.g. if all RCTRootView's in iOS have been deallocated, no one will tell JS that the color scheme changes. So let's just always ask native side for the latest value.

Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D18117334

fbshipit-source-id: e8564fb284c5720061592ba72e5b4907e5b48853
2019-10-24 11:09:10 -07:00
Moti Zilberman 99d229e186 Make deepDiffer behavior with function inputs configurable, add logging
Summary: Changelog: [Internal]

Reviewed By: yungsters

Differential Revision: D17951644

fbshipit-source-id: 34bff1937a6157b049193359cb0ad346c48287a6
2019-10-23 00:58:56 -07:00
Emily Janzer f2f4d33a3a Remove unsupported flow types from OSS native module specs
Summary:
Some of our NativeModule type specs aren't compatible with our Android codegen and type safety checks - specifically, we don't support `$ReadOnly` in our type checks, and we don't support map types in the codegen. Removing these from a couple of the OSS type specs so we can enable codegen for these modules (eventually).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D17882093

fbshipit-source-id: 6e8669e4be775347199b2b5346bd8d40d7620886
2019-10-16 11:14:04 -07:00
Andres Suarez aee88b6843 Tidy up license headers [3/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952693

fbshipit-source-id: 8fcb8e58a2e04e7a3169f4d525bffc00835768e6
2019-10-16 10:06:34 -07:00
Andres Suarez 3b31e69e28 Tidy up license headers [2/n]
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: yungsters

Differential Revision: D17952694

fbshipit-source-id: 17c87de7ebb271fa2ac8d00af72a4d1addef8bd0
2019-10-16 10:06:34 -07:00
Dan Abramov 4ed05ca241 Send early logs to Metro too
Summary:
If you `console.log` early enough in the initialization sequence, it won't get sent to Metro because `hmrClient` isn't initialized yet. I've added a rolling array to catch at most 100 of those, and send them after we initialize.

Changelog: [General] [Fixed] - Early logs don't get dropped by Metro now

Reviewed By: cpojer

Differential Revision: D17952097

fbshipit-source-id: 964b4735a6a7c3ccd115f44151139d718bf5b26d
2019-10-16 08:03:21 -07:00
Andres Suarez e1cfeaddd4 Move non-license comments out of license header
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: cpojer

Differential Revision: D17749100

fbshipit-source-id: edca9c73a065e9fc311109cd6efeb1f75451a55a
2019-10-15 20:12:12 -07:00
luancurti d66931987a Fix platform ios get version type (#26639)
Summary:
Fix flow type platform ios get version

## Changelog

[INTERNAL] [FIXED] - Fix flow type platform ios get version

## Test Plan
Pull Request resolved: https://github.com/facebook/react-native/pull/26639

Differential Revision: D17743074

Pulled By: TheSavior

fbshipit-source-id: de97c612dbf615a8ede1905cb158f258c9ce5737
2019-10-03 12:29:47 -07:00
Rick Hanlon 2d95668aa8 Add fastRefresh to NativeDevSettings
Summary: This diff adds a method to call whenever a fast refresh happens. Right now this is only useful for reporting.

Reviewed By: cpojer

Differential Revision: D17528033

fbshipit-source-id: 17e82abe7a3e2bab6829de5adecda853fe5335c5
2019-09-30 07:03:51 -07:00
Rick Hanlon 549cac63cb Add reloadWithReason to DevSettings
Summary:
This diff adds reloadWithReason to the NativeDevSettings and updates the exposed DevSettings.reload method to send to it if it's available (setting an 'uncategorized' reason if one isn't set.

[General][Feature] Update DevSettings.reload to accept a reason

Reviewed By: RSNara

Differential Revision: D17499343

fbshipit-source-id: e8c9724800f93d3b9a5d2a8fe9f689d51947d39b
2019-09-30 07:03:50 -07:00
Eli White 69c38e5a63 Introduce flow type to differentiate between HostComponent, NativeMethodsMixin, and NativeComponent
Summary:
In React Native there are three types of "Native" components.

```
createReactClass with NativeMethodsMixin
```
```
class MyComponent extends ReactNative.NativeComponent
```
```
requireNativeComponent('RCTView')
```

The implementation for how to handle all three of these exists in the React Native Renderer. Refs attached to components created via these methods provide a set of functions such as
```
.measure
.measureInWindow
.measureLayout
.setNativeProps
```

These methods have been used for our core components in the repo to provide a consistent API. Many of the APIs in React Native require a `reactTag` to a host component. This is acquired by calling `findNodeHandle` with any component. `findNodeHandle` works with the first two approaches.

For a lot of our new Fabric APIs, we will require passing a ref to a HostComponent directly instead of relying on `findNodeHandle` to tunnel through the component tree as that behavior isn't safe with React concurrent mode.

The goal of this change is to enable us to differentiate between components created with `requireNativeComponent` and the other types. This will be needed to be able to safely type the new APIs.

For existing components that should support being a host component but need to use some JS behavior in a wrapper, they should use `forwardRef`. The majority of React Native's core components were migrated to use `forwardRef` last year. Components that can't use forwardRef will need to have a method like `getNativeRef()` to get access to the underlying host component ref.

Note, we will need follow up changes as well as changes to the React Renderer in the React repo to fully utilize this new type.

Changelog:
[Internal] Flow type to differentiate between HostComponent and NativeMethodsMixin and NativeComponent

Reviewed By: jbrown215

Differential Revision: D17551089

fbshipit-source-id: 7a30b4bb4323156c0b2465ca41fcd05f4315becf
2019-09-25 10:12:38 -07:00
Janic Duplessis cc068b0551 Export the DevSettings module, add `addMenuItem` method (#25848)
Summary:
I wanted to configure the RN dev menu without having to write native code. This is pretty useful in a greenfield app since it avoids having to write a custom native module for both platforms (and might enable the feature for expo too).

This ended up a bit more involved than planned since callbacks can only be called once. I needed to convert the `DevSettings` module to a `NativeEventEmitter` and use events when buttons are clicked. This means creating a JS wrapper for it. Currently it does not export all methods, they can be added in follow ups as needed.

## Changelog

[General] [Added] - Export the DevSettings module, add `addMenuItem` method
Pull Request resolved: https://github.com/facebook/react-native/pull/25848

Test Plan:
Tested in an app using the following code.

```js
if (__DEV__) {
 DevSettings.addMenuItem('Show Dev Screen', () => {
    dispatchNavigationAction(
      NavigationActions.navigate({
        routeName: 'dev',
      }),
    );
  });
}
```

Added an example in RN tester

![devmenu](https://user-images.githubusercontent.com/2677334/62000297-71624680-b0a1-11e9-8403-bc95c4747f0c.gif)

Differential Revision: D17394916

Pulled By: cpojer

fbshipit-source-id: f9d2c548b09821c594189d1436a27b97cf5a5737
2019-09-17 06:38:10 -07:00
Ram N 49f59a6b9e Handle empty string returned from NativeAppearance.getColorScheme()
Reviewed By: PeteTheHeat

Differential Revision: D17151675

fbshipit-source-id: 39b9a32271cd45b82faa5e0248d589ef1ed9f4c9
2019-09-03 12:11:15 -07:00
Héctor Ramos 51681e80ab useColorScheme hook (#26143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/26143

A new useColorScheme hook is provided as the preferred way of accessing the user's preferred color scheme (aka Dark Mode).

Changelog:

[General] [Added] - useColorScheme hook

Reviewed By: yungsters

Differential Revision: D16860954

fbshipit-source-id: 8a2b6c2624ed7cf431ab331158bc5456cde1f185
2019-08-31 11:22:43 -07:00
Héctor Ramos 63fa3f21c5 Add Appearance native module
Summary:
Implements the Appearance native module as discussed in https://github.com/react-native-community/discussions-and-proposals/issues/126.

The purpose of the Appearance native module is to expose the user's appearance preferences. It provides a basic get() API that returns the user's preferred color scheme on iOS 13 devices, also known as Dark Mode. It also provides the ability to subscribe to events whenever an appearance preference changes.

The name, "Appearance", was chosen purposefully to allow for future expansion to cover other appearance preferences such as reduced motion, reduced transparency, or high contrast modes.

Changelog:

[iOS] [Added] - The Appearance native module can be used to prepare your app for Dark Mode on iOS 13.

Reviewed By: yungsters

Differential Revision: D16699954

fbshipit-source-id: 03b4cc5d2a1a69f31f3a6d9bece23f6867b774ea
2019-08-30 17:07:57 -07:00
Dulmandakh 3b3c95b017 Fix useWindowDimensions firing continuously after dims change (#26008)
Summary:
https://github.com/facebook/react-native/pull/25990 fixed the `forceUpdate` method to actually update the component, but caused the useEffect to fire on every render, causing continuous updates after dimensions changed (e.g. from rotation).

This reworks things a bit to be a bit simpler and more idiomatic so it's not quite as confusing, and fixes the bugs.

## Changelog

[General] [Fixed] - Fix useWindowDimensions hook firing continuously after dimensions change

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

Test Plan:
Aparently the Mobile Home app supports rotation on iOS now, so replaced it's content with the first `DimensionsExample` and confirmed with logging that `useEffect` fires exactly once, on initial mount, but the view still updates as expected when rotated:

https://pxl.cl/Hfds

Reviewed By: yungsters

Differential Revision: D16765269

Pulled By: sahrens

fbshipit-source-id: ef55d8a470dcfe87aa125d4c426bf01cfe0091a7
2019-08-23 13:50:56 -07:00
Logan Daniels b6333f79e1 Final fixes and seal xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16946423

fbshipit-source-id: 89ca82c955e99a23a14984d51f3c97346c363afd
2019-08-23 08:45:11 -07:00
Logan Daniels 92073d4a71 Clean-up $TEMPORARY$object in xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16931667

fbshipit-source-id: d87e5ed02bf7f95005cf0f36c3cd127026189058
2019-08-21 09:58:24 -07:00
Logan Daniels 91f139b941 xplat/js/react-native-github
Reviewed By: panagosg7

Differential Revision: D16657770

fbshipit-source-id: 4e260842c838a35317515044c54ccf55a083da33
2019-08-09 10:11:15 -07:00
Logan Daniels 9127fb51fc Manual fixes for xplat/js/react-native-github
Summary:
Need to add explicit type annotations in these areas to unblock types-first architecture for Flow. These are locations the codemod could not automatically handle.

I'll call out areas I need a close eye on in the comments.

Reviewed By: panagosg7

Differential Revision: D16659053

fbshipit-source-id: 167dd2abe093019b128676426374c1c62cf71e7f
2019-08-09 10:11:15 -07:00
Bruno Lemos 742a544b73 Fix forceUpdate method on useWindowDimensions (#25990)
Summary:
useState won't trigger re-renders if the value passed is the same.

## Changelog

[Internal] [Fixed] - Fix forceUpdate method on useWindowDimensions
Pull Request resolved: https://github.com/facebook/react-native/pull/25990

Test Plan: Codesandbox: https://codesandbox.io/embed/elegant-cori-0ixbx

Differential Revision: D16723962

Pulled By: sahrens

fbshipit-source-id: 8a46152908a90553151e0353bbfd8c2e64cfd2af
2019-08-08 17:12:26 -07:00
Rick Hanlon 2e8ecab583 Add tests for codegenNativeComponent
Summary: Adds tests for codegenNativeComponent

Reviewed By: TheSavior

Differential Revision: D16582627

fbshipit-source-id: 3527126c7838f3e2c0c56b19956c618f0a7fb9f9
2019-08-07 06:00:23 -07:00
Rick Hanlon deaaab908b Fix error string in codegenNativeComponent
Summary: This diff fixes the error message in the codegenNativeComponent fallback

Reviewed By: TheSavior

Differential Revision: D16579775

fbshipit-source-id: 176f81ea91e11f671407a5e5e5b000c4b83f93b2
2019-08-06 07:02:57 -07:00
Spencer Ahrens 103ec2f770 Fix Dimensions for ComponentScript
Summary: ComponentScript uses Dimensions, but doesn't support native modules, so we need to keep the `nativeExtensions` stuff that was dropped in D16525189.

Reviewed By: PeteTheHeat

Differential Revision: D16611233

fbshipit-source-id: c0add40529743e02ab7943814dc9f2188e8e0633
2019-08-01 18:25:57 -07:00
Eli White a6fffb7cd0 Add runtime behavior to codegenNativeCommands
Summary:
Previously codegenNativeCommands was just a hint to the babel transform. This meant that in order to use the codegen'd JS command functions it required having the babel transform turned on.

We aren't ready to turn the transform on for open source so we are adding runtime behavior to the function that will run when it isn't replaced with the transform.

Reviewed By: rickhanlonii

Differential Revision: D16574781

fbshipit-source-id: 583e8857f69ae1695445ee887432d15248dd35a9
2019-08-01 15:05:57 -07:00
Eli White b526f66c19 Back out "Back out "[RNCodegen] codegenNativeCommands takes list of supported commands""
Summary:
Original commit changeset: 34a8f8395ca7

The problem with the original commit was the usage of optional chaining. This diff removes the usage of optional chaining with good old fashioned null checks.

Reviewed By: rickhanlonii

Differential Revision: D16593623

fbshipit-source-id: d24cc40c85de9a2e712e5de19e9deb196003ccf2
2019-08-01 15:05:57 -07:00
Joshua Gross 678d5f7cd1 Back out "[RNCodegen] codegenNativeCommands takes list of supported commands"
Summary: Original commit changeset: 189754a567a3

Reviewed By: rickhanlonii

Differential Revision: D16586885

fbshipit-source-id: 34a8f8395ca73e190ccf0242f02626094f6d87b6
2019-07-31 14:11:06 -07:00
Eli White f161583713 codegenNativeCommands takes list of supported commands
Summary:
We want to enable codegenNativeCommands to have a runtime fallback that will work if the babel transform is not enabled. For example, in open source until we turn it on everywhere. By listing the supported commands, we can create the necessary functions at runtime to support what we need.

A follow up diff will add that runtime behavior to codegenNativeCommands.

Reviewed By: JoshuaGross

Differential Revision: D16573450

fbshipit-source-id: 189754a567a3a5ccd34629a8dfedf808e6824e82
2019-07-30 20:28:26 -07:00
Spencer Ahrens 5ec382d1be New `useWindowDimensions` hook to replace most `Dimensions` usage
Summary:
Automatically provides and subscribes to dimension updates - super easy usage:
```
function MyComponent(props: Props) {
  const {width, height, scale, fontScale} = useWindowDimensions();
  return <Text ...
};
```

Only window for now - it's what people want 99% of the time, so we'll just shovel out a pit of success for them...

There are still cases where `Dimensions` is needed outside of React component render functions, like in GraphQL variables, so we need to keep the existing module.

Reviewed By: zackargyle

Differential Revision: D16525189

fbshipit-source-id: 0a049fb3be8d92888a8a69e3898d337b93422a09
2019-07-29 11:09:44 -07:00
Christoph Nakazawa 179889704b Fall back to `JSON.stringify` in `console.log` if Symbol is unavailable
Summary: Symbol is not available in older versions of JSON resulting in crashes in `prettyFormat` because we are using a clowny transform.

Reviewed By: sebmck

Differential Revision: D16501208

fbshipit-source-id: 9952bf4993ae05335707cd386f9aa4bbc14b7564
2019-07-25 15:32:06 -07:00
Christoph Nakazawa abd7faf354 Use prettyFormat for Metro logging
Summary: Right now we are using `JSON.stringify` which is very lossy with regards to JavaScript data types like functions, `undefined`, NaN and others. This diff switches the logging on the client side to use `prettyFormat` which is part of Jest. It allows to handle much richer log messages.

Reviewed By: gaearon

Differential Revision: D16458775

fbshipit-source-id: e1d2c125eb8357a9508521aa15510cb4f30a7fa9
2019-07-25 01:24:55 -07:00
Dan Abramov 5e960e30eb Don't show warnings unless we managed to connect
Summary:
On iOS we don't call `HMRClient.setup()` when Metro is off. So we don't bump into any odd cases.

But on Android, we do call `HMRClient.setup()` even if Metro is off. As a result, we might show a warning about Metro not running to a native engineer who doesn't care (because they don't intend to work on JS).

We could fix this on Android on the native side. And we probably should.

But we can also strengthen it here. The idea is that we should only show warnings about disconnecting from Metro *if we ever managed to successfully connect in the first place*. Otherwise, we can assume that you didn't mean to connect.

If the user is trying to determine the source of the problem, they can still do a full Refresh (on iOS this will show a message about needing Metro, on Android it would show a redbox). So this diff makes the disconnected behavior closer to how it worked before Fast Refresh.

Reviewed By: sahrens

Differential Revision: D16460439

fbshipit-source-id: bf962ff34c25d9734d9668dd583591acacb98253
2019-07-24 11:11:46 -07:00
Dan Abramov 2a3ac0429b Tweak messages and fix the warning condition
Summary:
Two changes:

1. If you're connected at startup, and then disconnect, we're supposed to show a yellow box. Looks like we weren't doing it for a few days because the field we were checking has turned into a method.

2. I changed the wording back to remove "Metro" since the packager may be Haul, for example. So I'm just calling it "development server". Does that seem reasonable? I also removed mentions of Fast Refresh since it's not actually relevant to the problem.

Reviewed By: cpojer

Differential Revision: D16459080

fbshipit-source-id: c9c1f19718d522c745e4107a3e7e3a6c63f82642
2019-07-24 11:11:46 -07:00
Christoph Nakazawa 81ec2112a1 Use HMRClient to send console logs to Metro
Summary:
This change switches the sending of log messages to Metro from HTTP over to WebSocket. This is what I should have done from the beginning *however* I only spent very little time on this initially, didn't realize that it would be a popular feature *and* we didn't have a persistent WebSocket connection on the client before that was always on. Together with D16442656 we can finally make this happen!

This change:
* Changes the `fetch` call to `HMRClient.log`
* Removes the middleware and integrates logging with `HmrServer` directly in Metro.
* Simplifies the logging logic as WebSockets guarantee messages are processed in order.

This also fixes an issue makovkastar identified when using the `MessageQueue` spy: because we send messages back and forth over the bridge, using `console.log` within `MessageQueue`'s spy method will actually cause an infinite logging loop. This is the proper solution to that problem instead of hacking around it using custom headers.

Note: in a follow-up we will rename these modules to drop the `HMR` prefix. We have not come up with a better name yet and are open to ideas.

Reviewed By: sebmck

Differential Revision: D16458499

fbshipit-source-id: 4c06acece1fef5234015c877354fb730b155168c
2019-07-24 08:11:34 -07:00
Min ho Kim 84f5ebe4f9 Fix typos (#25770)
Summary:
Fix typos mostly in comments and some string literals.

## Changelog

[General] [Fixed] - Fix typos
Pull Request resolved: https://github.com/facebook/react-native/pull/25770

Differential Revision: D16437857

Pulled By: cpojer

fbshipit-source-id: ffeb4d6b175e341381352091134f7c97d78c679f
2019-07-23 03:23:11 -07:00
Dan Reynolds d544fa20b7 add support for stringifying error object messages to stringifySafe (#25723)
Summary:
Error objects logged as part of the arguments to `console.error` such as from [rejected es6 promises](https://github.com/zloirock/core-js/blob/v2/modules/es6.promise.js#L110) contain the error that the user would want to see as the error object's message, but is not captured by `stringifySafe`. Here we modify it to if the logged value is an error object print the error similar to chrome:

```
const error = new Error('error');
stringifySafe(error); // Error: error
```

Versus the current behavior which does not recognize the error type and instead tries to stringify the it as an object:

```
JSON.stringify(new Error('error')) // "{}"
```

## Changelog

[JavaScript] [Changed] - Add support for stringifying error object messages to safeStringify
Pull Request resolved: https://github.com/facebook/react-native/pull/25723

Test Plan:
Tests:
<img width="802" alt="Screen Shot 2019-07-18 at 8 39 52 PM" src="https://user-images.githubusercontent.com/2192930/61501171-39218080-a99c-11e9-8e87-48ea413b3d01.png">

Lint:
<img width="406" alt="Screen Shot 2019-07-18 at 8 43 35 PM" src="https://user-images.githubusercontent.com/2192930/61501318-dc729580-a99c-11e9-9264-c0232515352c.png">

Differential Revision: D16437956

Pulled By: cpojer

fbshipit-source-id: ca3ce9c98ad585beb29c2bfeb81bbd14b2b1c700
2019-07-23 02:46:19 -07:00
Dan Abramov b40aa7f8d8 Don't dismiss initial runtime error
Summary: If there's a redbox at the start, we shouldn't dismiss it. Instead, redboxes should only be dismissed on explicit edits.

Reviewed By: yungsters

Differential Revision: D16421934

fbshipit-source-id: 770c5b5fc85e6b6ce00a4477aa87d6e91b14fc3c
2019-07-22 20:38:16 -07:00
Rick Hanlon 42cf8a9241 Retry add JS view config for View
Summary: Adds the JavaScript view config for View

Reviewed By: TheSavior

Differential Revision: D15862368

fbshipit-source-id: 8a6a77cf57e84744044a2d6034aff2be6e600f5f
2019-07-22 09:30:31 -07:00
Dan Abramov e9d20eafa7 Remember and surface compile errors when turning on
Summary: When turning on Fast Refresh, we might have a compile error in previously saved files. We used to ignore it until a file is saved again, leading to a confusing experience. This changes it so that we remember the last compile error, and show it _either_ when we get it (if Fast Refresh is off), or when we _turn it on_.

Reviewed By: cpojer

Differential Revision: D16359160

fbshipit-source-id: 8dc237563c2a271a23019a32ff85b57de99cfabe
2019-07-18 11:11:30 -07:00
Dan Abramov d5e49bdd05 Add `isInitialUpdate` to HmrServer
Summary: Right now we are using a local boolean and `bundle-registered` to hide the "Refresh" banner on the first update from the server (right after loading the bundle). This change adds `isInitialUpdate` to the `update-start` message which I'm now using to disable the banner. This also simplifies the HMRClient a little bit.

Reviewed By: cpojer

Differential Revision: D16357287

fbshipit-source-id: 29e72774989c4ba895a85be06a366e1b2fe7c02f
2019-07-18 11:11:30 -07:00
Dan Abramov 7c7fe1caae Stash updates when Fast Refresh is off
Summary:
If you change a file while Fast Refresh is off, this now stashes an update instead of ignoring it. When/if you turn it on, we will apply those stash updates. This solves the confusion that can happen when you enable it midway after making a bunch of changes, and therefore makes the experience more reliable.

**This current implementation is unfortunate because the app memory load increases with the number of file saves. This isn't really sustainable. So in the next diff I will change it to only remember the *latest versions* of every edited file instead.**

Reviewed By: cpojer

Differential Revision: D16344332

fbshipit-source-id: 69609a00eb9022f6b2797269fa091fa1b4125dd1
2019-07-18 11:11:29 -07:00
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
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
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
Christoph Nakazawa a622421634 Add `registerEntryPoint` to HmrServer
Summary: This diff changes a few things around so that a diff coming on top of this stack will be smaller. The aim of this change is to add a method `registerEntryPoint` which will allow a client to subscribe to updates for multiple bundles.

Reviewed By: gaearon

Differential Revision: D16131963

fbshipit-source-id: d460d6647b15a711021c7a3a51f52486a1aea535
2019-07-09 03:21:25 -07:00
Dan Abramov abc663dd5a Add a shim for HMRClient in prod bundles
Summary:
Running a PROD JS bundle with a DEV binary used to redbox with Fast Refresh on. The error said "HMRClient is not a registered callable module".

This isn't a new issue: https://www.google.com/search?q=%22hmrclient%20is%20not%20a%20registered%22. However, now it happens every time because `setup()` is now called unconditionally in a DEV native build.

Because a combination of DEV binary + PROD JS is technically possible, I'm adding a tiny shim that will make it a no-op instead of crashing. It will also explain what's wrong if you *intentionally* try to turn on Fast Refresh.

Reviewed By: sahrens

Differential Revision: D16145378

fbshipit-source-id: 0b9c0a6f30c02ca7f4a0133048450bdde3576ad2
2019-07-07 13:25:10 -07:00
Christoph Nakazawa c92cc11bed Remove `_` from module local variables in HMRClient
Summary: Dropping these for readability.

Reviewed By: gaearon

Differential Revision: D16121694

fbshipit-source-id: 2f6e3fb862a93d284631114c6736173e6ffbee91
2019-07-04 11:21:54 -07:00
Christoph Nakazawa 1c5944be16 Disable logging from performance logger unless it is enabled
Summary: D16107933 disabled the logs around setup unless they are explicitly enabled and this diff disables all logs from this module entirely unless they are explicitly turned on at the top of the file.

Reviewed By: gaearon

Differential Revision: D16108151

fbshipit-source-id: 355aaf8624fb0778884f25f02d58fe4e1237d686
2019-07-04 02:54:46 -07:00
Christoph Nakazawa c31fa2a45d Do not show setup logs from `createPerformanceLogger` unless logs are enabled for it
Summary: This module logs helpful messages in `__DEV__` but it only logs actionable performance logs when the flag on top of the file is enabled. This diff changes those to only log when the toggle on top of the file is enabled as well.

Reviewed By: gaearon

Differential Revision: D16107933

fbshipit-source-id: 7671bc521af984d617a0f5ffc0eacd1aa5674a62
2019-07-04 02:54:45 -07:00
Dan Abramov ea817fd7f5 Don't symbolicate transform errors
Summary:
Metro symbolication can be expensive in large apps. However, there is no need to symbolicate _runtime stacks from compile errors_. Those are pretty much useless anyway.

This will reduce the workload on Metro workers, and the delays when iterating with Fast Refresh, as the server will be busy much less often.

So I'm special-casing them and not sending the symbolication request anymore.

Reviewed By: rickhanlonii

Differential Revision: D16030087

fbshipit-source-id: 41f83ac01780c0a60cca777014e4ed95c0f3d14b
2019-06-27 07:58:50 -07:00
Panagiotis Vekris 454bbff3ba Flow v0.102 in xplat/js
Summary:
https://our.intern.facebook.com/intern/wiki/Flow/Flow_Release_Process/Updating_Internal_Repositories/#update-xplat-js

allow-large-files

Reviewed By: jbrown215

Differential Revision: D16013696

fbshipit-source-id: 1a6185dafd14ef9c9e1aa214cdbf8cf9c573b08f
2019-06-26 19:07:39 -07:00
Eli White 2bd503285e Update View Config generator to create command methods
Summary:
Flow types like this:
```
interface NativeCommands {
  +hotspotUpdate: (viewRef: React.Ref<'RCTView'>, x: Int32, y: Int32) => void;
}

export const Commands = codegenNativeCommands<NativeCommands>();
```

get turned into this:

```
export const Commands = {
  hotspotUpdate(viewRef: React.Ref<'RCTView'>, x: number, y: number) {
    UIManager.dispatchViewCommand(
      findNodeHandle(viewRef),
      UIManager.getViewManagerConfig('RCTView').Commands.hotspotUpdate,
      [x, y]
    );
  }
}
```

Reviewed By: rickhanlonii

Differential Revision: D15953126

fbshipit-source-id: edbb91056347d021dd0683391c903b76f3d1c33f
2019-06-24 18:54:41 -07:00
Dan Abramov 7d2a95d43d Syntax errors should dismiss redboxes
Summary: If you make a syntax error while there is a redbox while Fast Refresh is on, we should dismiss that redbox. Otherwise there is no way for you to tell why your code is not working.

Reviewed By: rickhanlonii

Differential Revision: D15970337

fbshipit-source-id: 1ca6c9a1b2269d198ae726d3b64e5c51506503db
2019-06-24 13:54:40 -07:00
Dan Abramov cf7813a625 Downgrade "packager disconnected" to a warning
Summary:
If the error doesn't come in direct response to a user action, I think a redbox is too severe. I think we don't want to associate turning on Fast Refresh with a higher frequency of redboxes. So this downgrades these messages to warnings.

If you manually try to turn it off and on again, we'll still show a redbox to remind why it's not working.

Reviewed By: rickhanlonii, cpojer

Differential Revision: D15958952

fbshipit-source-id: bd144c98e87a9836871391ac583c268dca8009b3
2019-06-24 13:54:39 -07:00
Dan Abramov a52e6d1dbb Unify "Hot Reloading" and "Reload-on-Save" into "Fast Refresh"
Summary:
We have too many options in the Dev Menu, and they're really hard to pick from. They're also somewhat conflicting. This replaces two menu choices that have a similar purpose (faster iteration cycle) with one.

"Fast Refresh" tries to only update the affected modules, but falls back to doing a full reload if the update can't be handled by the React components.

If for some reason you prefer the "Reload-on-Save" behavior, please:

- Reach out to me so I can learn more about your use case.
- As a workaround, you can add `if (__DEV__) require.Refresh.forceFullRefresh = true` to your app's entry point to always do a full refresh.

Also note that I only removed the user-facing part of "Reload-on-Save". So if you have automation depending on it, that's gonna keep working.

I moved it above Systrace since it's a more generic feature.

As a total aside nit, I renamed "Enable Inspector" and "Disable Inspector" to "Show Inspector" and "Hide Inspector" because... that's what those options do, really.

Reviewed By: rickhanlonii

Differential Revision: D15958697

fbshipit-source-id: 20e856d56f661fe4d39b5ab47d8c44754bf70f67
2019-06-24 13:54:39 -07:00
Dan Abramov 08bfdfad67 Remove useless module.hot checks
Summary:
Since we always create `module.hot` objects, the `module.hot` checks were unnecessary. They give a false impression that we're checking for a Hot Reloading mode. However, they're just Flow refinements and always exist in DEV. I made that explicit by throwing early.

Similarly, I removed a `module.hot` check inside `setupReactRefresh`, as it is always truish in DEV.

Finally, I'm adding a new mechanism as an escape hatch. It lets you do:

```
if (__DEV__) {
  require.Refresh.forceFullRefresh = true;
}
```

in your entry point and opt into full refreshes on every edit. This sounds similar to "Reload-on-Save". That is because in the next diff, I plan to remove "Reload-on-Save" from user-visible options (but it'll stay for automated workflows).

So this workaround is intended for people who for one reason or another don't want to opt into Hot Reloading as an alternative. We'll need to talk to them and find out why.

Reviewed By: rickhanlonii

Differential Revision: D15958475

fbshipit-source-id: 674187ddf86a4e286dfae28f4182555a8b5d7396
2019-06-24 09:48:57 -07:00
Dan Abramov 1f04ff580d Make "Enable Hot Reloading" Instant
Summary:
As we saw in D15947985, and later traced down to D5623623, the `hot` option isn't used by Metro anymore. The relevant transforms _always_ run in DEV regardless of the option.

Given that, it doesn't make sense that enabling or disabling Hot Reloading forces a full refresh. This significantly raises the usage barrier because **currently, you might have to wait ~20 seconds (on a large app) to just start using Hot Reloading when you're already in the middle of some screen.** So you just end up not using it.

This diff changes enabling/disabling Hot Reloading to be _instant_.

Here's how it works:

1. Now we always send the necessary info to the client via the new `HMRClient.setup()` function. It creates a Metro HMR client instance, but only actually sets up the socket if Hot Reloading is on.

2. The "Enable Hot Reloading" menu no longer forces a reload. Instead, it calls `HMRClient.enable()` which lazily sets up a socket (at most once).

3. The "Disable Hot Reloading" menu also doesn't trigger a refresh now. Instead, it calls `HMRClient.disable()`. We don't actually tear down the socket here because it's a pain to deal with race conditions and such. Instead, we keep the connection — but we _ignore the updates_ that come in while we're disabled.

4. As a result, it is possible to enable and disable it many times during a single session. (Updates while disabled would be ignored — which has a risk of making your running app inconsistent — but I'd argue it's expected and is worth it. You can always save a particular file to force it to update once the mode is on.)

5. In order to support "ignoring" updates, Metro's `HMRClient` (not to be confused with RN's module) now supports a `shouldApplyUpdates` field. The RN module uses it to disable handling updates when the mode is off.

6. In case there is an error that makes hot reloading unavailable (such as the server disconnecting), we surface the error only if the mode is on. If the mode is off, we stash the error message in the `_hmrUnavailableReason` variable, and display it next time you try to enable Hot Reloading.

Reviewed By: rickhanlonii

Differential Revision: D15958160

fbshipit-source-id: 8256fc4d5c2c3f653a78edf13b8515a5671953e4
2019-06-24 09:48:56 -07:00
Dan Abramov e81c1e3c7a Change top bar colors for Hot Reloading label
Summary: The current grey one is very bland, hard to read (no contrast) and often looks like a bug. I've changed it to match the iOS Personal Hotspot colors which look more idiomatic.

Reviewed By: cpojer

Differential Revision: D15941200

fbshipit-source-id: d60a3744c73675b40f42c329c2a44e6b8b0a93dc
2019-06-21 09:02:47 -07:00
Dan Abramov acd349e35a Don't show "Hot Reloading" banner on first load
Summary:
D10527979 made the "update" message sequence part of initial connection signals. But the HMR client uses this sequence as a signal to show "Hot Reloading..." bar. As a result, we were showing it on every initial load when Hot Reloading is on. This is very confusing.

As a simple fix, I now send an explicit message to mark the end of the first load. I could infer that by first update message but figured this is more explicit and less likely to break. Until we receive `connection-done`, we now don't attempt to show the "Hot Reloading..." bar.

Reviewed By: rubennorte

Differential Revision: D15936085

fbshipit-source-id: b18b6aceea6c47d919b4265e58b21fc44f77b0b3
2019-06-21 06:04:19 -07:00
Rick Hanlon ff5592cff4 Add paperComponentName and paperComponentNameDeprecated
Summary:
This diff removes an option from the codegen and replaces it with two new options

Removes:
- `isDeprecatedPaperComponentNameRCT`

Adds:
- `paperComponentName`: a better version of the removed option that allows more than just adding RCT
- `paperComponentNameDeprecated`: a new option that allows migrating native code to a new name

```
  // Use for components with no current paper rename in progress
  // Does not check for new name
  paperComponentName?: string,

  // Use for components currently being renamed in paper
  // Will use new name if it is available and fallback to this name
  paperComponentNameDeprecated?: string,
```

For example, Slider uses `paperComponentName: 'RCTSlider'` because it has a different name in fabric but is not currently being migrated to a new name. Because of other work in progress, we don't want to use UIManager check if we don't need to

Reviewed By: shergin

Differential Revision: D15857629

fbshipit-source-id: ca0d3b7dc4a75e00d136ae1f5c84f7423960399d
2019-06-19 09:56:04 -07:00
Kevin Gozali a89e9323fc Cache Platform constants in JS
Summary: For better perf with TurboModule, cache the return value of NativePlatformConstants*.getConstants() in JS so that we avoid going back into native (from JS) for each call. This specific method is called very frequently throughout RN codebase.

Reviewed By: mdvacca

Differential Revision: D15893289

fbshipit-source-id: ce8016ed7d3efb420df93e27dbfa77d7d4f06cf8
2019-06-18 23:10:50 -07:00
Rick Hanlon d789bb80c3 Revert D15780039: [RN Codegen] Add JS view config for View
Differential Revision:
D15780039

Original commit changeset: 1ec8ed1b57fd

fbshipit-source-id: d023e896dce9bb61e2e2ad6bd6babbeb973812a5
2019-06-17 11:29:45 -07:00
Rick Hanlon 6fef48096d Add JS view config for View
Summary: This diff adds the generated view config for View (in DEV)

Reviewed By: ejanzer

Differential Revision: D15780039

fbshipit-source-id: 1ec8ed1b57fd2341552746051980129848cb8e85
2019-06-17 10:50:13 -07:00
Rick Hanlon a3b9840885 Add Slider and Switch
Summary: This diff turns on codegen for Slider and Switch

Reviewed By: TheSavior

Differential Revision: D15738544

fbshipit-source-id: a0dfb5b05fd62f28fc3865855986e49598dd5e19
2019-06-11 05:06:42 -07:00
Rick Hanlon d8bacc28f6 Add test screen for generating view configs
Summary:
This diff adds a testing screen dev route to the facebook app for testing generated view configs

It's not pretty (i have 0 tetra experiance) but it gets the job done

There are three cases handled:
- No generated config �
- Invalid generated config (useful for dev) �
- Valid generated config �

On the description page we:
- Redbox it it's invalid (this could be used to redbox test all host components)
- Show diffs of the view config properties
- List all of the generated config properties
- List all of the native config properties

Using this tool, it's easy to see what the current config on native is, add correct flow types for the generated config, and validate the generated config

Coming later: adding all of the native configs to the list (will probably need filtering)

Reviewed By: cpojer

Differential Revision: D15683033

fbshipit-source-id: 5a566a56bef4f3f0bac3ea581c2e6acb2b9984e3
2019-06-11 05:06:42 -07:00
Emily Janzer 422472e5d9 Don't check native view configs in bridgeless mode
Summary: `verifyComponentAttributeEquivalence` checks the new JS view configs against what we get from native at runtime (in dev only). This breaks in bridgeless mode because there is no paper UIManager to ask for the viewconfigs from; this diff uses the flag from D15721940 to skip this check.

Reviewed By: fkgozali

Differential Revision: D15722127

fbshipit-source-id: d9227107e0ff7814c34beaae6461bb8232699c94
2019-06-10 15:03:01 -07:00
Rick Hanlon 504fc0c7d0 Update flow parser to use codegenNativeComponent
Summary:
This diff updated the codegen flow types syntax replacing:

```
type Options = {
  isDeprecatedPaperComponentNameRCT: true,
};

type ActivityIndicatorNativeType = CodegenNativeComponent<
  'ActivityIndicatorView',
  NativeProps,
  Options,
>;

module.exports = ((requireNativeComponent(
  'RCTActivityIndicatorView',
): any): ActivityIndicatorNativeType);
```
with:

```
export default codegenNativeComponent<NativeProps>('ActivityIndicatorView', {
  isDeprecatedPaperComponentNameRCT: true,
});
```

This is from Tim's comment in the [View Config Codegen Quip](https://fb.quip.com/jR2aASHad4Se):

> What it CodegenNativeComponent were instead `NativeComponent.fromFlow<T>('…')` that returned `'...'`?
>And the Babel plugin swapped it for NativeComponent.fromSchema('...', {…}) which would both register and return '...'?

I went with `codegenNativeComponent` because it has nice parity with `requireNativeComponent`

I also didn't update the babel output here (we can update that whenever) because I think `registerGeneratedViewConfig` is more clear for what it's doing

Reviewed By: cpojer

Differential Revision: D15602077

fbshipit-source-id: 2d24dc32136ba6d31724f8c929b51417ba625a58
2019-06-07 12:31:36 -07:00
Rick Hanlon 886fb501bd RN Codegen] Add registerGeneratedViewConfig
Summary:
This diff updated the format of generated view configs so that they don't need to spread View props into every config, by adding a new registerGeneratedConfig function which will spread them instead

This is a bit of a cleanup of the generated output but is primarily so that the view config babel plugin will not need to rely on object spreading or object.assigns

Reviewed By: TheSavior, cpojer

Differential Revision: D15517199

fbshipit-source-id: 08e575578177bad12d40ee3dcad9381974b6466d
2019-06-07 12:31:35 -07:00
Tim Yung 796e9b0e37 RN: Debug Menu Cleanup (iOS)
Summary:
Addresses a number of pieces of feedback regarding the debug menu.

- Simplify labels for the debugger actions (e.g. no "remote", no emoji).
- Reorder actions so that modal items are generally lower.
- Changed "Toggle Inspector" to "Show/Hide Inspector".
- Renamed "Live Reloading" to "Reload-on-Save".
- Hide disabled debug items when profiling is enabled.
- Changed "Start Systrace" to "Systrace Unavailable" when debugging.
- Renamed "Change packager location" to "Configure Bundler".
- Revised nomenclature in "Configure Bundler" menu to be clearer.
- Removed extraneous debug menu title.
- Consistently refer to HMR as "Hot Reloading".

Changelog:
[iOS] [Changed] - Cleaned up debug menu.

Reviewed By: axe-fb

Differential Revision: D15548628

fbshipit-source-id: 26b2ddca8280d1f6f8ff904439b403600e98a3b3
2019-05-30 22:42:24 -07:00
Tom Sanderson 7fd08e1461 add spec for PlatformConstants (#24928)
Summary:
part of #24875.

## Changelog

[General] [Added] - add TM spec for PlatformConstants
Pull Request resolved: https://github.com/facebook/react-native/pull/24928

Reviewed By: RSNara

Differential Revision: D15551340

Pulled By: fkgozali

fbshipit-source-id: 9de15ff4cfe717f963332868bd873d5147a37506
2019-05-30 14:29:42 -07:00
James Ide 33ee6f8b99 Add a lint rule to disallow Haste imports (#25058)
Summary:
This is an ESLint plugin that infers whether an import looks like a Haste module name. To keep the linter fast and simple, it does not look in the Haste map. Instead, it looks for uppercase characters in single-name import paths, since npm has disallowed uppercase letters in package names for a long time. There are some false negatives (e.g. "merge" is a Haste module and this linter rule would not pick it up) but those are about 1.1% of the module names in the RN repo, and unit tests and integration tests will fail anyway once Haste is turned off.

You can disable the lint rule on varying granular levels with ESLint's normal disabling/enabling mechanisms.

Also rewrote more Haste imports so that the linter passes (i.e. fixed lint errors as part of this PR).

## Changelog

[General] [Changed] - Add a lint rule to disallow Haste imports
Pull Request resolved: https://github.com/facebook/react-native/pull/25058

Differential Revision: D15515826

Pulled By: cpojer

fbshipit-source-id: d58a3c30dfe0887f8a530e3393af4af5a1ec1cac
2019-05-30 07:45:16 -07:00
Emily Janzer 96a5001024 Add spec for DeviceInfo module
Summary: Adding flow types for DeviceInfo module and migrating our codebase over to using `DeviceInfo.getConstants()`

Reviewed By: fkgozali

Differential Revision: D14645744

fbshipit-source-id: e30a060c6dc92938cd1420ba11a1d837c79d1e32
2019-05-29 16:37:15 -07:00
Emily Janzer d83ba5ad51 Revert D15488008: Use JS ViewConfig for View
Differential Revision:
D15488008

Original commit changeset: 48e925ec0ca2

fbshipit-source-id: 4ffa223e636116777c178386b6e966a4f253c30a
2019-05-28 16:37:46 -07:00
Emily Janzer 77a6617a39 Use JS ViewConfig for View
Summary: Rick manually created view config in JS for View; adding some missing attributes/events and using this instead of `requireNativeComponent`

Reviewed By: rickhanlonii

Differential Revision: D15488008

fbshipit-source-id: 48e925ec0ca2aeba9e6cc66edef0b70ee1c94d27
2019-05-28 10:22:43 -07:00
Rick Hanlon ac62274e56 Use generated view config for ActivityIndicatorView
Summary: This diff moves ActivityIndicatorView to the generated view config

Reviewed By: shergin

Differential Revision: D15392561

fbshipit-source-id: 67a2fa0dbbb884af9e9c02b9062d3a610a023240
2019-05-24 09:21:27 -07:00
James Ide a7a7970e54 Replace more Haste imports with path-based imports (#25001)
Summary:
This is another step in moving RN towards standard path-based requires, updating more code to use path-based requires. See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail.

## Changelog

[General] [Changed] - Replace more Haste imports with path-based imports
Pull Request resolved: https://github.com/facebook/react-native/pull/25001

Differential Revision: D15467829

Pulled By: cpojer

fbshipit-source-id: 58c364bb4c1c757689907d5ed0d0f3fac0e22f3f
2019-05-23 00:51:31 -07:00
Wojteg1337 94029eee54 Add spec for HeapCapture (#24899)
Summary:
Part of #24875, adds a spec for HeapCapture

## Changelog

[General] [Added] - TM Spec for HeapCapture
Pull Request resolved: https://github.com/facebook/react-native/pull/24899

Reviewed By: fkgozali

Differential Revision: D15393464

Pulled By: RSNara

fbshipit-source-id: d8778285753ce8dbc87204ecfbddfa7339acd264
2019-05-22 13:10:25 -07:00
Michał Pierzchała 8ea749ad3e Add spec for ExceptionsManager (#24900)
Summary:
Part of #24875, adds a spec for ExceptionsManager

## Changelog

[General] [Added] - TM Add spec for ExceptionsManager
Pull Request resolved: https://github.com/facebook/react-native/pull/24900

Reviewed By: fkgozali

Differential Revision: D15434006

Pulled By: RSNara

fbshipit-source-id: 1a505744a84c0c4ac3a9fac6c91a391fbd8a9f46
2019-05-22 13:10:24 -07:00
Eric Lewis d7a5e3e215 add spec for JSDevSupport (#24905)
Summary:
Part of #24875.

## Changelog

[General] [Added] - add TM spec for JSDevSupport
Pull Request resolved: https://github.com/facebook/react-native/pull/24905

Reviewed By: fkgozali

Differential Revision: D15391754

Pulled By: rickhanlonii

fbshipit-source-id: afca6ce3d6bcfaaf097e13c148496cdd1f062465
2019-05-22 03:27:54 -07:00
Eric Lewis c44d4f9ef6 add spec for RedBox (#24922)
Summary:
part of #24875.

## Changelog

[General] [Added] - add TM spec for RedBox
Pull Request resolved: https://github.com/facebook/react-native/pull/24922

Reviewed By: RSNara

Differential Revision: D15423532

Pulled By: fkgozali

fbshipit-source-id: 3c30e5b32a29628caf0bb9286c0628597ac64fb7
2019-05-20 18:05:55 -07:00
Glenna Buford 35cf427365 Add spec for DevLoadingView (#24930)
Summary:
Part of #24875

## Changelog

[General] [Added] - add TM spec for DevLoadingView
Pull Request resolved: https://github.com/facebook/react-native/pull/24930

Reviewed By: RSNara

Differential Revision: D15423524

Pulled By: fkgozali

fbshipit-source-id: 18ca65abcd4fb3c0ec0434ccba0c0e1d97c17995
2019-05-20 18:05:55 -07:00
Uilque Messias 580088c199 Add spec for NativeDeviceEventManager (#24914)
Summary:
Part of #24875.

## Changelog

[General] [Added] - TM add spec for NativeDeviceEventManager
Pull Request resolved: https://github.com/facebook/react-native/pull/24914

Reviewed By: RSNara

Differential Revision: D15421462

Pulled By: fkgozali

fbshipit-source-id: 78b90c615cd031ecd010a552751e506406ab739a
2019-05-20 18:05:54 -07:00
Rick Hanlon 531f11f084 Fix flow and formatting
Summary: Fixes a flow failure in the generated output and adds trailing commas to pass linting

Reviewed By: yungsters

Differential Revision: D15354725

fbshipit-source-id: 1eac27fa753af595a9a2787426b147e5f49a4e1d
2019-05-20 02:52:37 -07:00
Rick Hanlon 382846aefd Add viewconfig verification
Summary: This diff adds a line to the codegen'd view configs which will check that all of the properties in the native view config are also in the JS view config we generate (note that the JS view config may have more properties than one native platform because it includes a union of both platforms)

Reviewed By: TheSavior

Differential Revision: D15278478

fbshipit-source-id: 0fef20c12265b952c69aca4e4c070a7d036db05a
2019-05-16 10:51:06 -07:00
James Ide 0ee5f68929 Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749)
Summary:
This is the next step in moving RN towards standard path-based requires. All the requires in `Libraries` have been rewritten to use relative requires with a few exceptions, namely, `vendor` and `Renderer/oss` since those need to be changed upstream. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change.

See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail.

[General] [Changed] - Migrate "Libraries" from Haste to standard path-based requires
Pull Request resolved: https://github.com/facebook/react-native/pull/24749

Differential Revision: D15258017

Pulled By: cpojer

fbshipit-source-id: a1f480ea36c05c659b6f37c8f02f6f9216d5a323
2019-05-08 08:48:59 -07:00
Alexey Lang c3475419a9 Add removeExtra()
Reviewed By: bestander

Differential Revision: D14386282

fbshipit-source-id: 045dd0f12cc462da694d20da52f3a591b538dc57
2019-03-19 10:24:52 -07:00
Alexey Lang abe737fe74 Proxy statics for the wrapped component
Summary: Currently we can't access navigationOptions  from measureAppRequire and that breaks fetchRelayQuery logs.

Reviewed By: fkgozali

Differential Revision: D14505525

fbshipit-source-id: 97ae4461ebb0e703633f782323b13b4e4f7c5cb7
2019-03-19 07:32:20 -07:00
Casper Boone f541c34067 Add tests for utilities (#23989)
Summary:
This PR add tests for several utilities in `Libraries/Utilities`, as a follow-up of #23903.

The following utilities are now tested:
* `clamp.js`
* `binareToBase64.js`
* `DeviceInfo.js`
* `mergeIntoFast.js`
* `PixelRatio.js`
* `infoLog.js`
* `logError.js`
* `warnOnce.js`
* `mapWithSeparator` (added a missing test)

Not applicable, since it only adds tests.
Pull Request resolved: https://github.com/facebook/react-native/pull/23989

Differential Revision: D14502806

Pulled By: cpojer

fbshipit-source-id: e2c3b3a35f4f765d5336b998ab92dba14eeac7bc
2019-03-18 07:40:55 -07:00
Alexey Lang 022dc8ef38 Implement withPerformanceLoggerContext
Summary:
This function returns a HOC that passes `scopedPerformanceLogger` as a prop to the wrapped component. That HOC
can be used whenever we can't declare `static contextType` as `PerformanceLoggerContext` on a component,
for example because React supports only one React Context per component.

Reviewed By: sahrens

Differential Revision: D14385560

fbshipit-source-id: 41971b4bf499f336c34b9220a3ee97c4ed89498d
2019-03-15 07:38:00 -07:00
Georgios Andreadis 47e061549f Add tests for utility functions of library (#23903)
Summary:
I was looking at the coverage report of the JavaScript code in the `Libraries` folder, and found some of the modules and functions to be (partially) untested. I believe that adding tests to them would formally capture their behaviour and avoid future regressions. In this PR, I've added some unit tests for 3 utility components.

Perhaps a more general question: Are these kinds of PRs appreciated? I'd be interested in submitting more of them in the future.

Not applicable, since it only adds tests.
Pull Request resolved: https://github.com/facebook/react-native/pull/23903

Differential Revision: D14477601

Pulled By: cpojer

fbshipit-source-id: c0700c5b514cd0df983fecfd91c93fc2bd049f5d
2019-03-15 04:46:48 -07:00
Peter van der Zee dcd4e90d9a Bump Prettier to 1.16.4
Summary:
@public
This bumps Prettier to v1.16.4
Only format source files were updated.

Reviewed By: mjesun

Differential Revision: D14454893

fbshipit-source-id: 72f9872fe764a79dbf0d9fab9bebb1456b039f2f
2019-03-14 07:00:27 -07:00
Alexey Lang 03841cf08c Migrate PerformanceLoggerFlag to scoped performance logger
Reviewed By: xyin96

Differential Revision: D14385136

fbshipit-source-id: beaf060866ed5b7dee80e18fcd432e7701cff5d3
2019-03-14 06:49:47 -07:00
Alexey Lang 40143519a1 Use GlobalPerformanceLogger explicitly during bundle load
Reviewed By: sahrens

Differential Revision: D14377700

fbshipit-source-id: 66bc120701ffb7fb15030e5dcb5c6200e7c04434
2019-03-14 06:49:46 -07:00
Evan Bacon 05d5eeb818 Removed `Platform.web` (#23830)
Summary:
Initially if a `react-native-web` project were to use a library that required internals `expo/webpack-config` would polyfill those internals. This `Platform.web` was used for cases where `react-native` modules needed other internal `react-native` modules, ex: `Animated/src/AnimatedEvent -> Renderer/shims/ReactNative -> Renderer/oss/ReactNativeRenderer-dev -> Core/InitializeCore -> Devtools/setupDevtools -> WebSocket/WebSocket -> Utilities/Platform`

The consensus is that if any `react-native` library references a `react-native` internal (ex: `react-native/*`), it should continue to throw errors. We've removed the use of internals from all of the Unimodules, `react-navigation`, and `react-native-gesture-handler`. This covers a wide enough area for a lot of projects to get web support.

* Add emitters for libs referencing internals necolas/react-native-web#1275
* Remove monkey patch that bundles RN, libs that use internals will crash instead expo/expo-cli#409
* Remove all unsupported internals and polyfills from the Expo suite expo/expo#3676
* Remove internals from react-native-gesture-handler kmagiera/react-native-gesture-handler#406

* Related #23387

[GENERAL] [REMOVED] - Platform.web.js
Pull Request resolved: https://github.com/facebook/react-native/pull/23830

Differential Revision: D14406145

Pulled By: hramos

fbshipit-source-id: bdda99a334d33f5543fdb954eb80e2e7186f985a
2019-03-11 11:38:22 -07:00
Alexander Zhang efd28bdc84 Revert D14186694: [RN] Use global or scoped performance loggers everywhere
Differential Revision:
D14186694

Original commit changeset: 062c76eea8fc

fbshipit-source-id: 6d99b94d21da6df4375e342fdecceeebf05959d5
2019-03-07 13:12:12 -08:00
George Zahariev 35d2dfcabf Deploy 0.94 to xplat
Summary:
Update Flow version in xplat (https://our.intern.facebook.com/intern/wiki/Flow/Flow_Release_Process/#update-xplat-js)

allow-large-files
bypass-lint

Reviewed By: nmote

Differential Revision: D14317820

fbshipit-source-id: 07ec22c0745321db036f4e10a502009a4b640652
2019-03-06 14:57:30 -08:00
Alexey Lang a9b3ca7fa7 Use global or scoped performance loggers everywhere
Summary:
I'm changing all callsites to use either global or scoped perf logger explicitly in one diff.
`GlobalPerformanceLogger` is basically a singleton
`scopedPerformanceLogger` is scoped to the React tree by using a React Context

Reviewed By: sahrens

Differential Revision: D14186694

fbshipit-source-id: 062c76eea8fce9d9b531f0eddf153bb79d52f68d
2019-03-06 09:51:56 -08:00
Alexey Lang 60640485e1 Introduce PerformanceLoggerContext and use it with renderApplication
Reviewed By: sahrens

Differential Revision: D14167646

fbshipit-source-id: 3f8dd27ba1c8866471e2af493c4cc0bc84706042
2019-02-28 03:39:40 -08:00
Alexey Lang 1aabbf5dce Allow to create local performance loggers
Reviewed By: bestander

Differential Revision: D14159631

fbshipit-source-id: 62830f67060e575841cbc864dde30c7bee7e7c4c
2019-02-28 03:39:40 -08:00
Evan Bacon 104b1f9367 Add HMRLoadingView module for web target (#23389)
Summary:
* Added a default value for HMRLoadingView this will prevent errors from being thrown when `HMRClient` attempts to include it in a `web` context.

* [Web] [Added] - HMRLoadingView
Pull Request resolved: https://github.com/facebook/react-native/pull/23389

Differential Revision: D14045475

Pulled By: cpojer

fbshipit-source-id: df5c3cf3536af3b37eaf82342b6346bc25054319
2019-02-20 18:22:44 -08:00
Evan Bacon daa79b0f97 Add Platform module for web target (#23387)
Summary:
Added a Platform file for module for instances where internal modules need Platform.
ex: 78be6efda9/Libraries/Utilities/Dimensions.js (L14)

* Added `Libraries/Utilities/Platform.web.js`
[CATEGORY] [TYPE] - Message
Pull Request resolved: https://github.com/facebook/react-native/pull/23387

Differential Revision: D14041834

Pulled By: cpojer

fbshipit-source-id: 9be7ad647d6a644956efa622b936fcecee7c1a1f
2019-02-12 03:32:29 -08:00
empyrical 9a7fff9eb1 Introduce generic `warnOnce` function for warning messages (#22109)
Summary:
This pull request adds a function called `warnOnce` that prints a warning message to the console once per session.

It uses a unique key per callsite to help ensure that the message is not printed multiple times.

[General] [Added] - Added new `warnOnce` function for printing a message to the developer console once per session
[General] [Changed] - Changed the warnings in `react-native-implementation` to use `warnOnce`
Pull Request resolved: https://github.com/facebook/react-native/pull/22109

Differential Revision: D13955887

Pulled By: cpojer

fbshipit-source-id: aa51ac427a80cc0554a6bcc915715821d0bd5439
2019-02-05 02:24:59 -08:00
Brian Shin 5c0b9071e7 Remove PlatformOS from RN
Summary: The existence of this file was confusing many in open source (5ee27ff755) and is no longer needed internally. Delete this file to remove the fork.

Reviewed By: fkgozali

Differential Revision: D13625760

fbshipit-source-id: 1be1943471b67e914377c24d445568532e378385
2019-01-10 12:52:02 -08:00
glevi@fb.com 24f8d4d3db Deploy v0.89
Reviewed By: jbrown215

Differential Revision: D13457087

fbshipit-source-id: 9f01371ae3515990c5595f1eb2361174050066b8
2018-12-14 13:57:50 -08:00
Christoph Nakazawa deb2a94568 Add Flow types for `Platform.select` [5/5]
Summary: This change adds type information for `Platform.select` to make sure things are properly typed. This is the last diff in a stack that actually enables the newly fixed/added annotations and it will only land once all the type errors (320+) are fixed.

Reviewed By: sahrens

Differential Revision: D13318805

fbshipit-source-id: af0475d1a2f1e5ace4d513be48827e3659bd7f62
2018-12-06 02:54:19 -08:00
Christoph Nakazawa 4148976a83 Use `invariant` instead of `fbjs/lib/invariant`
Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.

Reviewed By: yungsters

Differential Revision: D13195941

fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
2018-12-03 00:07:02 -08:00
Panagiotis Vekris ef2084c6bd 0.87.0 in xplat/js
Summary: allow-large-files

Reviewed By: samwgoldman

Differential Revision: D13230018

fbshipit-source-id: f07e2371a3b7382de0592cc7c7b20e7f4faa6889
2018-11-28 17:32:50 -08:00
Rubén Norte 2ae559a2a4 eslint: Disable jasmine env and only enable jest env for test files
Summary:
Modified the ESLint configuration to only enable the Jest environment for files we consider now tests, which are files with the `-test.js` suffix under `__tests__`. Also enabled some globals for test helpers (any file under `__tests__`).

This will allow us to catch misspelled tests, while allowing test helpers to use most Jest APIs.

Also disabled the Jasmine environment so people stop using Jasmine APIs and we can rollout Circus soon.

Reviewed By: aaronabramov

Differential Revision: D13199591

fbshipit-source-id: 12a32cf5835630b9987452b0c33d3f8085001689
2018-11-27 03:51:02 -08:00
Spencer Ahrens 6f34bc4016 Back out "reapply TextInput es6 conversion with fixes, attemps to fix"
Summary:
Back it out again. This time really not sure why this is breaking, but it seems to be production only. The error seems to be "RCTSinglelineTextInputView" was not found in the UIManager" but the relavent logic is not changed in this diff, just moved around, so unclear why it would trigger a failure.

Reverting to be safe. When we re-apply the diff, we'll need to test a full OTA to prod to verify the fix.

Reviewed By: blairvanderhoof

Differential Revision: D13108463

fbshipit-source-id: 5f877a0c1a08dc114ce45921d6d92bf619575977
2018-11-16 14:50:23 -08:00
Spencer Ahrens 9ea1295179 reapply TextInput es6 conversion with fixes, attemps to fix
Summary: D10515754 reapplied by backing out D12989604 and then fixed by manually forwarding the instance methods to the host function instead of using `forwardRef`. This also removes the need for the $flowFixMe.

Reviewed By: TheSavior

Differential Revision: D13048482

fbshipit-source-id: ff2447aff123e0960eddaef645f7dc976a426e14
2018-11-15 20:51:52 -08:00