diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index c0f3a1a91..0a82b05e2 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -88,6 +88,11 @@ static const char *__rct_import_##module##_##method##__ = #module"."#method; url:(NSURL *)url onComplete:(RCTJavaScriptCompleteBlock)onComplete; +/** + * URL of the script that was loaded into the bridge. + */ +@property (nonatomic, copy, readonly) NSURL *bundleURL; + @property (nonatomic, strong) Class executorClass; /** diff --git a/React/Modules/RCTSourceCode.m b/React/Modules/RCTSourceCode.m index e29a05637..1b6eb842e 100644 --- a/React/Modules/RCTSourceCode.m +++ b/React/Modules/RCTSourceCode.m @@ -10,12 +10,15 @@ #import "RCTSourceCode.h" #import "RCTAssert.h" +#import "RCTBridge.h" #import "RCTUtils.h" @implementation RCTSourceCode RCT_EXPORT_MODULE() +@synthesize bridge = _bridge; + RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback failureCallback:(RCTResponseSenderBlock)failureCallback) { @@ -26,4 +29,10 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback } } +- (NSDictionary *)constantsToExport +{ + NSString *URL = [self.bridge.bundleURL absoluteString] ?: @""; + return @{@"scriptURL": URL}; +} + @end