16733 Commits

Author SHA1 Message Date
David Aurelio
bd959700db Publish events for layout pass
Summary:
Adds `LayoutPassStart` and `LayoutPassEnd` events.

The existing `NodeLayout` event in isolation is not as useful as it could be. Having events that mark start and end of a layout pass are a useful addition.

Differential Revision: D15305467

fbshipit-source-id: 14af6f65e698fb1e3112eb2ffd87a74d31df4840
2019-05-10 19:04:15 -07:00
David Vacca
1b4678105b Ensures constraintSurfaceLayout is executed before 'JS run application' starts
Summary:
This diff ensures the method scheduler.constraintSurfaceLayout is executed before the JS run application start.
This is necessary to properly set the pointScaleFactor for the Root before running JS.

This is a workaround to fix a bug when the pointScaleFactor changes over time for the rootShadowNode. The bug is easily reproducible when rendering the "fabric" indicator on Fabric screens. During the first render of a Fabric screen this method was called before "JS run application" starts, and the Fabric indicator was render correctly.
Beacuse of timing of measure APIS, the second time a Fabric screen is rendered the method is called after the "JS run application process started", as a consecuence the Fabric indicator is not rendered correctlly (the pointScaleFactor is incorrectly assigned into the layout metrics of the Fabric indicator text).

We still need to analyze why the pointScaleFactor is not correctly assigned when it is set after the "JS run application process started", but this will be part of another diff.

Reviewed By: shergin

Differential Revision: D15303554

fbshipit-source-id: 7d985cefee20fd40dbe04166c1a1358b3f3ddc85
2019-05-10 16:32:01 -07:00
David Vacca
ac9195a506 Include pointScaleFactor into the equality method of LayoutMetrics
Summary:
Previously the pointScaleFactor field was not being compared properly in LayoutMetrics equality method.
This diff fixes that

Reviewed By: shergin

Differential Revision: D15303555

fbshipit-source-id: 8863e9e1fbad15b43400afc32b97bf6d252cbe55
2019-05-10 16:32:01 -07:00
Valentin Shergin
184073813e Fabric: Making YogaStylableProps.yogaStyle protected
Summary: `YogaStylableProps.yogaStyle` is designed to be consumed by Yoga only. Making it `protected` allows us to avoid confusion and misuse of this props.

Reviewed By: JoshuaGross

Differential Revision: D15296474

fbshipit-source-id: cf9e416afee99fb426d72765557b34d303a63dbe
2019-05-10 15:34:25 -07:00
Valentin Shergin
16499c1086 Fabric: Removing of all unnececery nil checks in RCTMountingManager
Summary: We needed that in the very beginning when diffing algorithm produces mount instructions for <Text> nodes which don't have ComponentView representation, so we simply silence those error here. That's not the case anymore, so we don't need those ugly checks.

Reviewed By: JoshuaGross

Differential Revision: D15296473

fbshipit-source-id: ea3717062056907e5395776fe95e3d581d3e9b09
2019-05-10 15:34:24 -07:00
Valentin Shergin
9e3856fd99 Fabric: Fixed threading issues in RCTSurfacePresenter
Summary: RCTComponentViewRegistry is not a thread-safe class and must be accessed only from the main thread.

Reviewed By: JoshuaGross

Differential Revision: D15296475

fbshipit-source-id: 67192abd6290191f3b8119972efc41cec48a793a
2019-05-10 15:34:24 -07:00
Vladimir Kolbun
55db1d05fb Fix object initialization
Summary: self should be assigned to result of [super init]

Reviewed By: shergin

Differential Revision: D15295275

fbshipit-source-id: 722ae9ad3f9fb8ee3a86892bfb5b2a4cb7b8c708
2019-05-10 10:10:27 -07:00
Dan Abramov
6001acb319 Declare a dependency on scheduler (#24802)
Summary:
ReactNativeRenderer has `require('scheduler')` in it but we don't seem to declare a dependency. As a result, the latest sync broke `useEffect` in open source master:

```js
function Counter() {
  const [count, setCount] = useState(0);
  useEffect(() => {
    const id = setInterval(() => {
      setCount(c => c + 1);
    }, 1000)
    return () => clearInterval(id);
  }, [])
  return <View><Text>{count}</Text></View>
}
```

<img width="535" alt="Screen Shot 2019-05-10 at 3 26 05 PM" src="https://user-images.githubusercontent.com/810438/57535832-e04dc000-733a-11e9-8e3e-d685171ec55a.png">

This adds an explicit dependency on the same version we're currently using internally.

<img width="535" alt="Screen Shot 2019-05-10 at 3 47 42 PM" src="https://user-images.githubusercontent.com/810438/57535886-f65b8080-733a-11e9-82c3-78e6c3a3888b.png">
Pull Request resolved: https://github.com/facebook/react-native/pull/24802

Differential Revision: D15295252

Pulled By: hramos

fbshipit-source-id: cd897ac590de1b719f28234f7631b0dcc069d043
2019-05-10 08:59:12 -07:00
Kudo Chien
310cc38a5a Fix PickerAndroid will reset selected value during items update. (#24793)
Summary:
Fixes #13351

Two root causes:
1. Android Spinner will reset selection to undefined after setAdapter()
   which will trigger onValueChange().
   The behavior is not expected for RN.
   And the solution is to setSelection() explicitly

2. In original implementation, it setups `items` immediately,
   but delays the `selected` setup after update transaction.
   There will be some race condition and incosistency
   if update `items` only.
   The fix will do the setup all after update transaction.

[Android] [Fixed] - Fix #13351 PickerAndroid will reset selected value during items update.
Pull Request resolved: https://github.com/facebook/react-native/pull/24793

Differential Revision: D15293516

Pulled By: cpojer

fbshipit-source-id: 5a99a60015c7e1b2968252cdc0b2661d52a15b9d
2019-05-10 02:01:14 -07:00
Maciej Srokowski
ebeb893b50 Fix Android Camera Roll crash on mime type guessing (#24780)
Summary:
Fixes this issue:
https://github.com/facebook/react-native/issues/24468
It was incorrectly closed by a fix on react-native-community CameraRoll implementation. CameraRoll in react-native still crashes when finding a file with # sign

[Android] [Fix] - Fix Android Camera Roll crash on mime type guessing
Pull Request resolved: https://github.com/facebook/react-native/pull/24780

Reviewed By: mdvacca

Differential Revision: D15281062

Pulled By: lunaleaps

fbshipit-source-id: ca3364c8478d9bfc9a0a6657b531ffb384145d8c
2019-05-09 18:40:59 -07:00
Héctor Ramos
a6f905fdb8 Contributing Guide Revamp (#24705)
Summary:
This is the first step in revamping the Contribution Guide at `/CONTRIBUTING.md`. This work will require changes to the React Native website repository, as well as the React Native GitHub wiki. For review purposes, changes to copy that exists outside of this repository will be included within a `.github/wiki` directory in this PR, but they are not intended to be part of the final PR that gets merged.

[General] [Changed] - Contribution Guide Revamp
Pull Request resolved: https://github.com/facebook/react-native/pull/24705

Differential Revision: D15290268

Pulled By: hramos

fbshipit-source-id: b09c86738e75143fbdf2fea97ccd860da79362d2
2019-05-09 18:13:57 -07:00
Emily Janzer
d5b27fc0a8 Allow creating ThemedReactContext without a CatalystInstance
Summary: In the future we're planning to decouple ThemedReactContext from the bridge (CatalystInstance). For now, we just need to be able to create a ThemedReactContext with a ReactContext that has no Catalyst instance.

Reviewed By: mdvacca

Differential Revision: D15246442

fbshipit-source-id: 99ebda6521f4df72969011ea0e6ea41b046875c8
2019-05-09 17:47:18 -07:00
David Vacca
5f9bb72bb3 Replace abort() with assert() when a prop-value is not found during parsing
Summary: This diff replaces usage of abort() with assert() when a prop-value is not found during parsing of prop values

Reviewed By: shergin

Differential Revision: D14563338

fbshipit-source-id: c799420e6b49df35e1d7ccdbd4bc4845067d33cc
2019-05-09 16:24:13 -07:00
Eli Perkins
e7085cd488 Change new app screen greeting (#24785)
Summary:
We're all friends here, right? 💗

Related to conversation in #24783: https://github.com/facebook/react-native/pull/24783#discussion_r282662623

We're just [making React run on phones](https://www.youtube.com/watch?v=xKu4kmVivFs&start=17&end=21), right?

[General] [Changed] - Updated new app greeting screen title 💗
Pull Request resolved: https://github.com/facebook/react-native/pull/24785

Differential Revision: D15286468

Pulled By: cpojer

fbshipit-source-id: eb73d1c870331f03766b237e9ccb3fa952463be0
2019-05-09 15:54:49 -07:00
Emily Janzer
db40c28728 Move message queue initialization in ReactContext into its own method
Summary: Refactoring ReactContext to move message queue initialization into its own function that can be called independently of initializeWithInstance. This allows you to create a ReactContext with message queue threads without a CatalystInstance.

Reviewed By: mdvacca

Differential Revision: D15246287

fbshipit-source-id: 4b8c53e68112af7eded47d8c31311500cc296dfe
2019-05-09 15:49:18 -07:00
Valentin Shergin
1d985b5e6e Fabric: Removing leftovers from previous implementation of view preallocation infra
Summary: Now it's implementled differently (see -[RCTComponentViewRegistry preallocateViewComponents]), so this code is not being used.

Reviewed By: mdvacca

Differential Revision: D15242045

fbshipit-source-id: c02eceb978cf1eae778f84a73456e7156ccf503b
2019-05-09 15:49:18 -07:00
Valentin Shergin
8c0ba25f19 Fabric: Storing ImageLoader (instead of ImageManager) in ContextConteiner
Summary:
ImageLoader is an actual external dependency, not a ImageManager.
That change allows to remove dependency on ImageManager from SurfacePresenter and make some other code simpler.

Reviewed By: mdvacca

Differential Revision: D15242047

fbshipit-source-id: 8622d15b8fdb5c3a7e25091adf7be1108f87ecd5
2019-05-09 15:49:18 -07:00
Valentin Shergin
656c415f76 Fabric: Removing references to MessageQueueThread in RCTSurfacePresenter
Summary: The particular meaningful piece of code that diff removes was added as (successful) attempt to fix an issue which was lately fixed by D14868547.

Reviewed By: mdvacca

Differential Revision: D15242046

fbshipit-source-id: 88a3e3c629d7c5f84c402b03e45034644147fec4
2019-05-09 15:49:18 -07:00
Eli Perkins
233fddbe01 Polish new app screen component styling (#24783)
Summary:
Related to #24760 and #24737

This simplifies some styling within the components used for the New App Screen to help advocate for best practices when styling with CSS-like styles in React Native, as well as using React Native's own unique components.

There's a bit more detail in each commit. Let me know if you'd like me to pull that info out into the PR description here!

[General] [Changed] - Polished up new app screen component styling
Pull Request resolved: https://github.com/facebook/react-native/pull/24783

Differential Revision: D15284851

Pulled By: cpojer

fbshipit-source-id: 954db00d39fc0082bbd4dc96afa7d38dfb7f67d5
2019-05-09 14:46:52 -07:00
Valentin Shergin
4e37d37cbf Fixed accesibility problem with <TextInput>'s Clear Button
Summary:
UITextView is accessible by default (some nested views are) and disabling that is not supported.

The problem happened because JS side sets `isAccessible` flag for UITextView and UITextField to `true` (with good intent!), which actually disables (surprise!) bult-in accessibility of TextInput on iOS.
On iOS accessible elements cannot be nested, so enabling accessibily for some container view (even in a case where this is view is a public API of TextInput on iOS) shadows some features implemented inside the component.

(Disabling accessibility of TextInput via `accessible=false` was never supported.)

Reviewed By: JoshuaGross

Differential Revision: D15280667

fbshipit-source-id: 72509b40383db6ef66c4263bd920f5ee56a42fc1
2019-05-09 12:25:06 -07:00
Emily Janzer
078f14c5d2 Require passing in JSCallInvokerHolder to TurboModuleManager
Summary: Right now TurboModuleManager gets the JSCallInvokerHolder from the bridge in its constructor; this diff changes the constructor to make the JSCallInvokerHolder a required argument so that TurboModuleManager doesn't directly depend on the bridge.

Reviewed By: axe-fb, RSNara

Differential Revision: D15227184

fbshipit-source-id: b16e6abaa727587986a132d0e124163acdf55408
2019-05-09 11:28:30 -07:00
Valentin Shergin
335c81ec31 Fabric: Optimizations in view flattening algorithm
Summary:
This diff changes the condition in `ViewShadowNode::isLayoutOnly()` removing checking for `onLayout` event listener.
We needed that before because the mechanism of emitting events was based on analyzing mutation instructures (we needed those to be generated for nodes with `onLayout`).
Recenly we changed that algorithm deeply integrating in layout infra, so we don't need this anymore.

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D15273491

fbshipit-source-id: 2d43f00d1b87369d5993fe5ba70c2de36b8ce0c5
2019-05-09 10:56:44 -07:00
Valentin Shergin
c60d9f8c15 Fabric: Fixed memory leak happened between RCTSurfacePresenter and RCTBridge
Summary: RCTBridge does not need to retain RCTSurfacePresenter, so we enforce that using `OBJC_ASSOCIATION_ASSIGN`.

Reviewed By: mdvacca

Differential Revision: D15273325

fbshipit-source-id: f223192ff5f781d9e905b004907739a36882bb63
2019-05-09 10:56:43 -07:00
Janic Duplessis
4e215b20a3 Fix event ordering when combining coalescable and non-coalescable events (#24693)
Summary:
Fixes an issue introduced in https://github.com/facebook/react-native/pull/15894 that can cause events to be dispatched out of order.

Also reverted `viewTag` moved to optional property as it didn't actually work and makes code more complex.

[iOS] [Fixed] - Fix event ordering when combining coalescable and non-coalescable events
Pull Request resolved: https://github.com/facebook/react-native/pull/24693

Differential Revision: D15279513

Pulled By: shergin

fbshipit-source-id: 3c64aba6d644ea9564572e6de8330b59b51cf4a9
2019-05-09 10:36:56 -07:00
Sidharth Guglani
12fb97d9e9 move event files to yoga/events folder
Summary: Moved events files to yoga/events for better code structure

Reviewed By: davidaurelio

Differential Revision: D15198566

fbshipit-source-id: 74d451011841d59fae5a1c637f9c33a7d2d1f87e
2019-05-09 07:47:05 -07:00
Damien
eb534bca58 Fix duplicate resource error in Android gradle build (#22234) (#24778)
Summary:
If `$buildDir/generated/res/react/${flavorPathSegment}release/raw` contains files during `gradle assembleRelease` script will fail with `Error: Duplicate resources` error.

This patch is based on this issue [22234](https://github.com/facebook/react-native/issues/22234) and pull request [24518](https://github.com/facebook/react-native/pull/24518).

[Android] [Fixed] - Fix duplicate resource error for raw folder in Android build

[CC from Mike Hardy PR]
Reports of success on the linked issue via use of the patch + patch-package for a couple months, I personally use it full time with all gradle builds (./gradlew clean assembleRelease or if you have a 'staging' flavor, e.g. ./gradlew clean assembleStagingRelease)

Related reading, also cross-links with the linked issue here:
https://stackoverflow.com/questions/53239705/react-native-error-duplicate-resources-android
Pull Request resolved: https://github.com/facebook/react-native/pull/24778

Differential Revision: D15277766

Pulled By: cpojer

fbshipit-source-id: 0ccd76d2aa2e13f7c8bfac07d4ef23b74945807a
2019-05-09 06:26:19 -07:00
Mike Hardy
962437fafd Fix duplicate resource error in Android gradle build (#22234) (#24518)
Summary:
Issue #22234 includes a number of people (myself included) suffering with duplicate resource errors while building in Android. We have been collectively using a patch there but I don't believe any attempt has been made to PR it upstream.

I am not excellent at gradle, so I may have approached this in completely the wrong way, but it works for me in the standard init templates, as well as my current work project which has a complicated 2 buildType + 4 productFlavor configuration. If there is a better way to achieve the result I am happy to learn

The approach here is to determine the generated path the resources land in, then move them into the main build output tree. If they remain in the generated path android merging fails with duplicate resource errors, so that move (vs copy) is important.

[Android] [Fixed] - Fix duplicate resource error in Android build
Pull Request resolved: https://github.com/facebook/react-native/pull/24518

Differential Revision: D15276981

Pulled By: cpojer

fbshipit-source-id: 3fe8c8556e4dcdac5f96a2d4658ac9b5d9b67379
2019-05-09 04:22:43 -07:00
David Aurelio
6ccdf85cef Publish event when visiting nodes during layout
Summary:
@public

Publish an event when visiting nodes during layouts.

Reviewed By: SidharthGuglani

Differential Revision: D15206965

fbshipit-source-id: c201f084b1d4186bc64560b8033be965f2549236
2019-05-09 04:22:43 -07:00
David Aurelio
7d44113bee **breaking:** remove YGNodeGetInstanceCount
Summary:
@public

`YGNodeGetInstanceCount` was only ever meant for tests, and caused data races in multi-threaded environments.

It was completely replaced with event-based counting for tests.

Here we remove public API around the counter, and the counter itself.

Reviewed By: SidharthGuglani

Differential Revision: D15174857

fbshipit-source-id: 228e85da565bac9e8485121e956a2e41910b11c8
2019-05-09 04:22:42 -07:00
David Aurelio
03bf17898a Add test utilities for C++ and Java
Summary:
@public

Test utility on top of the new event system that maintains a counter of instantiated nodes. Meant to replace the global node counter.

Reviewed By: SidharthGuglani

Differential Revision: D15174855

fbshipit-source-id: 6998472f95a09b8da652257a26596164bdcf43d6
2019-05-09 04:22:42 -07:00
David Aurelio
d1411cc92f Publish events for node allocation and deallocation
Summary:
@public

Publish two events, `NodeAllocation` and `NodeDeallocation`, in the same places where the global node counter is changed.

Reviewed By: SidharthGuglani

Differential Revision: D15174858

fbshipit-source-id: 6e4e9add88513b9e987189ca5035d76da2a1de55
2019-05-09 04:22:42 -07:00
Héctor Ramos
25ee3e00f4 Consolidate issue templates (#24765)
Summary:
Eliminate the regression template, as it is hardly used and it is already served by the bug report template. Triagers can add the Regression label selectively, or we can do so through the bot.

Eliminate the discussion template, as it is not meant to be used and we can point people in the right direction using the existing questions template.

Rename the document bug template, and point people to the website repo.

Update the bug report template, and be less prescriptive about how an issue is reported. As long as the issue is well-described and the steps to repro can be reasonably followed by someone who is investigating the bug, we'll be happy.

[Internal] [Changed] - Consolidated issue templates.
Pull Request resolved: https://github.com/facebook/react-native/pull/24765

Differential Revision: D15276866

Pulled By: cpojer

fbshipit-source-id: d99a174982d2454d8cad3a195dfd627a07438611
2019-05-09 03:31:16 -07:00
David Aurelio
71c3c23862 Reduce measure cache size to 8
Summary:
@public

Reduces measure cache size to a number that is enough for 95% of nodes, according to our (FB-internal) measurements.

Node size: 776b -> 584b

Reviewed By: SidharthGuglani

Differential Revision: D15183567

fbshipit-source-id: 9ae8cc78074271a015e7618b931ba0356de87a0c
2019-05-09 03:26:03 -07:00
Xiuli Shen
d4d463bc2b Revert accessibility textinput issue to see if it is the root cause of labels not showing up properly
Summary: Reverting cb7e26ab6a to see if this fixes the accessibility issue we are seeing in text inputs.

Reviewed By: shergin

Differential Revision: D15271883

fbshipit-source-id: e956f93af539e146ac5a7948fdae020c99a1301e
2019-05-08 21:16:21 -07:00
cpojer
e7ebb17452 Fix RNTester on iOS (#24736)
Summary:
See e94b116d76 which broke RNTester in open source. Environment variables are always strings, so "0" is a truthy value. This fixes it.

[iOS] [fixed] - Fixed broken RNTester
Pull Request resolved: https://github.com/facebook/react-native/pull/24736

Reviewed By: fkgozali

Differential Revision: D15272951

Pulled By: hramos

fbshipit-source-id: aa78f229e05cb553f75cdf6fb4f926829e20a557
2019-05-08 19:36:07 -07:00
licd
3163479e0f add nonnull/nullable for swift (#24729)
Summary:
add nonnull/nullable for swift

[iOS] [Changed] - add nonnull/nullable for swift
Pull Request resolved: https://github.com/facebook/react-native/pull/24729

Differential Revision: D15273046

Pulled By: shergin

fbshipit-source-id: 5603007e5aa01d54064da349666a4e4d998b5471
2019-05-08 18:21:26 -07:00
Valentin Shergin
d8677752f8 Fabric: Enable useLegacyStretchBehaviour for Yoga in Fabric
Summary: Apparently, Yoga has a "quirks mode" and we have to enable that for Fabric. Which is probably a mistake that we have to make one more time.

Reviewed By: davidaurelio

Differential Revision: D15267852

fbshipit-source-id: 88a910fafc9ff64fb19376f4b74a2f2fd5827eba
2019-05-08 17:56:16 -07:00
Jeffrey Beauchamp
bccac53a45 Revert D15240810: [react-native][PR] Fix RNTester on iOS
Differential Revision:
D15240810

Original commit changeset: 76f498222b6a

fbshipit-source-id: c6bb1bb0738609b36faccbee93a32e76d17cde87
2019-05-08 16:44:07 -07:00
cpojer
58328558c6 Fix RNTester on iOS (#24736)
Summary:
See e94b116d76 which broke RNTester in open source. Environment variables are always strings, so "0" is a truthy value. This fixes it.

[iOS] [fixed] - Fixed broken RNTester
Pull Request resolved: https://github.com/facebook/react-native/pull/24736

Differential Revision: D15240810

Pulled By: hramos

fbshipit-source-id: 76f498222b6ac05131b3820d8356bfee696f46b8
2019-05-08 15:41:10 -07:00
cpojer
6b393b27e1 Polish the new app screen (#24737)
Summary:
Continuation of #24687

> Issue: [Polish the "new app screen"](https://github.com/react-native-community/discussions-and-proposals/issues/122)
> This is the pull request for the new intro screen proposal in react native as directed by cpojer

This PR was created because the previous one could not be pushed to for some reason. I cleaned up a few small things and added the component as an example to RNTester so we can keep iterating. My plan is to land this, and then polish it and make it the default in a follow-up.

[General][Added] - New Intro screen, Icons

Removed Lottie Integration
100% React Native 💥
Pull Request resolved: https://github.com/facebook/react-native/pull/24737

Differential Revision: D15259092

Pulled By: cpojer

fbshipit-source-id: bc141fb1425cf354f29deffd907c37f83fd92c75
2019-05-08 14:59:08 -07:00
Joshua Gross
d7447fadeb Core React/Litho support and Java codegen
Summary:
Core React/Litho support and Java codegen. View updating still in progress.

Generated ViewManager code:

```
// Copyright 2004-present Facebook. All Rights Reserved.
//
// Autogenerated by ComponentsReactNativeSupportProcessor
package com.facebook.catalyst.samples.componentsembedding;

import com.facebook.litho.Component;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.reactnative.ComponentsShadowNode;
import com.facebook.litho.reactnative.ComponentsViewManager;
import com.facebook.litho.reactnative.ReactLithoView;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;
import java.util.HashMap;
import java.util.Map;

ReactModule(
    name = "SampleComponent"
)
public class GeneratedSampleComponentViewManager extends ComponentsViewManager {
  Override
  public String getName() {
    return "SampleComponent";
  }

  Override
  public ReactLithoView createViewInstanceWithProps(ThemedReactContext context,
      ReactStylesDiffMap props) {
    Map<String, Object> propsMap;
    if (props != null && props.toMap() != null) {
      propsMap = props.toMap();
    } else {
      // Non-Fabric will always follow this path, initial props are never provided;
      return ReactLithoView.create(context, null, null);
    }
    Component component = createComponentInstanceWithPropsMap(new ComponentContext(context), propsMap);
    return ReactLithoView.create(context, component, propsMap);
  }

  Override
  public Component createComponentInstanceWithPropsMap(ComponentContext context,
      Map<String, Object> propsMap) {
    SampleComponent.Builder componentBuilder = SampleComponent.create(context);
    setComponentBuilderPropsWithMap(componentBuilder, propsMap);
    return componentBuilder.build();
  }

  Override
  public void updateProperties(ReactLithoView view, ReactStylesDiffMap props) {
    super.updateProperties(view, props);
    Map<String, Object> propsMap = props.toMap();
    Map<String, Object> oldProps = view.getProps();
    if (oldProps == null) {
      // Non-Fabric RN will always terminate here; we do not store props, nor do we need to.;
      // Prop updating happens incrementally in non-Fabric RN.;
      return;
    }
    Map<String, Object> mergedProps = new HashMap<>(oldProps);
    mergedProps.putAll(propsMap);
    SampleComponent.Builder componentBuilder = SampleComponent.create(new ComponentContext(view.getComponentContext()));
    setComponentBuilderPropsWithMap(componentBuilder, mergedProps);
    view.setProps(mergedProps);
    view.setComponent(componentBuilder.build());
  }

  private void setComponentBuilderPropsWithMap(SampleComponent.Builder componentBuilder,
      Map<String, Object> propsMap) {
    if (propsMap != null && propsMap.containsKey("title")) {
      componentBuilder.title((((String)propsMap.getOrDefault("title", null))));
    }
    if (propsMap != null && propsMap.containsKey("imageUri")) {
      componentBuilder.imageUri(android.net.Uri.parse(((String)propsMap.getOrDefault("imageUri", null))));
    }
  }

  Override
  public GeneratedSampleComponentShadowNode createShadowNodeInstance(ReactApplicationContext context) {
    return new GeneratedSampleComponentShadowNode();
  }

  Override
  public Class<? extends ComponentsShadowNode> getShadowNodeClass() {
    return GeneratedSampleComponentShadowNode.class;
  }

  Override
  public void updateState(ReactLithoView view, StateWrapper stateWrapper) {
    view.setStateWrapper(stateWrapper);
  }
}
```

Reviewed By: shergin

Differential Revision: D14846423

fbshipit-source-id: 4eeeb991f7e32c0cec5e9307d6175b81c8fd034e
2019-05-08 14:53:51 -07:00
Moti Zilberman
343f0a1d50 Upgrade Metro packages to 0.54.0
Summary: Upgrades React Native's Metro dependencies to 0.54.0.

Reviewed By: alexeylang

Differential Revision: D15212988

fbshipit-source-id: 5799740bc8df1b778630bba063be17d8739cbef8
2019-05-08 14:22:23 -07:00
Janic Duplessis
9ef5107d04 Release underlying resources when JS instance in GC'ed (#24745)
Summary:
Our Blob implementation was very problematic because it didn't release its underlying resource when the JS instance was dealocated. The main issue is that the fetch polyfill uses blobs by default if the module is available, which causes large memory leaks.

This fixes it by using the new jsi infra to attach a `jsi::HostObject` (`BlobCollector`)  to `Blob` instances. This way when the `Blob` is collected, the `BlobCollector` also gets collected. Using the `jsi::HostObject` dtor we can schedule the cleanup of native resources. This is definitely not the ideal solution but otherwise it would require rewriting the whole module using TurboModules + jsi.

Fixes #23801, #20352, #21092

[General] [Fixed] - [Blob] Release underlying resources when JS instance in GC'ed
Pull Request resolved: https://github.com/facebook/react-native/pull/24745

Reviewed By: fkgozali

Differential Revision: D15248848

Pulled By: hramos

fbshipit-source-id: 1da835cc935dfbf4e7bb6fbf2aea29bfdc9bd6fa
2019-05-08 14:15:09 -07:00
Ramanpreet Nara
f2618fd81b Fix OSS Android build (#24764)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/24764

The `test_android` CI build was failing:

```
./scripts/circleci/buck_fetch.sh
+ buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
Not using buckd because watchman isn't installed.
Picked up _JAVA_OPTIONS: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
PARSING BUCK FILES: FINISHED IN 1.1s
No build file at ReactAndroid/src/main/libraries/fbjni/BUCK when resolving target //ReactAndroid/src/main/libraries/fbjni:java.

This error happened while trying to get dependency '//ReactAndroid/src/main/libraries/fbjni:java' of target '//ReactAndroid/src/main/java/com/facebook/react/turbomodule/core:jscallinvokerholder'
Exited with code 1
```

The problem was that I was using `react_native_dep("libraries/fbjni:java")` to access JNI classes like `HybridData`. In open source this target translates to the path `//ReactAndroid/src/main/libraries/fbjni`, which doesn't exist. Instead, the actual classes are available at the path `//ReactAndroid/src/main/java/com/facebook/jni`. Therefore, I changed the target to `react_native_dep("java/com/facebook/jni:jni")`. This is exactly how the bridge (i.e: `//ReactAndroid/src/main/java/com/facebook/react/bridge:bridge`) accesses JNI clases.

Reviewed By: hramos

Differential Revision: D15261218

fbshipit-source-id: 659a5627389bbca3603db7de347618cd400d4ffc
2019-05-08 12:28:26 -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
James Ide
59749f527a Migrate Jest setup scripts from Haste to path-based requires (#24753)
Summary:
This is another step in moving RN towards standard path-based requires. All the requires in Jest's setup script have been rewritten to use relative requires. 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.

[General] [Changed] - Migrate Jest setup scripts from Haste to path-based requires
Pull Request resolved: https://github.com/facebook/react-native/pull/24753

Differential Revision: D15258238

Pulled By: cpojer

fbshipit-source-id: aa05dc8ea2e4ba195226e8ec7ba6482b7de03240
2019-05-08 06:59:47 -07:00
Alan Kenyon
09f17a4e29 AccessibilityInfo.announceForAccessibility (#24746)
Summary:
AccessibilityInfo.announceForAccessibility is currently only available on iOS. I've added the Android specific implementation, updated RNTester, and the documentation.

[Android] [Added] - Added AccessibilityInfo.announceForAccessibility for Android
[General] [Added] - RNTester example for AccessibilityInfo.announceForAccessibility
Pull Request resolved: https://github.com/facebook/react-native/pull/24746

Differential Revision: D15258054

Pulled By: cpojer

fbshipit-source-id: 3e057a5c32b28e30ea2ee74a18854b012cd2dbfd
2019-05-08 03:58:13 -07:00
Janic Duplessis
9261035c2b Move accessibility props to UIView+React (#24743)
Summary:
React Native Gesture Handler uses a `RCTViewManager` subclass to manage `UIControl` so the cast to set accessibility props is not safe. This moves the accessibility props we set to `UIView+React` so they can be used safely on any `UIView`.

![image](https://user-images.githubusercontent.com/2677334/57042641-46e42700-6c33-11e9-9a97-76661ad5d14d.png)

[General] [Fixed] - Move accessibility props to UIView+React
Pull Request resolved: https://github.com/facebook/react-native/pull/24743

Differential Revision: D15258062

Pulled By: cpojer

fbshipit-source-id: 4a25b79407e5cb7b3b368c7506161e989794bb26
2019-05-08 03:48:03 -07:00
Héctor Ramos
b4b9c0f6fe Add Internal and JavaScript categories (#24744)
Summary:
So far we have only officially supported "iOS" and "Android" as categories, with a "General" catch all for everything else.
Let's add a "JavaScript" category for changes that only affect JavaScript, and an "Internal" category for things that do not make sense in a changelog (e.g. CI changes).

[Internal] [Added] - Added JavaScript and Internal categories to changelog regex
Pull Request resolved: https://github.com/facebook/react-native/pull/24744

Differential Revision: D15258061

Pulled By: cpojer

fbshipit-source-id: 8b6cb193adf602d3bd6639b550e04775b201fe59
2019-05-08 03:17:04 -07:00
Injung Chung
c802d0b757 Make Linking.getInitialURL works properly even if current activity is not initialized (#24748)
Summary:
Solves #15961 - [ANDROID] Linking.getInitialURL() returns null after exiting the app with back button and using deep linking again (only in production!)

As the issue says, it seems that `currentActivity` is null in [IntentModule#getInitialURL](1e8f3b1102/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.java (L50)). So I used the `InteractionManager` to wait until current activity to finish initializing.

[Android] [Fixed] - In `Linking.getInitialURL` method, use the `InteractionManager` to wait for the current activity to finish initializing.
Pull Request resolved: https://github.com/facebook/react-native/pull/24748

Differential Revision: D15258046

Pulled By: cpojer

fbshipit-source-id: 0ec1c873766ae90955d47e5e023556eb6c5d5fbb
2019-05-08 03:17:04 -07:00