UNPKG

sprotty-vscode

Version:

Glue code to integrate Sprotty diagrams in VSCode extensions (extension part)

70 lines 4.05 kB
/******************************************************************************** * Copyright (c) 2022 TypeFox and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { SprottyDiagramIdentifier } from 'sprotty-vscode-protocol'; import * as vscode from 'vscode'; import { Messenger } from 'vscode-messenger'; import { IWebviewEndpointManager, OpenDiagramOptions, WebviewContainer, WebviewEndpoint } from './webview-endpoint'; export interface SprottyViewProviderOptions { extensionUri: vscode.Uri; viewType: string; messenger?: Messenger; supportedFileExtensions?: string[]; openActiveEditor?: boolean; createWebviewHtml?: (identifier: SprottyDiagramIdentifier, container: WebviewContainer) => string; configureEndpoint?: (endpoint: WebviewEndpoint) => void; localResourceRoots?: vscode.Uri[]; } export interface OpenViewOptions extends OpenDiagramOptions { preserveFocus?: boolean; quiet?: boolean; } /** * View provider for rendering diagrams. This must be registered in the package.json with a `views` contribution. */ export declare class SprottyViewProvider implements vscode.WebviewViewProvider, IWebviewEndpointManager { readonly options: SprottyViewProviderOptions; protected static viewCount: number; protected readonly clientId: string; protected endpoint?: WebviewEndpoint; readonly messenger: Messenger; constructor(options: SprottyViewProviderOptions); /** * Returns the webview endpoint of the created view if it is already opened. */ findActiveWebview(): WebviewEndpoint | undefined; /** * Open the given URI in the view if it is already opened. There is currently no way to open the view * programmatically, so this method shows an error message if the view is not opened. The message can * be suppressed with the `quiet` option. */ openDiagram(uri: vscode.Uri, options?: OpenViewOptions): Promise<WebviewEndpoint | undefined>; resolveWebviewView(webviewView: vscode.WebviewView, context: vscode.WebviewViewResolveContext<unknown>, cancelToken: vscode.CancellationToken): Promise<void>; protected createEndpoint(webviewContainer: vscode.WebviewView, identifier?: SprottyDiagramIdentifier): WebviewEndpoint; /** * Configure the given webview view. The default implementation sets `localResourceRoots` to the `pack` subfolder of the extension host * and `scriptUri` to `pack/webview.js`. Please configure your bundler to generate such an output file from the Sprotty webview frontend. * In case you need to use different settings or change the HTML content, you can override this functionality in a subclass. */ protected configureWebview(webviewView: vscode.WebviewView, endpoint: WebviewEndpoint, cancelToken: vscode.CancellationToken): Promise<void> | void; protected createDiagramIdentifier(uri: vscode.Uri, diagramType?: string): Promise<SprottyDiagramIdentifier | undefined>; /** * Determine a diagram type from the given URI. The default implementation returns the `viewType` of the view * if the URI matches the `supportedFileExtensions` or no file extensions were provided. */ protected getDiagramType(uri: vscode.Uri): Promise<string | undefined> | string | undefined; protected didCloseWebview(endpoint: WebviewEndpoint): void; } //# sourceMappingURL=sprotty-view-provider.d.ts.map