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

16269 Коммитов

Автор SHA1 Сообщение Дата
Mikael Sand 5e4a5892b9 Support Interpolation of strings when using native driver in Animated, fix Expected node to be marked as "native", optimize AnimatedNode creation and connections (#18187)
Summary:
Allow interpolation of strings with useNativeDriver. This allows animating much more of react-native-svg. This PR adds support for native animation of lengths with units, path data, colors etc. Plus, fixing the redundantly created nodes and (and thus, previously incorrect) connection of native animated nodes, improving performance.

Docs will need to change, specifying that string interpolation works with the native driver as well.

[GENERAL] [Added] Add support for native driven string interpolation in Animated
[GENERAL] Fix exception: Expected node to be marked as "native"
[GENERAL] Fix connection of AnimatedNodes and creation of redundant AnimatedNodes
Pull Request resolved: https://github.com/facebook/react-native/pull/18187

Differential Revision: D14597147

Pulled By: cpojer

fbshipit-source-id: 82a948a95419236be7931a8cc4ff72f41e477e9c
2019-03-26 09:33:25 -07:00
Sidharth Guglani 81a702b426 removing unused const int
Summary: Removed unused const int

Reviewed By: davidaurelio

Differential Revision: D14368114

fbshipit-source-id: f63b978813a01a37710fac299dc7ec9aff610844
2019-03-26 08:50:33 -07:00
Christoph Nakazawa 938c3bdfa0 Change WebView to be required from 'WebView' module directly
Summary: This is the first diff part of moving WebView internally to Facebook. It will be available under the same name `WebView` but won't be required from `react-native` any longer.

Reviewed By: TheSavior

Differential Revision: D14598043

fbshipit-source-id: f870d3f58e1d304071405344de09598dd22cdcc2
2019-03-26 08:20:37 -07:00
Sidharth Guglani d5a8f4d600 moved all the properties used for layout outputs to YogaNodeJNI
Summary:
Moved layout outputs transfer logic from YogaNodeJNIBase to YogaNodeJNI.
This change set is for adding experiment for layout outputs batching using a float array

Reviewed By: davidaurelio

Differential Revision: D14368107

fbshipit-source-id: 75ca330c1e7f07adc0ab8e7a5927d93977088918
2019-03-26 07:36:58 -07:00
David Aurelio 82b27832d6 `CompactValue` overrides of `YGResolveValue`/`YGValueEqual`
Summary:
@public

I would like to get rid of implicit conversions between `YGValue` and `CompactValue`, because they don’t come for free.

That’s why I am adding `CompactValue` specific overrides for `YGResolveValue` and  `YGValueEqual`, that do explicit casts. Up the commit stack, we will be able mark both `CompactValue(const YGValue&)` and `CompactValue::operator YGValue()` as `explicit`.

Reviewed By: SidharthGuglani

Differential Revision: D14598447

fbshipit-source-id: 75dc15cefb2dddcf8def891c5fb37893cacd9d46
2019-03-26 05:22:24 -07:00
David Aurelio d1c7760ef7 Remove duplicated function declaration
Summary:
@public

Just removes a duplicated function declaration.

Reviewed By: SidharthGuglani

Differential Revision: D14598446

fbshipit-source-id: b4d8fe192f9a07f512f6a346f27d9046bb3bae23
2019-03-26 05:22:23 -07:00
satyajit.happy b49fdd19e4 Add typescript support to the ESLint config (#24100)
Summary:
This adds TypeScript support to the community ESLint config. Our babel preset supports TypeScript by default, so it's nice to have TypeScript support pre-configured in the ESLint config too.

Note: Users need to install `typescript` in their project for linting to work for TypeScript files.

[General] [Added] - Add TypeScript support to the ESLint config
Pull Request resolved: https://github.com/facebook/react-native/pull/24100

Differential Revision: D14597127

Pulled By: cpojer

fbshipit-source-id: dfbf1b97061ed6e8c46aa49adb21630f5acdb5d1
2019-03-25 21:28:26 -07:00
Valentin Shergin cc66d36583 Fabric: Removing ShadowNode::constructAncestorPath()
Summary: We don't use it anymore.

Reviewed By: mdvacca

Differential Revision: D14523377

fbshipit-source-id: 20777d835960105e875c9e37bbe753bd925dfd78
2019-03-25 20:32:21 -07:00
Spencer Ahrens d9eae2a809 fix setNativeProps crash
Summary:
setNativeProps ends up calling UIManager.updateView which fails to find the view tag in the Paper UIManager and crashes.

This diff simply checks if the tag is managed by fabric, and calls `fabricUIManager.synchronouslyUpdateViewOnUIThread` if it is.

Not the ideal fix, but it generally works (js-driven animations work as well as in Paper) and it's better than crashing or not working at all.

Reviewed By: JoshuaGross

Differential Revision: D14414523

fbshipit-source-id: 0acd404f55094f8ce8eda39cb87ab58c727fb068
2019-03-25 12:24:46 -07:00
Spencer Ahrens 45b9b656cc factor out common native obj switch code
Summary: No reason to duplicate it.

Reviewed By: mdvacca

Differential Revision: D14488262

fbshipit-source-id: b5ce23ea591abc3e9bc07ee48cc756322cae220c
2019-03-25 12:12:11 -07:00
Spencer Ahrens a062b34493 same cleanup but for ReadableNativeArray
Summary: Removes useArrayNativeAccessor and everything needed to support it, similar to D14486283

Reviewed By: mdvacca

Differential Revision: D14487244

fbshipit-source-id: 7cfa91f7cf322c648c82be5951f3622cd6468961
2019-03-25 12:12:11 -07:00
Spencer Ahrens b257e06bc6 remove useMapNativeAccessor stuff
Summary:
This was quite a rabit hole of remove deps -> delete dead code -> repeat.

Waaay simpler now with less duplicate lookups, redundant type verification, and extra function calls.

Reviewed By: mdvacca

Differential Revision: D14486283

fbshipit-source-id: 035db30181755d046a1ae99760468b954b2449df
2019-03-25 12:12:10 -07:00
Spencer Ahrens a46fba5dd3 use DynamicFromObject to avoid maps
Summary:
Changes our property access pattern to iterate through props once and pass the Object value directly rather than looking the value up in the map with the key.

Note some ViewManagers methods (especially yoga related ones on shadow nodes) expect a `Dyanamic`, so this diff also creates Dynamic's only when needed by the hand-written code, and introduces a new `DynamicWithObject` to create them that simply wraps the underlying object (as opposed to `DynamicWithMap` which wraps the map and does a lookup any time the `Dynamic` is accessed.

Reviewed By: mdvacca

Differential Revision: D14453300

fbshipit-source-id: df98567b6eff1e6b7c611f179eb11e413fb94e5d
2019-03-25 12:12:10 -07:00
Valentin Shergin af38a0cf87 Fabric: `Transform` type was moved to `graphics` module.
Summary:
We will use it inside `core` module, so we have to decouple it from `view`.
As part of this, I added some comments, changed `const Float &` to just `Float` and put the implementation into `.cpp` file.

Reviewed By: mdvacca

Differential Revision: D14593952

fbshipit-source-id: 80f7746f4fc5b95febc8df9f5a9c0386a6425c88
2019-03-25 12:04:53 -07:00
David Vacca b943db418f Fix IllegalStateException when tapping next on Android Keyboard
Summary: This diff fixes an IllegalStateException that is thrown when the user click is on a edit text and tap 'Next' on the keyboard to focus on the next view, but the next view is hidden.

Reviewed By: lunaleaps, mmmulani

Differential Revision: D14598410

fbshipit-source-id: 2999cc468ed24bedff163eedcfaec50f6ee005d6
2019-03-25 10:17:39 -07:00
Dhaval Kapil 64f3a87c9d Refactor JSIExecutor to use runtimeInstaller for injecting the logger instance
Summary: This is based on the work done in D8686586. Removed the logger instance from JSIExecutor constructor and installed it into the runtimeInstaller at all call sites.

Reviewed By: mhorowitz

Differential Revision: D14444120

fbshipit-source-id: 0476fda4230c467573ea04102a12101bcdf36c53
2019-03-25 09:12:11 -07:00
Mr. Anonymous 9db347fabc Update projectRoot in launchPackager.bat (#24115)
Summary:
`launchPackager.bat` starts metro server but does not pass projectRoot to it. So metro server starts in the wrong directory, It is because `startServerInNewWindow` pass `react-native` directory instead of `projectRoot` in the third argument of `spawn()` in `runAndroid.js`

Its working for people
See https://github.com/facebook/react-native/issues/23908#issuecomment-475889443

[Android] [Fixed] - projectRoot in launchPackager.bat
Pull Request resolved: https://github.com/facebook/react-native/pull/24115

Differential Revision: D14597101

Pulled By: cpojer

fbshipit-source-id: fb4155b72e35062cfb41fe1b3ecca0e2b4e849ce
2019-03-25 07:27:11 -07:00
Sidharth Guglani 526b40bfe3 fixed @Nullable missing infer errors
Summary: Fixed Nullable lint errors

Reviewed By: davidaurelio

Differential Revision: D14383930

fbshipit-source-id: 0847e19c50a0b8d4039199045b74aa86c96ac096
2019-03-25 06:36:15 -07:00
David Aurelio 4ba34b0a26 Automatic lint fixes
Summary:
@public
A round of automatic lint fixes.

Reviewed By: SidharthGuglani

Differential Revision: D14590396

fbshipit-source-id: f0b4a0ce503a1d9d46ea7ae788f9f2eac09c2ac7
2019-03-25 05:55:21 -07:00
David Vacca d53200a4c3 ReactTTRCRenderFlag component in Fabric android
Summary: This diff migrates ReactTTRCRenderFlag component to Fabric android

Reviewed By: fkgozali

Differential Revision: D14591212

fbshipit-source-id: c10de2ab4a77af985853da6d3fe7a7c6a1bc7a1e
2019-03-23 22:53:23 -07:00
David Vacca ce3952faf5 Replace abort() with LOG(FATAL) when a prop-value is not found during parsing
Summary: This diff replaces usage of abort() with LOG(FATAL) when a prop-value is not found during parsing of prop values

Reviewed By: fkgozali

Differential Revision: D14591210

fbshipit-source-id: 4a8484ea6bdfec5534122ded43cc24ef80c13c1d
2019-03-23 22:53:23 -07:00
David Vacca 06c1f3c502 Fix parsing of flex-wrap='nowrap'
Summary: This diff fixes parsing of  flex-wrap='nowrap' prop in Fabric

Reviewed By: fkgozali

Differential Revision: D14591211

fbshipit-source-id: 2ece2cd03b1b78eaeb01f7fc15bf62c510f70501
2019-03-23 22:53:22 -07:00
Yuan Du 146b2839f5 Revert D14554656: [Fabric][C++] Fix parsing of flex-wrap='nowrap'
Differential Revision:
D14554656

Original commit changeset: 259b2cdaf204

fbshipit-source-id: 3bca12f204ff7be85c4901eb01894935e7857d75
2019-03-23 13:08:20 -07:00
Yuan Du 66e04347d1 Revert D14570713: [Fabric][C++] Replace abort() with LOG(FATAL) when a prop-value is not found during parsing
Differential Revision:
D14570713

Original commit changeset: 57b0f993ba26

fbshipit-source-id: 5f4eb0282b028e36d2cbb04a5ab85f469572aa37
2019-03-23 13:08:20 -07:00
Yuan Du a3296ff40f Revert D14572430: [Fabric][Android] ReactTTRCRenderFlag component in Fabric android
Differential Revision:
D14572430

Original commit changeset: 0e7c6cb5520b

fbshipit-source-id: 2cde5c9316c055c3836aab656a06c508f3e468af
2019-03-23 13:08:20 -07:00
David Vacca 819c584c46 ReactTTRCRenderFlag component in Fabric android
Summary: This diff migrates ReactTTRCRenderFlag component to Fabric android

Reviewed By: shergin

Differential Revision: D14572430

fbshipit-source-id: 0e7c6cb5520be44221939b0e711269b84f4657dc
2019-03-23 12:10:00 -07:00
David Vacca 1ceb4708f7 Replace abort() with LOG(FATAL) when a prop-value is not found during parsing
Summary: This diff replaces usage of abort() with LOG(FATAL) when a prop-value is not found during parsing of prop values

Reviewed By: sahrens

Differential Revision: D14570713

fbshipit-source-id: 57b0f993ba264a4949baf4022d807c55cdfe03b1
2019-03-23 12:09:59 -07:00
David Vacca f01a0d33ab Fix parsing of flex-wrap='nowrap'
Summary: This diff fixes parsing of  flex-wrap='nowrap' prop in Fabric

Reviewed By: fkgozali

Differential Revision: D14554656

fbshipit-source-id: 259b2cdaf2043f72c261ae7d74a80eb012883244
2019-03-23 12:09:59 -07:00
David Vacca bd7df8bdaa Remove BatchedExecutionTime from Fabric metrics
Summary: This diff removes BatchedExecutionTime from the metrics that are measured in Fabric. This does not add much value and it is not easy to compare against current version of RN

Reviewed By: shergin

Differential Revision: D14541976

fbshipit-source-id: c488e0951815306a978dd7a4246ec8a16d663218
2019-03-23 00:38:57 -07:00
Ramanpreet Nara 8618a5824f Add support for argument conversion via RCTConvert
Summary:
With our current infra, we support automatic conversion of method arguments using `RCTConvert`.

```
RCT_EXPORT_METHOD(foo:(RCTSound*) sound)
{
  //...
}
```

```
interface RCTConvert (RCTSound)
+ (RCTSound *) RCTSound: (NSDictionary *) dict;
end

implementation RCTConvert (RCTSound)
+ (RCTSound *) RCTSound: (NSDictionary *) dict
{
  //...
}
end
```

```
export interface Spec extends TurboModule {
  +foo: (dict: Object) => void,
}
```

With this setup, when we call the foo method on the TurboModule in JS, we'd first convert `dict` from a JS Object to an `NSDictionary`. Then, because the `foo` method has an argument of type`RCTSound*`, and because `RCTConvert` has a method called `RCTSound`, before we invoke the `foo` NativeModule native method, we first convert the `NSDictionary` to `RCTSound` using `[RCTConvert RCTSound:obj]`. Essentially, if an argument type of a TurboModule method is neither a primitive type nor a struct (i.e: is an identifier), and it corresponds to a selector on `RCTConvert`, we call `[RCTConvert argumentType:obj]` to convert `obj` to the type `argumentType` before passing in `obj` as an argument to the NativeModule method call.

**Note:** I originally planned on using `NSMethodSignature` to get the argument types. Unfortunately, while the Objective C Runtime lets us know that the type is an identifier, it doesn't inform us which identifier it is. In other words, at runtime, we can't determine whether identifier represents `RCTSound *` or some other Objective C class. I figure this also the reason why the old code relies on the `RCT_EXPORT_METHOD` macros to implement this very same feature: https://git.io/fjJsC. It uses `NSMethodSignature` to switch on the argument type, and then uses the `RCTMethodInfo` struct to parse the argument type name, from which it constructs the RCTConvert selector.

One caveat of the current solution is that it won't work work unless we decorate our TurboModule methods with `RCT_EXPORT_METHOD`.

Reviewed By: fkgozali

Differential Revision: D14582661

fbshipit-source-id: 3c7dfb2059f031dba7495f12cbdf406b14f0b5b4
2019-03-22 16:23:40 -07:00
nicholaslee119 077c0f7094 add checkbox-moved warning (#24098)
Summary:
checkbox has been moved to react-native-community in this PR:
https://github.com/react-native-community/react-native-checkbox/pull/1

[General] [Changed] - Add warning info about checkbox which is moved to react native community
Pull Request resolved: https://github.com/facebook/react-native/pull/24098

Differential Revision: D14585872

Pulled By: PeteTheHeat

fbshipit-source-id: 02d0167a3bf32ff8fac3880c1e7b7c04d8f37b48
2019-03-22 16:09:07 -07:00
Achille Urbain 3711ea6937 Make KeyboardAvoidingView with behavior="height" resize on keyboard close (#18889)
Summary:
<!--
  Required: Write your motivation here.
  If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged.
-->
Fixes #13754
Pull Request resolved: https://github.com/facebook/react-native/pull/18889

Differential Revision: D14486115

Pulled By: PeteTheHeat

fbshipit-source-id: 7b8b4fa9d2c99fc5d6145fed4681afdc4bb14fb8
2019-03-22 15:08:21 -07:00
Rafi Ciesielczuk e2bf843d86 Introduce Module Setup Metric (#23859)
Summary:
The `RCTBridge` contains numerous definitions of notification names, which we can observe in order to get insights into the React Native performance.

The Android implementation is a little different, such that you can listen for any of the [following](https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactMarkerConstants.java) marker constants, simply by including the following code:

```java
ReactMarker.addListener(new ReactMarker.MarkerListener() {
  Override
  public void logMarker(ReactMarkerConstants name, Nullable String tag, int instanceKey) {
    Log.d("ReactNativeEvent", "name: "+ name.name() + " tag: " + tag);
  }
});
```
This will allow you to perform the necessary processing, calculations as required.

 ---

This PR enables observing for the module setup event (`RCTDidSetupModuleNotification`) by including the respective module's name & setup time in milliseconds.

[iOS] [Added] - Gain insights on the module setup times by observing `RCTDidSetupModuleNotification`. The `userInfo` dictionary will contain the module name and setup time in milliseconds. These values can be extracted via `RCTDidSetupModuleNotificationModuleNameKey ` and `RCTDidSetupModuleNotificationSetupTimeKey`.
Pull Request resolved: https://github.com/facebook/react-native/pull/23859

Differential Revision: D14579066

Pulled By: PeteTheHeat

fbshipit-source-id: 52645127c3fc6aa5bd73e3bd471fccd79cb05c14
2019-03-22 10:43:00 -07:00
David Aurelio f9a344c4dc Switch style getters to JNI fast calls
Summary:
@public

After changing native methods to return `long` rather than `YogaValue`, we switch them to JNI fast calls, as there is no more interaction with the Java GC.

Reviewed By: pasqualeanatriello

Differential Revision: D14576815

fbshipit-source-id: b5a33caef7343ba1de3d9634a50dc82ab3148cc7
2019-03-22 10:35:49 -07:00
David Aurelio 672a101ee3 Create `YogaValue` instances in Java, not C++
Summary:
@public

Passing primitive data via JNI is more efficient than passing objects.

Here, we avoid creating `YogaValue` (Java) instances via JNI, and rather pass a `long` back to Java. The instance is then created by extracting the necessary bytes on the Java side.

Reviewed By: foghina

Differential Revision: D14576755

fbshipit-source-id: 22d09ad50c3ac6c49b0a797a0dad639ea4829df9
2019-03-22 10:35:49 -07:00
David Aurelio cef6bb1f72 Move native methods to a single class
Summary:
@public

Moving all native methods in a single class provides the benefit of not having to load native bindings eagerly when just creating config objects in the startup paths, or setting Java-only values on them.
Loading native bindings triggers additional class loads (`YogaConfig` / `YogaNode`), and can lead to problems in multi-dex scenarions.

Reviewed By: pasqualeanatriello

Differential Revision: D14560658

fbshipit-source-id: 14e31e3c3b560675b5a752a38ae75ab80a565ea1
2019-03-22 09:44:29 -07:00
zhongwuzw bbd98d5c46 Fixed crash when textinput's default value exceeds maxLength (#24084)
Summary:
Bug comes from #23545, if `allowedLength < 0`, it would crash if `text.length > 1`.

cc. cpojer

[iOS] [Fixed] - Fixed crash when textinput's default value exceeds maxLength
Pull Request resolved: https://github.com/facebook/react-native/pull/24084

Differential Revision: D14562719

Pulled By: cpojer

fbshipit-source-id: 87ed930e35b8fa889d8b04829795fa46b7787b07
2019-03-22 03:57:58 -07:00
Ville Immonen cd8064bc5c Add CocoaPods Podfile to the project template (#23563)
Summary:
CocoaPods makes it easier to add new iOS dependencies to a project without having to manually edit Xcode projects. Editing Xcode projects is time consuming and merging changes to them difficult. Automating the changes to Xcode project `react-native link` is error prone. CocoaPods is a de-facto standard way to manage iOS dependencies and a central part of unimodules and upcoming improvements to `react-native link`.

This PR adds a `Podfile` to the default project template of React Native. To use a project with CocoaPods, after creating it, run `cd ios; pod install` and use the created `<projectname>.xcworkspace` file instead of the `.xcodeproj` file. (We could make this a part of `react-native init` so you only need to run one command when creating a project.)

[iOS] [Added] - Add CocoaPods Podfile to the project template
Pull Request resolved: https://github.com/facebook/react-native/pull/23563

Differential Revision: D14576505

Pulled By: cpojer

fbshipit-source-id: f6c9e93d61a52ad445d2931ccc4933d559a6ec1a
2019-03-22 03:29:11 -07:00
zhongwuzw 27e727968a Add copy for surface registry when return enumerator (#24056)
Summary:
To ensure all methods in surface registry thread safe, add copy to enumerator method.
cc. shergin .

[iOS] [Fixed] - Add copy for surface registry when return enumerator
Pull Request resolved: https://github.com/facebook/react-native/pull/24056

Differential Revision: D14575446

Pulled By: shergin

fbshipit-source-id: 6757f71e251381c4a38d13df4729e9494b3164d1
2019-03-21 23:37:18 -07:00
Ramanpreet Nara ef512194a6 Implement struct arguments for methods
Summary:
Before invoking TurboModule ObjC methods, we loop through all the arguments and transform them from `jsi::Value` to ObjC data structures. `jsi::Value`s that represent JS Objects get converted to `NSDictionary`s in ObjC. This isn't good enough because `NSDictionary` isn't typed. What we really need is a C/C++ struct that represents the type of the JS Object.

Therefore, for every argument of a TurboModule method that is a JS Object, this diff allows you to specify a method on `RCTCxxConvert` (which you have to declare and implement) that transforms that type of JS Object into something else. Basically, with the changes in this diff, we'll be able to transform JS Objects into C++ struct instances, which gives us type safety for JS Object method argumetns to TurboModule functions.

I modified the codegen to also create a mapping from NativeModule method name => argument num => `RCTCxxModule` conversion selector. This way, the FB codegen that generates the `RCTCxxConversion` function also informs our TurboModule system which conversion function to use before we call the method requiring complex argument. I just had to extend the `ObjCTurboModule` class to accomplish this.

The old system relies on the additional method generated by `RCT_EXPORT_METHOD` macro. It takes the written code, does string processing on it to parse the type of the struct arguments, and then replaces all instances of `::` with `_`. Super hacky. I didn't take this approach because it seemed unnecessarily hacky brittle.

The other approach I considered was to try to use reflection to infer the type of the struct at runtime. We'd have to do a bit of string processing and concat the TurboModule class name with the struct type. The solution would be simpler because it'd only modify the objective C and it wouldn't touch the Codegen system. **Edit:** I implemented it here: D14513078. The one downside of this design is that the name of the conversion function is individually constructed in two different locations in the code (i.e: no source of truth for this name). The other downside is that we have to rely on `RCTBridgeModuleNameForClass`, which we want to eliminate. This also computationally more expensive since it requires string processing/regex parsing and additional reflection. Therefore, we decided to move on with the current solution.

Reviewed By: fkgozali

Differential Revision: D14513429

fbshipit-source-id: 3d1b87e02ee908a19305686ff82b2ed624d8ac67
2019-03-21 17:37:18 -07:00
Kevin Gozali 3e8d2a18d7 iOS: undefined prop in an object shouldn't become [NSNull null] in the dictionary
Summary: [iOS] [Fixed] - The existing logic defaults `undefined` & `null` in JS to be `[NSNull null]` when converting JS object to `NSDictionary`. Let's not insert the prop to the dictionary if it's `undefined`.

Reviewed By: blairvanderhoof

Differential Revision: D14571128

fbshipit-source-id: e03c713b055672b0a001d3305d694912ee36ab36
2019-03-21 17:05:57 -07:00
Peter Ammon dd9959ab0e JSBigString to map via MAP_PRIVATE not MAP_SHARED
Summary:
JSBigString was inadvertently changed to a shared mapping. This means
that any changes to the string will be written back to the file. Ensure
we have a private (COW) mapping.

Reviewed By: kodafb

Differential Revision: D14532757

fbshipit-source-id: 6afb9635493496c90904f1432847c2f0da882c58
2019-03-21 14:27:23 -07:00
Marc Horowitz dcc40a6267 JSI es6 Symbol impl for JSCRuntime
Summary: this is an empirical hack

Reviewed By: fkgozali

Differential Revision: D14216647

fbshipit-source-id: 577ffb555c6e2f5a6456ccea5dff8e6ec757f80f
2019-03-21 13:33:32 -07:00
Marc Horowitz 7ccec333e9 sync with upstream jsi
Reviewed By: willholen

Differential Revision: D14232752

fbshipit-source-id: 2548158f2c2c8aa6e15656ef346d92d3c0937c4a
2019-03-21 13:33:32 -07:00
Sergei Dryganets aad4dbbbfe OkHttp is more strict than other http libraries. (#21231)
Summary:
It crashes with IllegalStateException in case you pass a wrong URL.
It crashes if it meets unexpected symbols in the header name and value,
while standard says it is not recommended to use those symbols not that
they are prohibited.

The headers handing is a special use case as a client might have an auth token in the header. In this case, we want to get 401 error response
from the server to find out that token is wrong. In case of the onerror
client will continue to retry with an existing token.

[ANDROID][Fixed] - Networking: Passing invalid URL not crashes the app instead onerror callback of HttpClient is called. Invalid symbols are stripped from the headers to allow HTTP query to fail with 401 error code in case of the broken token.

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

Reviewed By: axe-fb

Differential Revision: D10222129

Pulled By: hramos

fbshipit-source-id: b23340692d0fb059a90e338fa85ad4d9612275f2
2019-03-21 11:22:55 -07:00
Matthieu Lemoine fe3aebf87b fix: Start Metro packager from project root (#24070)
Summary:
Fixes #23342.

Since Metro [v0.47](https://github.com/facebook/metro/releases/tag/v0.47.0), some babel plugins such as [babel-plugin-module-resolver](https://github.com/tleunen/babel-plugin-module-resolver) or [babel-plugin-import-graphql](https://github.com/detrohutt/babel-plugin-import-graphql) fail to resolve files if the packager is started through Xcode. They receive wrong filenames from Babel such as `${projectRoot}/node_modules/react-native/src/index.js` instead of `${projectRoot}/src/index.js`.

It happens because the start command of the local-cli is not executed in the projectRoot directory. In this case, the cwd will be `${projectRoot}/node_modules/react-native`.

This issue doesn't occur if you start the packager yourself using `node node_modules/react-native/local-cli/cli.js start` from your project root.

It comes from this [line](b640b6faf7/scripts/packager.sh (L11)). This script changed the working directory to `${projectRoot}/node_modules/react-native` and started Metro from there.

Starting Metro from the project root fixes this issue.

[iOS] [Fixed] - Start Metro packager from project root
Pull Request resolved: https://github.com/facebook/react-native/pull/24070

Differential Revision: D14563996

Pulled By: cpojer

fbshipit-source-id: cdeff34610f1ebb5fb7bc82a96f4ac9eec750d16
2019-03-21 11:17:40 -07:00
Christoph Nakazawa 73245555cd js1 upgrade jest adds a caret (^)
Summary: This diff changes `js1 upgrade jest` to add a caret when upgrading so that the open source version of RN is not locked to a concrete version of Jest which doesn't really make much sense. I also added `pretty-format` to the packages that get updated because it is part of Jest's repo.

Reviewed By: rubennorte

Differential Revision: D14503180

fbshipit-source-id: 683c9a6ac768baa578771b9ad677e02df4912baa
2019-03-21 11:13:13 -07:00
Matt Hargett 13351e6acf Bundle size reduction (#23968)
Summary:
With recent activity to extract out non-core things into separate repos, I did an audit of the package.json to see what can be removed, and what packages remain that have newer versions that result in less/smaller javascript code. The goal is to:

1.  make developer experience better by removing unneeded dependencies, and
2. eliminate things the app bundler needs to process to make the production app bundle smaller.

[internal] [chore] - Remove unneeded packages, bump package versions who now have smaller size
Pull Request resolved: https://github.com/facebook/react-native/pull/23968

Differential Revision: D14519070

Pulled By: cpojer

fbshipit-source-id: 579f035f925668a34d07293810e3d35a7d0ae076
2019-03-21 11:13:13 -07:00
zhongwuzw de18977b42 Fixed native animated crash because of thread-safe issue (#24063)
Summary:
After we imported Fabric surface presenter observer mechanism, the thread-safe issue comes up, `operations` may read-write on main thread and shadow queue.

```
2019-03-20 15:53:21.249742+0800 RNTester[36039:1402802] *** Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x60000396a730> was mutated while being enumerated.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001083221bb __exceptionPreprocess + 331
    1   libobjc.A.dylib                     0x0000000106a07735 objc_exception_throw + 48
    2   CoreFoundation                      0x000000010831ee9c __NSFastEnumerationMutationHandler + 124
    3   RNTester                            0x00000001048c8784 -[RCTNativeAnimatedModule didMountComponentsWithRootTag:] + 596
    4   RNTester                            0x000000010491423e -[RCTSurfacePresenter mountingManager:didMountComponentsWithRootTag:] + 1662
    5   RNTester                            0x00000001048f54e9 -[RCTMountingManager _performMountItems:rootTag:] + 1369
    6   RNTester                            0x00000001048f4eba __62-[RCTMountingManager performTransactionWithMutations:rootTag:]_block_invoke + 58
    7   RNTester                            0x0000000104710d1d __RCTExecuteOnMainQueue_block_invoke + 29
    8   libdispatch.dylib                   0x000000010a4db595 _dispatch_call_block_and_release + 12
    9   libdispatch.dylib                   0x000000010a4dc602 _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x000000010a4e999a _dispatch_main_queue_callback_4CF + 1541
    11  CoreFoundation                      0x00000001082873e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    12  CoreFoundation                      0x0000000108281a76 __CFRunLoopRun + 2342
    13  CoreFoundation                      0x0000000108280e11 CFRunLoopRunSpecific + 625
    14  GraphicsServices                    0x000000010e0c11dd GSEventRunModal + 62
    15  UIKitCore                           0x000000011567281d UIApplicationMain + 140
    16  RNTester                            0x0000000104553380 main + 112
    17  libdyld.dylib                       0x000000010a552575 start + 1
)

```

[iOS] [Fixed] - Fixed native animated crash because of thread-safe issue
Pull Request resolved: https://github.com/facebook/react-native/pull/24063

Differential Revision: D14563994

Pulled By: shergin

fbshipit-source-id: 98970c8993b7b794273ed3a8c40dbbce147e1f4b
2019-03-21 11:05:00 -07:00
michalchudziak c8e26e6ac4 Fix eslint glob for `.test.js` and `.spec.js` files. (#24088)
Summary:
Existing glob might not work very well with `spec.js` and `test.js` files unless they're placed in `__tests__` directory. This PR aims to bring back the support of `jest` globals in these files, even if they're outside of `__tests__` directory.

[General] [Fixed] - Fixed globs for `spec.js` and `test.js` files.
Pull Request resolved: https://github.com/facebook/react-native/pull/24088

Differential Revision: D14562085

Pulled By: cpojer

fbshipit-source-id: 543d67e3f8a154256f454b34ccc68bb070197a75
2019-03-21 08:39:39 -07:00