import { Event } from "../../../base/common/event.js"; import { VSBuffer } from "../../../base/common/buffer.js"; import { UriComponents } from "../../../base/common/uri.js"; import { IElementData } from "@codingame/monaco-vscode-chat-service-override/vscode/vs/platform/browserElements/common/browserElements"; export declare enum BrowserViewCommandId { Open = "workbench.action.browser.open", NewTab = "workbench.action.browser.newTab", QuickOpen = "workbench.action.browser.quickOpen", CloseAll = "workbench.action.browser.closeAll", CloseAllInGroup = "workbench.action.browser.closeAllInGroup", GoBack = "workbench.action.browser.goBack", GoForward = "workbench.action.browser.goForward", Reload = "workbench.action.browser.reload", HardReload = "workbench.action.browser.hardReload", FocusUrlInput = "workbench.action.browser.focusUrlInput", OpenExternal = "workbench.action.browser.openExternal", OpenSettings = "workbench.action.browser.openSettings", AddElementToChat = "workbench.action.browser.addElementToChat", AddConsoleLogsToChat = "workbench.action.browser.addConsoleLogsToChat", ToggleDevTools = "workbench.action.browser.toggleDevTools", ClearGlobalStorage = "workbench.action.browser.clearGlobalStorage", ClearWorkspaceStorage = "workbench.action.browser.clearWorkspaceStorage", ClearEphemeralStorage = "workbench.action.browser.clearEphemeralStorage", ShowFind = "workbench.action.browser.showFind", HideFind = "workbench.action.browser.hideFind", FindNext = "workbench.action.browser.findNext", FindPrevious = "workbench.action.browser.findPrevious" } export interface IBrowserViewBounds { windowId: number; x: number; y: number; width: number; height: number; zoomFactor: number; cornerRadius: number; } export interface IBrowserViewCaptureScreenshotOptions { quality?: number; screenRect?: { x: number; y: number; width: number; height: number; }; pageRect?: { x: number; y: number; width: number; height: number; }; } export interface IBrowserViewState { url: string; title: string; canGoBack: boolean; canGoForward: boolean; loading: boolean; focused: boolean; visible: boolean; isDevToolsOpen: boolean; lastScreenshot: VSBuffer | undefined; lastFavicon: string | undefined; lastError: IBrowserViewLoadError | undefined; certificateError: IBrowserViewCertificateError | undefined; storageScope: BrowserViewStorageScope; browserZoomIndex: number; } export interface IBrowserViewNavigationEvent { url: string; title: string; canGoBack: boolean; canGoForward: boolean; certificateError: IBrowserViewCertificateError | undefined; } export interface IBrowserViewLoadingEvent { loading: boolean; error?: IBrowserViewLoadError; } export interface IBrowserViewLoadError { url: string; errorCode: number; errorDescription: string; certificateError?: IBrowserViewCertificateError; } export interface IBrowserViewCertificateError { host: string; fingerprint: string; error: string; url: string; hasTrustedException: boolean; issuerName: string; subjectName: string; validStart: number; validExpiry: number; } export interface IBrowserViewFocusEvent { focused: boolean; } export interface IBrowserViewVisibilityEvent { visible: boolean; } export interface IBrowserViewDevToolsStateEvent { isDevToolsOpen: boolean; } export interface IBrowserViewKeyDownEvent { key: string; keyCode: number; code: string; ctrlKey: boolean; shiftKey: boolean; altKey: boolean; metaKey: boolean; repeat: boolean; } export interface IBrowserViewTitleChangeEvent { title: string; } export interface IBrowserViewFaviconChangeEvent { favicon: string | undefined; } export declare enum BrowserNewPageLocation { Foreground = "foreground", Background = "background", NewWindow = "newWindow" } export interface IBrowserViewNewPageRequest { resource: UriComponents; url: string; location: BrowserNewPageLocation; position?: { x?: number; y?: number; width?: number; height?: number; }; } export interface IBrowserViewFindInPageOptions { recompute?: boolean; forward?: boolean; matchCase?: boolean; } export interface IBrowserViewFindInPageResult { activeMatchOrdinal: number; matches: number; selectionArea?: { x: number; y: number; width: number; height: number; }; finalUpdate: boolean; } export declare enum BrowserViewStorageScope { Global = "global", Workspace = "workspace", Ephemeral = "ephemeral" } export declare const ipcBrowserViewChannelName = "browserView"; /** * Discrete zoom levels matching Edge/Chrome. * Note: When those browsers say "33%" and "67%" zoom, they really mean 33.33...% and 66.66...% */ export declare const browserZoomFactors: readonly [ 0.25, number, 0.5, number, 0.75, 0.8, 0.9, 1, 1.1, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5 ]; export declare const browserZoomDefaultIndex: number; export declare function browserZoomLabel(zoomFactor: number): string; export declare function browserZoomAccessibilityLabel(zoomFactor: number): string; /** * This should match the isolated world ID defined in `preload-browserView.ts`. */ export declare const browserViewIsolatedWorldId = 999; export interface IBrowserViewService { /** * Dynamic events that return an Event for a specific browser view ID. */ onDynamicDidNavigate(id: string): Event; onDynamicDidChangeLoadingState(id: string): Event; onDynamicDidChangeFocus(id: string): Event; onDynamicDidChangeVisibility(id: string): Event; onDynamicDidChangeDevToolsState(id: string): Event; onDynamicDidKeyCommand(id: string): Event; onDynamicDidChangeTitle(id: string): Event; onDynamicDidChangeFavicon(id: string): Event; onDynamicDidRequestNewPage(id: string): Event; onDynamicDidFindInPage(id: string): Event; onDynamicDidClose(id: string): Event; /** * Get or create a browser view instance * @param id The browser view identifier * @param scope The storage scope for the browser view. Ignored if the view already exists. * @param workspaceId Workspace identifier for session isolation. Only used if scope is 'workspace'. */ getOrCreateBrowserView(id: string, scope: BrowserViewStorageScope, workspaceId?: string): Promise; /** * Destroy a browser view instance * @param id The browser view identifier */ destroyBrowserView(id: string): Promise; /** * Get the state of an existing browser view by ID, or throw if it doesn't exist * @param id The browser view identifier * @return The state of the browser view for the given ID * @throws If no browser view exists for the given ID */ getState(id: string): Promise; /** * Update the bounds of a browser view * @param id The browser view identifier * @param bounds The new bounds for the view */ layout(id: string, bounds: IBrowserViewBounds): Promise; /** * Set the visibility of a browser view * @param id The browser view identifier * @param visible Whether the view should be visible */ setVisible(id: string, visible: boolean): Promise; /** * Navigate the browser view to a URL * @param id The browser view identifier * @param url The URL to navigate to */ loadURL(id: string, url: string): Promise; /** * Get the current URL of a browser view * @param id The browser view identifier */ getURL(id: string): Promise; /** * Go back in navigation history * @param id The browser view identifier */ goBack(id: string): Promise; /** * Go forward in navigation history * @param id The browser view identifier */ goForward(id: string): Promise; /** * Reload the current page * @param id The browser view identifier * @param hard Whether to do a hard reload (bypassing cache) */ reload(id: string, hard?: boolean): Promise; /** * Toggle developer tools for the browser view. * @param id The browser view identifier */ toggleDevTools(id: string): Promise; /** * Check if the view can go back * @param id The browser view identifier */ canGoBack(id: string): Promise; /** * Check if the view can go forward * @param id The browser view identifier */ canGoForward(id: string): Promise; /** * Capture a screenshot of the browser view * @param id The browser view identifier * @param options Screenshot options (quality and rect) * @returns Screenshot as a buffer */ captureScreenshot(id: string, options?: IBrowserViewCaptureScreenshotOptions): Promise; /** * Focus the browser view * @param id The browser view identifier */ focus(id: string): Promise; /** * Find text in the browser view's page * @param id The browser view identifier * @param text The text to search for * @param options Find options (forward direction, find next) */ findInPage(id: string, text: string, options?: IBrowserViewFindInPageOptions): Promise; /** * Stop the find in page session * @param id The browser view identifier * @param keepSelection Whether to keep the current selection */ stopFindInPage(id: string, keepSelection?: boolean): Promise; /** * Get the currently selected text in the browser view. * Returns immediately with empty string if the page is still loading. * @param id The browser view identifier * @returns The selected text, or empty string if no selection or page is loading */ getSelectedText(id: string): Promise; /** * Clear all storage data for the global browser session */ clearGlobalStorage(): Promise; /** * Clear all storage data for a specific workspace browser session * @param workspaceId The workspace identifier */ clearWorkspaceStorage(workspaceId: string): Promise; /** * Clear storage data for a specific browser view * @param id The browser view identifier */ clearStorage(id: string): Promise; /** Set the browser zoom index (independent from VS Code zoom). */ setBrowserZoomIndex(id: string, zoomIndex: number): Promise; /** * Trust a certificate for a given host in the browser view's session. * The page will be automatically reloaded after trusting. * @param id The browser view identifier * @param host The hostname that presented the certificate * @param fingerprint The SHA-256 fingerprint of the certificate to trust */ trustCertificate(id: string, host: string, fingerprint: string): Promise; /** * Revoke trust for a previously trusted certificate. * The browser view will be automatically closed after revoking. * @param id The browser view identifier * @param host The hostname to revoke the certificate for * @param fingerprint The SHA-256 fingerprint of the certificate to revoke */ untrustCertificate(id: string, host: string, fingerprint: string): Promise; /** * Get captured console logs for a browser view. * Console messages are automatically captured from the moment the view is created. * @param id The browser view identifier * @returns The captured console logs as a single string */ getConsoleLogs(id: string): Promise; /** * Start element inspection mode in a browser view. Sets up a CDP overlay that * highlights elements on hover. When the user clicks an element, its data is * returned and the overlay is removed. * @param id The browser view identifier * @param cancellationId An identifier that can be passed to {@link cancel} to abort * @returns The inspected element data, or undefined if cancelled */ getElementData(id: string, cancellationId: number): Promise; /** * Get element data for the currently focused element in the browser view. * @param id The browser view identifier * @returns The focused element's data, or undefined if no element is focused */ getFocusedElementData(id: string): Promise; /** * Cancel an in-progress request. */ cancel(cancellationId: number): Promise; /** * Update the keybinding accelerators used in browser view context menus. * @param keybindings A map of command ID to accelerator label */ updateKeybindings(keybindings: { [commandId: string]: string; }): Promise; }