mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add ReactNativeApplication CDP domain (#44894)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/44894 Adds the new CDP domain `ReactNativeApplication`, with the following messages: - `ReactNativeApplication.enable` (method) — Sent by the connected frontend to enable features under this domain. - `ReactNativeApplication.metadataUpdated` (event) — Sent by the backend containing a metadata object about the host. We intend to use this for displaying richer information in the debugger frontend, such as device information and React Native version. Changelog: [General][Added] - Add `ReactNativeApplication.[enable,metadataUpdated]` CDP messages for reading host metadata Reviewed By: motiz88 Differential Revision: D58288490 fbshipit-source-id: 02384f0cdfaa35f1c5de9fad7ddd5aab483b2768
This commit is contained in:
committed by
Facebook GitHub Bot
parent
28ded2c6cd
commit
aced4072cf
@@ -129,6 +129,20 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) {
|
||||
sendFuseboxNotice();
|
||||
}
|
||||
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = true;
|
||||
} else if (req.method == "ReactNativeApplication.enable") {
|
||||
sessionState_.isReactNativeApplicationDomainEnabled = true;
|
||||
|
||||
frontendChannel_(cdp::jsonNotification(
|
||||
"ReactNativeApplication.metadataUpdated",
|
||||
hostMetadataToDynamic(hostMetadata_)));
|
||||
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = true;
|
||||
} else if (req.method == "ReactNativeApplication.disable") {
|
||||
sessionState_.isReactNativeApplicationDomainEnabled = false;
|
||||
|
||||
shouldSendOKResponse = true;
|
||||
isFinishedHandlingRequest = true;
|
||||
} else if (req.method == "Tracing.start") {
|
||||
|
||||
@@ -220,4 +220,12 @@ bool HostTargetController::decrementPauseOverlayCounter() {
|
||||
return true;
|
||||
}
|
||||
|
||||
folly::dynamic hostMetadataToDynamic(const HostTargetMetadata& metadata) {
|
||||
folly::dynamic result = folly::dynamic::object;
|
||||
|
||||
result["integrationName"] = metadata.integrationName.value_or(nullptr);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace facebook::react::jsinspector_modern
|
||||
|
||||
@@ -251,4 +251,6 @@ class JSINSPECTOR_EXPORT HostTarget
|
||||
friend class HostTargetController;
|
||||
};
|
||||
|
||||
folly::dynamic hostMetadataToDynamic(const HostTargetMetadata& metadata);
|
||||
|
||||
} // namespace facebook::react::jsinspector_modern
|
||||
|
||||
@@ -22,6 +22,7 @@ struct SessionState {
|
||||
// TODO: Generalise this to arbitrary domains
|
||||
bool isDebuggerDomainEnabled{false};
|
||||
bool isLogDomainEnabled{false};
|
||||
bool isReactNativeApplicationDomainEnabled{false};
|
||||
bool isRuntimeDomainEnabled{false};
|
||||
|
||||
/**
|
||||
|
||||
@@ -332,6 +332,42 @@ TYPED_TEST(JsiIntegrationPortableTest, FuseboxSetClientMetadata) {
|
||||
})");
|
||||
}
|
||||
|
||||
TYPED_TEST(JsiIntegrationPortableTest, ReactNativeApplicationEnable) {
|
||||
this->connect();
|
||||
|
||||
this->expectMessageFromPage(JsonEq(R"({
|
||||
"id": 1,
|
||||
"result": {}
|
||||
})"));
|
||||
this->expectMessageFromPage(JsonEq(R"({
|
||||
"method": "ReactNativeApplication.metadataUpdated",
|
||||
"params": {
|
||||
"integrationName": "JsiIntegrationTest"
|
||||
}
|
||||
})"));
|
||||
|
||||
this->toPage_->sendMessage(R"({
|
||||
"id": 1,
|
||||
"method": "ReactNativeApplication.enable",
|
||||
"params": {}
|
||||
})");
|
||||
}
|
||||
|
||||
TYPED_TEST(JsiIntegrationPortableTest, ReactNativeApplicationDisable) {
|
||||
this->connect();
|
||||
|
||||
this->expectMessageFromPage(JsonEq(R"({
|
||||
"id": 1,
|
||||
"result": {}
|
||||
})"));
|
||||
|
||||
this->toPage_->sendMessage(R"({
|
||||
"id": 1,
|
||||
"method": "ReactNativeApplication.disable",
|
||||
"params": {}
|
||||
})");
|
||||
}
|
||||
|
||||
#pragma endregion // AllEngines
|
||||
#pragma region AllHermesVariants
|
||||
|
||||
|
||||
Reference in New Issue
Block a user