Skip to content

Commit

Permalink
Persist Debugger and Runtime domain state for Hermes CDPAgent (#43443)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #43443

TSIA

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D54712525

fbshipit-source-id: 34b1804088f15a2524607ebce81bceb82170feab
  • Loading branch information
motiz88 authored and facebook-github-bot committed Mar 12, 2024
1 parent d2c5db5 commit 1150f21
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class HermesRuntimeAgentDelegateNew::Impl final : public RuntimeAgentDelegate {
if (sessionState.isLogDomainEnabled) {
sendHermesIntegrationDescription();
}
if (sessionState.isRuntimeDomainEnabled) {
hermes_->enableRuntimeDomain();
}
if (sessionState.isDebuggerDomainEnabled) {
hermes_->enableDebuggerDomain();
}
}

bool handleRequest(const cdp::PreparsedRequest& req) override {
Expand Down
10 changes: 10 additions & 0 deletions packages/react-native/ReactCommon/jsinspector-modern/HostAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) {
} else if (req.method == "Runtime.disable") {
sessionState_.isRuntimeDomainEnabled = false;

shouldSendOKResponse = true;
isFinishedHandlingRequest = false;
} else if (req.method == "Debugger.enable") {
sessionState_.isDebuggerDomainEnabled = true;

shouldSendOKResponse = true;
isFinishedHandlingRequest = false;
} else if (req.method == "Debugger.disable") {
sessionState_.isDebuggerDomainEnabled = false;

shouldSendOKResponse = true;
isFinishedHandlingRequest = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace facebook::react::jsinspector_modern {
struct SessionState {
public:
// TODO: Generalise this to arbitrary domains
bool isDebuggerDomainEnabled{false};
bool isLogDomainEnabled{false};
bool isRuntimeDomainEnabled{false};

Expand Down

0 comments on commit 1150f21

Please sign in to comment.