Compare commits

...
Author SHA1 Message Date
Martin Konicek aee11c00ba Revert "Dont call npm before node is available"
This reverts commit 7ecb6936bc.

This breaks Xcode build, see discussion on https://github.com/facebook/react-native/pull/5156
2016-01-18 18:30:07 +00:00
Martin Konicek c56976a783 [0.18.0] Bump version numbers 2016-01-18 16:14:21 +00:00
Adam MiskiewiczandMartin Konicek 90def15f0a Fixing CLI to pass "sourcemap-output" option to bundler.
Summary:
Currently, the CLI is not passing the sourceMapURL option to the bundler, so source maps are output as "null".
Closes https://github.com/facebook/react-native/pull/5288

Reviewed By: svcscm

Differential Revision: D2828092

Pulled By: androidtrunkagent

fb-gh-sync-id: 2e464ddf65f0d4fcbff3c50281391cb30b5c799c
2016-01-18 15:23:06 +00:00
Nick LockwoodandMartin Konicek ccd8f99f0c Fixed iOS 7 support for URL query functions
Summary:
public
Unfortunately, it turns out that NSURLComponents.queryItems only works on iOS 8 and above. This diff re-implements the RCTGetURLQueryParam and RCTURLByReplacingQueryParam functions using functionality available in iOS 7.

Reviewed By: javache

Differential Revision: D2803679

fb-gh-sync-id: 56f10bef4894d16197975b6023b7aa5ab106d8cb
2016-01-18 15:22:56 +00:00
Lukas BenesandMartin Konicek 1d4fa71a94 Fix missing Alert in react-native.js.flow
Summary: Closes https://github.com/facebook/react-native/pull/5192

Reviewed By: svcscm

Differential Revision: D2815060

Pulled By: androidtrunkagent

fb-gh-sync-id: cbf9058e4e6b36584d8487fc132faa2a5c52bbe0
2016-01-18 15:22:27 +00:00
Henrik Kok JørgensenandMartin Konicek a7596140e0 Dont call npm before node is available
Summary:
This fixes an error introduced in `0.18.0-rc`

`node` and `npm` isn't available if the developer is using `nvm` or `nodeenv`. XCode throws an error because of the call to `npm`. Simple move the line to after `node` and `npm` has been setup.
Closes https://github.com/facebook/react-native/pull/5156

Reviewed By: svcscm

Differential Revision: D2807589

Pulled By: androidtrunkagent

fb-gh-sync-id: 30c33145b2cb6f30ff67f6648153d5aa67fb74ed
2016-01-18 15:22:16 +00:00
Gaëtan RenaudeauandMartin Konicek 0b63571a9f Fixes error when navigationBar is set back to null
Summary:
This fixes a regression introduced in https://github.com/facebook/react-native/commit/df70005c12e3be14bfbdf0b32f9ea0a5c052deba

If you set navigationBar props (on Navigator) and then later set it back to null, it will crashes.
(N.B. this should be possible as navigationBar is optional)

cc satya164
Closes https://github.com/facebook/react-native/pull/4941

Reviewed By: svcscm

Differential Revision: D2788889

Pulled By: bestander

fb-gh-sync-id: f8f1cd6cc2ce13b1b1b86fa76d3b22c26a8adb5b
2016-01-18 15:22:09 +00:00
Martin Konicek d623fda41f Don't enable Proguard by default just yet
Want to gather some feedback from a few people first.
2016-01-18 14:29:18 +00:00
Martin Konicek 10a17c6673 Add support for split build per architecture
Summary:
This allows everyone to deploy significantly smaller APKs to they Play Store by building separate APKs for ARM, x86 architectures.

For a simple app, a release APK minified with Produard:
- Universal APK is **7MB**
- x86 APK is **4.6MB** (34% reduction)
- ARM APK is **3.7MB** (47% reduction)

Created a sample project, uncommented `// include "armeabi-v7a", 'x86'`:

    cd android
    ./gradlew assembleDebug

Three APKs were created, unzipped each: one has only x86 binaries,
one has ARM binaries, one has both.

    ./gradlew assembleRelease

Three APKs were created, JS bundle is correcly added to assets.

    react-native run-android

The correct APK is installed on the emulator and the app runs fine
(Gradle output: "Installing APK 'app-x86-debug.apk'").

With the line commented out the behavior is exactly the same as before,
only one universal APK is built.

Checked that version codes are set correctly as described in
http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
http://developer.android.com/intl/ru/google/play/publishing/multiple-apks.html

Closes https://github.com/facebook/react-native/pull/5160

Reviewed By: svcscm

Differential Revision: D2811443

Pulled By: mkonicek

fb-gh-sync-id: 97b22b9cd567e53b8adac36669b90768458b7a55
2016-01-18 14:28:17 +00:00
tdzl2003andMartin Konicek 239eb4bceb Fix build error and runtime error after proguard enabled.
Summary:
Fix:
1. :app:packageRelease FAILED caused by proguard exception: `java.io.IOException: Please correct the above warnings first.`
2. Fix runtime exception
```
java.lang.ExceptionInInitializerError
   at com.facebook.react.ReactInstanceManagerImpl.recreateReactContextInBackgroundFromBundleFile(ReactInstanceManagerImpl.java:308)
```
Closes https://github.com/facebook/react-native/pull/5146

Reviewed By: svcscm

Differential Revision: D2807252

Pulled By: mkonicek

fb-gh-sync-id: 03d004405c7cca14a71230086b95351cfacbc055
2016-01-18 14:27:08 +00:00
Martin Konicek 9bf7c71751 Add support for global alert() on Android
Summary:
Use the new cross-platform [`Alert`](https://github.com/facebook/react-native/blob/master/Libraries/Utilities/Alert.js) API to implement global `alert()`.

public

Reviewed By: vjeux

Differential Revision: D2773589

fb-gh-sync-id: 4297c5dce6a55391af89d2675f2b9ac4dc715bb6
2016-01-18 14:26:55 +00:00
Martín BigioandMartin Konicek 3ef6f9f8a7 Pipe transforms errors through transformation pipelines
Summary:
public

Fixes an issue on the transforms pipeline which caused not to pipe errors that occured on the external transformer to JSTransformer.

Reviewed By: yungsters

Differential Revision: D2806498

fb-gh-sync-id: c9347d1957a3a9320b3f177ff9b19bf3802087a0
2016-01-18 14:26:47 +00:00
Martin Konicek d6ffc2fd6d [0.18.0-rc] Bump version numbers 2016-01-05 18:38:38 +00:00
13 changed files with 134 additions and 25 deletions
@@ -30,6 +30,13 @@
XCTAssertEqualObjects(bar, @"foo");
}
- (void)testGetEncodedParam
{
NSURL *URL = [NSURL URLWithString:@"http://example.com?foo=You%20%26%20Me"];
NSString *foo = RCTGetURLQueryParam(URL, @"foo");
XCTAssertEqualObjects(foo, @"You & Me");
}
- (void)testQueryParamNotFound
{
NSURL *URL = [NSURL URLWithString:@"http://example.com?foo=bar"];
@@ -58,6 +65,13 @@
XCTAssertEqualObjects(result.absoluteString, @"http://example.com?foo=foo&bar=foo");
}
- (void)testReplaceEncodedParam
{
NSURL *URL = [NSURL URLWithString:@"http://example.com?foo=You%20%26%20Me"];
NSURL *result = RCTURLByReplacingQueryParam(URL, @"foo", @"Me & You");
XCTAssertEqualObjects(result.absoluteString, @"http://example.com?foo=Me%20%26%20You");
}
- (void)testAppendParam
{
NSURL *URL = [NSURL URLWithString:@"http://example.com?bar=foo"];
@@ -1084,13 +1084,16 @@ var Navigator = React.createClass({
},
_renderNavigationBar: function() {
if (!this.props.navigationBar) {
let { navigationBar } = this.props;
if (!navigationBar) {
return null;
}
return React.cloneElement(this.props.navigationBar, {
return React.cloneElement(navigationBar, {
ref: (navBar) => {
this.props.navigationBar.ref instanceof Function && this.props.navigationBar.ref(navBar);
this._navBar = navBar;
if (navigationBar && typeof navigationBar.ref === 'function') {
navigationBar.ref(navBar);
}
},
navigator: this._navigationBarNavigator,
navState: this.state,
@@ -117,15 +117,11 @@ function setUpTimers() {
}
function setUpAlert() {
var RCTAlertManager = require('NativeModules').AlertManager;
if (!GLOBAL.alert) {
GLOBAL.alert = function(text) {
var alertOpts = {
title: 'Alert',
message: '' + text,
buttons: [{'cancel': 'OK'}],
};
RCTAlertManager.alertWithArgs(alertOpts, function () {});
// Require Alert on demand. Requiring it too early can lead to issues
// with things like Platform not being fully initialized.
require('Alert').alert('Alert', '' + text);
};
}
}
@@ -67,6 +67,7 @@ var ReactNative = Object.assign(Object.create(require('React')), {
// APIs
ActionSheetIOS: require('ActionSheetIOS'),
AdSupportIOS: require('AdSupportIOS'),
Alert: require('Alert'),
AlertIOS: require('AlertIOS'),
Animated: require('Animated'),
AppRegistry: require('AppRegistry'),
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "React"
s.version = "0.15.0"
s.version = "0.18.0"
s.summary = "Build high quality mobile apps using React."
s.description = <<-DESC
React Native apps are built using the React JS
+32 -8
View File
@@ -591,9 +591,13 @@ NSString *RCTGetURLQueryParam(NSURL *URL, NSString *param)
}
NSURLComponents *components = [NSURLComponents componentsWithURL:URL
resolvingAgainstBaseURL:YES];
for (NSURLQueryItem *item in components.queryItems.reverseObjectEnumerator) {
if ([item.name isEqualToString:param]) {
return item.value;
// TODO: use NSURLComponents.queryItems once we drop support for iOS 7
for (NSString *item in [components.percentEncodedQuery componentsSeparatedByString:@"&"].reverseObjectEnumerator) {
NSArray *keyValue = [item componentsSeparatedByString:@"="];
NSString *key = [keyValue.firstObject stringByRemovingPercentEncoding];
if ([key isEqualToString:param]) {
return [keyValue.lastObject stringByRemovingPercentEncoding];
}
}
return nil;
@@ -607,22 +611,42 @@ NSURL *RCTURLByReplacingQueryParam(NSURL *URL, NSString *param, NSString *value)
}
NSURLComponents *components = [NSURLComponents componentsWithURL:URL
resolvingAgainstBaseURL:YES];
// TODO: use NSURLComponents.queryItems once we drop support for iOS 7
// Unhelpfully, iOS doesn't provide this set as a constant
static NSCharacterSet *URLParamCharacterSet;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSMutableCharacterSet *characterSet = [NSMutableCharacterSet new];
[characterSet formUnionWithCharacterSet:[NSCharacterSet URLQueryAllowedCharacterSet]];
[characterSet removeCharactersInString:@"&=?"];
URLParamCharacterSet = [characterSet copy];
});
NSString *encodedParam =
[param stringByAddingPercentEncodingWithAllowedCharacters:URLParamCharacterSet];
__block NSInteger paramIndex = NSNotFound;
NSMutableArray *queryItems = [components.queryItems mutableCopy];
NSMutableArray *queryItems = [[components.percentEncodedQuery componentsSeparatedByString:@"&"] mutableCopy];
[queryItems enumerateObjectsWithOptions:NSEnumerationReverse usingBlock:
^(NSURLQueryItem *item, NSUInteger i, BOOL *stop) {
if ([item.name isEqualToString:param]) {
^(NSString *item, NSUInteger i, BOOL *stop) {
NSArray *keyValue = [item componentsSeparatedByString:@"="];
if ([keyValue.firstObject isEqualToString:encodedParam]) {
paramIndex = i;
*stop = YES;
}
}];
NSURLQueryItem *newItem = [NSURLQueryItem queryItemWithName:param value:value];
NSString *encodedValue =
[value stringByAddingPercentEncodingWithAllowedCharacters:URLParamCharacterSet];
NSString *newItem = [encodedParam stringByAppendingFormat:@"=%@", encodedValue];
if (paramIndex == NSNotFound) {
[queryItems addObject:newItem];
} else {
[queryItems replaceObjectAtIndex:paramIndex withObject:newItem];
}
components.queryItems = queryItems;
components.percentEncodedQuery = [queryItems componentsJoinedByString:@"&"];
return components.URL;
}
+1 -1
View File
@@ -1,4 +1,4 @@
VERSION_NAME=0.12.0-SNAPSHOT
VERSION_NAME=0.18.0
GROUP=com.facebook.react
POM_NAME=ReactNative
+1
View File
@@ -32,6 +32,7 @@ function buildBundle(args, config, output = outputBundle) {
const requestOpts = {
entryFile: args['entry-file'],
sourceMapUrl: args['sourcemap-output'],
dev: args.dev,
minify: !args.dev,
platform: args.platform,
@@ -1,5 +1,7 @@
apply plugin: "com.android.application"
import com.android.build.OutputFile
/**
* The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets.
* These basically call `react-native bundle` with the correct arguments during the Android build
@@ -49,6 +51,22 @@ apply plugin: "com.android.application"
apply from: "react.gradle"
/**
* Set this to true to create three separate APKs instead of one:
* - A universal APK that works on all devices
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
@@ -63,16 +81,37 @@ android {
abiFilters "armeabi-v7a", "x86"
}
}
splits {
abi {
enable enableSeparateBuildPerCPUArchitecture
universalApk true
reset()
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false // Set this to true to enable Proguard
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:0.13.0"
compile "com.facebook.react:react-native:0.18.+"
}
@@ -40,10 +40,13 @@
-keep class * extends com.facebook.react.bridge.JavaScriptModule { *; }
-keep class * extends com.facebook.react.bridge.NativeModule { *; }
-keepclassmembers,includedescriptorclasses class * { native <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.UIProp <fields>; }
-keepclassmembers class * { @com.facebook.react.uimanager.ReactProp <methods>; }
-keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup <methods>; }
-dontwarn com.facebook.react.**
# okhttp
-keepattributes Signature
@@ -58,3 +61,7 @@
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-dontwarn okio.**
# stetho
-dontwarn com.facebook.stetho.**
@@ -74,14 +74,33 @@ task bundleReleaseJsAndAssets(type: Exec) {
enabled config.bundleInRelease ?: true
}
void runBefore(String dependentTaskName, Task task) {
Task dependentTask = tasks.findByPath(dependentTaskName);
if (dependentTask != null) {
dependentTask.dependsOn task
}
}
gradle.projectsEvaluated {
// hook bundleDebugJsAndAssets into the android build process
bundleDebugJsAndAssets.dependsOn mergeDebugResources
bundleDebugJsAndAssets.dependsOn mergeDebugAssets
processDebugResources.dependsOn bundleDebugJsAndAssets
runBefore('processArmeabi-v7aDebugResources', bundleDebugJsAndAssets)
runBefore('processX86DebugResources', bundleDebugJsAndAssets)
runBefore('processUniversalDebugResources', bundleDebugJsAndAssets)
runBefore('processDebugResources', bundleDebugJsAndAssets)
// hook bundleReleaseJsAndAssets into the android build process
bundleReleaseJsAndAssets.dependsOn mergeReleaseResources
bundleReleaseJsAndAssets.dependsOn mergeReleaseAssets
processReleaseResources.dependsOn bundleReleaseJsAndAssets
runBefore('processArmeabi-v7aReleaseResources', bundleReleaseJsAndAssets)
runBefore('processX86ReleaseResources', bundleReleaseJsAndAssets)
runBefore('processUniversalReleaseResources', bundleReleaseJsAndAssets)
runBefore('processReleaseResources', bundleReleaseJsAndAssets)
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "react-native",
"version": "0.12.0",
"version": "0.18.0",
"description": "A framework for building native apps using React",
"license": "BSD-3-Clause",
"repository": {
+5
View File
@@ -32,6 +32,11 @@ function internalTransforms(sourceCode, filename, options) {
}
function onExternalTransformDone(data, callback, error, externalOutput) {
if (error) {
callback(error);
return;
}
var result;
if (data.options.enableInternalTransforms) {
result = internalTransforms(