Commit Graph

1562 Commits

Author SHA1 Message Date
Spencer Ahrens b1549337f3 [ReactNative][easy] Fix naming in PanResponderExample 2015-06-09 17:31:35 -08:00
Tadeu Zagallo f703000d1f [ReactNative] Replace console.error with alert on UIExplorer Geolocation example
Summary:
@public

The alert is less aggressive, otherwise it seems like the app is broken.

Test Plan:
Run the UIExplorer, open the Geolocation example and deny access. It should
alert instead of redbox'ing
2015-06-09 17:03:29 -08:00
Spencer Ahrens 3102fc5df9 [ReactNative] Fix secure text entry
Summary:
@public

`validAttributes` strikes again.

Test Plan: secure box in example is actually secure
2015-06-09 16:02:38 -08:00
Spencer Ahrens 6c6b8bec7e [ReactNative] Fix require-time redboxes 2015-06-09 15:42:47 -08:00
Tadeu Zagallo 847dff8d75 [ReactNative] Make JavaScript executors bridge modules
Summary:
@public

This is the first of a few diffs that change the way the executors are handled
by the bridge.

For they are just promoted to modules, so they are automatically loaded by the bridge.

Test Plan:
Tested on UIExplorer, Catalyst and MAdMan.
Tested all the 3 executors, everything looks fine.
2015-06-09 15:40:55 -08:00
Spencer Ahrens 68bb3a7e71 [ReactNative] orange box
Summary:
@public

There have been multiple instances of confusion about whether a redbox means the
developer did something they shouldn't but things will keep working, or if
something went horribly wrong and the app will crash in prod.  This diff
introduces an orange background color to the redbox for `console.error` and
`RCTLogError` to indicate that something bad happened, but that the app will
continue working.

Test Plan:
see orange error for geo permissions:

{F22541375}
2015-06-09 14:53:29 -08:00
Tadeu Zagallo 6358e163a5 [ReactNative] Revert `async exports` changes to MessageQueue + test
Summary:
@public

`[Bridge] Add support for JS async functions to RCT_EXPORT_METHOD` was imported but broke some internal code, reverting the `MessageQueue` that caused the issues and add a test, since the method is not used yet.

Test Plan: Run the test o/
2015-06-09 14:25:32 -08:00
James Ide 90439cec26 [Bridge] Add support for JS async functions to RCT_EXPORT_METHOD
Summary:
Adds support for JS async methods and helps guide people writing native modules w.r.t. the callbacks. With this diff, on the native side you write:

```objc
RCT_EXPORT_METHOD(getValueAsync:(NSString *)key
                       resolver:(RCTPromiseResolver)resolve
                       rejecter:(RCTPromiseRejecter)reject)
{
  NSError *error = nil;
  id value = [_nativeDataStore valueForKey:key error:&error];

  // "resolve" and "reject" are automatically defined blocks that take
  // any object (nil is OK) and an NSError, respectively
  if (!error) {
    resolve(value);
  } else {
    reject(error);
  }
}
```

On the JS side, you can write:

```js
var {DemoDataStore} = require('react-native').NativeModules;
DemoDataStore.getValueAsync('sample-key').then((value) => {
  console.log('Got:', value);
}, (error) => {
  console.error(error);
  // "error" is an Error object whose message is the NSError's description.
  // The NSError's code and domain are also set, and the native trace i
Closes https://github.com/facebook/react-native/pull/1232
Github Author: James Ide <ide@jameside.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-09 14:25:31 -08:00
David Callahan cf8c2693af Use getsectiondata 2015-06-09 12:40:52 -08:00
Nick Lockwood f88bc3eb73 [ReactNative] Refactor RCTDataManager to support pluggable data source modules (RCTURLRequestHandlers)
Summary:
@public

This is a refactor of @philikon's original diff that decouples the dependencies between the Network and Image modules, and replaces RCTDataQueryExecutor with a more useful abstraction.

I've introduced the RCTURLRequestHandler protocol, which is a new type of bridge module used for loading data using an NSURLRequest. RCTURLRequestHandlers can be registered using RCT_EXPORT_MODULE() and are then available at runtime for use by the RCTDataManager, which will automatically select the appropriate handler for a given request based on the handler's self-reported capabilities.

The currently implemented handlers are:

- RCTHTTPRequestHandler - the standard open source HTTP request handler that uses NSURLSession
- RKHTTPRequestHandler - the internal FB HTTP request handler that uses FBNetworking
- RCTImageRequestHandler - a handler for loading local images from the iOS asset-library

Depends on D2108193

Test Plan:
- Internal apps still work
- OSS port still compiles, Movies app and a sample Parse app still work
- uploading image to Parse using the above code snippet works
- tested `FormData` with string and image parameters using http://www.posttestserver.com/
2015-06-09 12:27:06 -08:00
Nick Lockwood f4bf80f3ea [ReactNative] Allow uploading native files (e.g. photos) and FormData via XMLHttpRequest 2015-06-09 12:27:05 -08:00
Spencer Ahrens f590a8b15b [ReactNative] fix navIOS example
Summary: constants were refactored to be enums.

Test Plan:
@public

navIOS example doesn't fatal.
2015-06-09 12:06:14 -08:00
Tadeu Zagallo 2a08897c6e [ReactNative] Batch JS -> Native calls per queue
Summary:
@public

For every call that comes from JS to Native we'd call dispatch_async so the
method would be cllead on the queue/thread it's expecting. This diff
buckets the calls by target queue, dispatches only once to that queue, and then
call all the methods for it inside the same dispatch.

Test Plan: {F22510090}
2015-06-09 06:52:54 -08:00
Tadeu Zagallo 459882ea7e [ReactNative] Fix BUCK file and reenable tests 2015-06-09 05:16:21 -08:00
Andy Street 0a3fca9520 [react_native] JS files from D2130816: [react_native] Don't render crumb container to texture 2015-06-09 03:09:17 -08:00
Tadeu Zagallo de1320acc7 [ReactNative] Check if bridge is valid on -modules 2015-06-09 02:54:59 -08:00
Philipp von Weitershausen 8e2727ad52 Back out D2128859: interop with react devtools 2015-06-08 20:54:21 -08:00
Philipp von Weitershausen 0a95edf6ea [ReactNative] use Map, not Object when functions are keys 2015-06-08 17:43:17 -08:00
Christopher Chedeau 1a12b95f7a [ReactNative] Revert D2134877 2015-06-08 13:49:28 -08:00
Christopher Chedeau c9e555f4b3 [ReactNative] Better error message when forgetting to wrap Animated 2015-06-08 12:44:32 -08:00
Andrei Coman 8a0390f5f8 [react_native] Fix UIExplorer 2015-06-08 11:26:01 -08:00
Eric Vicenti f6528171d0 [ReactNative] Fix navigator touch-blocking logic
Summary:
The logic for this is incorrect when the `state.transitionToIndex === 0`, and will return false and not capture the touch.

@public

Test Plan: Try to repro bugs on device and simulator
2015-06-08 11:20:12 -08:00
Jared Forsyth d68776d5de interop with react devtools 2015-06-08 09:04:09 -08:00
Adam Ernst 16b8747f61 @build-break Disable flaky react tests 2015-06-08 06:38:44 -08:00
Andrei Coman fc48f175c3 [react_native] JS files from D2126599: Android MentionInput Rendering (part 1/2) 2015-06-08 03:47:32 -08:00
Andrei Coman 8e3c02e4f0 [react_native] JS files from D2127018: [react_native] Add uiexplorer app 2015-06-08 03:28:35 -08:00
Tadeu Zagallo c2fb21b322 [ReactNative] Properly pause frame update observers when idle
Summary:
@public

`RCTDispatchEvent` and `RCTTiming` weren't being paused when there wasn't any
work left to be done.

Test Plan:
Run the timers example - check everything still works as expected
Test the ListView paging example - check scroll events are still fired as expected
Launch UIExplorer, let it idle, and put a break point on `-[RCTBridge dispatchBlock:moduleID:]`,
it should never fire.
2015-06-07 08:45:18 -08:00
Christopher Chedeau 8ee9bfe944 [ReactNative] Fix XHR 2015-06-06 16:44:55 -08:00
Tadeu Zagallo 1c9e957d22 [ReactNative] Invalidate modules on their own queues
Summary:
@public

Bridge modules were being invalidate on the main thread, what could lead to
racing conditions, move the calls to invalidate on happen to the module's
methodQueue

Test Plan: Run the tests
2015-06-06 14:13:32 -08:00
Tadeu Zagallo 35b770201d [ReactNative] Merge IntegrationTest into UIExplorer tests 2015-06-06 13:38:35 -08:00
Tadeu Zagallo c2b0e72771 [ReactNative] Move unit tests to UIExplorer 2015-06-06 13:38:34 -08:00
Tadeu Zagallo 40579181d3 [ReactNative] Split oss tests into two targets: unit and integration 2015-06-06 13:38:33 -08:00
Nick Lockwood 96c070de11 Fixed typo in XMLHttpRequest.ios.js 2015-06-05 18:47:18 -08:00
Nick Lockwood e00b9ac8f3 Added incremental XMLHttpRequest updates
Summary:
@public

Previously, our XMLHttpRequest implementation would only update the readyState when the download was fully completed. This diff adds support for receiving incremental data updates as the download happens, which can be monitored by adding the onreadystatechange event handler.

As a performance optimization, incremental data updates are only sent if the onreadystatechanged handler has been set in the JS, otherwise it just sends the whole data block once download is complete, as before.

Test Plan:
* Run the UIExplorer XMLHttpRequest example (in both OSS and Catalyst) to see incremental downloads working.
* Run the Movies app to see regular (non-incremental) downloads in action
* Run any network-based app in Catalyst shell to verify RKDataManager still works
2015-06-05 15:21:25 -08:00
Eric Vicenti bb95400f24 [ReactNative] Fix POPAnimation export issue from bad transform
Summary:
Some transform is going wrong here and produces broken code

@public

Test Plan: Test on OSS repo, e2e tests pass
2015-06-05 10:03:57 -08:00
Nick Lockwood 45d8fb0ef6 Removed deprecated RCT_EXPORT + code paths 2015-06-05 09:58:25 -08:00
Eric Vicenti f90fa53df9 Revert [react-packager] Add support for nested node_modules 2015-06-05 08:44:06 -08:00
Tadeu Zagallo 1a564eed77 [ReactNative] Run UIExplorer tests on sandcastle 2015-06-05 05:36:06 -08:00
Tadeu Zagallo 7009f0a47b [ReactNative] Add profiling hooks to bridge modules at runtime
Summary:
@public

Add `RCT_DEV`-only profiling hooks to every method in every bridge modules to
add a little bit more detail to the timeline profile.

Test Plan: {F22522834}
2015-06-05 04:22:57 -08:00
Eric Vicenti f744c7c444 [ReactNative] Native touch unique identifier
Summary:
This bug was causing a redbox when touching rapidly because multiple touches had the same identifier. This code was meant to ensure that a unique ID is found, but it was checking against the wrong property in the react touch array.

I don't think this was really affecting prod, because the invariant is guarded by a __DEV__ check

@public

Test Plan:
- Start several touches at once (or just rapidly jam fingers on your device), and you won't see a redbox
- Also verify that single touches, touch moves, and multi touches work as before
2015-06-04 20:21:19 -08:00
Amjad Masad 30fc7389d1 [react-packager] Fix more node_modules resolution rules
Summary:
@public
Fixes #773
This fixes `.json` name resolution. And also reads `package.json` when doing a directory module resolution.
The algorithm can be found here: https://nodejs.org/api/modules.html
I'll probably start including the node (or browserify) modules test in later diffs to make sure we're fully compliant.

Test Plan:
* ./runJestTests.sh
* ./runJestTests.sh PackagerIntegration
* open playground and require a json file
* test redbox
2015-06-04 15:07:03 -08:00
Jared Forsyth 53b2c39cc0 select up and down the inspector hierarchy
Summary:
This allows you to select the displayed owner hierarchy, and see the styles,
props, and position.

@public

Test Plan:
Open the inspector, select something in the middle of the page. Click the
breadcrumb train in the inspector, and verify that:
- styles are reflected
- margin/padding/box is correct
- the highlight updates to show the selected item

See video as well.

[Video](https://www.latest.facebook.com/pxlcld/mqnl)

Screenshot
{F22518618}
2015-06-04 10:18:56 -08:00
Alex Madjar 015b5cf8e5 [React Native] PickerIOS can update its items list
Summary:
@public
PickerIOS doesn't look at the content of its list. It just keeps a list ref
and pushes new items in.  Sadly this doesn't work with the naive reference checker
so new item lists don't trigger a native rerender.

The solution here is to ask PickerIOS to just pass its props down to native directly

Test Plan:
Implemented a simple Picker hooked up to a store getting new items.
Watched the list not update and then update after this diff as new items come in
2015-06-03 17:44:02 -08:00
Spencer Ahrens 7ffa7bd1f1 [ReactNative] Implement merge functionality for AsyncStorage 2015-06-03 16:53:29 -08:00
Alex Kotliarskyi 9fe7128493 [ReactNative] Refactor DevMenu items construction
Summary:
The idea behind this change it to couple together menu item title
and handler. The code becomes simpler and easier to maintain, but
also makes it possible to extend dev menu in the future.

@public

Test Plan:
All menu items works as before.
Changed websocket executor class name and made sure that when the class
is missing we get nice error message.
2015-06-03 16:42:23 -08:00
Alex Kotliarskyi 63b8262843 [ReactNative] Allow TouchableWithoutFeedback override accessible attribute 2015-06-03 16:37:11 -08:00
Eric Vicenti fa3491e9f5 [ReactNative] Remove unused touch arrays
Summary:
These two arrays aren't used. The code is easier to read without them

@public

Test Plan: Tap around UIExplorer and verify multi-touch and responder system behavior works the same
2015-06-03 16:12:03 -08:00
Andrei Coman 6d25ff83ec [react_native] Fix sync 2015-06-03 15:07:39 -08:00
Amjad Masad 856469a24b [react-packager] Support packages with '.' in the name
Summary:
@public
Fixes issue #1055
For some historical reason we used to strip the extension of the module name before passing it to `resolveDependency` which is completly capable of handling all kinds of names. The fix is one line, but added a few tests for this.

Test Plan:
* ./runJestTests.sh
* ./runJestTests.sh PacakgerIntegration
* Open app and click around
2015-06-03 14:07:31 -08:00
Andrew Imm 89a1e94a15 Add an event for remote notification registration, and improve permissions request
Summary:
In order to add Push support to the Parse JS SDK in React Native, we need a way to receive the APNS device token from the JS context. This adds another event to PushNotificationIOS, so that code can respond to a successful registration.

Additionally, I've updated the `requestPermissions` call to accept an optional map of parameters. This way, developers can request a subset of user notification types.
Closes https://github.com/facebook/react-native/pull/1304
Github Author: Andrew Imm <andrewi@fb.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
2015-06-03 14:06:44 -08:00