mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-05 17:23:51 -05:00
* 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
101 lines
4.0 KiB
TypeScript
101 lines
4.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 { WebContents, webContents, WebFrameMain } from 'electron';
|
|
import { Emitter } from 'vs/base/common/event';
|
|
import { Disposable } from 'vs/base/common/lifecycle';
|
|
import { FindInFrameOptions, FoundInFrameResult, IWebviewManagerService, WebviewWebContentsId, WebviewWindowId } from 'vs/platform/webview/common/webviewManagerService';
|
|
import { WebviewProtocolProvider } from 'vs/platform/webview/electron-main/webviewProtocolProvider';
|
|
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
|
|
|
|
export class WebviewMainService extends Disposable implements IWebviewManagerService {
|
|
|
|
declare readonly _serviceBrand: undefined;
|
|
|
|
private readonly _onFoundInFrame = this._register(new Emitter<FoundInFrameResult>());
|
|
public onFoundInFrame = this._onFoundInFrame.event;
|
|
|
|
constructor(
|
|
@IWindowsMainService private readonly windowsMainService: IWindowsMainService,
|
|
) {
|
|
super();
|
|
this._register(new WebviewProtocolProvider());
|
|
}
|
|
|
|
public async setIgnoreMenuShortcuts(id: WebviewWebContentsId | WebviewWindowId, enabled: boolean): Promise<void> {
|
|
let contents: WebContents | undefined;
|
|
|
|
if (typeof (id as WebviewWindowId).windowId === 'number') {
|
|
const { windowId } = (id as WebviewWindowId);
|
|
const window = this.windowsMainService.getWindowById(windowId);
|
|
if (!window?.win) {
|
|
throw new Error(`Invalid windowId: ${windowId}`);
|
|
}
|
|
contents = window.win.webContents;
|
|
} else {
|
|
const { webContentsId } = (id as WebviewWebContentsId);
|
|
contents = webContents.fromId(webContentsId);
|
|
if (!contents) {
|
|
throw new Error(`Invalid webContentsId: ${webContentsId}`);
|
|
}
|
|
}
|
|
|
|
if (!contents.isDestroyed()) {
|
|
contents.setIgnoreMenuShortcuts(enabled);
|
|
}
|
|
}
|
|
|
|
public async findInFrame(windowId: WebviewWindowId, frameName: string, text: string, options: { findNext?: boolean; forward?: boolean }): Promise<void> {
|
|
const initialFrame = this.getFrameByName(windowId, frameName);
|
|
|
|
type WebFrameMainWithFindSupport = WebFrameMain & {
|
|
findInFrame?(text: string, findOptions: FindInFrameOptions): void;
|
|
on(event: 'found-in-frame', listener: Function): WebFrameMain;
|
|
removeListener(event: 'found-in-frame', listener: Function): WebFrameMain;
|
|
};
|
|
const frame = initialFrame as unknown as WebFrameMainWithFindSupport;
|
|
if (typeof frame.findInFrame === 'function') {
|
|
frame.findInFrame(text, {
|
|
findNext: options.findNext,
|
|
forward: options.forward,
|
|
});
|
|
const foundInFrameHandler = (_: unknown, result: FoundInFrameResult) => {
|
|
if (result.finalUpdate) {
|
|
this._onFoundInFrame.fire(result);
|
|
frame.removeListener('found-in-frame', foundInFrameHandler);
|
|
}
|
|
};
|
|
frame.on('found-in-frame', foundInFrameHandler);
|
|
}
|
|
}
|
|
|
|
public async stopFindInFrame(windowId: WebviewWindowId, frameName: string, options: { keepSelection?: boolean }): Promise<void> {
|
|
const initialFrame = this.getFrameByName(windowId, frameName);
|
|
|
|
type WebFrameMainWithFindSupport = WebFrameMain & {
|
|
stopFindInFrame?(stopOption: 'keepSelection' | 'clearSelection'): void;
|
|
};
|
|
|
|
const frame = initialFrame as unknown as WebFrameMainWithFindSupport;
|
|
if (typeof frame.stopFindInFrame === 'function') {
|
|
frame.stopFindInFrame(options.keepSelection ? 'keepSelection' : 'clearSelection');
|
|
}
|
|
}
|
|
|
|
private getFrameByName(windowId: WebviewWindowId, frameName: string): WebFrameMain {
|
|
const window = this.windowsMainService.getWindowById(windowId.windowId);
|
|
if (!window?.win) {
|
|
throw new Error(`Invalid windowId: ${windowId}`);
|
|
}
|
|
const frame = window.win.webContents.mainFrame.framesInSubtree.find(frame => {
|
|
return frame.name === frameName;
|
|
});
|
|
if (!frame) {
|
|
throw new Error(`Unknown frame: ${frameName}`);
|
|
}
|
|
return frame;
|
|
}
|
|
}
|