Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8 (#14883)

* Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8

* Bump distro

* Upgrade GCC to 4.9 due to yarn install errors

* Update build image

* Fix bootstrap base url

* Bump distro

* Fix build errors

* Update source map file

* Disable checkbox for blocking migration issues (#15131)

* disable checkbox for blocking issues

* wip

* disable checkbox fixes

* fix strings

* Remove duplicate tsec command

* Default to off for tab color if settings not present

* re-skip failing tests

* Fix mocha error

* Bump sqlite version & fix notebooks search view

* Turn off esbuild warnings

* Update esbuild log level

* Fix overflowactionbar tests

* Fix ts-ignore in dropdown tests

* cleanup/fixes

* Fix hygiene

* Bundle in entire zone.js module

* Remove extra constructor param

* bump distro for web compile break

* bump distro for web compile break v2

* Undo log level change

* New distro

* Fix integration test scripts

* remove the "no yarn.lock changes" workflow

* fix scripts v2

* Update unit test scripts

* Ensure ads-kerberos2 updates in .vscodeignore

* Try fix unit tests

* Upload crash reports

* remove nogpu

* always upload crashes

* Use bash script

* Consolidate data/ext dir names

* Create in tmp directory

Co-authored-by: chlafreniere <hichise@gmail.com>
Co-authored-by: Christopher Suh <chsuh@microsoft.com>
Co-authored-by: chgagnon <chgagnon@microsoft.com>
This commit is contained in:
Karl Burtram
2021-04-27 14:01:59 -07:00
committed by GitHub
parent 7e1c0076ba
commit 867a963882
1817 changed files with 81812 additions and 50843 deletions

View File

@@ -0,0 +1,42 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
export function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
item.dispose();
}
}
}
export abstract class Disposable {
private _isDisposed = false;
protected _disposables: vscode.Disposable[] = [];
public dispose(): any {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
disposeAll(this._disposables);
}
protected _register<T extends vscode.Disposable>(value: T): T {
if (this._isDisposed) {
value.dispose();
} else {
this._disposables.push(value);
}
return value;
}
protected get isDisposed() {
return this._isDisposed;
}
}

View File

@@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { SimpleBrowserManager } from './simpleBrowserManager';
declare const URL: typeof import('url').URL;
const localize = nls.loadMessageBundle();
const openApiCommand = 'simpleBrowser.api.open';
const showCommand = 'simpleBrowser.show';
const enabledHosts = new Set<string>([
'localhost',
'127.0.0.1'
]);
const openerId = 'simpleBrowser.open';
export function activate(context: vscode.ExtensionContext) {
const manager = new SimpleBrowserManager(context.extensionUri);
context.subscriptions.push(manager);
context.subscriptions.push(vscode.commands.registerCommand(showCommand, async (url?: string) => {
if (!url) {
url = await vscode.window.showInputBox({
placeHolder: localize('simpleBrowser.show.placeholder', "https://example.com"),
prompt: localize('simpleBrowser.show.prompt', "Enter url to visit")
});
}
if (url) {
manager.show(url);
}
}));
context.subscriptions.push(vscode.commands.registerCommand(openApiCommand, (url: vscode.Uri, showOptions?: {
preserveFocus?: boolean,
viewColumn: vscode.ViewColumn,
}) => {
manager.show(url.toString(), showOptions);
}));
context.subscriptions.push(vscode.window.registerExternalUriOpener(openerId, {
canOpenExternalUri(uri: vscode.Uri) {
const originalUri = new URL(uri.toString());
if (enabledHosts.has(originalUri.hostname)) {
return isWeb()
? vscode.ExternalUriOpenerPriority.Default
: vscode.ExternalUriOpenerPriority.Option;
}
return vscode.ExternalUriOpenerPriority.None;
},
openExternalUri(resolveUri: vscode.Uri) {
return manager.show(resolveUri.toString(), {
viewColumn: vscode.window.activeTextEditor ? vscode.ViewColumn.Beside : vscode.ViewColumn.Active
});
}
}, {
schemes: ['http', 'https'],
label: localize('openTitle', "Open in simple browser"),
}));
}
function isWeb(): boolean {
// @ts-expect-error
return typeof navigator !== 'undefined' && vscode.env.uiKind === vscode.UIKind.Web;
}

View File

@@ -0,0 +1,38 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { ShowOptions, SimpleBrowserView } from './simpleBrowserView';
export class SimpleBrowserManager {
private _activeView?: SimpleBrowserView;
constructor(
private readonly extensionUri: vscode.Uri,
) { }
dispose() {
this._activeView?.dispose();
this._activeView = undefined;
}
public show(url: string, options?: ShowOptions): void {
if (this._activeView) {
this._activeView.show(url, options);
} else {
const view = new SimpleBrowserView(this.extensionUri, url, options);
view.onDispose(() => {
if (this._activeView === view) {
this._activeView = undefined;
}
});
this._activeView = view;
}
}
}

View File

@@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { Disposable } from './dispose';
const localize = nls.loadMessageBundle();
export interface ShowOptions {
readonly preserveFocus?: boolean;
readonly viewColumn?: vscode.ViewColumn;
}
export class SimpleBrowserView extends Disposable {
public static readonly viewType = 'simpleBrowser.view';
private static readonly title = localize('view.title', "Simple Browser");
private readonly _webviewPanel: vscode.WebviewPanel;
private readonly _onDidDispose = this._register(new vscode.EventEmitter<void>());
public readonly onDispose = this._onDidDispose.event;
constructor(
private readonly extensionUri: vscode.Uri,
url: string,
showOptions?: ShowOptions
) {
super();
this._webviewPanel = this._register(vscode.window.createWebviewPanel(SimpleBrowserView.viewType, SimpleBrowserView.title, {
viewColumn: showOptions?.viewColumn ?? vscode.ViewColumn.Active,
preserveFocus: showOptions?.preserveFocus
}, {
enableScripts: true,
retainContextWhenHidden: true,
}));
this._register(this._webviewPanel.webview.onDidReceiveMessage(e => {
switch (e.type) {
case 'openExternal':
try {
const url = vscode.Uri.parse(e.url);
vscode.env.openExternal(url);
} catch {
// Noop
}
break;
}
}));
this._register(this._webviewPanel.onDidDispose(() => {
this.dispose();
}));
this._register(vscode.workspace.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('simpleBrowser.focusLockIndicator.enabled')) {
const configuration = vscode.workspace.getConfiguration('simpleBrowser');
this._webviewPanel.webview.postMessage({
type: 'didChangeFocusLockIndicatorEnabled',
focusLockEnabled: configuration.get<boolean>('focusLockIndicator.enabled', true)
});
}
}));
this.show(url);
}
public dispose() {
this._onDidDispose.fire();
super.dispose();
}
public show(url: string, options?: ShowOptions) {
this._webviewPanel.webview.html = this.getHtml(url);
this._webviewPanel.reveal(options?.viewColumn, options?.preserveFocus);
}
private getHtml(url: string) {
const configuration = vscode.workspace.getConfiguration('simpleBrowser');
const nonce = new Date().getTime() + '' + new Date().getMilliseconds();
const mainJs = this.extensionResourceUrl('media', 'index.js');
const mainCss = this.extensionResourceUrl('media', 'main.css');
const codiconsUri = this.extensionResourceUrl('node_modules', 'vscode-codicons', 'dist', 'codicon.css');
const codiconsFontUri = this.extensionResourceUrl('node_modules', 'vscode-codicons', 'dist', 'codicon.ttf');
return /* html */ `<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta http-equiv="Content-Security-Policy" content="
default-src 'none';
font-src ${codiconsFontUri};
style-src ${this._webviewPanel.webview.cspSource};
script-src 'nonce-${nonce}';
frame-src *;
">
<meta id="simple-browser-settings" data-settings="${escapeAttribute(JSON.stringify({
url: url,
focusLockEnabled: configuration.get<boolean>('focusLockIndicator.enabled', true)
}))}">
<link rel="stylesheet" type="text/css" href="${mainCss}">
<link rel="stylesheet" type="text/css" href="${codiconsUri}">
</head>
<body>
<header class="header">
<nav class="controls">
<button
title="${localize('control.back.title', "Back")}"
class="back-button icon"><i class="codicon codicon-arrow-left"></i></button>
<button
title="${localize('control.forward.title', "Forward")}"
class="forward-button icon"><i class="codicon codicon-arrow-right"></i></button>
<button
title="${localize('control.reload.title', "Reload")}"
class="reload-button icon"><i class="codicon codicon-refresh"></i></button>
</nav>
<input class="url-input" type="text" value=${url}>
<nav class="controls">
<button
title="${localize('control.openExternal.title', "Open in browser")}"
class="open-external-button icon"><i class="codicon codicon-link-external"></i></button>
</nav>
</header>
<div class="content">
<div class="iframe-focused-alert">${localize('view.iframe-focused', "Focus Lock")}</div>
<iframe sandbox="allow-scripts allow-forms allow-same-origin"></iframe>
</div>
<script src="${mainJs}" nonce="${nonce}"></script>
</body>
</html>`;
}
private extensionResourceUrl(...parts: string[]): vscode.Uri {
return this._webviewPanel.webview.asWebviewUri(vscode.Uri.joinPath(this.extensionUri, ...parts));
}
}
function escapeAttribute(value: string | vscode.Uri): string {
return value.toString().replace(/"/g, '&quot;');
}

View File

@@ -0,0 +1,7 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>