diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index 4d61b9e0cdb57f..9a5fa5cd1f749d 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -171,6 +171,11 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); */ @property (nonatomic, strong, readonly) NSURL *bundleURL; +/** + * URL of the original script (not necessarily loaded) of the bridge. + */ +@property (nonatomic, strong, readonly) NSURL *bundledSourceURL; + /** * The class of the executor currently being used. Changes to this value will * take effect after the bridge is reloaded. diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index bdf741008f6a52..b69ea1d9fd5ae3 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -329,6 +329,11 @@ - (void)setUp // Sanitize the bundle URL _bundleURL = [RCTConvert NSURL:_bundleURL.absoluteString]; + if ([self.delegate respondsToSelector:@selector(bundledSourceURLForBridge:)]) { + _bundledSourceURL = [self.delegate bundledSourceURLForBridge:self]; + _bundledSourceURL = [RCTConvert NSURL:_bundledSourceURL.absoluteString]; + } + self.batchedBridge = [[bridgeClass alloc] initWithParentBridge:self]; [self.batchedBridge start]; diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index e0af63b2533422..aeb75c70ac85b7 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -175,10 +175,11 @@ @implementation RCTCxxBridge std::shared_ptr _reactInstance; } +@synthesize bridgeDescription = _bridgeDescription; @synthesize loading = _loading; -@synthesize valid = _valid; +@synthesize bundledSourceURL = _bundledSourceURL; @synthesize performanceLogger = _performanceLogger; -@synthesize bridgeDescription = _bridgeDescription; +@synthesize valid = _valid; + (void)initialize { @@ -207,6 +208,9 @@ - (instancetype)initWithParentBridge:(RCTBridge *)bridge launchOptions:bridge.launchOptions])) { _parentBridge = bridge; _performanceLogger = [bridge performanceLogger]; + if ([bridge.delegate respondsToSelector:@selector(bundledSourceURLForBridge:)]) { + _bundledSourceURL = [bridge.delegate bundledSourceURLForBridge:bridge]; + } registerPerformanceLoggerHooks(_performanceLogger); diff --git a/React/Modules/RCTSourceCode.m b/React/Modules/RCTSourceCode.m index 21661fa3f78987..aab1692010f96b 100644 --- a/React/Modules/RCTSourceCode.m +++ b/React/Modules/RCTSourceCode.m @@ -25,7 +25,8 @@ + (BOOL)requiresMainQueueSetup - (NSDictionary *)constantsToExport { return @{ - @"scriptURL": self.bridge.bundleURL.absoluteString ?: @"" + @"scriptURL": self.bridge.bundleURL.absoluteString ?: @"", + @"bundledScriptURL": self.bridge.bundledSourceURL.absoluteString ?: @"" }; }