Path: blob/main/src/vscode-dts/vscode.proposed.browser.d.ts
13379 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45declare module 'vscode' {67// @kycutler https://github.com/microsoft/vscode/issues/30031989/**10* An integrated browser page displayed in an editor tab.11*/12export interface BrowserTab {13/** The current URL of the page. */14readonly url: string;1516/** The current page title. */17readonly title: string;1819/** The page icon (favicon or a default globe icon). */20readonly icon: IconPath;2122/** Create a new CDP session that exposes this browser tab. */23startCDPSession(): Thenable<BrowserCDPSession>;2425/** Close this browser tab. */26close(): Thenable<void>;27}2829/**30* A CDP (Chrome DevTools Protocol) session that provides a bidirectional message channel.31*32* Create a session via {@link BrowserTab.startCDPSession}.33*/34export interface BrowserCDPSession {35/** Fires when a CDP message is received from an attached target. */36readonly onDidReceiveMessage: Event<unknown>;3738/** Fires when this session is closed. */39readonly onDidClose: Event<void>;4041/** Send a CDP request message to an attached target. */42sendMessage(message: unknown): Thenable<void>;4344/** Close this session and detach all targets. */45close(): Thenable<void>;46}4748/** Options for {@link window.openBrowserTab}. */49export interface BrowserTabShowOptions {50/**51* The view column to show the browser in. Defaults to {@link ViewColumn.Active}.52* Use {@linkcode ViewColumn.Beside} to open next to the current editor.53*/54viewColumn?: ViewColumn;5556/** When `true`, the browser tab will not take focus. */57preserveFocus?: boolean;5859/** When `true`, the browser tab will open in the background. */60background?: boolean;61}6263export namespace window {64/** The currently open browser tabs. */65export const browserTabs: readonly BrowserTab[];6667/** Fires when a browser tab is opened. */68export const onDidOpenBrowserTab: Event<BrowserTab>;6970/** Fires when a browser tab is closed. */71export const onDidCloseBrowserTab: Event<BrowserTab>;7273/** The currently active browser tab. */74export const activeBrowserTab: BrowserTab | undefined;7576/** Fires when {@link activeBrowserTab} changes. */77export const onDidChangeActiveBrowserTab: Event<BrowserTab | undefined>;7879/** Fires when a browser tab's state (url, title, or icon) changes. */80export const onDidChangeBrowserTabState: Event<BrowserTab>;8182/**83* Open a browser tab at the given URL.84*85* @param url The URL to navigate to.86* @param options Controls where and how the browser tab is shown.87* @returns The {@link BrowserTab} representing the opened page.88*/89export function openBrowserTab(url: string, options?: BrowserTabShowOptions): Thenable<BrowserTab>;90}91}929394