mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aee11c00ba | ||
|
|
c56976a783 | ||
|
|
90def15f0a | ||
|
|
ccd8f99f0c | ||
|
|
1d4fa71a94 | ||
|
|
a7596140e0 | ||
|
|
0b63571a9f | ||
|
|
d623fda41f | ||
|
|
10a17c6673 | ||
|
|
239eb4bceb | ||
|
|
9bf7c71751 | ||
|
|
3ef6f9f8a7 | ||
|
|
d6ffc2fd6d |
@@ -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
@@ -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
@@ -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,4 +1,4 @@
|
||||
VERSION_NAME=0.12.0-SNAPSHOT
|
||||
VERSION_NAME=0.18.0
|
||||
GROUP=com.facebook.react
|
||||
|
||||
POM_NAME=ReactNative
|
||||
|
||||
@@ -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
@@ -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": {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user