Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vscode-dts/vscode.proposed.browser.d.ts
13379 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
declare module 'vscode' {
7
8
// @kycutler https://github.com/microsoft/vscode/issues/300319
9
10
/**
11
* An integrated browser page displayed in an editor tab.
12
*/
13
export interface BrowserTab {
14
/** The current URL of the page. */
15
readonly url: string;
16
17
/** The current page title. */
18
readonly title: string;
19
20
/** The page icon (favicon or a default globe icon). */
21
readonly icon: IconPath;
22
23
/** Create a new CDP session that exposes this browser tab. */
24
startCDPSession(): Thenable<BrowserCDPSession>;
25
26
/** Close this browser tab. */
27
close(): Thenable<void>;
28
}
29
30
/**
31
* A CDP (Chrome DevTools Protocol) session that provides a bidirectional message channel.
32
*
33
* Create a session via {@link BrowserTab.startCDPSession}.
34
*/
35
export interface BrowserCDPSession {
36
/** Fires when a CDP message is received from an attached target. */
37
readonly onDidReceiveMessage: Event<unknown>;
38
39
/** Fires when this session is closed. */
40
readonly onDidClose: Event<void>;
41
42
/** Send a CDP request message to an attached target. */
43
sendMessage(message: unknown): Thenable<void>;
44
45
/** Close this session and detach all targets. */
46
close(): Thenable<void>;
47
}
48
49
/** Options for {@link window.openBrowserTab}. */
50
export interface BrowserTabShowOptions {
51
/**
52
* The view column to show the browser in. Defaults to {@link ViewColumn.Active}.
53
* Use {@linkcode ViewColumn.Beside} to open next to the current editor.
54
*/
55
viewColumn?: ViewColumn;
56
57
/** When `true`, the browser tab will not take focus. */
58
preserveFocus?: boolean;
59
60
/** When `true`, the browser tab will open in the background. */
61
background?: boolean;
62
}
63
64
export namespace window {
65
/** The currently open browser tabs. */
66
export const browserTabs: readonly BrowserTab[];
67
68
/** Fires when a browser tab is opened. */
69
export const onDidOpenBrowserTab: Event<BrowserTab>;
70
71
/** Fires when a browser tab is closed. */
72
export const onDidCloseBrowserTab: Event<BrowserTab>;
73
74
/** The currently active browser tab. */
75
export const activeBrowserTab: BrowserTab | undefined;
76
77
/** Fires when {@link activeBrowserTab} changes. */
78
export const onDidChangeActiveBrowserTab: Event<BrowserTab | undefined>;
79
80
/** Fires when a browser tab's state (url, title, or icon) changes. */
81
export const onDidChangeBrowserTabState: Event<BrowserTab>;
82
83
/**
84
* Open a browser tab at the given URL.
85
*
86
* @param url The URL to navigate to.
87
* @param options Controls where and how the browser tab is shown.
88
* @returns The {@link BrowserTab} representing the opened page.
89
*/
90
export function openBrowserTab(url: string, options?: BrowserTabShowOptions): Thenable<BrowserTab>;
91
}
92
}
93
94