Files
azuredatastudio/src/sql/workbench/api/common/extHostDashboardWebview.ts
Karl Burtram 8a3d08f0de Merge vscode 1.67 (#20883)
* Fix initial build breaks from 1.67 merge (#2514)

* Update yarn lock files

* Update build scripts

* Fix tsconfig

* Build breaks

* WIP

* Update yarn lock files

* Misc breaks

* Updates to package.json

* Breaks

* Update yarn

* Fix breaks

* Breaks

* Build breaks

* Breaks

* Breaks

* Breaks

* Breaks

* Breaks

* Missing file

* Breaks

* Breaks

* Breaks

* Breaks

* Breaks

* Fix several runtime breaks (#2515)

* Missing files

* Runtime breaks

* Fix proxy ordering issue

* Remove commented code

* Fix breaks with opening query editor

* Fix post merge break

* Updates related to setup build and other breaks (#2516)

* Fix bundle build issues

* Update distro

* Fix distro merge and update build JS files

* Disable pipeline steps

* Remove stats call

* Update license name

* Make new RPM dependencies a warning

* Fix extension manager version checks

* Update JS file

* Fix a few runtime breaks

* Fixes

* Fix runtime issues

* Fix build breaks

* Update notebook tests (part 1)

* Fix broken tests

* Linting errors

* Fix hygiene

* Disable lint rules

* Bump distro

* Turn off smoke tests

* Disable integration tests

* Remove failing "activate" test

* Remove failed test assertion

* Disable other broken test

* Disable query history tests

* Disable extension unit tests

* Disable failing tasks
2022-10-19 19:13:18 -07:00

95 lines
3.0 KiB
TypeScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtHostDashboardWebviewsShape, MainThreadDashboardWebviewShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
import { Emitter } from 'vs/base/common/event';
import { deepClone } from 'vs/base/common/objects';
import { SqlMainContext } from 'vs/workbench/api/common/extHost.protocol';
import * as vscode from 'vscode';
import * as azdata from 'azdata';
class ExtHostDashboardWebview implements azdata.DashboardWebview {
private _html: string;
public onMessageEmitter = new Emitter<any>();
public onClosedEmitter = new Emitter<any>();
constructor(
private readonly _proxy: MainThreadDashboardWebviewShape,
private readonly _handle: number,
private readonly _connection: azdata.connection.Connection,
private readonly _serverInfo: azdata.ServerInfo
) { }
public postMessage(message: any): Thenable<any> {
return this._proxy.$sendMessage(this._handle, message);
}
public get onMessage(): vscode.Event<any> {
return this.onMessageEmitter.event;
}
public get onClosed(): vscode.Event<any> {
return this.onClosedEmitter.event;
}
public get connection(): azdata.connection.Connection {
return deepClone(this._connection);
}
public get serverInfo(): azdata.ServerInfo {
return deepClone(this._serverInfo);
}
get html(): string {
return this._html;
}
set html(value: string) {
if (this._html !== value) {
this._html = value;
this._proxy.$setHtml(this._handle, value);
}
}
}
export class ExtHostDashboardWebviews implements ExtHostDashboardWebviewsShape {
private readonly _proxy: MainThreadDashboardWebviewShape;
private readonly _webviews = new Map<number, ExtHostDashboardWebview>();
private readonly _handlers = new Map<string, (webview: azdata.DashboardWebview) => void>();
constructor(
mainContext: IMainContext
) {
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadDashboardWebview);
}
$onMessage(handle: number, message: any): void {
const webview = this._webviews.get(handle);
webview.onMessageEmitter.fire(message);
}
$onClosed(handle: number): void {
const webview = this._webviews.get(handle);
webview.onClosedEmitter.fire(undefined);
this._webviews.delete(handle);
}
$registerProvider(widgetId: string, handler: (webview: azdata.DashboardWebview) => void): void {
this._handlers.set(widgetId, handler);
this._proxy.$registerProvider(widgetId);
}
$registerWidget(handle: number, id: string, connection: azdata.connection.Connection, serverInfo: azdata.ServerInfo): void {
let webview = new ExtHostDashboardWebview(this._proxy, handle, connection, serverInfo);
this._webviews.set(handle, webview);
this._handlers.get(id)(webview);
}
}