mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
resolved: https://github.com/facebook/react-native/pull/37501 fix for https://github.com/facebook/react-native/issues/36794.
This commit is contained in:
@@ -312,7 +312,17 @@ static void attemptAsynchronousLoadOfBundleAtURL(
|
||||
return;
|
||||
}
|
||||
|
||||
RCTSource *source = RCTSourceCreate(scriptURL, data, data.length);
|
||||
// Prefer `Content-Location` as the canonical source URL, if given, or fall back to scriptURL.
|
||||
NSURL *sourceURL = scriptURL;
|
||||
NSString *contentLocationHeader = headers[@"Content-Location"];
|
||||
if (contentLocationHeader) {
|
||||
NSURL *contentLocationURL = [NSURL URLWithString:contentLocationHeader relativeToURL:scriptURL];
|
||||
if (contentLocationURL) {
|
||||
sourceURL = contentLocationURL;
|
||||
}
|
||||
}
|
||||
|
||||
RCTSource *source = RCTSourceCreate(sourceURL, data, data.length);
|
||||
parseHeaders(headers, source);
|
||||
onComplete(nil, source);
|
||||
}
|
||||
|
||||
@@ -473,6 +473,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
// Load the source asynchronously, then store it for later execution.
|
||||
dispatch_group_enter(prepareBridge);
|
||||
__block NSData *sourceCode;
|
||||
__block NSURL *sourceURL = self.bundleURL;
|
||||
|
||||
#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include(<React/RCTDevLoadingViewProtocol.h>)
|
||||
{
|
||||
@@ -488,6 +489,9 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
}
|
||||
|
||||
sourceCode = source.data;
|
||||
if (source.url) {
|
||||
sourceURL = source.url;
|
||||
}
|
||||
dispatch_group_leave(prepareBridge);
|
||||
}
|
||||
onProgress:^(RCTLoadingProgress *progressData) {
|
||||
@@ -502,7 +506,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
dispatch_group_notify(prepareBridge, dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
|
||||
RCTCxxBridge *strongSelf = weakSelf;
|
||||
if (sourceCode && strongSelf.loading) {
|
||||
[strongSelf executeSourceCode:sourceCode sync:NO];
|
||||
[strongSelf executeSourceCode:sourceCode withSourceURL:sourceURL sync:NO];
|
||||
}
|
||||
});
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
@@ -1048,7 +1052,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
[_displayLink registerModuleForFrameUpdates:module withModuleData:moduleData];
|
||||
}
|
||||
|
||||
- (void)executeSourceCode:(NSData *)sourceCode sync:(BOOL)sync
|
||||
- (void)executeSourceCode:(NSData *)sourceCode withSourceURL:(NSURL *)url sync:(BOOL)sync
|
||||
{
|
||||
// This will get called from whatever thread was actually executing JS.
|
||||
dispatch_block_t completion = ^{
|
||||
@@ -1073,12 +1077,13 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
};
|
||||
|
||||
if (sync) {
|
||||
[self executeApplicationScriptSync:sourceCode url:self.bundleURL];
|
||||
[self executeApplicationScriptSync:sourceCode url:url];
|
||||
completion();
|
||||
} else {
|
||||
[self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:completion];
|
||||
[self enqueueApplicationScript:sourceCode url:url onComplete:completion];
|
||||
}
|
||||
|
||||
// Use the original request URL here - HMRClient uses this to derive the /hot URL and entry point.
|
||||
[self.devSettings setupHMRClientWithBundleURL:self.bundleURL];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user