Summary:
This PR was created in response to feedback from an older PR: https://github.com/facebook/react-native/pull/2045
The `.interpolate()` API of Animated values is quite effective to accomplish transformations based on a single animated value, but currently there is a class of animations that is impossible: animations being driven by more than one value.
Usage would be like the following:
```js
getInitialState: function() {
return {
panY: new Animated.Value(0),
offset: new Animated.Value(0),
};
}
```
```js
var scale = Animated.add(panY, offset).interpolate({
inputRange: [...],
outputRange: [...],
});
```
I have a real use case for this, and I cannot think of any way to accomplish what I need without an API like this.
The animation I am trying to accomplish is I have a PanResponder being used to detect both x and y panning. The y-axis panning drives a 3d sroll-like animation (which we can call `panY`), and the x-axis panning is driving a "swipe-to-remove" animation (
Closes https://github.com/facebook/react-native/pull/4395
Reviewed By: svcscm
Differential Revision: D2731305
Pulled By: vjeux
fb-gh-sync-id: 3b9422f10c7e7f3b3ecd270aeed8ea92315a89e9
Summary:
Docs say they're supported and presumably they should work exactly as for ScrollView but currently they are intercepted by the ListView
Closes https://github.com/facebook/react-native/pull/4712
Reviewed By: svcscm
Differential Revision: D2745080
Pulled By: vjeux
fb-gh-sync-id: 531907f03ae46d5200003cdb335c10b40c7d3bed
Summary:
public
This diff replaces the RegEx module method parser with a handwritten recursive descent parser that's faster and easier to maintain.
The new parser is ~8 times faster when tested on the UIManager.managerChildren() method, and uses ~1/10 as much RAM.
The new parser also supports lightweight generics, and is more tolerant of white space.
(This means that you now can – and should – use types like `NSArray<NSString *> *` for your exported properties and method arguments, instead of `NSStringArray`).
Reviewed By: jspahrsummers
Differential Revision: D2736636
fb-gh-sync-id: f6a11431935fa8acc8ac36f3471032ec9a1c8490
Summary:
public
A previous refactor introduced a bug where setting the tintColor of an <Image> to null no longer cleared the tint. This fixes it again.
Reviewed By: javache
Differential Revision: D2744279
fb-gh-sync-id: 1b5e0d546bf456d7b93e2ceee73c568c185c305c
Summary:
public
NativeModule getters call the nativeRequireModuleConfig function to lazily load a module if it's not already available, but this crashes on Android since the nativeRequireModuleConfig hook hasn't been implemented yet. This diff checks that the hook exists before calling it.
Reviewed By: gsaraf
Differential Revision: D2744080
fb-gh-sync-id: cae9c8c45a4d3c80ceb8c10f3d4d59a8d9d3c7f8
Summary:
If border radius is not set or is zero, then elevation will not
work properly. This bug seems to have been introduced when the
style in facebook/react-native#4180 was modified slightly to
produce commit b65f1f2234.
Closes https://github.com/facebook/react-native/pull/4555
Reviewed By: svcscm
Differential Revision: D2741203
Pulled By: mkonicek
fb-gh-sync-id: f4ee9ccdfc64374d58824a6e988409ac2b7532a4
Summary:
public
- Open source the unit test for `ClipboardModule`, start using the `ReactTestHelper` in two unit tests
- Fixes a few references to "pasteboard" in strings
Reviewed By: bestander
Differential Revision: D2739614
fb-gh-sync-id: e076940a3ae5c22314e181a37fe2c3f77a18cf85
Summary:
Functions from the path module return paths with the native file system path separator. generateAssetModule is using path.join and path.dirname to generate httpServerLocation. That means that on Windows systems, the generated URL path has backslashes rather than forward slashes which breaks the app's ability to retrieve image assets using require('./image.png'). This change fixes this by checking path.sep and replacing backslashes with slashes on systems that require it.
Closes https://github.com/facebook/react-native/pull/4416
Reviewed By: svcscm
Differential Revision: D2740529
Pulled By: mkonicek
fb-gh-sync-id: edae0f6762c7dc1db7af078209e38a2feab1e0a1
Summary:
Needed to support tagged template literals (which are already enabled in babel). Not having this helper means we get a runtime crash.
Closes https://github.com/facebook/react-native/pull/4680
Reviewed By: svcscm
Differential Revision: D2740233
Pulled By: spicyj
fb-gh-sync-id: 12729f670b7942ad7a04bd50ae1eca35d2b1e410
Summary:
public
Use the actual timestamp provided through `CADisplayLink` instead of the time
the handler is called.
Reviewed By: jspahrsummers
Differential Revision: D2739121
fb-gh-sync-id: 1da28190bb25351dc3dd94efaff21d49279a570f
Summary:
public
More people wanted to understand the motivation behind the intentional retain
cycle in `RCTJavaScriptContext`, add a small comment with some context.
Reviewed By: jspahrsummers
Differential Revision: D2738930
fb-gh-sync-id: d8c950778eb6bf3eaca627aabb6c98335d25d1fc
Summary:
When you did a typo in declaring a prop type (like using `boolean` insteal of `bool`) you'd got a bit misleading error message:
{F27113768}
The truth is that the prop type is defined, but not correctly. So I've changed the message in this case to be more accurate:
{F27113627}
public
Reviewed By: sahrens
Differential Revision: D2729340
fb-gh-sync-id: dd12c10a4f3a1c9825293f86481a082908127a76
Summary:
The JavaScript ecosystem doesn't have the notion of a built-in native module loader. Even Node is decoupled from its module loader. The module loader system is just JS that runs on top of the global `process` object which has all the built-in goodies.
Additionally there is no such thing as a global require. That is something unique to our providesModule system. In other module systems such as node, every require is contextual. Even registered npm names are localized by version.
The only global namespace that is accessible to the host environment is the global object. Normally module systems attaches itself onto the hooks provided by the host environment on the global object.
Currently, we have two forms of dispatch that reaches directly into the module system. executeJSCall which reaches directly into require. Everything now calls through the BatchedBridge module (except one RCTLog edge case that I will fix). I propose that the executors calls directly onto `BatchedBridge` through an instance on the global so that everything is guaranteed to go through it. It becomes the main communication hub.
I also propose that we drop the dynamic requires inside of MessageQueue/BatchBridge and instead have the modules register themselves with the bridge.
executeJSCall was originally modeled after the XHP equivalent. The XHP equivalent was designed that way because the act of doing the call was the thing that defined a dependency on the module from the page. However, that is not how React Native works.
The JS side is driving the dependencies by virtue of requiring new modules and frameworks and the existence of dependencies is driven by the JS side, so this design doesn't make as much sense.
The main driver for this is to be able to introduce a new module system like Prepack's module system. However, it also unlocks the possibility to do dead module elimination even in our current module system. It is currently not possible because we don't know which module might be called from native.
Since the module system now becomes decoupled we could publish all our providesModule modules as npm/CommonJS modules using a rewrite script. That's what React Core does.
That way people could use any CommonJS bundler such as Webpack, Closure Compiler, Rollup or some new innovation to create a JS bundle.
This diff expands the executeJSCalls to the BatchedBridge's three individual pieces to make them first class instead of being dynamic. This removes one layer of abstraction. Hopefully we can also remove more of the things that register themselves with the BatchedBridge (various EventEmitters) and instead have everything go through the public protocol. ReactMethod/RCT_EXPORT_METHOD.
public
Reviewed By: vjeux
Differential Revision: D2717535
fb-gh-sync-id: 70114f05483124f5ac5c4570422bb91a60a727f6
Summary:
public
Introduce a new Polyfill module to load bundles. This polyfill contains the function to which System.import gets transformed into. It works similarly to require in the way it's registered. It keeps track of the bundles that have ever been requested using promises, either fulfilled or not. The use of promises makes the implementation quite easy as we don't need to differenciate whether the request has been started or not.
There're a couple of follow up steps that still need to get done:
- Included this polyfill on the ones we automatically include on the bundle.
- Modify the transform to include the modules the user is actually requesting and pipe that through loadBundles so that the promise, once resolved, has the ordered list of modules the user requested.
- Implement the actual native code that loads a bundle. This shouldn't be that taught as native will be able to assume it will never receive the same request twice.
Reviewed By: davidaurelio
Differential Revision: D2727241
fb-gh-sync-id: 317d80754783caf43f10c71a34a4558a4d298d45
Summary:
In order to be able to reliable identify unbundles when loading files, prepend a magic number (0xFB0BD1E5)
public
Reviewed By: martinbigio
Differential Revision: D2734359
fb-gh-sync-id: b469e26459234e7f6270fffa0b872a93d137381d