improve detection of inspectable JS contexts
Reviewed By: Hypuk Differential Revision: D6578735 fbshipit-source-id: ac6a3a8bae9aef7fd3b4a036c3f154b3f6b7d80c
This commit is contained in:
parent
15cd98b782
commit
0673ac25f1
|
@ -10,8 +10,7 @@
|
|||
|
||||
@interface RCTInspectorDevServerHelper : NSObject
|
||||
|
||||
+ (void)connectForContext:(JSGlobalContextRef)context
|
||||
withBundleURL:(NSURL *)bundleURL;
|
||||
+ (void)connectWithBundleURL:(NSURL *)bundleURL;
|
||||
+ (void)disableDebugger;
|
||||
+ (void)attachDebugger:(NSString *)owner
|
||||
withBundleURL:(NSURL *)bundleURL
|
||||
|
|
|
@ -104,13 +104,8 @@ static void displayErrorAlert(UIViewController *view, NSString *message) {
|
|||
sendEventToAllConnections(kDebuggerMsgDisable);
|
||||
}
|
||||
|
||||
+ (void)connectForContext:(JSGlobalContextRef)context
|
||||
withBundleURL:(NSURL *)bundleURL
|
||||
+ (void)connectWithBundleURL:(NSURL *)bundleURL
|
||||
{
|
||||
if (!isCustomJSCPtr(context)) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSURL *inspectorURL = getInspectorDeviceUrl(bundleURL);
|
||||
|
||||
// Note, using a static dictionary isn't really the greatest design, but
|
||||
|
|
|
@ -195,12 +195,13 @@ RCT_EXPORT_MODULE()
|
|||
// finished with its initialisation. But it does finish by the time it
|
||||
// relinquishes control of the main thread, so only queue on the JS thread
|
||||
// after the current main thread operation is done.
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[bridge dispatchBlock:^{
|
||||
[RCTInspectorDevServerHelper connectForContext:bridge.jsContextRef
|
||||
withBundleURL:bridge.bundleURL];
|
||||
} queue:RCTJSThread];
|
||||
});
|
||||
if (self.isNuclideDebuggingAvailable) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[bridge dispatchBlock:^{
|
||||
[RCTInspectorDevServerHelper connectWithBundleURL:bridge.bundleURL];
|
||||
} queue:RCTJSThread];
|
||||
});
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -256,10 +257,10 @@ static void pokeSamplingProfiler(RCTBridge *const bridge, RCTPackagerClientRespo
|
|||
- (BOOL)isNuclideDebuggingAvailable
|
||||
{
|
||||
#if RCT_ENABLE_INSPECTOR
|
||||
return facebook::react::isCustomJSCPtr(_bridge.jsContextRef);
|
||||
return _bridge.isInspectable;
|
||||
#else
|
||||
return false;
|
||||
#endif //RCT_ENABLE_INSPECTOR
|
||||
#endif // RCT_ENABLE_INSPECTOR
|
||||
}
|
||||
|
||||
- (BOOL)isRemoteDebuggingAvailable
|
||||
|
|
Loading…
Reference in New Issue