From aa8ead7cd67b40285bcd4f1cb1be32934ebfa8f0 Mon Sep 17 00:00:00 2001 From: Mikhail Chinyakov Date: Fri, 9 Oct 2015 14:38:27 -0700 Subject: [PATCH 1/7] Fix build process for react-native-fbsdk libraries. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: I found the problem with building react-native-fbsdk (https://github.com/facebook/react-native-fbsdk) libraries when I used cocoapods. When we use the option 'header_mappings_dir = "."' , header files of React will be copied with subfolders structures, not into one folder "${PODS_ROOT}/Headers/Public/React". And we should add recursive search and write "${PODS_ROOT}/Headers/Public/React/**". However writing code in auto-generated files is not good idea. Closes https://github.com/facebook/react-native/pull/3248 Reviewed By: @​svcscm Differential Revision: D2528021 Pulled By: @vjeux fb-gh-sync-id: 4ea76eac4035f0bd7c5894f604f84f903714a4e3 --- React.podspec | 1 - 1 file changed, 1 deletion(-) diff --git a/React.podspec b/React.podspec index 4b762c858..523020ae9 100644 --- a/React.podspec +++ b/React.podspec @@ -24,7 +24,6 @@ Pod::Spec.new do |s| s.platform = :ios, "7.0" s.prepare_command = 'npm install --production' s.preserve_paths = "cli.js", "Libraries/**/*.js", "lint", "linter.js", "node_modules", "package.json", "packager", "PATENTS", "react-native-cli" - s.header_mappings_dir = "." s.subspec 'Core' do |ss| ss.source_files = "React/**/*.{c,h,m}" From c612d830bbc765a7acdf1ccd47f94934aead259f Mon Sep 17 00:00:00 2001 From: Ian MacLeod Date: Fri, 9 Oct 2015 14:39:24 -0700 Subject: [PATCH 2/7] Preserve original global properties when polyfilling them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes #934. Closes https://github.com/facebook/react-native/pull/3293 Reviewed By: @​svcscm Differential Revision: D2525598 Pulled By: @vjeux fb-gh-sync-id: 90672550f723a183897456dc9512851bfa34807a --- .../InitializeJavaScriptAppEngine.js | 41 +++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js index fcd695abd..5a1015758 100644 --- a/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ b/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js @@ -44,6 +44,31 @@ function handleError(e, isFatal) { } } +/** + * Assigns a new global property, replacing the existing one if there is one. + * + * Existing properties are preserved as `originalPropertyName`. Both properties + * will maintain the same enumerability & configurability. + * + * This allows you to undo the more aggressive polyfills, should you need to. + * For example, if you want to route network requests through DevTools (to trace + * them): + * + * GLOBAL.XMLHTTPRequest = GLOBAL.originalXMLHTTPRequest; + * + * For more info on that particular case, see: + * https://github.com/facebook/react-native/issues/934 + */ +function polyfillGlobal(name, newValue, scope=GLOBAL) { + var descriptor = Object.getOwnPropertyDescriptor(scope, name); + + if (scope[name] !== undefined) { + var backupName = `original${name[0].toUpperCase()}${name.substr(1)}`; + Object.defineProperty(scope, backupName, {...descriptor, value: scope[name]}); + } + Object.defineProperty(scope, name, {...descriptor, value: newValue}); +} + function setUpRedBoxErrorHandler() { var ErrorUtils = require('ErrorUtils'); ErrorUtils.setGlobalHandler(handleError); @@ -111,23 +136,23 @@ function setUpPromise() { function setUpXHR() { // The native XMLHttpRequest in Chrome dev tools is CORS aware and won't // let you fetch anything from the internet - GLOBAL.XMLHttpRequest = require('XMLHttpRequest'); - GLOBAL.FormData = require('FormData'); + polyfillGlobal('XMLHttpRequest', require('XMLHttpRequest')); + polyfillGlobal('FormData', require('FormData')); var fetchPolyfill = require('fetch'); - GLOBAL.fetch = fetchPolyfill.fetch; - GLOBAL.Headers = fetchPolyfill.Headers; - GLOBAL.Request = fetchPolyfill.Request; - GLOBAL.Response = fetchPolyfill.Response; + polyfillGlobal('fetch', fetchPolyfill.fetch); + polyfillGlobal('Headers', fetchPolyfill.Headers); + polyfillGlobal('Request', fetchPolyfill.Request); + polyfillGlobal('Response', fetchPolyfill.Response); } function setUpGeolocation() { GLOBAL.navigator = GLOBAL.navigator || {}; - GLOBAL.navigator.geolocation = require('Geolocation'); + polyfillGlobal('geolocation', require('Geolocation'), GLOBAL.navigator); } function setUpWebSockets() { - GLOBAL.WebSocket = require('WebSocket'); + polyfillGlobal('WebSocket', require('WebSocket')); } function setUpProfile() { From 4f0a7250cc8159a83db6fedab91a6a70ce56eaf5 Mon Sep 17 00:00:00 2001 From: James Ide Date: Fri, 9 Oct 2015 14:42:33 -0700 Subject: [PATCH 3/7] Add Node >= 4 requirement to package.json and packager/package.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: When you try to install these with old Node you'll now get a message from npm telling you that your version of Node is old. This makes it more obvious what's going on and hopefully reduces the number of issues we get due to people using an old version of Node. Closes https://github.com/facebook/react-native/pull/3296 Reviewed By: @​svcscm Differential Revision: D2526500 Pulled By: @vjeux fb-gh-sync-id: 036e10a8d1819ea082e419cd328a458202f0e071 --- package.json | 3 +++ packager/package.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/package.json b/package.json index 5e6118d3f..2f3870188 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,9 @@ "type": "git", "url": "git@github.com:facebook/react-native.git" }, + "engines": { + "node": ">=4" + }, "jest": { "scriptPreprocessor": "jestSupport/preprocessor.js", "setupEnvScriptFile": "jestSupport/env.js", diff --git a/packager/package.json b/packager/package.json index f9927a87c..61f733d64 100644 --- a/packager/package.json +++ b/packager/package.json @@ -6,6 +6,9 @@ "type": "git", "url": "git@github.com:facebook/react-native.git" }, + "engines": { + "node": ">=4" + }, "jest": { "setupEnvScriptFile": "jestSupport/env.js", "testPathIgnorePatterns": [ From 36f015c0dd402c690c6fa14b9408d51a1502663e Mon Sep 17 00:00:00 2001 From: Brent Vatne Date: Fri, 9 Oct 2015 14:44:36 -0700 Subject: [PATCH 4/7] [Docs] Add Dimensions to API docs --- website/server/extractDocs.js | 1 + 1 file changed, 1 insertion(+) diff --git a/website/server/extractDocs.js b/website/server/extractDocs.js index 867fdfa00..59627d5a0 100644 --- a/website/server/extractDocs.js +++ b/website/server/extractDocs.js @@ -225,6 +225,7 @@ var apis = [ '../Libraries/Storage/AsyncStorage.ios.js', '../Libraries/Utilities/BackAndroid.android.js', '../Libraries/CameraRoll/CameraRoll.js', + '../Libraries/Utilities/Dimensions.js', '../Libraries/Interaction/InteractionManager.js', '../Libraries/LayoutAnimation/LayoutAnimation.js', '../Libraries/LinkingIOS/LinkingIOS.js', From 7abf8ba631e0ff0840b1452f8b6154e716affc7a Mon Sep 17 00:00:00 2001 From: Atticus White Date: Fri, 9 Oct 2015 17:29:45 -0700 Subject: [PATCH 5/7] PanResponderExample fix for responding to events MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: Fixes #3312. The example was no longer reacting to touch/drag events. It looks like `setNativeProps` requires the `style` property to contain the style rules. It appears that this warning is [only in development mode](https://github.com/facebook/react-native/blob/381e2acd184fc4ba80a240ba3d7dda0464c6416b/Libraries/ReactIOS/NativeMethodsMixin.js#L115-L117), but after fixing it I am seeing the gestures recognized and properly handled. Running outside of the dev environment yielded the circle to be positioned at the top left of the screen, below the navigation bar, and inaccessible. ![after](http://g.recordit.co/UIbeHcKZUg.gif) Closes https://github.com/facebook/react-native/pull/3315 Reviewed By: @​svcscm Differential Revision: D2529010 Pulled By: @vjeux fb-gh-sync-id: 6b79573f42a2520197f77dcb76cd640ea614477f --- Examples/UIExplorer/PanResponderExample.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Examples/UIExplorer/PanResponderExample.js b/Examples/UIExplorer/PanResponderExample.js index b41b56f3e..c2e6a667c 100644 --- a/Examples/UIExplorer/PanResponderExample.js +++ b/Examples/UIExplorer/PanResponderExample.js @@ -52,8 +52,10 @@ var PanResponderExample = React.createClass({ this._previousLeft = 20; this._previousTop = 84; this._circleStyles = { - left: this._previousLeft, - top: this._previousTop, + style: { + left: this._previousLeft, + top: this._previousTop + } }; }, @@ -78,13 +80,17 @@ var PanResponderExample = React.createClass({ _highlight: function() { this.circle && this.circle.setNativeProps({ - backgroundColor: processColor(CIRCLE_HIGHLIGHT_COLOR) + style: { + backgroundColor: processColor(CIRCLE_HIGHLIGHT_COLOR) + } }); }, _unHighlight: function() { this.circle && this.circle.setNativeProps({ - backgroundColor: processColor(CIRCLE_COLOR) + style: { + backgroundColor: processColor(CIRCLE_COLOR) + } }); }, @@ -106,8 +112,8 @@ var PanResponderExample = React.createClass({ this._highlight(); }, _handlePanResponderMove: function(e: Object, gestureState: Object) { - this._circleStyles.left = this._previousLeft + gestureState.dx; - this._circleStyles.top = this._previousTop + gestureState.dy; + this._circleStyles.style.left = this._previousLeft + gestureState.dx; + this._circleStyles.style.top = this._previousTop + gestureState.dy; this._updatePosition(); }, _handlePanResponderEnd: function(e: Object, gestureState: Object) { From c86966c150b2615f1b0bc257ca7e605b4d317711 Mon Sep 17 00:00:00 2001 From: Jiajie Zhu Date: Fri, 9 Oct 2015 17:52:19 -0700 Subject: [PATCH 6/7] fix breadcrumb icon offset Reviewed By: @fkgozali Differential Revision: D2528804 fb-gh-sync-id: 6ed9e9ce330ecc147c3fb8217c7b1b0986c862fe --- ...orBreadcrumbNavigationBarStyles.android.js | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/Libraries/Components/Navigator/NavigatorBreadcrumbNavigationBarStyles.android.js b/Libraries/Components/Navigator/NavigatorBreadcrumbNavigationBarStyles.android.js index 359e63c32..3ae86f0e7 100644 --- a/Libraries/Components/Navigator/NavigatorBreadcrumbNavigationBarStyles.android.js +++ b/Libraries/Components/Navigator/NavigatorBreadcrumbNavigationBarStyles.android.js @@ -125,18 +125,14 @@ RIGHT[0].Title = merge(FIRST_TITLE_BASE, {opacity: 0}); var buildIndexSceneInterpolator = function(startStyles, endStyles) { return { Crumb: buildStyleInterpolator({ - translateX: { + left: { type: 'linear', - from: 0, - to: endStyles.Crumb.left - startStyles.Crumb.left, + from: startStyles.Crumb.left, + to: endStyles.Crumb.left, min: 0, max: 1, extrapolate: true, }, - left: { - value: startStyles.Crumb.left, - type: 'constant' - }, }), Icon: buildStyleInterpolator({ opacity: { @@ -164,18 +160,14 @@ var buildIndexSceneInterpolator = function(startStyles, endStyles) { min: 0, max: 1, }, - translateX: { + left: { type: 'linear', - from: 0, - to: endStyles.Title.left - startStyles.Title.left, + from: startStyles.Title.left, + to: endStyles.Title.left, min: 0, max: 1, extrapolate: true, }, - left: { - value: startStyles.Title.left, - type: 'constant' - }, }), RightItem: buildStyleInterpolator({ opacity: { From 9f1dab69c133841c8da3b67e0a8ded3891b12bb4 Mon Sep 17 00:00:00 2001 From: Andrei Coman Date: Sat, 10 Oct 2015 02:16:00 -0700 Subject: [PATCH 7/7] Use correct spans in shadow nodes Differential Revision: D2529951 fb-gh-sync-id: d3bfbe9ea4b9c0cd405a2e0fb9a3176274f0c9fa --- .../react/views/text/ReactTextShadowNode.java | 8 +++++++- .../react/views/textinput/ReactTextInputManager.java | 12 ++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java index 21540b59c..a841e2c9a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java @@ -73,7 +73,13 @@ public class ReactTextShadowNode extends ReactShadowNode { this.what = what; } public void execute(SpannableStringBuilder sb) { - sb.setSpan(what, start, end, Spannable.SPAN_INCLUSIVE_EXCLUSIVE); + // All spans will automatically extend to the right of the text, but not the left - except + // for spans that start at the beginning of the text. + int spanFlags = Spannable.SPAN_EXCLUSIVE_INCLUSIVE; + if (start == 0) { + spanFlags = Spannable.SPAN_INCLUSIVE_INCLUSIVE; + } + sb.setSpan(what, start, end, spanFlags); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 8a4833225..713209423 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -56,6 +56,8 @@ public class ReactTextInputManager extends public static final String PROP_TEXT_INPUT_TEXT = "text"; @UIProp(UIProp.Type.NUMBER) public static final String PROP_TEXT_INPUT_MOST_RECENT_EVENT_COUNT = "mostRecentEventCount"; + @UIProp(UIProp.Type.COLOR) + public static final String PROP_TEXT_INPUT_COLOR = ViewProps.COLOR; private static final String KEYBOARD_TYPE_EMAIL_ADDRESS = "email-address"; private static final String KEYBOARD_TYPE_NUMERIC = "numeric"; @@ -157,16 +159,6 @@ public class ReactTextInputManager extends (int) Math.ceil(PixelUtil.toPixelFromSP(fontSize))); } - // Prevents flickering color while waiting for JS update. - @ReactProp(name = ViewProps.COLOR, customType = "Color") - public void setColor(ReactEditText view, @Nullable Integer color) { - if (color == null) { - view.setTextColor(DefaultStyleValuesUtil.getDefaultTextColor(view.getContext())); - } else { - view.setTextColor(color); - } - } - @ReactProp(name = "placeholder") public void setPlaceholder(ReactEditText view, @Nullable String placeholder) { view.setHint(placeholder);