From bd925ac6b5c7cc2d11ebd302d05e924778917183 Mon Sep 17 00:00:00 2001 From: Bernd Paradies Date: Sat, 6 Jun 2015 16:45:44 -0700 Subject: [PATCH 01/15] Support for configurable debug port (issue 1429) --- Examples/2048/2048.xcodeproj/project.pbxproj | 17 ++++++++ Examples/2048/2048/AppDelegate.m | 3 +- Examples/2048/2048/Info.plist | 7 ++++ .../Movies/Movies.xcodeproj/project.pbxproj | 17 ++++++++ Examples/Movies/Movies/AppDelegate.m | 3 +- Examples/Movies/Movies/Info.plist | 11 +++++ .../iOS/SampleApp.xcodeproj/project.pbxproj | 17 ++++++++ Examples/SampleApp/iOS/SampleApp/Info.plist | 18 +++++--- .../TicTacToe.xcodeproj/project.pbxproj | 17 ++++++++ Examples/TicTacToe/TicTacToe/AppDelegate.m | 5 ++- Examples/TicTacToe/TicTacToe/Info.plist | 16 +++++--- .../UIExplorer.xcodeproj/project.pbxproj | 36 ++++++++++++++-- Examples/UIExplorer/UIExplorer/AppDelegate.m | 5 ++- Examples/UIExplorer/UIExplorer/Info.plist | 20 +++++---- Libraries/RCTTest/RCTTestRunner.m | 2 +- Libraries/WebSocket/RCTWebSocketExecutor.m | 2 +- React/Base/RCTUtils.h | 3 ++ React/Base/RCTUtils.m | 18 ++++++++ React/React.xcodeproj/project.pbxproj | 1 - .../generator-ios/templates/app/AppDelegate.m | 3 +- .../generator-ios/templates/app/Info.plist | 18 +++++--- .../templates/xcodeproj/project.pbxproj | 29 +++++++++++++ packager/launchPackager.command | 41 ++++++++++++++++--- packager/packager.js | 8 +++- packager/packager.sh | 4 ++ 25 files changed, 276 insertions(+), 45 deletions(-) diff --git a/Examples/2048/2048.xcodeproj/project.pbxproj b/Examples/2048/2048.xcodeproj/project.pbxproj index 48ebefe41fd54f..fd43726638af49 100644 --- a/Examples/2048/2048.xcodeproj/project.pbxproj +++ b/Examples/2048/2048.xcodeproj/project.pbxproj @@ -140,6 +140,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "2048" */; buildPhases = ( + 4CED848A1B37581600715E21 /* ShellScript */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -230,6 +231,22 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4CED848A1B37581600715E21 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 13B07F871A680F5B00A75B9A /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Examples/2048/2048/AppDelegate.m b/Examples/2048/2048/AppDelegate.m index b4b1769ff28d0d..817d1daf39661b 100644 --- a/Examples/2048/2048/AppDelegate.m +++ b/Examples/2048/2048/AppDelegate.m @@ -15,6 +15,7 @@ #import "AppDelegate.h" #import "RCTRootView.h" +#import "RCTUtils.h" @implementation AppDelegate @@ -36,7 +37,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( * on the same Wi-Fi network. */ - jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/2048/Game2048.bundle?platform=ios&dev=true"]; + jsCodeLocation = RCTPackagerURL(@"/Examples/2048/Game2048.bundle?platform=ios&dev=true"); /** * OPTION 2 diff --git a/Examples/2048/2048/Info.plist b/Examples/2048/2048/Info.plist index 6105445463d64b..0aedb782723a44 100644 --- a/Examples/2048/2048/Info.plist +++ b/Examples/2048/2048/Info.plist @@ -39,5 +39,12 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + RCTPackager + + url + http://localhost + port + 8088 + diff --git a/Examples/Movies/Movies.xcodeproj/project.pbxproj b/Examples/Movies/Movies.xcodeproj/project.pbxproj index f3937e4285ad60..717987870a6a1f 100644 --- a/Examples/Movies/Movies.xcodeproj/project.pbxproj +++ b/Examples/Movies/Movies.xcodeproj/project.pbxproj @@ -197,6 +197,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "Movies" */; buildPhases = ( + 4CED84A71B37590B00715E21 /* ShellScript */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -320,6 +321,22 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4CED84A71B37590B00715E21 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 13B07F871A680F5B00A75B9A /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Examples/Movies/Movies/AppDelegate.m b/Examples/Movies/Movies/AppDelegate.m index 3cfd1dfa2c7127..ef879291e97761 100644 --- a/Examples/Movies/Movies/AppDelegate.m +++ b/Examples/Movies/Movies/AppDelegate.m @@ -16,6 +16,7 @@ #import "RCTLinkingManager.h" #import "RCTRootView.h" +#import "RCTUtils.h" @implementation AppDelegate @@ -37,7 +38,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( * on the same Wi-Fi network. */ - jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/Movies/MoviesApp.ios.bundle?platform=ios&dev=true"]; + jsCodeLocation = RCTPackagerURL(@"/Examples/Movies/MoviesApp.ios.bundle?platform=ios&dev=true"); /** * OPTION 2 diff --git a/Examples/Movies/Movies/Info.plist b/Examples/Movies/Movies/Info.plist index 4ecf97f70446d6..e2f4239a5ffc59 100644 --- a/Examples/Movies/Movies/Info.plist +++ b/Examples/Movies/Movies/Info.plist @@ -52,5 +52,16 @@ UIViewControllerBasedStatusBarAppearance + + NSAllowsArbitraryLoads + + + RCTPackager + + url + http://localhost + port + 8089 + diff --git a/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj b/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj index 7123b2d3b2cdac..b5a5baec46429a 100644 --- a/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj +++ b/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj @@ -331,6 +331,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "SampleApp" */; buildPhases = ( + 4CED847C1B3756CA00715E21 /* ShellScript */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -513,6 +514,22 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4CED847C1B3756CA00715E21 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 00E356EA1AD99517003FC87E /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Examples/SampleApp/iOS/SampleApp/Info.plist b/Examples/SampleApp/iOS/SampleApp/Info.plist index cddf0766c98062..2924782bd13c15 100644 --- a/Examples/SampleApp/iOS/SampleApp/Info.plist +++ b/Examples/SampleApp/iOS/SampleApp/Info.plist @@ -38,11 +38,17 @@ NSLocationWhenInUseUsageDescription - NSAppTransportSecurity - - - NSAllowsArbitraryLoads - - + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + RCTPackager + + url + http://localhost + port + 8087 + diff --git a/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj b/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj index ec0802a837de54..9b2129c8d7f6c5 100644 --- a/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj +++ b/Examples/TicTacToe/TicTacToe.xcodeproj/project.pbxproj @@ -178,6 +178,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "TicTacToe" */; buildPhases = ( + 4CED84BE1B3759D900715E21 /* ShellScript */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -290,6 +291,22 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4CED84BE1B3759D900715E21 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 13B07F871A680F5B00A75B9A /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Examples/TicTacToe/TicTacToe/AppDelegate.m b/Examples/TicTacToe/TicTacToe/AppDelegate.m index f0199b6dd64650..5fb4867a86a7f3 100644 --- a/Examples/TicTacToe/TicTacToe/AppDelegate.m +++ b/Examples/TicTacToe/TicTacToe/AppDelegate.m @@ -15,6 +15,7 @@ #import "AppDelegate.h" #import "RCTRootView.h" +#import "RCTUtils.h" @implementation AppDelegate @@ -36,8 +37,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( * on the same Wi-Fi network. */ - jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/Examples/TicTacToe/TicTacToeApp.bundle?platform=ios&dev=true"]; - + jsCodeLocation = RCTPackagerURL(@"/Examples/TicTacToe/TicTacToeApp.bundle?platform=ios&dev=true"); + /** * OPTION 2 * Load from pre-bundled file on disk. To re-generate the static bundle, `cd` diff --git a/Examples/TicTacToe/TicTacToe/Info.plist b/Examples/TicTacToe/TicTacToe/Info.plist index 25742279c9dce4..857be1cea459b4 100644 --- a/Examples/TicTacToe/TicTacToe/Info.plist +++ b/Examples/TicTacToe/TicTacToe/Info.plist @@ -37,10 +37,16 @@ UIViewControllerBasedStatusBarAppearance NSAppTransportSecurity - - - NSAllowsArbitraryLoads - - + + NSAllowsArbitraryLoads + + + RCTPackager + + url + http://localhost + port + 8090 + diff --git a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj index a259da744d332d..5c5cf505df9881 100644 --- a/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj +++ b/Examples/UIExplorer/UIExplorer.xcodeproj/project.pbxproj @@ -35,7 +35,6 @@ 1497CFB11B21F5E400C1F8F2 /* RCTEventDispatcherTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFA91B21F5E400C1F8F2 /* RCTEventDispatcherTests.m */; }; 1497CFB21B21F5E400C1F8F2 /* RCTSparseArrayTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAA1B21F5E400C1F8F2 /* RCTSparseArrayTests.m */; }; 1497CFB31B21F5E400C1F8F2 /* RCTUIManagerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 1497CFAB1B21F5E400C1F8F2 /* RCTUIManagerTests.m */; }; - 14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; }; 14B6DA821B276C5900BF4DD1 /* libRCTTest.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 58005BEE1ABA80530062E044 /* libRCTTest.a */; }; 14D6D7111B220EB3001FB087 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14D6D7101B220EB3001FB087 /* libOCMock.a */; }; 14D6D71E1B2222EF001FB087 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 147CED4B1AB34F8C00DA3E4C /* libRCTActionSheet.a */; }; @@ -52,7 +51,7 @@ 14D6D7291B2222EF001FB087 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; }; 14DC67F41AB71881001358AB /* libRCTPushNotification.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14DC67F11AB71876001358AB /* libRCTPushNotification.a */; }; 3578590A1B28D2CF00341EDB /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 357859011B28D2C500341EDB /* libRCTLinking.a */; }; - 3DB99D0C1BA0340600302749 /* UIExplorerIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DB99D0B1BA0340600302749 /* UIExplorerIntegrationTests.m */; }; + 4CED845A1B3754F400715E21 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 14AADF041AC3DB95002390C9 /* libReact.a */; }; 834C36EC1AF8DED70019C93C /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 834C36D21AF8DA610019C93C /* libRCTSettings.a */; }; 83636F8F1B53F22C009F943E /* RCTUIManagerScenarioTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 83636F8E1B53F22C009F943E /* RCTUIManagerScenarioTests.m */; }; 8385CEF51B873B5C00C6273E /* RCTImageLoaderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8385CEF41B873B5C00C6273E /* RCTImageLoaderTests.m */; }; @@ -260,7 +259,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 14AADF051AC3DBB1002390C9 /* libReact.a in Frameworks */, + 4CED845A1B3754F400715E21 /* libReact.a in Frameworks */, 147CED4C1AB3532B00DA3E4C /* libRCTActionSheet.a in Frameworks */, 134454601AAFCABD003F0779 /* libRCTAdSupport.a in Frameworks */, 138DEE241B9EDFB6007F4EA5 /* libRCTCameraRoll.a in Frameworks */, @@ -557,6 +556,7 @@ isa = PBXNativeTarget; buildConfigurationList = 004D28AD1AAF61C70097A701 /* Build configuration list for PBXNativeTarget "UIExplorerUnitTests" */; buildPhases = ( + 4CED84D91B3760EE00715E21 /* ShellScript */, 004D289A1AAF61C70097A701 /* Sources */, 004D289B1AAF61C70097A701 /* Frameworks */, 004D289C1AAF61C70097A701 /* Resources */, @@ -574,6 +574,7 @@ isa = PBXNativeTarget; buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "UIExplorer" */; buildPhases = ( + 4CC373051B23ADA4004C3480 /* ShellScript */, 13B07F871A680F5B00A75B9A /* Sources */, 13B07F8C1A680F5B00A75B9A /* Frameworks */, 13B07F8E1A680F5B00A75B9A /* Resources */, @@ -828,6 +829,35 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 4CC373051B23ADA4004C3480 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; + 4CED84D91B3760EE00715E21 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 004D289A1AAF61C70097A701 /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/Examples/UIExplorer/UIExplorer/AppDelegate.m b/Examples/UIExplorer/UIExplorer/AppDelegate.m index 1d0d0079cf5691..cab4dd63840ec4 100644 --- a/Examples/UIExplorer/UIExplorer/AppDelegate.m +++ b/Examples/UIExplorer/UIExplorer/AppDelegate.m @@ -17,6 +17,7 @@ #import "RCTBridge.h" #import "RCTJavaScriptLoader.h" #import "RCTRootView.h" +#import "RCTUtils.h" @interface AppDelegate() @@ -59,8 +60,8 @@ - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge * on the same Wi-Fi network. */ - sourceURL = [NSURL URLWithString:@"http://localhost:8081/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=true"]; - + sourceURL = RCTPackagerURL(@"/Examples/UIExplorer/UIExplorerApp.ios.bundle?platform=ios&dev=true"); + /** * OPTION 2 * Load from pre-bundled file on disk. To re-generate the static bundle, `cd` diff --git a/Examples/UIExplorer/UIExplorer/Info.plist b/Examples/UIExplorer/UIExplorer/Info.plist index 9e91b1cef8cc6b..094ed9e8c4e685 100644 --- a/Examples/UIExplorer/UIExplorer/Info.plist +++ b/Examples/UIExplorer/UIExplorer/Info.plist @@ -22,8 +22,6 @@ 1 LSRequiresIPhoneOS - NSLocationWhenInUseUsageDescription - You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*! UILaunchStoryboardName LaunchScreen UIRequiredDeviceCapabilities @@ -36,13 +34,21 @@ UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight + NSLocationWhenInUseUsageDescription + You need to add NSLocationWhenInUseUsageDescription key in Info.plist to enable geolocation, otherwise it is going to *fail silently*! UIViewControllerBasedStatusBarAppearance + RCTPackager + + url + http://localhost + port + 8081 + NSAppTransportSecurity - - - NSAllowsArbitraryLoads - - + + NSAllowsArbitraryLoads + + diff --git a/Libraries/RCTTest/RCTTestRunner.m b/Libraries/RCTTest/RCTTestRunner.m index 41316360ba1271..bd6d85cb634bef 100644 --- a/Libraries/RCTTest/RCTTestRunner.m +++ b/Libraries/RCTTest/RCTTestRunner.m @@ -44,7 +44,7 @@ - (instancetype)initWithApp:(NSString *)app _scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; RCTAssert(_scriptURL != nil, @"Could not locate main.jsBundle"); #else - _scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]]; + _scriptURL = RCTPackagerURL( [NSString stringWithFormat:@"/%@.bundle?platform=ios&dev=true", app] ); #endif } return self; diff --git a/Libraries/WebSocket/RCTWebSocketExecutor.m b/Libraries/WebSocket/RCTWebSocketExecutor.m index 815ab56d1c280a..3c50a7e7b40674 100644 --- a/Libraries/WebSocket/RCTWebSocketExecutor.m +++ b/Libraries/WebSocket/RCTWebSocketExecutor.m @@ -39,7 +39,7 @@ @implementation RCTWebSocketExecutor - (instancetype)init { - return [self initWithURL:[RCTConvert NSURL:@"http://localhost:8081/debugger-proxy"]]; + return [self initWithURL:RCTPackagerURL(@"/debugger-proxy")]; } - (instancetype)initWithURL:(NSURL *)URL diff --git a/React/Base/RCTUtils.h b/React/Base/RCTUtils.h index 65eb99f8c2ed58..ad583bf0bab82f 100644 --- a/React/Base/RCTUtils.h +++ b/React/Base/RCTUtils.h @@ -66,3 +66,6 @@ RCT_EXTERN NSURL *RCTDataURL(NSString *mimeType, NSData *data); // Gzip functionality - compression level in range 0 - 1 (-1 for default) RCT_EXTERN NSData *RCTGzipData(NSData *data, float level); + +// Create NSURL for jsCodeLocation in AppDelegate:application +RCT_EXTERN NSURL *RCTPackagerURL(NSString *appendString); diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 2fba55f00486bf..baa49c68347224 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -422,3 +422,21 @@ BOOL RCTIsGzippedData(NSData *data) return output; } + +NSURL *RCTPackagerURL(NSString *appendString) +{ + NSMutableString *url; + NSDictionary *dict = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"RCTPackager"]; + if (dict) { + NSString *port = [NSString stringWithFormat:@"%@", [dict objectForKey:@"port"]]; + url = [NSMutableString stringWithString:dict[@"url"]]; + [url appendString:@":"]; + [url appendString:port]; + } else { + url = [NSMutableString stringWithString:@"http://localhost:8081"]; + } + // i.e. @"/Examples/UIExplorer/UIExplorerApp.ios.includeRequire.runModule.bundle?dev=true" + [url appendString:appendString]; + + return [NSURL URLWithString:url]; +} diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 276e3943d04252..50028092a36782 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -517,7 +517,6 @@ isa = PBXNativeTarget; buildConfigurationList = 83CBBA3F1A601D0F00E9B192 /* Build configuration list for PBXNativeTarget "React" */; buildPhases = ( - 006B79A01A781F38006873D1 /* ShellScript */, 83CBBA2A1A601D0E00E9B192 /* Sources */, 83CBBA2B1A601D0E00E9B192 /* Frameworks */, 83CBBA2C1A601D0E00E9B192 /* Copy Files */, diff --git a/local-cli/generator-ios/templates/app/AppDelegate.m b/local-cli/generator-ios/templates/app/AppDelegate.m index 3f96e60fe47ff4..8d8f9a34c8adff 100644 --- a/local-cli/generator-ios/templates/app/AppDelegate.m +++ b/local-cli/generator-ios/templates/app/AppDelegate.m @@ -10,6 +10,7 @@ #import "AppDelegate.h" #import "RCTRootView.h" +#import "RCTUtils.h" @implementation AppDelegate @@ -31,7 +32,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( * on the same Wi-Fi network. */ - jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"]; + jsCodeLocation = RCTPackagerURL(@"/index.ios.bundle?platform=ios&dev=true"); /** * OPTION 2 diff --git a/local-cli/generator-ios/templates/app/Info.plist b/local-cli/generator-ios/templates/app/Info.plist index cddf0766c98062..ad4feac9ead957 100644 --- a/local-cli/generator-ios/templates/app/Info.plist +++ b/local-cli/generator-ios/templates/app/Info.plist @@ -38,11 +38,17 @@ NSLocationWhenInUseUsageDescription - NSAppTransportSecurity - - - NSAllowsArbitraryLoads - - + NSAppTransportSecurity + + NSAllowsArbitraryLoads + + + RCTPackager + + url + http://localhost + port + 8081 + diff --git a/local-cli/generator-ios/templates/xcodeproj/project.pbxproj b/local-cli/generator-ios/templates/xcodeproj/project.pbxproj index f3955bb8798754..8710627fcd80a5 100644 --- a/local-cli/generator-ios/templates/xcodeproj/project.pbxproj +++ b/local-cli/generator-ios/templates/xcodeproj/project.pbxproj @@ -513,6 +513,35 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 5CC373051B23ADA4004C3480 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; + 5CED84D91B3760EE00715E21 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/bash; + shellScript = "if [ -d \"$SRCROOT/../../packager\" ]\nthen\n PACKAGER_ROOT=$SRCROOT/../../packager\nelse\n PACKAGER_ROOT=$SRCROOT/node_modules/react-native/packager\nfi\n\n$PACKAGER_ROOT/launchPackager.command ${INFOPLIST_FILE}\n"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 00E356EA1AD99517003FC87E /* Sources */ = { isa = PBXSourcesBuildPhase; diff --git a/packager/launchPackager.command b/packager/launchPackager.command index 0537f7c84d8105..7319834fb45e0e 100755 --- a/packager/launchPackager.command +++ b/packager/launchPackager.command @@ -7,11 +7,40 @@ # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. -# Set terminal title -echo -en "\033]0;React Packager\a" -clear + +if [ -z "$1" ]; then + echo "Missing argument: \$INFOPLIST_FILE" + exit 0 +fi + +export INFOPLIST_FILE=$1 + +# extract RCTPackager/protocol from Info.plist +URL=$(/usr/libexec/PlistBuddy -c "Print :RCTPackager:url" "${INFOPLIST_FILE}" 2>/dev/null) +if [ -z "$URL" ]; then + URL ="http://localhost" +fi + +# extract RCTPackager/port from Info.plist +PORT=$(/usr/libexec/PlistBuddy -c "Print :RCTPackager:port" "${INFOPLIST_FILE}" 2>/dev/null) +if [ -z "$PORT" ]; then + PORT="8081" +fi + +export URL; +export PORT; THIS_DIR=$(dirname "$0") -$THIS_DIR/packager.sh -echo "Process terminated. Press to close the window" -read + +if nc -w 5 -z localhost $PORT ; then + if ! curl -s "${URL}:${PORT}/status" | grep -q "packager-status:running" ; then + echo "Port ${URL}:${PORT} already in use, packager is either not running or not running correctly" + exit 2 + fi +else + # open w/t --args doesn't work: + # open $THIS_DIR/packager.sh --args --url=${URL} --port=${PORT} || echo "Can't start packager automatically" + osascript -e 'tell app "Terminal" + do script "'$THIS_DIR'/packager.sh --url='${URL}' --port='${PORT}'" + end tell' || echo "Can't start packager automatically" +fi \ No newline at end of file diff --git a/packager/packager.js b/packager/packager.js index a543aba0243af1..335bd575d34a05 100644 --- a/packager/packager.js +++ b/packager/packager.js @@ -37,6 +37,10 @@ var parseCommandLine = require('./parseCommandLine.js'); var webSocketProxy = require('./webSocketProxy.js'); var options = parseCommandLine([{ + command: 'url', + default: 'http://localhost', + type: 'string', +}, { command: 'port', default: 8081, type: 'string', @@ -116,7 +120,7 @@ if (options.assetRoots) { checkNodeVersion(); console.log(formatBanner( - 'Running packager on port ' + options.port + '.\n'+ + 'Running packager on ' + options.url + ":" + options.port + '.\n'+ '\n' + 'Keep this packager running while developing on any JS projects. Feel free ' + 'to close this tab and run your own packager instance if you prefer.\n' + @@ -195,7 +199,7 @@ function getDevToolsLauncher(options) { res.writeHead(200, {'Content-Type': 'text/html'}); fs.createReadStream(debuggerPath).pipe(res); } else if (req.url === '/launch-chrome-devtools') { - var debuggerURL = 'http://localhost:' + options.port + '/debugger-ui'; + var debuggerURL = options.url + ':' + options.port + '/debugger-ui'; var script = 'launchChromeDevTools.applescript'; console.log('Launching Dev Tools...'); childProcess.execFile(path.join(__dirname, script), [debuggerURL], function(err, stdout, stderr) { diff --git a/packager/packager.sh b/packager/packager.sh index 95cd8ce1e60c10..826db5fe28e5bc 100755 --- a/packager/packager.sh +++ b/packager/packager.sh @@ -7,6 +7,10 @@ # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. +# Set terminal title +echo -en "\033]0;React Packager\a" +clear + if [ $REACT_PACKAGER_LOG ]; then echo "Logs will be redirected to $REACT_PACKAGER_LOG" From ba414c01fbcb46cddbdcbb7b1f29fda780a20a02 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 16 Sep 2015 10:24:43 -0700 Subject: [PATCH 02/15] Update TransformPropTypes.js --- Libraries/StyleSheet/TransformPropTypes.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Libraries/StyleSheet/TransformPropTypes.js b/Libraries/StyleSheet/TransformPropTypes.js index 3382bf206b4eb8..c5ea9cea37889f 100644 --- a/Libraries/StyleSheet/TransformPropTypes.js +++ b/Libraries/StyleSheet/TransformPropTypes.js @@ -28,12 +28,6 @@ var TransformPropTypes = { ReactPropTypes.shape({translateY: ReactPropTypes.number}) ]) ), - - /* - * `transformMatrix` accepts a 4x4 matrix expressed as a row-major ordered - * array. This property is DEPRECATED and cannot be used simultaneously with - * the `transform` property. - */ transformMatrix: ReactPropTypes.arrayOf(ReactPropTypes.number), // DEPRECATED From c1ed1309be5fcdf08d331c3726986e18392474fc Mon Sep 17 00:00:00 2001 From: Christoph Pojer Date: Tue, 15 Sep 2015 21:49:56 -0700 Subject: [PATCH 03/15] Simplify jest config + update to jest 0.5.5 in react-native-github Reviewed By: @DmitrySoshnikov Differential Revision: D2445071 --- npm-debug.log | 33 --------------------------------- package.json | 4 ++-- 2 files changed, 2 insertions(+), 35 deletions(-) delete mode 100644 npm-debug.log diff --git a/npm-debug.log b/npm-debug.log deleted file mode 100644 index a1e33cdf52be6a..00000000000000 --- a/npm-debug.log +++ /dev/null @@ -1,33 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/local/Cellar/iojs/3.2.0/bin/iojs', -1 verbose cli '/usr/local/bin/npm', -1 verbose cli 'shrinkwrap', -1 verbose cli '--dev' ] -2 info using npm@2.13.5 -3 info using node@v3.2.0 -4 verbose stack Error: Problems were encountered -4 verbose stack Please correct and try again. -4 verbose stack missing: timed-out@^2.0.0, required by got@2.9.2 -4 verbose stack missing: timed-out@^2.0.0, required by got@3.3.1 -4 verbose stack at shrinkwrap_ (/usr/local/lib/node_modules/npm/lib/shrinkwrap.js:37:15) -4 verbose stack at /usr/local/lib/node_modules/npm/lib/shrinkwrap.js:31:5 -4 verbose stack at /usr/local/lib/node_modules/npm/lib/ls.js:47:30 -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-installed/read-installed.js:142:5 -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-installed/read-installed.js:263:14 -4 verbose stack at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24) -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-installed/read-installed.js:263:14 -4 verbose stack at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24) -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-installed/read-installed.js:263:14 -4 verbose stack at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24) -5 verbose cwd /Users/cpojer/Projects/fbsource/fbobjc/Libraries/FBReactKit/js/react-native-github -6 error Darwin 14.5.0 -7 error argv "/usr/local/Cellar/iojs/3.2.0/bin/iojs" "/usr/local/bin/npm" "shrinkwrap" "--dev" -8 error node v3.2.0 -9 error npm v2.13.5 -10 error Problems were encountered -10 error Please correct and try again. -10 error missing: timed-out@^2.0.0, required by got@2.9.2 -10 error missing: timed-out@^2.0.0, required by got@3.3.1 -11 error If you need help, you may report this error at: -11 error -12 verbose exit [ 1, true ] diff --git a/package.json b/package.json index 00cfd6afba1635..747039a833b38f 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "git@github.com:facebook/react-native.git" }, "jest": { - "scriptPreprocessor": "jestSupport/scriptPreprocess.js", + "scriptPreprocessor": "jestSupport/preprocessor.js", "setupEnvScriptFile": "jestSupport/env.js", "testPathIgnorePatterns": [ "/node_modules/", @@ -80,7 +80,7 @@ "yeoman-generator": "^0.20.3" }, "devDependencies": { - "jest-cli": "0.5.1", + "jest-cli": "0.5.5", "babel-eslint": "4.1.1", "eslint": "1.3.1", "eslint-plugin-react": "3.3.1" From 00149b2ce79ecfef9efc30ce3c50a0e15d86a810 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 16 Sep 2015 01:14:04 -0700 Subject: [PATCH 04/15] Kill old transform propTypes/attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: I can't find anywhere these are being used by the bridge / native views anymore. I don't think they work anymore. ART has a similar API but uses a different code path. We might as well clean this up. Makes it easier to reason about. @​public Reviewed By: @vjeux Differential Revision: D2445353 --- Libraries/StyleSheet/TransformPropTypes.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Libraries/StyleSheet/TransformPropTypes.js b/Libraries/StyleSheet/TransformPropTypes.js index c5ea9cea37889f..7cd6980573fb78 100644 --- a/Libraries/StyleSheet/TransformPropTypes.js +++ b/Libraries/StyleSheet/TransformPropTypes.js @@ -29,13 +29,6 @@ var TransformPropTypes = { ]) ), transformMatrix: ReactPropTypes.arrayOf(ReactPropTypes.number), - - // DEPRECATED - rotation: ReactPropTypes.number, - scaleX: ReactPropTypes.number, - scaleY: ReactPropTypes.number, - translateX: ReactPropTypes.number, - translateY: ReactPropTypes.number, }; module.exports = TransformPropTypes; From 54aee9d8ee16c2b7fbb7d6152e07b4b5e2b6b64a Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Wed, 16 Sep 2015 07:40:14 -0700 Subject: [PATCH 05/15] Added logic to detect text encoding for downloaded data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: @​public RCTNetworking currently relies on network responses to include an accurate text encoding, otherwise it is unable to convert the response data to text unless it's encoded as UTF8. See: https://github.com/facebook/react-native/issues/1780#issuecomment-139334294 for details. This diff makes use of a new feature in iOS8 to detect the encoding of the text authomatically Reviewed By: @sahrens Differential Revision: D2443446 --- Examples/UIExplorer/XHRExample.ios.js | 67 +++++++++++++++++++++++++++ Libraries/Network/RCTNetworking.m | 21 ++++++++- 2 files changed, 86 insertions(+), 2 deletions(-) diff --git a/Examples/UIExplorer/XHRExample.ios.js b/Examples/UIExplorer/XHRExample.ios.js index 250061f1f46570..57f7fc31ee9194 100644 --- a/Examples/UIExplorer/XHRExample.ios.js +++ b/Examples/UIExplorer/XHRExample.ios.js @@ -302,6 +302,53 @@ class FormUploader extends React.Component { } } +class FetchTest extends React.Component { + + constructor(props) { + super(props); + this.state = { + responseText: null, + }; + } + + submit(uri: String) { + fetch(uri).then((response) => { + return response.text(); + }).then((body) => { + this.setState({responseText: body}); + }); + } + + render() { + + var response = this.state.responseText ? ( + + Server response: + + + ) : null; + + return ( + + Edit URL to submit: + { + this.submit(event.nativeEvent.text); + }} + style={styles.textInput} + /> + {response} + + ); + } +} exports.framework = 'React'; exports.title = 'XMLHttpRequest'; @@ -316,6 +363,11 @@ exports.examples = [{ render() { return ; } +}, { + title: 'fetch test', + render() { + return ; + } }]; var styles = StyleSheet.create({ @@ -373,4 +425,19 @@ var styles = StyleSheet.create({ fontSize: 16, fontWeight: '500', }, + label: { + flex: 1, + color: '#aaa', + fontWeight: '500', + height: 20, + }, + textOutput: { + flex: 1, + fontSize: 17, + borderRadius: 3, + borderColor: 'grey', + borderWidth: 1, + height: 200, + paddingLeft: 8, + }, }); diff --git a/Libraries/Network/RCTNetworking.m b/Libraries/Network/RCTNetworking.m index 4853beff8f41f1..7621eada9cf828 100644 --- a/Libraries/Network/RCTNetworking.m +++ b/Libraries/Network/RCTNetworking.m @@ -271,10 +271,27 @@ - (void)sendData:(NSData *)data forTask:(RCTDownloadTask *)task encoding = CFStringConvertEncodingToNSStringEncoding(cfEncoding); } + // Attempt to decode text NSString *responseText = [[NSString alloc] initWithData:data encoding:encoding]; if (!responseText && data.length) { - RCTLogWarn(@"Received data was invalid."); - return; + + // We don't have an encoding, or the encoding is incorrect, so now we + // try to guess (unfortunately, this feature is available of iOS 8+ only) + if ([NSString respondsToSelector:@selector(stringEncodingForData: + encodingOptions: + convertedString: + usedLossyConversion:)]) { + [NSString stringEncodingForData:data + encodingOptions:nil + convertedString:&responseText + usedLossyConversion:NULL]; + } + + // If we still can't decode it, bail out + if (!responseText) { + RCTLogWarn(@"Received data was not a string, or was not a recognised encoding."); + return; + } } NSArray *responseJSON = @[task.requestID, responseText ?: @""]; From 40b79e384d8c75b4e4431ae627fddc8d2077690b Mon Sep 17 00:00:00 2001 From: facebook-github-bot-6 Date: Wed, 16 Sep 2015 10:30:53 -0700 Subject: [PATCH 06/15] Get back 100% in sync with fb codebase --- Examples/Movies/Movies/AppDelegate.m | 2 +- .../app/src/main/java/MainActivity.java | 1 + .../UIExplorer/ScrollViewSimpleExample.js | 1 - .../SwitchAndroidExample.android.js | 14 +- .../UIExplorer/ToastAndroidExample.android.js | 3 +- Examples/UIExplorer/XHRExample.android.js | 3 +- .../Components/Touchable/TouchableOpacity.js | 3 - Libraries/Storage/AsyncStorage.ios.js | 2 +- .../browser/eventPlugins/PanResponder.js | 2 +- React.podspec | 2 +- ReactAndroid/build.gradle | 247 +----------------- ReactAndroid/settings.gradle | 1 + ReactAndroid/src/main/java/Dummy.java | 1 + jestSupport/env.js | 8 +- jestSupport/preprocessor.js | 17 ++ package.json | 2 +- packager/README.md | 4 +- .../src/Bundler/__tests__/Bundler-test.js | 3 +- 18 files changed, 39 insertions(+), 277 deletions(-) create mode 100644 Examples/SampleApp/android/app/src/main/java/MainActivity.java create mode 100644 ReactAndroid/settings.gradle create mode 100644 ReactAndroid/src/main/java/Dummy.java create mode 100644 jestSupport/preprocessor.js diff --git a/Examples/Movies/Movies/AppDelegate.m b/Examples/Movies/Movies/AppDelegate.m index ef879291e97761..8b0cbb6d598344 100644 --- a/Examples/Movies/Movies/AppDelegate.m +++ b/Examples/Movies/Movies/AppDelegate.m @@ -45,7 +45,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( * Load from pre-bundled file on disk. To re-generate the static bundle, `cd` * to your Xcode project folder in the terminal, and run * - * $ curl 'http://localhost:8081/Examples/Movies/MoviesApp.ios.includeRequire.runModule.bundle' -o main.jsbundle + * $ curl 'http://localhost:8081/Examples/Movies/MoviesApp.includeRequire.runModule.bundle' -o main.jsbundle * * then add the `main.jsbundle` file to your project and uncomment this line: */ diff --git a/Examples/SampleApp/android/app/src/main/java/MainActivity.java b/Examples/SampleApp/android/app/src/main/java/MainActivity.java new file mode 100644 index 00000000000000..a1b42145d6393d --- /dev/null +++ b/Examples/SampleApp/android/app/src/main/java/MainActivity.java @@ -0,0 +1 @@ +// Temp dummy Java file, shouldn't be exported to github, will be deleted. \ No newline at end of file diff --git a/Examples/UIExplorer/ScrollViewSimpleExample.js b/Examples/UIExplorer/ScrollViewSimpleExample.js index af7d6863bce474..c9bbe74072153d 100644 --- a/Examples/UIExplorer/ScrollViewSimpleExample.js +++ b/Examples/UIExplorer/ScrollViewSimpleExample.js @@ -30,7 +30,6 @@ var ScrollViewSimpleExample = React.createClass({ title: '', description: 'Component that enables scrolling through child components.' }, - makeItems: function(nItems: number, styles): Array { var items = []; for (var i = 0; i < nItems; i++) { diff --git a/Examples/UIExplorer/SwitchAndroidExample.android.js b/Examples/UIExplorer/SwitchAndroidExample.android.js index ef58c5a368680b..6b703bc2f3fa68 100644 --- a/Examples/UIExplorer/SwitchAndroidExample.android.js +++ b/Examples/UIExplorer/SwitchAndroidExample.android.js @@ -1,15 +1,5 @@ /** - * The examples provided by Facebook are for non-commercial testing and - * evaluation purposes only. - * - * Facebook reserves all rights not expressly granted. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL - * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * Copyright 2004-present Facebook. All Rights Reserved. */ 'use strict'; @@ -23,7 +13,7 @@ var UIExplorerPage = require('UIExplorerPage'); var SwitchAndroidExample = React.createClass({ statics: { title: '', - description: 'Standard Android two-state toggle component' + description: 'Standard Android two-state toggle component.' }, getInitialState : function() { diff --git a/Examples/UIExplorer/ToastAndroidExample.android.js b/Examples/UIExplorer/ToastAndroidExample.android.js index 0e9964766559e7..05943cd272c222 100644 --- a/Examples/UIExplorer/ToastAndroidExample.android.js +++ b/Examples/UIExplorer/ToastAndroidExample.android.js @@ -13,6 +13,7 @@ * * @flow */ + 'use strict'; var React = require('react-native'); @@ -30,7 +31,7 @@ var ToastExample = React.createClass({ statics: { title: 'Toast Example', - description: 'Toast Example', + description: 'Example that demostrates the use of an Android Toast to provide feedback.', }, getInitialState: function() { diff --git a/Examples/UIExplorer/XHRExample.android.js b/Examples/UIExplorer/XHRExample.android.js index b0069794e74bce..92344e72d0d998 100644 --- a/Examples/UIExplorer/XHRExample.android.js +++ b/Examples/UIExplorer/XHRExample.android.js @@ -262,7 +262,8 @@ class FormUploader extends React.Component { exports.framework = 'React'; exports.title = 'XMLHttpRequest'; -exports.description = 'XMLHttpRequest'; +exports.description = 'Example that demostrates upload and download requests ' + + 'using XMLHttpRequest.'; exports.examples = [{ title: 'File Download', render() { diff --git a/Libraries/Components/Touchable/TouchableOpacity.js b/Libraries/Components/Touchable/TouchableOpacity.js index 17b6cbeaf60019..eddf2ff83b9e15 100644 --- a/Libraries/Components/Touchable/TouchableOpacity.js +++ b/Libraries/Components/Touchable/TouchableOpacity.js @@ -45,9 +45,6 @@ type Event = Object; * ); * }, * ``` - * > **NOTE**: TouchableOpacity supports only one child - * > - * > If you wish to have to have several child components, wrap them in a View. */ var TouchableOpacity = React.createClass({ diff --git a/Libraries/Storage/AsyncStorage.ios.js b/Libraries/Storage/AsyncStorage.ios.js index 167a8791bfcbe5..ed028db4bc93ac 100644 --- a/Libraries/Storage/AsyncStorage.ios.js +++ b/Libraries/Storage/AsyncStorage.ios.js @@ -183,7 +183,7 @@ var AsyncStorage = { /** * multiSet and multiMerge take arrays of key-value array pairs that match - * the output of multiGet. Returns a `Promise` object. + * the output of multiGet, e.g. Returns a `Promise` object. * * multiSet([['k1', 'val1'], ['k2', 'val2']], cb); */ diff --git a/Libraries/vendor/react/browser/eventPlugins/PanResponder.js b/Libraries/vendor/react/browser/eventPlugins/PanResponder.js index bf3ed46c1d73e3..ed93f88f671f48 100644 --- a/Libraries/vendor/react/browser/eventPlugins/PanResponder.js +++ b/Libraries/vendor/react/browser/eventPlugins/PanResponder.js @@ -45,7 +45,7 @@ var currentCentroidY = TouchHistoryMath.currentCentroidY; * * ``` * componentWillMount: function() { - * this._panResponder = PanResponder.create({ + * this._panGesture = PanResponder.create({ * // Ask to be the responder: * onStartShouldSetPanResponder: (evt, gestureState) => true, * onStartShouldSetPanResponderCapture: (evt, gestureState) => true, diff --git a/React.podspec b/React.podspec index b3004d01575838..4b762c858d7477 100644 --- a/React.podspec +++ b/React.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "React" - s.version = "0.11.0-rc" + s.version = "0.8.0" s.summary = "Build high quality mobile apps using React." s.description = <<-DESC React Native apps are built using the React JS diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index 97c77d10d66d86..c2d5490253086a 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -1,246 +1 @@ -// Copyright 2015-present Facebook. All Rights Reserved. - -apply plugin: 'com.android.library' -apply plugin: 'maven' - -apply plugin: 'de.undercouch.download' - -import de.undercouch.gradle.tasks.download.Download -import org.apache.tools.ant.taskdefs.condition.Os -import org.apache.tools.ant.filters.ReplaceTokens - -// We download various C++ open-source dependencies into downloads. -// We then copy both downloaded code and our custom makefiles and headers into third-party-ndk -// After that we build native code from src/main/jni with module path pointing at third-party-ndk - -def downloadsDir = new File("$buildDir/downloads") -def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") - -task createNativeDepsDirectories { - downloadsDir.mkdirs() - thirdPartyNdkDir.mkdirs() -} - -task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) { - // Use ZIP version as it's faster this way to selectively extract some parts of the archive - src 'https://downloads.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.zip' - onlyIfNewer true - overwrite false - dest new File(downloadsDir, 'boost_1_57_0.zip') -} - -task prepareBoost(dependsOn: downloadBoost, type: Copy) { - from zipTree(downloadBoost.dest) - from 'src/main/jni/third-party/boost/Android.mk' - include 'boost_1_57_0/boost/**/*.hpp', 'Android.mk' - into "$thirdPartyNdkDir/boost" -} - -task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) { - src 'https://github.com/google/double-conversion/archive/v1.1.1.tar.gz' - onlyIfNewer true - overwrite false - dest new File(downloadsDir, 'double-conversion-1.1.1.tar.gz') -} - -task prepareDoubleConversion(dependsOn: downloadDoubleConversion, type: Copy) { - from tarTree(downloadDoubleConversion.dest) - from 'src/main/jni/third-party/double-conversion/Android.mk' - include 'double-conversion-1.1.1/src/**/*', 'Android.mk' - filesMatching('*/src/**/*', {fname -> fname.path = "double-conversion/${fname.name}"}) - includeEmptyDirs = false - into "$thirdPartyNdkDir/double-conversion" -} - -task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) { - src 'https://github.com/facebook/folly/archive/v0.50.0.tar.gz' - onlyIfNewer true - overwrite false - dest new File(downloadsDir, 'folly-0.50.0.tar.gz'); -} - -task prepareFolly(dependsOn: downloadFolly, type: Copy) { - from tarTree(downloadFolly.dest) - from 'src/main/jni/third-party/folly/Android.mk' - include 'folly-0.50.0/folly/**/*', 'Android.mk' - eachFile {fname -> fname.path = (fname.path - "folly-0.50.0/")} - includeEmptyDirs = false - into "$thirdPartyNdkDir/folly" -} - -task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) { - src 'https://github.com/google/glog/archive/v0.3.3.tar.gz' - onlyIfNewer true - overwrite false - dest new File(downloadsDir, 'glog-0.3.3.tar.gz') -} - -// Prepare glog sources to be compiled, this task will perform steps that normally shoudl've been -// executed by automake. This way we can avoid dependencies on make/automake -task prepareGlog(dependsOn: downloadGlog, type: Copy) { - from tarTree(downloadGlog.dest) - from 'src/main/jni/third-party/glog/' - include 'glog-0.3.3/src/**/*', 'Android.mk', 'config.h' - includeEmptyDirs = false - filesMatching('**/*.h.in') { - filter(ReplaceTokens, tokens: [ - ac_cv_have_unistd_h: '1', - ac_cv_have_stdint_h: '1', - ac_cv_have_systypes_h: '1', - ac_cv_have_inttypes_h: '1', - ac_cv_have_libgflags: '0', - ac_google_start_namespace: 'namespace google {', - ac_cv_have_uint16_t: '1', - ac_cv_have_u_int16_t: '1', - ac_cv_have___uint16: '0', - ac_google_end_namespace: '}', - ac_cv_have___builtin_expect: '1', - ac_google_namespace: 'google', - ac_cv___attribute___noinline: '__attribute__ ((noinline))', - ac_cv___attribute___noreturn: '__attribute__ ((noreturn))', - ac_cv___attribute___printf_4_5: '__attribute__((__format__ (__printf__, 4, 5)))' - ]) - it.path = (it.name - '.in') - } - into "$thirdPartyNdkDir/glog" -} - -task downloadJSCHeaders(type: Download) { - def jscAPIBaseURL = 'https://svn.webkit.org/repository/webkit/!svn/bc/174650/trunk/Source/JavaScriptCore/API/' - def jscHeaderFiles = ['JSBase.h', 'JSContextRef.h', 'JSObjectRef.h', 'JSRetainPtr.h', 'JSStringRef.h', 'JSValueRef.h', 'WebKitAvailability.h'] - def output = new File(downloadsDir, 'jsc') - output.mkdirs() - src(jscHeaderFiles.collect { headerName -> "$jscAPIBaseURL$headerName" }) - onlyIfNewer true - overwrite false - dest output -} - -// Create Android.mk library module based on so files from mvn + include headers fetched from webkit.org -task prepareJSC(dependsOn: downloadJSCHeaders) << { - copy { - from zipTree(configurations.compile.fileCollection { dep -> dep.name == 'android-jsc' }.singleFile) - from {downloadJSCHeaders.dest} - from 'src/main/jni/third-party/jsc/Android.mk' - include 'jni/**/*.so', '*.h', 'Android.mk' - filesMatching('*.h', { fname -> fname.path = "JavaScriptCore/${fname.path}"}) - into "$thirdPartyNdkDir/jsc"; - } -} - -def getNdkBuildName() { - if (Os.isFamily(Os.FAMILY_WINDOWS)) { - return "ndk-build.cmd" - } else { - return "ndk-build" - } -} - -def findNdkBuildFullPath() { - // we allow to provide full path to ndk-build tool - if (hasProperty('ndk.command')) { - return property('ndk.command') - } - // or just a path to the containing directory - if (hasProperty('ndk.path')) { - def ndkDir = property('ndk.path') - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - if (System.getenv('ANDROID_NDK') != null) { - def ndkDir = System.getenv('ANDROID_NDK') - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder : - plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder() - if (ndkDir) { - return new File(ndkDir, getNdkBuildName()).getAbsolutePath() - } - return null -} - -def getNdkBuildFullPath() { - def ndkBuildFullPath = findNdkBuildFullPath() - if (ndkBuildFullPath == null || !new File(ndkBuildFullPath).canExecute()) { - throw new GradleScriptException( - "ndk-build binary cannot be found, check if you've set " + - "\$ANDROID_NDK environment variable correctly or if ndk.dir is " + - "setup in local.properties", - null) - } - return ndkBuildFullPath -} - -task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type: Exec) { - inputs.file('src/main/jni/react') - outputs.dir("$buildDir/react-ndk/all") - commandLine getNdkBuildFullPath(), - 'NDK_PROJECT_PATH=null', - "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", - 'NDK_OUT=' + temporaryDir, - "NDK_LIBS_OUT=$buildDir/react-ndk/all", - "THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk", - '-C', file('src/main/jni/react/jni').absolutePath, - '--jobs', Runtime.runtime.availableProcessors() -} - -task cleanReactNdkLib(type: Exec) { - commandLine getNdkBuildFullPath(), - '-C', file('src/main/jni/react/jni').absolutePath, - 'clean' -} - -task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) { - from "$buildDir/react-ndk/all" - exclude '**/libjsc.so' - into "$buildDir/react-ndk/exported" -} - -android { - compileSdkVersion 22 - buildToolsVersion "22.0.1" - - defaultConfig { - minSdkVersion 16 - targetSdkVersion 22 - versionCode 1 - versionName "1.0" - - ndk { - moduleName "reactnativejni" - } - - buildConfigField 'boolean', 'IS_INTERNAL_BUILD', 'false' - } - - sourceSets.main { - jni.srcDirs = [] - jniLibs.srcDir "$buildDir/react-ndk/exported" - res.srcDirs = ['src/main/res/devsupport', 'src/main/res/shell'] - } - - tasks.withType(JavaCompile) { - compileTask -> compileTask.dependsOn packageReactNdkLibs - } - - clean.dependsOn cleanReactNdkLib - - lintOptions { - abortOnError false - } -} - -dependencies { - compile fileTree(dir: 'libs', include: ['*.jar']) - compile 'com.android.support:appcompat-v7:22.2.0' - compile 'com.facebook.fresco:fresco:0.6.1' - compile 'com.facebook.fresco:imagepipeline-okhttp:0.6.1' - compile 'com.fasterxml.jackson.core:jackson-core:2.2.3' - compile 'com.google.code.findbugs:jsr305:3.0.0' - compile 'com.squareup.okhttp:okhttp:2.4.0' - compile 'com.squareup.okhttp:okhttp-ws:2.4.0' - compile 'com.squareup.okio:okio:1.5.0' - compile 'org.webkit:android-jsc:r174650' -} - -apply from: 'release.gradle' - +// Temp dummy Gradle file, shouldn't be exported to github, will be deleted. \ No newline at end of file diff --git a/ReactAndroid/settings.gradle b/ReactAndroid/settings.gradle new file mode 100644 index 00000000000000..c2d5490253086a --- /dev/null +++ b/ReactAndroid/settings.gradle @@ -0,0 +1 @@ +// Temp dummy Gradle file, shouldn't be exported to github, will be deleted. \ No newline at end of file diff --git a/ReactAndroid/src/main/java/Dummy.java b/ReactAndroid/src/main/java/Dummy.java new file mode 100644 index 00000000000000..a1b42145d6393d --- /dev/null +++ b/ReactAndroid/src/main/java/Dummy.java @@ -0,0 +1 @@ +// Temp dummy Java file, shouldn't be exported to github, will be deleted. \ No newline at end of file diff --git a/jestSupport/env.js b/jestSupport/env.js index 0bb465e0b74427..160f26766bfec9 100644 --- a/jestSupport/env.js +++ b/jestSupport/env.js @@ -8,7 +8,7 @@ */ 'use strict'; -window.__DEV__ = true; -window.Env = {}; - -require.requireActual('./setupEnvPolyfills'); +global.__DEV__ = true; +global.setImmediate = global.setImmediate || function(fn) { + return setTimeout(fn, 0); +}; diff --git a/jestSupport/preprocessor.js b/jestSupport/preprocessor.js new file mode 100644 index 00000000000000..8198a6824bc781 --- /dev/null +++ b/jestSupport/preprocessor.js @@ -0,0 +1,17 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ +'use strict'; + +var transformer = require('../packager/transformer.js'); + +module.exports = { + process(src, file) { + return transformer.transform(src, file).code; + } +}; diff --git a/package.json b/package.json index 747039a833b38f..1f905bc1329774 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native", - "version": "0.11.0-rc", + "version": "0.8.0", "description": "A framework for building native apps using React", "license": "BSD-3-Clause", "repository": { diff --git a/packager/README.md b/packager/README.md index 0b6762baf76254..c3fae48064e801 100644 --- a/packager/README.md +++ b/packager/README.md @@ -19,8 +19,8 @@ namely the node module format. We want to even go further, and let you choose your own packager and asset pipeline or even integrate into your existing infrastructure. -React Native users need not understand how the packager works. -However, this documentation might be useful for advanced users and +React Native users need not to understand how the packager work, +however, this documentation might be useful for advanced users and people who want to fix bugs or add features to the packager (patches welcome!). diff --git a/packager/react-packager/src/Bundler/__tests__/Bundler-test.js b/packager/react-packager/src/Bundler/__tests__/Bundler-test.js index 60e21c072b7bdf..fb205d8ac31668 100644 --- a/packager/react-packager/src/Bundler/__tests__/Bundler-test.js +++ b/packager/react-packager/src/Bundler/__tests__/Bundler-test.js @@ -13,8 +13,7 @@ jest .dontMock('underscore') .dontMock('../../lib/ModuleTransport') .setMock('uglify-js') - .dontMock('../') - .setMock('chalk', { dim: function(s) { return s; } }); + .dontMock('../'); jest.mock('fs'); From 62eb72821f6d13c0117b022265c730aed4c54ad9 Mon Sep 17 00:00:00 2001 From: facebook-github-bot-6 Date: Wed, 16 Sep 2015 10:38:42 -0700 Subject: [PATCH 07/15] Restore unintended sync --- .../app/src/main/java/MainActivity.java | 1 - ReactAndroid/build.gradle | 247 +++++++++++++++++- ReactAndroid/settings.gradle | 1 - ReactAndroid/src/main/java/Dummy.java | 1 - 4 files changed, 246 insertions(+), 4 deletions(-) delete mode 100644 Examples/SampleApp/android/app/src/main/java/MainActivity.java delete mode 100644 ReactAndroid/settings.gradle delete mode 100644 ReactAndroid/src/main/java/Dummy.java diff --git a/Examples/SampleApp/android/app/src/main/java/MainActivity.java b/Examples/SampleApp/android/app/src/main/java/MainActivity.java deleted file mode 100644 index a1b42145d6393d..00000000000000 --- a/Examples/SampleApp/android/app/src/main/java/MainActivity.java +++ /dev/null @@ -1 +0,0 @@ -// Temp dummy Java file, shouldn't be exported to github, will be deleted. \ No newline at end of file diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index c2d5490253086a..97c77d10d66d86 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -1 +1,246 @@ -// Temp dummy Gradle file, shouldn't be exported to github, will be deleted. \ No newline at end of file +// Copyright 2015-present Facebook. All Rights Reserved. + +apply plugin: 'com.android.library' +apply plugin: 'maven' + +apply plugin: 'de.undercouch.download' + +import de.undercouch.gradle.tasks.download.Download +import org.apache.tools.ant.taskdefs.condition.Os +import org.apache.tools.ant.filters.ReplaceTokens + +// We download various C++ open-source dependencies into downloads. +// We then copy both downloaded code and our custom makefiles and headers into third-party-ndk +// After that we build native code from src/main/jni with module path pointing at third-party-ndk + +def downloadsDir = new File("$buildDir/downloads") +def thirdPartyNdkDir = new File("$buildDir/third-party-ndk") + +task createNativeDepsDirectories { + downloadsDir.mkdirs() + thirdPartyNdkDir.mkdirs() +} + +task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) { + // Use ZIP version as it's faster this way to selectively extract some parts of the archive + src 'https://downloads.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.zip' + onlyIfNewer true + overwrite false + dest new File(downloadsDir, 'boost_1_57_0.zip') +} + +task prepareBoost(dependsOn: downloadBoost, type: Copy) { + from zipTree(downloadBoost.dest) + from 'src/main/jni/third-party/boost/Android.mk' + include 'boost_1_57_0/boost/**/*.hpp', 'Android.mk' + into "$thirdPartyNdkDir/boost" +} + +task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) { + src 'https://github.com/google/double-conversion/archive/v1.1.1.tar.gz' + onlyIfNewer true + overwrite false + dest new File(downloadsDir, 'double-conversion-1.1.1.tar.gz') +} + +task prepareDoubleConversion(dependsOn: downloadDoubleConversion, type: Copy) { + from tarTree(downloadDoubleConversion.dest) + from 'src/main/jni/third-party/double-conversion/Android.mk' + include 'double-conversion-1.1.1/src/**/*', 'Android.mk' + filesMatching('*/src/**/*', {fname -> fname.path = "double-conversion/${fname.name}"}) + includeEmptyDirs = false + into "$thirdPartyNdkDir/double-conversion" +} + +task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) { + src 'https://github.com/facebook/folly/archive/v0.50.0.tar.gz' + onlyIfNewer true + overwrite false + dest new File(downloadsDir, 'folly-0.50.0.tar.gz'); +} + +task prepareFolly(dependsOn: downloadFolly, type: Copy) { + from tarTree(downloadFolly.dest) + from 'src/main/jni/third-party/folly/Android.mk' + include 'folly-0.50.0/folly/**/*', 'Android.mk' + eachFile {fname -> fname.path = (fname.path - "folly-0.50.0/")} + includeEmptyDirs = false + into "$thirdPartyNdkDir/folly" +} + +task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) { + src 'https://github.com/google/glog/archive/v0.3.3.tar.gz' + onlyIfNewer true + overwrite false + dest new File(downloadsDir, 'glog-0.3.3.tar.gz') +} + +// Prepare glog sources to be compiled, this task will perform steps that normally shoudl've been +// executed by automake. This way we can avoid dependencies on make/automake +task prepareGlog(dependsOn: downloadGlog, type: Copy) { + from tarTree(downloadGlog.dest) + from 'src/main/jni/third-party/glog/' + include 'glog-0.3.3/src/**/*', 'Android.mk', 'config.h' + includeEmptyDirs = false + filesMatching('**/*.h.in') { + filter(ReplaceTokens, tokens: [ + ac_cv_have_unistd_h: '1', + ac_cv_have_stdint_h: '1', + ac_cv_have_systypes_h: '1', + ac_cv_have_inttypes_h: '1', + ac_cv_have_libgflags: '0', + ac_google_start_namespace: 'namespace google {', + ac_cv_have_uint16_t: '1', + ac_cv_have_u_int16_t: '1', + ac_cv_have___uint16: '0', + ac_google_end_namespace: '}', + ac_cv_have___builtin_expect: '1', + ac_google_namespace: 'google', + ac_cv___attribute___noinline: '__attribute__ ((noinline))', + ac_cv___attribute___noreturn: '__attribute__ ((noreturn))', + ac_cv___attribute___printf_4_5: '__attribute__((__format__ (__printf__, 4, 5)))' + ]) + it.path = (it.name - '.in') + } + into "$thirdPartyNdkDir/glog" +} + +task downloadJSCHeaders(type: Download) { + def jscAPIBaseURL = 'https://svn.webkit.org/repository/webkit/!svn/bc/174650/trunk/Source/JavaScriptCore/API/' + def jscHeaderFiles = ['JSBase.h', 'JSContextRef.h', 'JSObjectRef.h', 'JSRetainPtr.h', 'JSStringRef.h', 'JSValueRef.h', 'WebKitAvailability.h'] + def output = new File(downloadsDir, 'jsc') + output.mkdirs() + src(jscHeaderFiles.collect { headerName -> "$jscAPIBaseURL$headerName" }) + onlyIfNewer true + overwrite false + dest output +} + +// Create Android.mk library module based on so files from mvn + include headers fetched from webkit.org +task prepareJSC(dependsOn: downloadJSCHeaders) << { + copy { + from zipTree(configurations.compile.fileCollection { dep -> dep.name == 'android-jsc' }.singleFile) + from {downloadJSCHeaders.dest} + from 'src/main/jni/third-party/jsc/Android.mk' + include 'jni/**/*.so', '*.h', 'Android.mk' + filesMatching('*.h', { fname -> fname.path = "JavaScriptCore/${fname.path}"}) + into "$thirdPartyNdkDir/jsc"; + } +} + +def getNdkBuildName() { + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + return "ndk-build.cmd" + } else { + return "ndk-build" + } +} + +def findNdkBuildFullPath() { + // we allow to provide full path to ndk-build tool + if (hasProperty('ndk.command')) { + return property('ndk.command') + } + // or just a path to the containing directory + if (hasProperty('ndk.path')) { + def ndkDir = property('ndk.path') + return new File(ndkDir, getNdkBuildName()).getAbsolutePath() + } + if (System.getenv('ANDROID_NDK') != null) { + def ndkDir = System.getenv('ANDROID_NDK') + return new File(ndkDir, getNdkBuildName()).getAbsolutePath() + } + def ndkDir = android.hasProperty('plugin') ? android.plugin.ndkFolder : + plugins.getPlugin('com.android.library').sdkHandler.getNdkFolder() + if (ndkDir) { + return new File(ndkDir, getNdkBuildName()).getAbsolutePath() + } + return null +} + +def getNdkBuildFullPath() { + def ndkBuildFullPath = findNdkBuildFullPath() + if (ndkBuildFullPath == null || !new File(ndkBuildFullPath).canExecute()) { + throw new GradleScriptException( + "ndk-build binary cannot be found, check if you've set " + + "\$ANDROID_NDK environment variable correctly or if ndk.dir is " + + "setup in local.properties", + null) + } + return ndkBuildFullPath +} + +task buildReactNdkLib(dependsOn: [prepareJSC, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type: Exec) { + inputs.file('src/main/jni/react') + outputs.dir("$buildDir/react-ndk/all") + commandLine getNdkBuildFullPath(), + 'NDK_PROJECT_PATH=null', + "NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk", + 'NDK_OUT=' + temporaryDir, + "NDK_LIBS_OUT=$buildDir/react-ndk/all", + "THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk", + '-C', file('src/main/jni/react/jni').absolutePath, + '--jobs', Runtime.runtime.availableProcessors() +} + +task cleanReactNdkLib(type: Exec) { + commandLine getNdkBuildFullPath(), + '-C', file('src/main/jni/react/jni').absolutePath, + 'clean' +} + +task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) { + from "$buildDir/react-ndk/all" + exclude '**/libjsc.so' + into "$buildDir/react-ndk/exported" +} + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + minSdkVersion 16 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + + ndk { + moduleName "reactnativejni" + } + + buildConfigField 'boolean', 'IS_INTERNAL_BUILD', 'false' + } + + sourceSets.main { + jni.srcDirs = [] + jniLibs.srcDir "$buildDir/react-ndk/exported" + res.srcDirs = ['src/main/res/devsupport', 'src/main/res/shell'] + } + + tasks.withType(JavaCompile) { + compileTask -> compileTask.dependsOn packageReactNdkLibs + } + + clean.dependsOn cleanReactNdkLib + + lintOptions { + abortOnError false + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.2.0' + compile 'com.facebook.fresco:fresco:0.6.1' + compile 'com.facebook.fresco:imagepipeline-okhttp:0.6.1' + compile 'com.fasterxml.jackson.core:jackson-core:2.2.3' + compile 'com.google.code.findbugs:jsr305:3.0.0' + compile 'com.squareup.okhttp:okhttp:2.4.0' + compile 'com.squareup.okhttp:okhttp-ws:2.4.0' + compile 'com.squareup.okio:okio:1.5.0' + compile 'org.webkit:android-jsc:r174650' +} + +apply from: 'release.gradle' + diff --git a/ReactAndroid/settings.gradle b/ReactAndroid/settings.gradle deleted file mode 100644 index c2d5490253086a..00000000000000 --- a/ReactAndroid/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -// Temp dummy Gradle file, shouldn't be exported to github, will be deleted. \ No newline at end of file diff --git a/ReactAndroid/src/main/java/Dummy.java b/ReactAndroid/src/main/java/Dummy.java deleted file mode 100644 index a1b42145d6393d..00000000000000 --- a/ReactAndroid/src/main/java/Dummy.java +++ /dev/null @@ -1 +0,0 @@ -// Temp dummy Java file, shouldn't be exported to github, will be deleted. \ No newline at end of file From f91ea8a492a006f489a4537126474c3454c6aa58 Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 16 Sep 2015 10:58:05 -0700 Subject: [PATCH 08/15] Bring back build status --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e42f49ba037fc8..3af1bcaacf2798 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# React Native [![npm version](https://badge.fury.io/js/react-native.svg)](http://badge.fury.io/js/react-native) +# React Native [![Build Status](https://travis-ci.org/facebook/react-native.svg?branch=master)](https://travis-ci.org/facebook/react-native) [![npm version](https://badge.fury.io/js/react-native.svg)](http://badge.fury.io/js/react-native) React Native enables you to build world-class application experiences on native platforms using a consistent developer experience based on JavaScript and [React](http://facebook.github.io/react). The focus of React Native is on developer efficiency across all the platforms you care about - learn once, write anywhere. Facebook uses React Native in multiple production apps and will continue investing in React Native. From e70c8f90896f06020afb9270498278857f9b3601 Mon Sep 17 00:00:00 2001 From: James Ide Date: Thu, 3 Sep 2015 15:48:22 -0700 Subject: [PATCH 09/15] [Node 4] Update .travis.yml to install Node 4.x + upgrade jest Jest 0.5.2 ships with a fix for bound functions, which RN exercises. And with this Travis change, the automated tests will install Node 4.x with nvm before running. Test Plan:`nvm use 4 && npm i && npm test` See if Travis tests pass. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9319fb00a60c2b..f7a6a90487c796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ install: - mkdir -p .nvm - export NVM_DIR="$PWD/.nvm" - source $(brew --prefix nvm)/nvm.sh - - nvm install iojs-v3 + - nvm install 4 - rm -Rf `node -p "require('os').tmpDir()"`/jest_preprocess_cache - npm install -g flow-bin@`node -p "require('fs').readFileSync('.flowconfig', 'utf8').split('[version]')[1].trim()"` - npm config set spin=false From 7bde0be3c690f392a41f8a6cc9072796ae358a4a Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 16 Sep 2015 11:36:02 -0700 Subject: [PATCH 10/15] Delete setupEnvPolyfills.js which is no longer being used --- jestSupport/setupEnvPolyfills.js | 67 -------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 jestSupport/setupEnvPolyfills.js diff --git a/jestSupport/setupEnvPolyfills.js b/jestSupport/setupEnvPolyfills.js deleted file mode 100644 index be12e0d7c75fae..00000000000000 --- a/jestSupport/setupEnvPolyfills.js +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * This pipes all of our console logging functions to native logging so that - * JavaScript errors in required modules show up in Xcode via NSLog. - */ - -'use strict'; - -// WARNING: This is an optimized version that fails on hasOwnProperty checks -// and non objects. It's not spec-compliant. It's a perf optimization. - -Object.assign = function(target, sources) { - if (__DEV__) { - if (target == null) { - throw new TypeError('Object.assign target cannot be null or undefined'); - } - if (typeof target !== 'object' && typeof target !== 'function') { - throw new TypeError( - 'In this environment the target of assign MUST be an object.' + - 'This error is a performance optimization and not spec compliant.' - ); - } - } - - for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) { - var nextSource = arguments[nextIndex]; - if (nextSource == null) { - continue; - } - - if (__DEV__) { - if (typeof nextSource !== 'object' && - typeof nextSource !== 'function') { - throw new TypeError( - 'In this environment the target of assign MUST be an object.' + - 'This error is a performance optimization and not spec compliant.' - ); - } - } - - // We don't currently support accessors nor proxies. Therefore this - // copy cannot throw. If we ever supported this then we must handle - // exceptions and side-effects. - - for (var key in nextSource) { - if (__DEV__) { - var hasOwnProperty = Object.prototype.hasOwnProperty; - if (!hasOwnProperty.call(nextSource, key)) { - throw new TypeError( - 'One of the sources to assign has an enumerable key on the ' + - 'prototype chain. This is an edge case that we do not support. ' + - 'This error is a performance optimization and not spec compliant.' - ); - } - } - target[key] = nextSource[key]; - } - } - - return target; -}; From 6c818ef005041a4fb217f4a72f118a0c1fe224ba Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Wed, 16 Sep 2015 19:49:06 +0100 Subject: [PATCH 11/15] Update KnownIssues.md --- docs/KnownIssues.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/KnownIssues.md b/docs/KnownIssues.md index 3e624a774626ab..4f8e9086d825b6 100644 --- a/docs/KnownIssues.md +++ b/docs/KnownIssues.md @@ -37,6 +37,9 @@ Pasteboard Alert ``` +### Props that are only supported on one platform +There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with `@platform` in JS docs and have a platform badge on the website (generated from JS docs). See e.g. [Image](https://facebook.github.io/react-native/docs/image.html). + ### Publishing modules on Android There is currently no easy way of publishing custom native modules on Android. Smooth work flow for contributors is important and this will be looked at very closely after the initial Open Source release. Of course the aim will be to streamline and optimize the process between iOS and Android as much as possible. From d530c625d23fc72ef68ca88322dea5662fa32b3a Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Wed, 16 Sep 2015 19:50:28 +0100 Subject: [PATCH 12/15] Update KnownIssues.md --- docs/KnownIssues.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/KnownIssues.md b/docs/KnownIssues.md index 4f8e9086d825b6..ab82bc70c9b92c 100644 --- a/docs/KnownIssues.md +++ b/docs/KnownIssues.md @@ -38,7 +38,7 @@ Alert ``` ### Props that are only supported on one platform -There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with `@platform` in JS docs and have a platform badge on the website (generated from JS docs). See e.g. [Image](https://facebook.github.io/react-native/docs/image.html). +There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with `@platform` in JS docs and have a platform badge on the website. See e.g. [Image](https://facebook.github.io/react-native/docs/image.html). ### Publishing modules on Android @@ -76,7 +76,7 @@ We don't support shadows on Android currently. These are notoriously hard to imp ### Layout-only nodes on Android -An optimization feature of the Android version of React Native is for views which only contribute to the layout to not have a native view, only their layout properties are propagated to their children views. This optimization is to provide stability in deep view hierarchies for React Native and is therefore enabled by default. Should you depend on a view being present or internal tests incorrectly detect a view is layout only it will be necessary to turn off this behavior. To do this, set `collapsable` to false as in this example: +An optimization feature of the Android version of React Native is for views which only contribute to the layout to not have a native view, only their layout properties are propagated to their children views. This optimization is to provide stability in deep view hierarchies for React Native and gis therefore enabled by default. Should you depend on a view being present or internal tests incorrectly detect a view is layout only it will be necessary to turn off this behavior. To do this, set `collapsable` to false as in this example: ``` ... From edb8cb2536b7932a4b4d7a4b542a5d67bd2c5d64 Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Wed, 16 Sep 2015 19:53:26 +0100 Subject: [PATCH 13/15] Update KnownIssues.md --- docs/KnownIssues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/KnownIssues.md b/docs/KnownIssues.md index ab82bc70c9b92c..778eeab40a6aa5 100644 --- a/docs/KnownIssues.md +++ b/docs/KnownIssues.md @@ -37,7 +37,7 @@ Pasteboard Alert ``` -### Props that are only supported on one platform +### Some props are only supported on one platform There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with `@platform` in JS docs and have a platform badge on the website. See e.g. [Image](https://facebook.github.io/react-native/docs/image.html). ### Publishing modules on Android From b1b81cfca96d1bec185dc3fa4d2579d10692b30d Mon Sep 17 00:00:00 2001 From: Martin Konicek Date: Wed, 16 Sep 2015 19:54:49 +0100 Subject: [PATCH 14/15] Update KnownIssues.md --- docs/KnownIssues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/KnownIssues.md b/docs/KnownIssues.md index 778eeab40a6aa5..c981825604feef 100644 --- a/docs/KnownIssues.md +++ b/docs/KnownIssues.md @@ -38,7 +38,7 @@ Alert ``` ### Some props are only supported on one platform -There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with `@platform` in JS docs and have a platform badge on the website. See e.g. [Image](https://facebook.github.io/react-native/docs/image.html). +There are properties that work on one platform only, either because they can inherently only be supported on that platform or because they haven't been implemented on the other platforms yet. All of these are annotated with `@platform` in JS docs and have a small badge next to them on the website. See e.g. [Image](https://facebook.github.io/react-native/docs/image.html). ### Publishing modules on Android From edfb024d2878df4f1a014dc37b6523fc3869972e Mon Sep 17 00:00:00 2001 From: Christopher Chedeau Date: Wed, 16 Sep 2015 12:58:45 -0700 Subject: [PATCH 15/15] Fix more tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: beeper node modules has a `return` statement outside of a function which doesn't parse. To fix it, we mock it. Also, setupEnvPolyfills is no longer being used. Closes https://github.com/facebook/react-native/pull/2770 Reviewed By: @​svcscm Differential Revision: D2448882 Pulled By: @vjeux --- local-cli/__mocks__/beeper.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 local-cli/__mocks__/beeper.js diff --git a/local-cli/__mocks__/beeper.js b/local-cli/__mocks__/beeper.js new file mode 100644 index 00000000000000..93d96304b0245a --- /dev/null +++ b/local-cli/__mocks__/beeper.js @@ -0,0 +1,5 @@ +// beeper@1.1.0 has a return statement outside of a function +// and therefore doesn't parse. Let's mock it so that we can +// run the tests. + +module.exports = function () {};