improve detection of inspectable JS contexts

Reviewed By: Hypuk

Differential Revision: D6578735

fbshipit-source-id: ac6a3a8bae9aef7fd3b4a036c3f154b3f6b7d80c
This commit is contained in:
Ben Nham 2017-12-18 13:19:39 -08:00 committed by Facebook Github Bot
parent 15cd98b782
commit 0673ac25f1
3 changed files with 11 additions and 16 deletions

View File

@ -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

View File

@ -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

View File

@ -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