mirror of
https://github.com/status-im/react-native.git
synced 2025-01-11 18:14:14 +00:00
Added RCTInspectorDevServerHelper call in FBReactJSExecutor. Added UTF8StringForSourceURL
Reviewed By: javache Differential Revision: D5246399 fbshipit-source-id: 179ff0b69886c4ff71911fc7b1d3491ff4d5967d
This commit is contained in:
parent
c9a39b3bd3
commit
879edf0d05
@ -1062,19 +1062,20 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTCxxBridge enqueueApplicationScript]", nil);
|
||||
|
||||
[self _tryAndHandleError:^{
|
||||
NSString *sourceUrlStr = deriveSourceURL(url);
|
||||
if (isRAMBundle(script)) {
|
||||
[self->_performanceLogger markStartForTag:RCTPLRAMBundleLoad];
|
||||
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(url.path.UTF8String);
|
||||
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(sourceUrlStr.UTF8String);
|
||||
std::unique_ptr<const JSBigString> scriptStr = ramBundle->getStartupCode();
|
||||
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
|
||||
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
|
||||
if (self->_reactInstance) {
|
||||
self->_reactInstance->loadUnbundle(std::move(ramBundle), std::move(scriptStr),
|
||||
[[url absoluteString] UTF8String], false);
|
||||
sourceUrlStr.UTF8String, false);
|
||||
}
|
||||
} else if (self->_reactInstance) {
|
||||
self->_reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script),
|
||||
[[url absoluteString] UTF8String], false);
|
||||
sourceUrlStr.UTF8String, false);
|
||||
} else {
|
||||
throw std::logic_error("Attempt to call loadApplicationScript: on uninitialized bridge");
|
||||
}
|
||||
@ -1092,19 +1093,20 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||
- (void)executeApplicationScriptSync:(NSData *)script url:(NSURL *)url
|
||||
{
|
||||
[self _tryAndHandleError:^{
|
||||
NSString *sourceUrlStr = deriveSourceURL(url);
|
||||
if (isRAMBundle(script)) {
|
||||
[self->_performanceLogger markStartForTag:RCTPLRAMBundleLoad];
|
||||
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(url.path.UTF8String);
|
||||
auto ramBundle = std::make_unique<JSIndexedRAMBundle>(sourceUrlStr.UTF8String);
|
||||
std::unique_ptr<const JSBigString> scriptStr = ramBundle->getStartupCode();
|
||||
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
|
||||
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
|
||||
if (self->_reactInstance) {
|
||||
self->_reactInstance->loadUnbundle(std::move(ramBundle), std::move(scriptStr),
|
||||
[[url absoluteString] UTF8String], true);
|
||||
sourceUrlStr.UTF8String, true);
|
||||
}
|
||||
} else if (self->_reactInstance) {
|
||||
self->_reactInstance->loadScriptFromString(std::make_unique<NSDataBigString>(script),
|
||||
[[url absoluteString] UTF8String], true);
|
||||
sourceUrlStr.UTF8String, true);
|
||||
} else {
|
||||
throw std::logic_error("Attempt to call loadApplicationScriptSync: on uninitialized bridge");
|
||||
}
|
||||
|
@ -48,5 +48,6 @@ struct ValueEncoder<NSArray *> {
|
||||
};
|
||||
|
||||
NSError *tryAndReturnError(const std::function<void()>& func);
|
||||
NSString *deriveSourceURL(NSURL *url);
|
||||
|
||||
} }
|
||||
|
@ -133,4 +133,16 @@ NSError *tryAndReturnError(const std::function<void()>& func) {
|
||||
}
|
||||
}
|
||||
|
||||
NSString *deriveSourceURL(NSURL *url) {
|
||||
NSString *sourceUrl;
|
||||
if (url.isFileURL) {
|
||||
// Url will contain only path to resource (i.g. file:// will be removed)
|
||||
sourceUrl = url.path;
|
||||
} else {
|
||||
// Url will include protocol (e.g. http://)
|
||||
sourceUrl = url.absoluteString;
|
||||
}
|
||||
return sourceUrl ?: @"";
|
||||
}
|
||||
|
||||
} }
|
||||
|
Loading…
x
Reference in New Issue
Block a user