1- import * as Common from '../common/common.js' ;
2- import * as Platform from '../platform/platform.js' ;
3- import * as Root from '../root/root.js' ;
4- import { type AidaClientResult , type AidaCodeCompleteResult , type CanShowSurveyResult , type ChangeEvent , type ClickEvent , type ContextMenuDescriptor , type DispatchHttpRequestRequest , type DispatchHttpRequestResult , type DoAidaConversationResult , type DragEvent , type EnumeratedHistogram , type EventTypes , type ExtensionDescriptor , type FunctionCallEvent , type HoverEvent , type ImpressionEvent , type InspectorFrontendHostAPI , type KeyDownEvent , type LoadNetworkResourceResult , type ResizeEvent , type SettingAccessEvent , type ShowSurveyResult , type SyncInformation } from './InspectorFrontendHostAPI.js' ;
5- /**
6- * The `InspectorFrontendHostStub` is a stub interface used the frontend is loaded like a webpage. Examples:
7- * - devtools://devtools/bundled/devtools_app.html
8- * - https://chrome-devtools-frontend.appspot.com/serve_rev/@030cc140435b0152645522b9864b75cac6c0a854/worker_app.html
9- * - http://localhost:9222/devtools/inspector.html?ws=localhost:9222/devtools/page/xTARGET_IDx
10- *
11- * When the frontend runs within the native embedder, then the InspectorFrontendHostAPI methods are provided
12- * by devtools_compatibility.js. Those leverage `DevToolsAPI.sendMessageToEmbedder()` which match up with
13- * the embedder API defined here: https://source.chromium.org/search?q=f:devtools%20f:dispatcher%20f:cc%20symbol:CreateForDevToolsFrontend&sq=&ss=chromium%2Fchromium%2Fsrc
14- * The native implementations live in devtools_ui_bindings.cc: https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/devtools/devtools_ui_bindings.cc
15- */
16- export declare class InspectorFrontendHostStub implements InspectorFrontendHostAPI {
17- #private;
18- /**
19- * Injected bellow in both stub and normal runs via:
20- * ```ts
21- * InspectorFrontendHostInstance.events = new Common.ObjectWrapper.ObjectWrapper();
22- * ```
23- */
24- events : Common . EventTarget . EventTarget < EventTypes > ;
25- recordedCountHistograms : Array < {
26- histogramName : string ;
27- sample : number ;
28- min : number ;
29- exclusiveMax : number ;
30- bucketSize : number ;
31- } > ;
32- recordedEnumeratedHistograms : Array < {
33- actionName : EnumeratedHistogram ;
34- actionCode : number ;
35- } > ;
36- recordedPerformanceHistograms : Array < {
37- histogramName : string ;
38- duration : number ;
39- } > ;
40- constructor ( ) ;
41- platform ( ) : string ;
42- loadCompleted ( ) : void ;
43- bringToFront ( ) : void ;
44- closeWindow ( ) : void ;
45- setIsDocked ( _isDocked : boolean , callback : ( ) => void ) : void ;
46- showSurvey ( _trigger : string , callback : ( arg0 : ShowSurveyResult ) => void ) : void ;
47- canShowSurvey ( _trigger : string , callback : ( arg0 : CanShowSurveyResult ) => void ) : void ;
48- /**
49- * Requests inspected page to be placed atop of the inspector frontend with specified bounds.
50- */
51- setInspectedPageBounds ( _bounds : {
52- x : number ;
53- y : number ;
54- width : number ;
55- height : number ;
56- } ) : void ;
57- inspectElementCompleted ( ) : void ;
58- setInjectedScriptForOrigin ( _origin : string , _script : string ) : void ;
59- inspectedURLChanged ( url : Platform . DevToolsPath . UrlString ) : void ;
60- copyText ( text : string | null | undefined ) : void ;
61- openInNewTab ( url : Platform . DevToolsPath . UrlString ) : void ;
62- openSearchResultsInNewTab ( _query : string ) : void ;
63- showItemInFolder ( _fileSystemPath : Platform . DevToolsPath . RawPathString ) : void ;
64- save ( url : Platform . DevToolsPath . RawPathString | Platform . DevToolsPath . UrlString , content : string , _forceSaveAs : boolean , isBase64 : boolean ) : void ;
65- append ( url : Platform . DevToolsPath . RawPathString | Platform . DevToolsPath . UrlString , content : string ) : void ;
66- close ( url : Platform . DevToolsPath . RawPathString | Platform . DevToolsPath . UrlString ) : void ;
67- sendMessageToBackend ( _message : string ) : void ;
68- recordCountHistogram ( histogramName : string , sample : number , min : number , exclusiveMax : number , bucketSize : number ) : void ;
69- recordEnumeratedHistogram ( actionName : EnumeratedHistogram , actionCode : number , _bucketSize : number ) : void ;
70- recordPerformanceHistogram ( histogramName : string , duration : number ) : void ;
71- recordUserMetricsAction ( _umaName : string ) : void ;
72- recordNewBadgeUsage ( _featureName : string ) : void ;
73- connectAutomaticFileSystem ( _fileSystemPath : Platform . DevToolsPath . RawPathString , _fileSystemUUID : string , _addIfMissing : boolean , callback : ( result : {
74- success : boolean ;
75- } ) => void ) : void ;
76- disconnectAutomaticFileSystem ( _fileSystemPath : Platform . DevToolsPath . RawPathString ) : void ;
77- requestFileSystems ( ) : void ;
78- addFileSystem ( _type ?: string ) : void ;
79- removeFileSystem ( _fileSystemPath : Platform . DevToolsPath . RawPathString ) : void ;
80- isolatedFileSystem ( _fileSystemId : string , _registeredName : string ) : FileSystem | null ;
81- loadNetworkResource ( url : string , _headers : string , streamId : number , callback : ( arg0 : LoadNetworkResourceResult ) => void ) : void ;
82- registerPreference ( _name : string , _options : {
83- synced ?: boolean ;
84- } ) : void ;
85- getPreferences ( callback : ( arg0 : Record < string , string > ) => void ) : void ;
86- getPreference ( name : string , callback : ( arg0 : string ) => void ) : void ;
87- setPreference ( name : string , value : string ) : void ;
88- removePreference ( name : string ) : void ;
89- clearPreferences ( ) : void ;
90- getSyncInformation ( callback : ( arg0 : SyncInformation ) => void ) : void ;
91- getHostConfig ( callback : ( hostConfig : Root . Runtime . HostConfig ) => void ) : void ;
92- upgradeDraggedFileSystemPermissions ( _fileSystem : FileSystem ) : void ;
93- indexPath ( _requestId : number , _fileSystemPath : Platform . DevToolsPath . RawPathString , _excludedFolders : string ) : void ;
94- stopIndexing ( _requestId : number ) : void ;
95- searchInPath ( _requestId : number , _fileSystemPath : Platform . DevToolsPath . RawPathString , _query : string ) : void ;
96- zoomFactor ( ) : number ;
97- zoomIn ( ) : void ;
98- zoomOut ( ) : void ;
99- resetZoom ( ) : void ;
100- setWhitelistedShortcuts ( _shortcuts : string ) : void ;
101- setEyeDropperActive ( _active : boolean ) : void ;
102- showCertificateViewer ( _certChain : string [ ] ) : void ;
103- reattach ( _callback : ( ) => void ) : void ;
104- readyForTest ( ) : void ;
105- connectionReady ( ) : void ;
106- setOpenNewWindowForPopups ( _value : boolean ) : void ;
107- setDevicesDiscoveryConfig ( _config : Adb . Config ) : void ;
108- setDevicesUpdatesEnabled ( _enabled : boolean ) : void ;
109- openRemotePage ( _browserId : string , _url : string ) : void ;
110- openNodeFrontend ( ) : void ;
111- showContextMenuAtPoint ( _x : number , _y : number , _items : ContextMenuDescriptor [ ] , _document : Document ) : void ;
112- /**
113- * Think of **Hosted mode** as "non-embedded" mode; you can see a devtools frontend URL as the tab's URL. It's an atypical way that DevTools is run.
114- * Whereas in **Non-hosted** (aka "embedded"), DevTools is embedded and fully dockable. It's the common way DevTools is run.
115- *
116- * **Hosted mode** == we're using the `InspectorFrontendHostStub`. impl. (@see `InspectorFrontendHostStub` class comment)
117- * Whereas with **non-hosted** mode, native `DevToolsEmbedderMessageDispatcher` is used for CDP and more. `globalThis.DevToolsAPI` is present.
118- *
119- * Relationships to other signals:
120- * - _Connection_: Hosted-ness does not indicate whether the frontend is _connected to a valid CDP target_.
121- * - _Dockability_: Being _"dockable"_ (aka `canDock`) is typically aligned but technically orthogonal.
122- * - _URL scheme_: If the main frame's URL scheme is `devtools://`, it's non-hosted.
123- *
124- * | Example case | Mode | Example devtools |
125- * | :------------------------------------------ | :------------- | :---------------------------------------------------------------------------- |
126- * | tab URL: `devtools://…` | **NOT Hosted** | `devtools://devtools/bundled/devtools_app.html?targetType=tab&...` |
127- * | tab URL: `devtools://…?ws=…` | **NOT Hosted** | `devtools://devtools/bundled/devtools_app.html?ws=localhost:9228/...` |
128- * | tab URL: `devtools://…` but no connection | **NOT Hosted** | `devtools://devtools/bundled/trace_app.html` |
129- * | tab URL: `https://…` but no connection | **Hosted** | `https://chrome-devtools-frontend.appspot.com/serve_rev/@.../trace_app.html` |
130- * | tab URL: `http://…?ws=` (connected) | **Hosted** | `http://localhost:9222/devtools/inspector.html?ws=localhost:9222/...` |
131- */
132- isHostedMode ( ) : boolean ;
133- setAddExtensionCallback ( _callback : ( arg0 : ExtensionDescriptor ) => void ) : void ;
134- initialTargetId ( ) : Promise < string | null > ;
135- doAidaConversation ( _request : string , _streamId : number , callback : ( result : DoAidaConversationResult ) => void ) : void ;
136- registerAidaClientEvent ( _request : string , callback : ( result : AidaClientResult ) => void ) : void ;
137- aidaCodeComplete ( _request : string , callback : ( result : AidaCodeCompleteResult ) => void ) : void ;
138- dispatchHttpRequest ( _request : DispatchHttpRequestRequest , callback : ( result : DispatchHttpRequestResult ) => void ) : void ;
139- recordImpression ( _event : ImpressionEvent ) : void ;
140- recordResize ( _event : ResizeEvent ) : void ;
141- recordClick ( _event : ClickEvent ) : void ;
142- recordHover ( _event : HoverEvent ) : void ;
143- recordDrag ( _event : DragEvent ) : void ;
144- recordChange ( _event : ChangeEvent ) : void ;
145- recordKeyDown ( _event : KeyDownEvent ) : void ;
146- recordSettingAccess ( _event : SettingAccessEvent ) : void ;
147- recordFunctionCall ( _event : FunctionCallEvent ) : void ;
1+ import { type InspectorFrontendHostAPI } from './InspectorFrontendHostAPI.js' ;
2+ import { InspectorFrontendHostStub } from './InspectorFrontendHostStub.js' ;
3+ export declare let InspectorFrontendHostInstance : InspectorFrontendHostAPI ;
4+ declare global {
5+ var InspectorFrontendHost : InspectorFrontendHostAPI ;
6+ var InspectorFrontendAPI : InspectorFrontendAPIImpl ;
1487}
149- export declare let InspectorFrontendHostInstance : InspectorFrontendHostStub ;
1508declare class InspectorFrontendAPIImpl {
1519 constructor ( ) ;
15210 private dispatch ;
@@ -157,5 +15,15 @@ declare class InspectorFrontendAPIImpl {
15715 * are valid.
15816 */
15917export type InspectorFrontendAPIImplMethods = keyof InspectorFrontendAPIImpl ;
18+ /**
19+ * Installs the provided host bindings implementation as the globally used one by DevTools.
20+ *
21+ * - In non-hosted mode this is provided by `devtools_compatibility.js`.
22+ * - In hosted mode this tends to be the {@link InspectorFrontendHostStub}.
23+ * - For the MCP server this is a custom node.js specific implementation.
24+ *
25+ * Note that missing methods will be copied over from the stub.
26+ */
27+ export declare function installInspectorFrontendHost ( instance : InspectorFrontendHostAPI ) : void ;
16028export declare function isUnderTest ( prefs ?: Record < string , string > ) : boolean ;
161- export { } ;
29+ export { InspectorFrontendHostStub } ;
0 commit comments