From ec564cd13c86c34c967999b28d472321884a61ea Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Mon, 20 May 2024 14:06:50 +0100 Subject: [PATCH] Migrate FuseboxClient domain to a codegenned agent --- .../core/protocol_client/InspectorBackend.ts | 4 ++++ front_end/entrypoints/rn_fusebox/rn_fusebox.ts | 8 +------- .../generated/InspectorBackendCommands.js | 3 +++ front_end/generated/protocol-mapping.d.ts | 11 +++++++++++ front_end/generated/protocol-proxy-api.d.ts | 18 ++++++++++++++++++ front_end/generated/protocol.ts | 7 +++++++ scripts/deps/generate_protocol_resources.py | 1 + .../devtools_protocol/browser_protocol.json | 11 +++++++++++ .../devtools_protocol/react_native_domains.pdl | 12 ++++++++++++ 9 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 third_party/blink/public/devtools_protocol/react_native_domains.pdl diff --git a/front_end/core/protocol_client/InspectorBackend.ts b/front_end/core/protocol_client/InspectorBackend.ts index 30e43f6d60f..4c8926d6ac1 100644 --- a/front_end/core/protocol_client/InspectorBackend.ts +++ b/front_end/core/protocol_client/InspectorBackend.ts @@ -672,6 +672,10 @@ export class TargetBase { return this.getAgent('Fetch'); } + fuseboxClientAgent(): ProtocolProxyApi.FuseboxClientApi { + return this.getAgent('FuseboxClient'); + } + heapProfilerAgent(): ProtocolProxyApi.HeapProfilerApi { return this.getAgent('HeapProfiler'); } diff --git a/front_end/entrypoints/rn_fusebox/rn_fusebox.ts b/front_end/entrypoints/rn_fusebox/rn_fusebox.ts index 3cc9a333a96..2e803aa3c17 100644 --- a/front_end/entrypoints/rn_fusebox/rn_fusebox.ts +++ b/front_end/entrypoints/rn_fusebox/rn_fusebox.ts @@ -75,13 +75,7 @@ Host.rnPerfMetrics.entryPointLoadingStarted('rn_fusebox'); class FuseboxClientMetadataModel extends SDK.SDKModel.SDKModel { constructor(target: SDK.Target.Target) { super(target); - target.router()?.sendMessage( - target.sessionId, - 'FuseboxClient', - 'FuseboxClient.setClientMetadata' as InspectorBackend.QualifiedName, - {}, - () => {}, - ); + void target.fuseboxClientAgent().invoke_setClientMetadata(); } } diff --git a/front_end/generated/InspectorBackendCommands.js b/front_end/generated/InspectorBackendCommands.js index 5167778ffab..ce43d66ec18 100644 --- a/front_end/generated/InspectorBackendCommands.js +++ b/front_end/generated/InspectorBackendCommands.js @@ -40,6 +40,9 @@ export let InspectorBackendAPI; export function registerCommands(inspectorBackend) { +// FuseboxClient. +inspectorBackend.registerCommand("FuseboxClient.setClientMetadata", [], [], "Identifies the current client as being Fusebox. The Fusebox backend may use this knowledge to print an informational message to the console, etc. The client should send this before enabling the Runtime and Log domains."); + // Accessibility. inspectorBackend.registerEnum("Accessibility.AXValueType", {Boolean: "boolean", Tristate: "tristate", BooleanOrUndefined: "booleanOrUndefined", Idref: "idref", IdrefList: "idrefList", Integer: "integer", Node: "node", NodeList: "nodeList", Number: "number", String: "string", ComputedString: "computedString", Token: "token", TokenList: "tokenList", DomRelation: "domRelation", Role: "role", InternalRole: "internalRole", ValueUndefined: "valueUndefined"}); inspectorBackend.registerEnum("Accessibility.AXValueSourceType", {Attribute: "attribute", Implicit: "implicit", Style: "style", Contents: "contents", Placeholder: "placeholder", RelatedElement: "relatedElement"}); diff --git a/front_end/generated/protocol-mapping.d.ts b/front_end/generated/protocol-mapping.d.ts index b6dbb77f196..2f53b6f212f 100644 --- a/front_end/generated/protocol-mapping.d.ts +++ b/front_end/generated/protocol-mapping.d.ts @@ -760,6 +760,17 @@ export namespace ProtocolMapping { } export interface Commands { + /** + * Identifies the current client as being Fusebox. + * + * The Fusebox backend may use this knowledge to print an informational + * message to the console, etc. The client should send this before enabling + * the Runtime and Log domains. + */ + 'FuseboxClient.setClientMetadata': { + paramsType: []; + returnType: void; + }; /** * Disables the accessibility domain. */ diff --git a/front_end/generated/protocol-proxy-api.d.ts b/front_end/generated/protocol-proxy-api.d.ts index f1238149f95..671589f35ff 100644 --- a/front_end/generated/protocol-proxy-api.d.ts +++ b/front_end/generated/protocol-proxy-api.d.ts @@ -18,6 +18,8 @@ declare namespace ProtocolProxyApi { export type ProtocolDomainName = keyof ProtocolApi; export interface ProtocolApi { + FuseboxClient: FuseboxClientApi; + Accessibility: AccessibilityApi; Animation: AnimationApi; @@ -119,6 +121,8 @@ declare namespace ProtocolProxyApi { } export interface ProtocolDispatchers { + FuseboxClient: FuseboxClientDispatcher; + Accessibility: AccessibilityDispatcher; Animation: AnimationDispatcher; @@ -220,6 +224,20 @@ declare namespace ProtocolProxyApi { } + export interface FuseboxClientApi { + /** + * Identifies the current client as being Fusebox. + * + * The Fusebox backend may use this knowledge to print an informational + * message to the console, etc. The client should send this before enabling + * the Runtime and Log domains. + */ + invoke_setClientMetadata(): Promise; + + } + export interface FuseboxClientDispatcher { + } + export interface AccessibilityApi { /** * Disables the accessibility domain. diff --git a/front_end/generated/protocol.ts b/front_end/generated/protocol.ts index 950cfde7123..8e0e1e17a23 100644 --- a/front_end/generated/protocol.ts +++ b/front_end/generated/protocol.ts @@ -18,6 +18,13 @@ export interface ProtocolResponseWithError { type OpaqueType = {protocolOpaqueTypeTag: Tag}; type OpaqueIdentifier = RepresentationType&OpaqueType; +/** + * A React Native-specific domain pertaining to the Fusebox (React Native + * DevTools) client. + */ +export namespace FuseboxClient { +} + export namespace Accessibility { /** diff --git a/scripts/deps/generate_protocol_resources.py b/scripts/deps/generate_protocol_resources.py index 45b33812911..decf581bd74 100755 --- a/scripts/deps/generate_protocol_resources.py +++ b/scripts/deps/generate_protocol_resources.py @@ -142,6 +142,7 @@ def main(): popen([GENERATE_DEPRECATIONS_SCRIPT]) popen([CONCATENATE_PROTOCOL_SCRIPT] + [ + path.join(PROTOCOL_LOCATION, 'react_native_domains.pdl'), path.join(PROTOCOL_LOCATION, 'browser_protocol.pdl'), path.join(V8_DIRECTORY_PATH, 'include', 'js_protocol.pdl'), # output_file diff --git a/third_party/blink/public/devtools_protocol/browser_protocol.json b/third_party/blink/public/devtools_protocol/browser_protocol.json index a3ba2e39c83..3aa3457039a 100644 --- a/third_party/blink/public/devtools_protocol/browser_protocol.json +++ b/third_party/blink/public/devtools_protocol/browser_protocol.json @@ -4,6 +4,17 @@ "minor": "3" }, "domains": [ + { + "domain": "FuseboxClient", + "description": "A React Native-specific domain pertaining to the Fusebox (React Native\nDevTools) client.", + "experimental": true, + "commands": [ + { + "name": "setClientMetadata", + "description": "Identifies the current client as being Fusebox.\n\nThe Fusebox backend may use this knowledge to print an informational\nmessage to the console, etc. The client should send this before enabling\nthe Runtime and Log domains." + } + ] + }, { "domain": "Accessibility", "experimental": true, diff --git a/third_party/blink/public/devtools_protocol/react_native_domains.pdl b/third_party/blink/public/devtools_protocol/react_native_domains.pdl new file mode 100644 index 00000000000..b7af5cf1202 --- /dev/null +++ b/third_party/blink/public/devtools_protocol/react_native_domains.pdl @@ -0,0 +1,12 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. + +# A React Native-specific domain pertaining to the Fusebox (React Native +# DevTools) client. +experimental domain FuseboxClient + + # Identifies the current client as being Fusebox. + # + # The Fusebox backend may use this knowledge to print an informational + # message to the console, etc. The client should send this before enabling + # the Runtime and Log domains. + command setClientMetadata