From bcac6e7d39fbc0d6132fca77d6057f3d6d9da4e0 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 18 Nov 2016 04:59:40 -0800 Subject: [PATCH] Cleanup RCTSourceCode Reviewed By: mmmulani Differential Revision: D4124428 fbshipit-source-id: 0db5bfd5897c37c11374fe90516ac7aeb2ae5d53 --- Examples/UIExplorer/UIExplorer/AppDelegate.m | 4 ++-- React/Base/RCTBatchedBridge.m | 4 ---- React/Base/RCTJavaScriptLoader.m | 1 - React/Base/RCTRootView.m | 1 - React/Executors/RCTJSCExecutor.mm | 2 -- React/Modules/RCTDevMenu.m | 16 +++++----------- React/Modules/RCTSourceCode.h | 2 -- React/Modules/RCTSourceCode.m | 8 +++----- 8 files changed, 10 insertions(+), 28 deletions(-) diff --git a/Examples/UIExplorer/UIExplorer/AppDelegate.m b/Examples/UIExplorer/UIExplorer/AppDelegate.m index 75a24b172..cd5ec8647 100644 --- a/Examples/UIExplorer/UIExplorer/AppDelegate.m +++ b/Examples/UIExplorer/UIExplorer/AppDelegate.m @@ -55,8 +55,8 @@ - (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge { - NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/UIExplorer/js/UIExplorerApp.ios" fallbackResource:nil]; - + NSURL *jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"Examples/UIExplorer/js/UIExplorerApp.ios" + fallbackResource:nil]; if (!getenv("CI_USE_PACKAGER")) { jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; } diff --git a/React/Base/RCTBatchedBridge.m b/React/Base/RCTBatchedBridge.m index 80df61ff7..a7de971ae 100644 --- a/React/Base/RCTBatchedBridge.m +++ b/React/Base/RCTBatchedBridge.m @@ -21,7 +21,6 @@ #import "RCTModuleData.h" #import "RCTPerformanceLogger.h" #import "RCTProfile.h" -#import "RCTSourceCode.h" #import "RCTUtils.h" #import "RCTRedBox.h" #import "RCTDevLoadingView.h" @@ -497,9 +496,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id)dele return; } - RCTSourceCode *sourceCodeModule = [self moduleForClass:[RCTSourceCode class]]; - sourceCodeModule.scriptURL = self.bundleURL; - [self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:^(NSError *loadError) { if (!self->_valid) { return; diff --git a/React/Base/RCTJavaScriptLoader.m b/React/Base/RCTJavaScriptLoader.m index 306677a43..f308421f1 100755 --- a/React/Base/RCTJavaScriptLoader.m +++ b/React/Base/RCTJavaScriptLoader.m @@ -12,7 +12,6 @@ #import "RCTBridge.h" #import "RCTConvert.h" #import "RCTJSCWrapper.h" -#import "RCTSourceCode.h" #import "RCTUtils.h" #import "RCTPerformanceLogger.h" #import "RCTMultipartDataTask.h" diff --git a/React/Base/RCTRootView.m b/React/Base/RCTRootView.m index 0b9f5b0e3..8aaed2900 100644 --- a/React/Base/RCTRootView.m +++ b/React/Base/RCTRootView.m @@ -20,7 +20,6 @@ #import "RCTKeyCommands.h" #import "RCTLog.h" #import "RCTPerformanceLogger.h" -#import "RCTSourceCode.h" #import "RCTTouchHandler.h" #import "RCTUIManager.h" #import "RCTUtils.h" diff --git a/React/Executors/RCTJSCExecutor.mm b/React/Executors/RCTJSCExecutor.mm index b1ce0ee8f..551358ab2 100644 --- a/React/Executors/RCTJSCExecutor.mm +++ b/React/Executors/RCTJSCExecutor.mm @@ -27,8 +27,6 @@ #import "RCTPerformanceLogger.h" #import "RCTUtils.h" #import "RCTJSCProfiler.h" -#import "RCTRedBox.h" -#import "RCTSourceCode.h" #import "RCTJSCWrapper.h" #import "RCTJSCErrorHandling.h" #import "JSCSamplingProfiler.h" diff --git a/React/Modules/RCTDevMenu.m b/React/Modules/RCTDevMenu.m index dbc49486d..a4ef85c94 100644 --- a/React/Modules/RCTDevMenu.m +++ b/React/Modules/RCTDevMenu.m @@ -19,7 +19,6 @@ #import "RCTLog.h" #import "RCTProfile.h" #import "RCTRootView.h" -#import "RCTSourceCode.h" #import "RCTUtils.h" #import "RCTWebSocketProxy.h" @@ -376,17 +375,12 @@ RCT_EXPORT_MODULE() _jsLoaded = YES; // Check if live reloading is available - _liveReloadURL = nil; - RCTSourceCode *sourceCodeModule = [_bridge moduleForClass:[RCTSourceCode class]]; - if (!sourceCodeModule.scriptURL) { - if (!sourceCodeModule) { - RCTLogWarn(@"RCTSourceCode module not found"); - } else if (!RCTRunningInTestEnvironment()) { - RCTLogWarn(@"RCTSourceCode module scriptURL has not been set"); - } - } else if (!sourceCodeModule.scriptURL.fileURL) { + NSURL *scriptURL = _bridge.bundleURL; + if (![scriptURL isFileURL]) { // Live reloading is disabled when running from bundled JS file - _liveReloadURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL]; + _liveReloadURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:scriptURL]; + } else { + _liveReloadURL = nil; } dispatch_async(dispatch_get_main_queue(), ^{ diff --git a/React/Modules/RCTSourceCode.h b/React/Modules/RCTSourceCode.h index 4e2ef845c..bd39a01ec 100644 --- a/React/Modules/RCTSourceCode.h +++ b/React/Modules/RCTSourceCode.h @@ -13,6 +13,4 @@ @interface RCTSourceCode : NSObject -@property (nonatomic, copy) NSURL *scriptURL; - @end diff --git a/React/Modules/RCTSourceCode.m b/React/Modules/RCTSourceCode.m index df81bb89a..f14a7367f 100644 --- a/React/Modules/RCTSourceCode.m +++ b/React/Modules/RCTSourceCode.m @@ -9,10 +9,7 @@ #import "RCTSourceCode.h" -#import "RCTDefines.h" -#import "RCTAssert.h" #import "RCTBridge.h" -#import "RCTUtils.h" @implementation RCTSourceCode @@ -22,8 +19,9 @@ RCT_EXPORT_MODULE() - (NSDictionary *)constantsToExport { - NSString *URL = self.bridge.bundleURL.absoluteString ?: @""; - return @{@"scriptURL": URL}; + return @{ + @"scriptURL": self.bridge.bundleURL.absoluteString ?: @"" + }; } @end