This commit is contained in:
hediet 2023-02-15 16:00:42 +00:00
parent 3d7d7c3fdd
commit 33c03b6c91
2552 changed files with 1265957 additions and 5199 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.de.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.de",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.de", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.es.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.es",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.es", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.fr.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.fr",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.fr", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.it.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.it",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.it", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.ja.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.ja",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.ja", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,15 @@
/*! For license information please see simpleWorker.nls.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
/*---------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls", {
"vs/base/common/platform": [
"_"
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.ko.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.ko",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.ko", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.ru.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.ru",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.ru", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.zh-cn.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.zh-cn",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.zh-cn", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1,2 +1,12 @@
/*! For license information please see simpleWorker.nls.zh-tw.js.LICENSE.txt */
define("vs/base/common/worker/simpleWorker.nls.zh-tw",{"vs/base/common/platform":["_"]});
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/
define("vs/base/common/worker/simpleWorker.nls.zh-tw", {
"vs/base/common/platform": [
"_",
]
});

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,8 +0,0 @@
/*! @license DOMPurify 2.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.1/LICENSE */
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

File diff suppressed because one or more lines are too long

View file

@ -1,6 +0,0 @@
/*!-----------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.35.0-dev.20230127(212670ceb460441b3ebed29e6ca30aa1e9bdde85)
* Released under the MIT license
* https://github.com/microsoft/vscode/blob/main/LICENSE.txt
*-----------------------------------------------------------*/

View file

@ -1 +1,131 @@
import{Emitter}from"../common/event.js";import{Disposable,markAsSingleton}from"../common/lifecycle.js";class WindowManager{constructor(){this._zoomFactor=1}getZoomFactor(){return this._zoomFactor}}WindowManager.INSTANCE=new WindowManager;class DevicePixelRatioMonitor extends Disposable{constructor(){super(),this._onDidChange=this._register(new Emitter),this.onDidChange=this._onDidChange.event,this._listener=()=>this._handleChange(!0),this._mediaQueryList=null,this._handleChange(!1)}_handleChange(e){var t;null===(t=this._mediaQueryList)||void 0===t||t.removeEventListener("change",this._listener),this._mediaQueryList=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._mediaQueryList.addEventListener("change",this._listener),e&&this._onDidChange.fire()}}class PixelRatioImpl extends Disposable{get value(){return this._value}constructor(){super(),this._onDidChange=this._register(new Emitter),this.onDidChange=this._onDidChange.event,this._value=this._getPixelRatio();const e=this._register(new DevicePixelRatioMonitor);this._register(e.onDidChange((()=>{this._value=this._getPixelRatio(),this._onDidChange.fire(this._value)})))}_getPixelRatio(){const e=document.createElement("canvas").getContext("2d");return(window.devicePixelRatio||1)/(e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1)}}class PixelRatioFacade{constructor(){this._pixelRatioMonitor=null}_getOrCreatePixelRatioMonitor(){return this._pixelRatioMonitor||(this._pixelRatioMonitor=markAsSingleton(new PixelRatioImpl)),this._pixelRatioMonitor}get value(){return this._getOrCreatePixelRatioMonitor().value}get onDidChange(){return this._getOrCreatePixelRatioMonitor().onDidChange}}export function addMatchMediaChangeListener(e,t){"string"==typeof e&&(e=window.matchMedia(e)),e.addEventListener("change",t)}export const PixelRatio=new PixelRatioFacade;export function getZoomFactor(){return WindowManager.INSTANCE.getZoomFactor()}const userAgent=navigator.userAgent;export const isFirefox=userAgent.indexOf("Firefox")>=0;export const isWebKit=userAgent.indexOf("AppleWebKit")>=0;export const isChrome=userAgent.indexOf("Chrome")>=0;export const isSafari=!isChrome&&userAgent.indexOf("Safari")>=0;export const isWebkitWebView=!isChrome&&!isSafari&&isWebKit;export const isElectron=userAgent.indexOf("Electron/")>=0;export const isAndroid=userAgent.indexOf("Android")>=0;let standalone=!1;if(window.matchMedia){const e=window.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=window.matchMedia("(display-mode: fullscreen)");standalone=e.matches,addMatchMediaChangeListener(e,(({matches:e})=>{standalone&&t.matches||(standalone=e)}))}export function isStandalone(){return standalone}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter } from '../common/event.js';
import { Disposable, markAsSingleton } from '../common/lifecycle.js';
class WindowManager {
constructor() {
// --- Zoom Factor
this._zoomFactor = 1;
}
getZoomFactor() {
return this._zoomFactor;
}
}
WindowManager.INSTANCE = new WindowManager();
/**
* See https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio#monitoring_screen_resolution_or_zoom_level_changes
*/
class DevicePixelRatioMonitor extends Disposable {
constructor() {
super();
this._onDidChange = this._register(new Emitter());
this.onDidChange = this._onDidChange.event;
this._listener = () => this._handleChange(true);
this._mediaQueryList = null;
this._handleChange(false);
}
_handleChange(fireEvent) {
var _a;
(_a = this._mediaQueryList) === null || _a === void 0 ? void 0 : _a.removeEventListener('change', this._listener);
this._mediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
this._mediaQueryList.addEventListener('change', this._listener);
if (fireEvent) {
this._onDidChange.fire();
}
}
}
class PixelRatioImpl extends Disposable {
get value() {
return this._value;
}
constructor() {
super();
this._onDidChange = this._register(new Emitter());
this.onDidChange = this._onDidChange.event;
this._value = this._getPixelRatio();
const dprMonitor = this._register(new DevicePixelRatioMonitor());
this._register(dprMonitor.onDidChange(() => {
this._value = this._getPixelRatio();
this._onDidChange.fire(this._value);
}));
}
_getPixelRatio() {
const ctx = document.createElement('canvas').getContext('2d');
const dpr = window.devicePixelRatio || 1;
const bsr = ctx.webkitBackingStorePixelRatio ||
ctx.mozBackingStorePixelRatio ||
ctx.msBackingStorePixelRatio ||
ctx.oBackingStorePixelRatio ||
ctx.backingStorePixelRatio || 1;
return dpr / bsr;
}
}
class PixelRatioFacade {
constructor() {
this._pixelRatioMonitor = null;
}
_getOrCreatePixelRatioMonitor() {
if (!this._pixelRatioMonitor) {
this._pixelRatioMonitor = markAsSingleton(new PixelRatioImpl());
}
return this._pixelRatioMonitor;
}
/**
* Get the current value.
*/
get value() {
return this._getOrCreatePixelRatioMonitor().value;
}
/**
* Listen for changes.
*/
get onDidChange() {
return this._getOrCreatePixelRatioMonitor().onDidChange;
}
}
export function addMatchMediaChangeListener(query, callback) {
if (typeof query === 'string') {
query = window.matchMedia(query);
}
query.addEventListener('change', callback);
}
/**
* Returns the pixel ratio.
*
* This is useful for rendering <canvas> elements at native screen resolution or for being used as
* a cache key when storing font measurements. Fonts might render differently depending on resolution
* and any measurements need to be discarded for example when a window is moved from a monitor to another.
*/
export const PixelRatio = new PixelRatioFacade();
/** The zoom scale for an index, e.g. 1, 1.2, 1.4 */
export function getZoomFactor() {
return WindowManager.INSTANCE.getZoomFactor();
}
const userAgent = navigator.userAgent;
export const isFirefox = (userAgent.indexOf('Firefox') >= 0);
export const isWebKit = (userAgent.indexOf('AppleWebKit') >= 0);
export const isChrome = (userAgent.indexOf('Chrome') >= 0);
export const isSafari = (!isChrome && (userAgent.indexOf('Safari') >= 0));
export const isWebkitWebView = (!isChrome && !isSafari && isWebKit);
export const isElectron = (userAgent.indexOf('Electron/') >= 0);
export const isAndroid = (userAgent.indexOf('Android') >= 0);
let standalone = false;
if (window.matchMedia) {
const standaloneMatchMedia = window.matchMedia('(display-mode: standalone) or (display-mode: window-controls-overlay)');
const fullScreenMatchMedia = window.matchMedia('(display-mode: fullscreen)');
standalone = standaloneMatchMedia.matches;
addMatchMediaChangeListener(standaloneMatchMedia, ({ matches }) => {
// entering fullscreen would change standaloneMatchMedia.matches to false
// if standalone is true (running as PWA) and entering fullscreen, skip this change
if (standalone && fullScreenMatchMedia.matches) {
return;
}
// otherwise update standalone (browser to PWA or PWA to browser)
standalone = matches;
});
}
export function isStandalone() {
return standalone;
}

View file

@ -1 +1,31 @@
import*as browser from"./browser.js";import*as platform from"../common/platform.js";export const BrowserFeatures={clipboard:{writeText:platform.isNative||document.queryCommandSupported&&document.queryCommandSupported("copy")||!!(navigator&&navigator.clipboard&&navigator.clipboard.writeText),readText:platform.isNative||!!(navigator&&navigator.clipboard&&navigator.clipboard.readText)},keyboard:platform.isNative||browser.isStandalone()?0:navigator.keyboard||browser.isSafari?1:2,touch:"ontouchstart"in window||navigator.maxTouchPoints>0,pointerEvents:window.PointerEvent&&("ontouchstart"in window||window.navigator.maxTouchPoints>0||navigator.maxTouchPoints>0)};
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as browser from './browser.js';
import * as platform from '../common/platform.js';
/**
* Browser feature we can support in current platform, browser and environment.
*/
export const BrowserFeatures = {
clipboard: {
writeText: (platform.isNative
|| (document.queryCommandSupported && document.queryCommandSupported('copy'))
|| !!(navigator && navigator.clipboard && navigator.clipboard.writeText)),
readText: (platform.isNative
|| !!(navigator && navigator.clipboard && navigator.clipboard.readText))
},
keyboard: (() => {
if (platform.isNative || browser.isStandalone()) {
return 0 /* KeyboardSupport.Always */;
}
if (navigator.keyboard || browser.isSafari) {
return 1 /* KeyboardSupport.FullScreen */;
}
return 2 /* KeyboardSupport.None */;
})(),
// 'ontouchstart' in window always evaluates to true with typescript's modern typings. This causes `window` to be
// `never` later in `window.navigator`. That's why we need the explicit `window as Window` cast
touch: 'ontouchstart' in window || navigator.maxTouchPoints > 0,
pointerEvents: window.PointerEvent && ('ontouchstart' in window || window.navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0)
};

View file

@ -1 +1,5 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export {};

View file

@ -1 +1,120 @@
var _a;import{globals}from"../common/platform.js";import{logOnceWebWorkerWarning}from"../common/worker/simpleWorker.js";const ttPolicy=null===(_a=window.trustedTypes)||void 0===_a?void 0:_a.createPolicy("defaultWorkerFactory",{createScriptURL:r=>r});function getWorker(r){if(globals.MonacoEnvironment){if("function"==typeof globals.MonacoEnvironment.getWorker)return globals.MonacoEnvironment.getWorker("workerMain.js",r);if("function"==typeof globals.MonacoEnvironment.getWorkerUrl){const e=globals.MonacoEnvironment.getWorkerUrl("workerMain.js",r);return new Worker(ttPolicy?ttPolicy.createScriptURL(e):e,{name:r})}}throw new Error("You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker")}function isPromiseLike(r){return"function"==typeof r.then}class WebWorker{constructor(r,e,o,t,n){this.id=e;const i=getWorker(o);isPromiseLike(i)?this.worker=i:this.worker=Promise.resolve(i),this.postMessage(r,[]),this.worker.then((r=>{r.onmessage=function(r){t(r.data)},r.onmessageerror=n,"function"==typeof r.addEventListener&&r.addEventListener("error",n)}))}getId(){return this.id}postMessage(r,e){var o;null===(o=this.worker)||void 0===o||o.then((o=>o.postMessage(r,e)))}dispose(){var r;null===(r=this.worker)||void 0===r||r.then((r=>r.terminate())),this.worker=null}}class DefaultWorkerFactory{constructor(r){this._label=r,this._webWorkerFailedBeforeError=!1}create(r,e,o){const t=++DefaultWorkerFactory.LAST_WORKER_ID;if(this._webWorkerFailedBeforeError)throw this._webWorkerFailedBeforeError;return new WebWorker(r,t,this._label||"anonymous"+t,e,(r=>{logOnceWebWorkerWarning(r),this._webWorkerFailedBeforeError=r,o(r)}))}}DefaultWorkerFactory.LAST_WORKER_ID=0;export{DefaultWorkerFactory};
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var _a;
import { globals } from '../common/platform.js';
import { logOnceWebWorkerWarning } from '../common/worker/simpleWorker.js';
const ttPolicy = (_a = window.trustedTypes) === null || _a === void 0 ? void 0 : _a.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });
function getWorker(label) {
// Option for hosts to overwrite the worker script (used in the standalone editor)
if (globals.MonacoEnvironment) {
if (typeof globals.MonacoEnvironment.getWorker === 'function') {
return globals.MonacoEnvironment.getWorker('workerMain.js', label);
}
if (typeof globals.MonacoEnvironment.getWorkerUrl === 'function') {
const workerUrl = globals.MonacoEnvironment.getWorkerUrl('workerMain.js', label);
return new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) : workerUrl, { name: label });
}
}
// ESM-comment-begin
// if (typeof require === 'function') {
// // check if the JS lives on a different origin
// const workerMain = require.toUrl('vs/base/worker/workerMain.js'); // explicitly using require.toUrl(), see https://github.com/microsoft/vscode/issues/107440#issuecomment-698982321
// const workerUrl = getWorkerBootstrapUrl(workerMain, label);
// return new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label });
// }
// ESM-comment-end
throw new Error(`You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker`);
}
// ESM-comment-begin
// export function getWorkerBootstrapUrl(scriptPath: string, label: string): string {
// if (/^((http:)|(https:)|(file:))/.test(scriptPath) && scriptPath.substring(0, self.origin.length) !== self.origin) {
// // this is the cross-origin case
// // i.e. the webpage is running at a different origin than where the scripts are loaded from
// const myPath = 'vs/base/worker/defaultWorkerFactory.js';
// const workerBaseUrl = require.toUrl(myPath).slice(0, -myPath.length); // explicitly using require.toUrl(), see https://github.com/microsoft/vscode/issues/107440#issuecomment-698982321
// const js = `/*${label}*/self.MonacoEnvironment={baseUrl: '${workerBaseUrl}'};const ttPolicy = self.trustedTypes?.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });importScripts(ttPolicy?.createScriptURL('${scriptPath}') ?? '${scriptPath}');/*${label}*/`;
// const blob = new Blob([js], { type: 'application/javascript' });
// return URL.createObjectURL(blob);
// }
//
// const start = scriptPath.lastIndexOf('?');
// const end = scriptPath.lastIndexOf('#', start);
// const params = start > 0
// ? new URLSearchParams(scriptPath.substring(start + 1, ~end ? end : undefined))
// : new URLSearchParams();
//
// COI.addSearchParam(params, true, true);
// const search = params.toString();
//
// if (!search) {
// return `${scriptPath}#${label}`;
// } else {
// return `${scriptPath}?${params.toString()}#${label}`;
// }
// }
// ESM-comment-end
function isPromiseLike(obj) {
if (typeof obj.then === 'function') {
return true;
}
return false;
}
/**
* A worker that uses HTML5 web workers so that is has
* its own global scope and its own thread.
*/
class WebWorker {
constructor(moduleId, id, label, onMessageCallback, onErrorCallback) {
this.id = id;
const workerOrPromise = getWorker(label);
if (isPromiseLike(workerOrPromise)) {
this.worker = workerOrPromise;
}
else {
this.worker = Promise.resolve(workerOrPromise);
}
this.postMessage(moduleId, []);
this.worker.then((w) => {
w.onmessage = function (ev) {
onMessageCallback(ev.data);
};
w.onmessageerror = onErrorCallback;
if (typeof w.addEventListener === 'function') {
w.addEventListener('error', onErrorCallback);
}
});
}
getId() {
return this.id;
}
postMessage(message, transfer) {
var _a;
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.then(w => w.postMessage(message, transfer));
}
dispose() {
var _a;
(_a = this.worker) === null || _a === void 0 ? void 0 : _a.then(w => w.terminate());
this.worker = null;
}
}
class DefaultWorkerFactory {
constructor(label) {
this._label = label;
this._webWorkerFailedBeforeError = false;
}
create(moduleId, onMessageCallback, onErrorCallback) {
const workerId = (++DefaultWorkerFactory.LAST_WORKER_ID);
if (this._webWorkerFailedBeforeError) {
throw this._webWorkerFailedBeforeError;
}
return new WebWorker(moduleId, workerId, this._label || 'anonymous' + workerId, onMessageCallback, (err) => {
logOnceWebWorkerWarning(err);
this._webWorkerFailedBeforeError = err;
onErrorCallback(err);
});
}
}
DefaultWorkerFactory.LAST_WORKER_ID = 0;
export { DefaultWorkerFactory };

View file

@ -1 +1,20 @@
import{Mimes}from"../common/mime.js";export const DataTransfers={RESOURCES:"ResourceURLs",DOWNLOAD_URL:"DownloadURL",FILES:"Files",TEXT:Mimes.text};
import { Mimes } from '../common/mime.js';
// Common data transfers
export const DataTransfers = {
/**
* Application specific resource transfer type
*/
RESOURCES: 'ResourceURLs',
/**
* Browser specific transfer type to download
*/
DOWNLOAD_URL: 'DownloadURL',
/**
* Browser specific transfer type for files
*/
FILES: 'Files',
/**
* Typically transfer type for copy/paste transfers.
*/
TEXT: Mimes.text
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
/*! @license DOMPurify 2.3.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.3.1/LICENSE */

View file

@ -1 +1,20 @@
import{Emitter}from"../common/event.js";export class DomEmitter{get event(){return this.emitter.event}constructor(e,t,i){const r=e=>this.emitter.fire(e);this.emitter=new Emitter({onWillAddFirstListener:()=>e.addEventListener(t,r,i),onDidRemoveLastListener:()=>e.removeEventListener(t,r,i)})}dispose(){this.emitter.dispose()}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Emitter } from '../common/event.js';
export class DomEmitter {
get event() {
return this.emitter.event;
}
constructor(element, type, useCapture) {
const fn = (e) => this.emitter.fire(e);
this.emitter = new Emitter({
onWillAddFirstListener: () => element.addEventListener(type, fn, useCapture),
onDidRemoveLastListener: () => element.removeEventListener(type, fn, useCapture)
});
}
dispose() {
this.emitter.dispose();
}
}

View file

@ -1 +1,250 @@
export class FastDomNode{constructor(t){this.domNode=t,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingLeft="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(t){const i=numberAsPixels(t);this._maxWidth!==i&&(this._maxWidth=i,this.domNode.style.maxWidth=this._maxWidth)}setWidth(t){const i=numberAsPixels(t);this._width!==i&&(this._width=i,this.domNode.style.width=this._width)}setHeight(t){const i=numberAsPixels(t);this._height!==i&&(this._height=i,this.domNode.style.height=this._height)}setTop(t){const i=numberAsPixels(t);this._top!==i&&(this._top=i,this.domNode.style.top=this._top)}setLeft(t){const i=numberAsPixels(t);this._left!==i&&(this._left=i,this.domNode.style.left=this._left)}setBottom(t){const i=numberAsPixels(t);this._bottom!==i&&(this._bottom=i,this.domNode.style.bottom=this._bottom)}setRight(t){const i=numberAsPixels(t);this._right!==i&&(this._right=i,this.domNode.style.right=this._right)}setPaddingLeft(t){const i=numberAsPixels(t);this._paddingLeft!==i&&(this._paddingLeft=i,this.domNode.style.paddingLeft=this._paddingLeft)}setFontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(t){const i=numberAsPixels(t);this._fontSize!==i&&(this._fontSize=i,this.domNode.style.fontSize=this._fontSize)}setFontStyle(t){this._fontStyle!==t&&(this._fontStyle=t,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(t){this._fontFeatureSettings!==t&&(this._fontFeatureSettings=t,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(t){this._fontVariationSettings!==t&&(this._fontVariationSettings=t,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(t){this._textDecoration!==t&&(this._textDecoration=t,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(t){const i=numberAsPixels(t);this._lineHeight!==i&&(this._lineHeight=i,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(t){const i=numberAsPixels(t);this._letterSpacing!==i&&(this._letterSpacing=i,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(t){this._className!==t&&(this._className=t,this.domNode.className=this._className)}toggleClassName(t,i){this.domNode.classList.toggle(t,i),this._className=this.domNode.className}setDisplay(t){this._display!==t&&(this._display=t,this.domNode.style.display=this._display)}setPosition(t){this._position!==t&&(this._position=t,this.domNode.style.position=this._position)}setVisibility(t){this._visibility!==t&&(this._visibility=t,this.domNode.style.visibility=this._visibility)}setColor(t){this._color!==t&&(this._color=t,this.domNode.style.color=this._color)}setBackgroundColor(t){this._backgroundColor!==t&&(this._backgroundColor=t,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(t){this._layerHint!==t&&(this._layerHint=t,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(t){this._boxShadow!==t&&(this._boxShadow=t,this.domNode.style.boxShadow=t)}setContain(t){this._contain!==t&&(this._contain=t,this.domNode.style.contain=this._contain)}setAttribute(t,i){this.domNode.setAttribute(t,i)}removeAttribute(t){this.domNode.removeAttribute(t)}appendChild(t){this.domNode.appendChild(t.domNode)}removeChild(t){this.domNode.removeChild(t.domNode)}}function numberAsPixels(t){return"number"==typeof t?`${t}px`:t}export function createFastDomNode(t){return new FastDomNode(t)}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export class FastDomNode {
constructor(domNode) {
this.domNode = domNode;
this._maxWidth = '';
this._width = '';
this._height = '';
this._top = '';
this._left = '';
this._bottom = '';
this._right = '';
this._paddingLeft = '';
this._fontFamily = '';
this._fontWeight = '';
this._fontSize = '';
this._fontStyle = '';
this._fontFeatureSettings = '';
this._fontVariationSettings = '';
this._textDecoration = '';
this._lineHeight = '';
this._letterSpacing = '';
this._className = '';
this._display = '';
this._position = '';
this._visibility = '';
this._color = '';
this._backgroundColor = '';
this._layerHint = false;
this._contain = 'none';
this._boxShadow = '';
}
setMaxWidth(_maxWidth) {
const maxWidth = numberAsPixels(_maxWidth);
if (this._maxWidth === maxWidth) {
return;
}
this._maxWidth = maxWidth;
this.domNode.style.maxWidth = this._maxWidth;
}
setWidth(_width) {
const width = numberAsPixels(_width);
if (this._width === width) {
return;
}
this._width = width;
this.domNode.style.width = this._width;
}
setHeight(_height) {
const height = numberAsPixels(_height);
if (this._height === height) {
return;
}
this._height = height;
this.domNode.style.height = this._height;
}
setTop(_top) {
const top = numberAsPixels(_top);
if (this._top === top) {
return;
}
this._top = top;
this.domNode.style.top = this._top;
}
setLeft(_left) {
const left = numberAsPixels(_left);
if (this._left === left) {
return;
}
this._left = left;
this.domNode.style.left = this._left;
}
setBottom(_bottom) {
const bottom = numberAsPixels(_bottom);
if (this._bottom === bottom) {
return;
}
this._bottom = bottom;
this.domNode.style.bottom = this._bottom;
}
setRight(_right) {
const right = numberAsPixels(_right);
if (this._right === right) {
return;
}
this._right = right;
this.domNode.style.right = this._right;
}
setPaddingLeft(_paddingLeft) {
const paddingLeft = numberAsPixels(_paddingLeft);
if (this._paddingLeft === paddingLeft) {
return;
}
this._paddingLeft = paddingLeft;
this.domNode.style.paddingLeft = this._paddingLeft;
}
setFontFamily(fontFamily) {
if (this._fontFamily === fontFamily) {
return;
}
this._fontFamily = fontFamily;
this.domNode.style.fontFamily = this._fontFamily;
}
setFontWeight(fontWeight) {
if (this._fontWeight === fontWeight) {
return;
}
this._fontWeight = fontWeight;
this.domNode.style.fontWeight = this._fontWeight;
}
setFontSize(_fontSize) {
const fontSize = numberAsPixels(_fontSize);
if (this._fontSize === fontSize) {
return;
}
this._fontSize = fontSize;
this.domNode.style.fontSize = this._fontSize;
}
setFontStyle(fontStyle) {
if (this._fontStyle === fontStyle) {
return;
}
this._fontStyle = fontStyle;
this.domNode.style.fontStyle = this._fontStyle;
}
setFontFeatureSettings(fontFeatureSettings) {
if (this._fontFeatureSettings === fontFeatureSettings) {
return;
}
this._fontFeatureSettings = fontFeatureSettings;
this.domNode.style.fontFeatureSettings = this._fontFeatureSettings;
}
setFontVariationSettings(fontVariationSettings) {
if (this._fontVariationSettings === fontVariationSettings) {
return;
}
this._fontVariationSettings = fontVariationSettings;
this.domNode.style.fontVariationSettings = this._fontVariationSettings;
}
setTextDecoration(textDecoration) {
if (this._textDecoration === textDecoration) {
return;
}
this._textDecoration = textDecoration;
this.domNode.style.textDecoration = this._textDecoration;
}
setLineHeight(_lineHeight) {
const lineHeight = numberAsPixels(_lineHeight);
if (this._lineHeight === lineHeight) {
return;
}
this._lineHeight = lineHeight;
this.domNode.style.lineHeight = this._lineHeight;
}
setLetterSpacing(_letterSpacing) {
const letterSpacing = numberAsPixels(_letterSpacing);
if (this._letterSpacing === letterSpacing) {
return;
}
this._letterSpacing = letterSpacing;
this.domNode.style.letterSpacing = this._letterSpacing;
}
setClassName(className) {
if (this._className === className) {
return;
}
this._className = className;
this.domNode.className = this._className;
}
toggleClassName(className, shouldHaveIt) {
this.domNode.classList.toggle(className, shouldHaveIt);
this._className = this.domNode.className;
}
setDisplay(display) {
if (this._display === display) {
return;
}
this._display = display;
this.domNode.style.display = this._display;
}
setPosition(position) {
if (this._position === position) {
return;
}
this._position = position;
this.domNode.style.position = this._position;
}
setVisibility(visibility) {
if (this._visibility === visibility) {
return;
}
this._visibility = visibility;
this.domNode.style.visibility = this._visibility;
}
setColor(color) {
if (this._color === color) {
return;
}
this._color = color;
this.domNode.style.color = this._color;
}
setBackgroundColor(backgroundColor) {
if (this._backgroundColor === backgroundColor) {
return;
}
this._backgroundColor = backgroundColor;
this.domNode.style.backgroundColor = this._backgroundColor;
}
setLayerHinting(layerHint) {
if (this._layerHint === layerHint) {
return;
}
this._layerHint = layerHint;
this.domNode.style.transform = this._layerHint ? 'translate3d(0px, 0px, 0px)' : '';
}
setBoxShadow(boxShadow) {
if (this._boxShadow === boxShadow) {
return;
}
this._boxShadow = boxShadow;
this.domNode.style.boxShadow = boxShadow;
}
setContain(contain) {
if (this._contain === contain) {
return;
}
this._contain = contain;
this.domNode.style.contain = this._contain;
}
setAttribute(name, value) {
this.domNode.setAttribute(name, value);
}
removeAttribute(name) {
this.domNode.removeAttribute(name);
}
appendChild(child) {
this.domNode.appendChild(child.domNode);
}
removeChild(child) {
this.domNode.removeChild(child.domNode);
}
}
function numberAsPixels(value) {
return (typeof value === 'number' ? `${value}px` : value);
}
export function createFastDomNode(domNode) {
return new FastDomNode(domNode);
}

View file

@ -1 +1,167 @@
import*as DOM from"./dom.js";export function renderText(e,t={}){const n=createElement(t);return n.textContent=e,n}export function renderFormattedText(e,t={}){const n=createElement(t);return _renderFormattedText(n,parseFormattedText(e,!!t.renderCodeSegments),t.actionHandler,t.renderCodeSegments),n}export function createElement(e){const t=e.inline?"span":"div",n=document.createElement(t);return e.className&&(n.className=e.className),n}class StringStream{constructor(e){this.source=e,this.index=0}eos(){return this.index>=this.source.length}next(){const e=this.peek();return this.advance(),e}peek(){return this.source[this.index]}advance(){this.index++}}function _renderFormattedText(e,t,n,r){let c;if(2===t.type)c=document.createTextNode(t.content||"");else if(3===t.type)c=document.createElement("b");else if(4===t.type)c=document.createElement("i");else if(7===t.type&&r)c=document.createElement("code");else if(5===t.type&&n){const e=document.createElement("a");n.disposables.add(DOM.addStandardDisposableListener(e,"click",(e=>{n.callback(String(t.index),e)}))),c=e}else 8===t.type?c=document.createElement("br"):1===t.type&&(c=e);c&&e!==c&&e.appendChild(c),c&&Array.isArray(t.children)&&t.children.forEach((e=>{_renderFormattedText(c,e,n,r)}))}function parseFormattedText(e,t){const n={type:1,children:[]};let r=0,c=n;const s=[],a=new StringStream(e);for(;!a.eos();){let e=a.next();const n="\\"===e&&0!==formatTagType(a.peek(),t);if(n&&(e=a.next()),!n&&isFormatTag(e,t)&&e===a.peek()){a.advance(),2===c.type&&(c=s.pop());const n=formatTagType(e,t);if(c.type===n||5===c.type&&6===n)c=s.pop();else{const e={type:n,children:[]};5===n&&(e.index=r,r++),c.children.push(e),s.push(c),c=e}}else if("\n"===e)2===c.type&&(c=s.pop()),c.children.push({type:8});else if(2!==c.type){const t={type:2,content:e};c.children.push(t),s.push(c),c=t}else c.content+=e}return 2===c.type&&(c=s.pop()),s.length,n}function isFormatTag(e,t){return 0!==formatTagType(e,t)}function formatTagType(e,t){switch(e){case"*":return 3;case"_":return 4;case"[":return 5;case"]":return 6;case"`":return t?7:0;default:return 0}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as DOM from './dom.js';
export function renderText(text, options = {}) {
const element = createElement(options);
element.textContent = text;
return element;
}
export function renderFormattedText(formattedText, options = {}) {
const element = createElement(options);
_renderFormattedText(element, parseFormattedText(formattedText, !!options.renderCodeSegments), options.actionHandler, options.renderCodeSegments);
return element;
}
export function createElement(options) {
const tagName = options.inline ? 'span' : 'div';
const element = document.createElement(tagName);
if (options.className) {
element.className = options.className;
}
return element;
}
class StringStream {
constructor(source) {
this.source = source;
this.index = 0;
}
eos() {
return this.index >= this.source.length;
}
next() {
const next = this.peek();
this.advance();
return next;
}
peek() {
return this.source[this.index];
}
advance() {
this.index++;
}
}
function _renderFormattedText(element, treeNode, actionHandler, renderCodeSegments) {
let child;
if (treeNode.type === 2 /* FormatType.Text */) {
child = document.createTextNode(treeNode.content || '');
}
else if (treeNode.type === 3 /* FormatType.Bold */) {
child = document.createElement('b');
}
else if (treeNode.type === 4 /* FormatType.Italics */) {
child = document.createElement('i');
}
else if (treeNode.type === 7 /* FormatType.Code */ && renderCodeSegments) {
child = document.createElement('code');
}
else if (treeNode.type === 5 /* FormatType.Action */ && actionHandler) {
const a = document.createElement('a');
actionHandler.disposables.add(DOM.addStandardDisposableListener(a, 'click', (event) => {
actionHandler.callback(String(treeNode.index), event);
}));
child = a;
}
else if (treeNode.type === 8 /* FormatType.NewLine */) {
child = document.createElement('br');
}
else if (treeNode.type === 1 /* FormatType.Root */) {
child = element;
}
if (child && element !== child) {
element.appendChild(child);
}
if (child && Array.isArray(treeNode.children)) {
treeNode.children.forEach((nodeChild) => {
_renderFormattedText(child, nodeChild, actionHandler, renderCodeSegments);
});
}
}
function parseFormattedText(content, parseCodeSegments) {
const root = {
type: 1 /* FormatType.Root */,
children: []
};
let actionViewItemIndex = 0;
let current = root;
const stack = [];
const stream = new StringStream(content);
while (!stream.eos()) {
let next = stream.next();
const isEscapedFormatType = (next === '\\' && formatTagType(stream.peek(), parseCodeSegments) !== 0 /* FormatType.Invalid */);
if (isEscapedFormatType) {
next = stream.next(); // unread the backslash if it escapes a format tag type
}
if (!isEscapedFormatType && isFormatTag(next, parseCodeSegments) && next === stream.peek()) {
stream.advance();
if (current.type === 2 /* FormatType.Text */) {
current = stack.pop();
}
const type = formatTagType(next, parseCodeSegments);
if (current.type === type || (current.type === 5 /* FormatType.Action */ && type === 6 /* FormatType.ActionClose */)) {
current = stack.pop();
}
else {
const newCurrent = {
type: type,
children: []
};
if (type === 5 /* FormatType.Action */) {
newCurrent.index = actionViewItemIndex;
actionViewItemIndex++;
}
current.children.push(newCurrent);
stack.push(current);
current = newCurrent;
}
}
else if (next === '\n') {
if (current.type === 2 /* FormatType.Text */) {
current = stack.pop();
}
current.children.push({
type: 8 /* FormatType.NewLine */
});
}
else {
if (current.type !== 2 /* FormatType.Text */) {
const textCurrent = {
type: 2 /* FormatType.Text */,
content: next
};
current.children.push(textCurrent);
stack.push(current);
current = textCurrent;
}
else {
current.content += next;
}
}
}
if (current.type === 2 /* FormatType.Text */) {
current = stack.pop();
}
if (stack.length) {
// incorrectly formatted string literal
}
return root;
}
function isFormatTag(char, supportCodeSegments) {
return formatTagType(char, supportCodeSegments) !== 0 /* FormatType.Invalid */;
}
function formatTagType(char, supportCodeSegments) {
switch (char) {
case '*':
return 3 /* FormatType.Bold */;
case '_':
return 4 /* FormatType.Italics */;
case '[':
return 5 /* FormatType.Action */;
case ']':
return 6 /* FormatType.ActionClose */;
case '`':
return supportCodeSegments ? 7 /* FormatType.Code */ : 0 /* FormatType.Invalid */;
default:
return 0 /* FormatType.Invalid */;
}
}

View file

@ -1 +1,80 @@
import*as dom from"./dom.js";import{DisposableStore,toDisposable}from"../common/lifecycle.js";export class GlobalPointerMoveMonitor{constructor(){this._hooks=new DisposableStore,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(o,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;const i=this._onStopCallback;this._onStopCallback=null,o&&i&&i(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(o,t,i,s,e){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=s,this._onStopCallback=e;let n=o;try{o.setPointerCapture(t),this._hooks.add(toDisposable((()=>{try{o.releasePointerCapture(t)}catch(o){}})))}catch(o){n=window}this._hooks.add(dom.addDisposableListener(n,dom.EventType.POINTER_MOVE,(o=>{o.buttons===i?(o.preventDefault(),this._pointerMoveCallback(o)):this.stopMonitoring(!0)}))),this._hooks.add(dom.addDisposableListener(n,dom.EventType.POINTER_UP,(o=>this.stopMonitoring(!0))))}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from './dom.js';
import { DisposableStore, toDisposable } from '../common/lifecycle.js';
export class GlobalPointerMoveMonitor {
constructor() {
this._hooks = new DisposableStore();
this._pointerMoveCallback = null;
this._onStopCallback = null;
}
dispose() {
this.stopMonitoring(false);
this._hooks.dispose();
}
stopMonitoring(invokeStopCallback, browserEvent) {
if (!this.isMonitoring()) {
// Not monitoring
return;
}
// Unhook
this._hooks.clear();
this._pointerMoveCallback = null;
const onStopCallback = this._onStopCallback;
this._onStopCallback = null;
if (invokeStopCallback && onStopCallback) {
onStopCallback(browserEvent);
}
}
isMonitoring() {
return !!this._pointerMoveCallback;
}
startMonitoring(initialElement, pointerId, initialButtons, pointerMoveCallback, onStopCallback) {
if (this.isMonitoring()) {
this.stopMonitoring(false);
}
this._pointerMoveCallback = pointerMoveCallback;
this._onStopCallback = onStopCallback;
let eventSource = initialElement;
try {
initialElement.setPointerCapture(pointerId);
this._hooks.add(toDisposable(() => {
try {
initialElement.releasePointerCapture(pointerId);
}
catch (err) {
// See https://github.com/microsoft/vscode/issues/161731
//
// `releasePointerCapture` sometimes fails when being invoked with the exception:
// DOMException: Failed to execute 'releasePointerCapture' on 'Element':
// No active pointer with the given id is found.
//
// There's no need to do anything in case of failure
}
}));
}
catch (err) {
// See https://github.com/microsoft/vscode/issues/144584
// See https://github.com/microsoft/vscode/issues/146947
// `setPointerCapture` sometimes fails when being invoked
// from a `mousedown` listener on macOS and Windows
// and it always fails on Linux with the exception:
// DOMException: Failed to execute 'setPointerCapture' on 'Element':
// No active pointer with the given id is found.
// In case of failure, we bind the listeners on the window
eventSource = window;
}
this._hooks.add(dom.addDisposableListener(eventSource, dom.EventType.POINTER_MOVE, (e) => {
if (e.buttons !== initialButtons) {
// Buttons state has changed in the meantime
this.stopMonitoring(true);
return;
}
e.preventDefault();
this._pointerMoveCallback(e);
}));
this._hooks.add(dom.addDisposableListener(eventSource, dom.EventType.POINTER_UP, (e) => this.stopMonitoring(true)));
}
}

View file

@ -1 +1,5 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export {};

View file

@ -1 +1,86 @@
let hasDifferentOriginAncestorFlag=!1,sameOriginWindowChainCache=null;function getParentWindowIfSameOrigin(i){if(!i.parent||i.parent===i)return null;try{const n=i.location,e=i.parent.location;if("null"!==n.origin&&"null"!==e.origin&&n.origin!==e.origin)return hasDifferentOriginAncestorFlag=!0,null}catch(i){return hasDifferentOriginAncestorFlag=!0,null}return i.parent}export class IframeUtils{static getSameOriginWindowChain(){if(!sameOriginWindowChainCache){sameOriginWindowChainCache=[];let i,n=window;do{i=getParentWindowIfSameOrigin(n),i?sameOriginWindowChainCache.push({window:n,iframeElement:n.frameElement||null}):sameOriginWindowChainCache.push({window:n,iframeElement:null}),n=i}while(n)}return sameOriginWindowChainCache.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(i,n){if(!n||i===n)return{top:0,left:0};let e=0,t=0;const r=this.getSameOriginWindowChain();for(const i of r){if(e+=i.window.scrollY,t+=i.window.scrollX,i.window===n)break;if(!i.iframeElement)break;const r=i.iframeElement.getBoundingClientRect();e+=r.top,t+=r.left}return{top:e,left:t}}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
let hasDifferentOriginAncestorFlag = false;
let sameOriginWindowChainCache = null;
function getParentWindowIfSameOrigin(w) {
if (!w.parent || w.parent === w) {
return null;
}
// Cannot really tell if we have access to the parent window unless we try to access something in it
try {
const location = w.location;
const parentLocation = w.parent.location;
if (location.origin !== 'null' && parentLocation.origin !== 'null' && location.origin !== parentLocation.origin) {
hasDifferentOriginAncestorFlag = true;
return null;
}
}
catch (e) {
hasDifferentOriginAncestorFlag = true;
return null;
}
return w.parent;
}
export class IframeUtils {
/**
* Returns a chain of embedded windows with the same origin (which can be accessed programmatically).
* Having a chain of length 1 might mean that the current execution environment is running outside of an iframe or inside an iframe embedded in a window with a different origin.
* To distinguish if at one point the current execution environment is running inside a window with a different origin, see hasDifferentOriginAncestor()
*/
static getSameOriginWindowChain() {
if (!sameOriginWindowChainCache) {
sameOriginWindowChainCache = [];
let w = window;
let parent;
do {
parent = getParentWindowIfSameOrigin(w);
if (parent) {
sameOriginWindowChainCache.push({
window: w,
iframeElement: w.frameElement || null
});
}
else {
sameOriginWindowChainCache.push({
window: w,
iframeElement: null
});
}
w = parent;
} while (w);
}
return sameOriginWindowChainCache.slice(0);
}
/**
* Returns the position of `childWindow` relative to `ancestorWindow`
*/
static getPositionOfChildWindowRelativeToAncestorWindow(childWindow, ancestorWindow) {
if (!ancestorWindow || childWindow === ancestorWindow) {
return {
top: 0,
left: 0
};
}
let top = 0, left = 0;
const windowChain = this.getSameOriginWindowChain();
for (const windowChainEl of windowChain) {
top += windowChainEl.window.scrollY;
left += windowChainEl.window.scrollX;
if (windowChainEl.window === ancestorWindow) {
break;
}
if (!windowChainEl.iframeElement) {
break;
}
const boundingRect = windowChainEl.iframeElement.getBoundingClientRect();
top += boundingRect.top;
left += boundingRect.left;
}
return {
top: top,
left: left
};
}
}

View file

@ -1 +1,119 @@
import*as browser from"./browser.js";import{EVENT_KEY_CODE_MAP,KeyCodeUtils}from"../common/keyCodes.js";import{KeyCodeChord}from"../common/keybindings.js";import*as platform from"../common/platform.js";function extractKeyCode(e){if(e.charCode){const t=String.fromCharCode(e.charCode).toUpperCase();return KeyCodeUtils.fromString(t)}const t=e.keyCode;if(3===t)return 7;if(browser.isFirefox){if(59===t)return 80;if(107===t)return 81;if(109===t)return 83;if(platform.isMacintosh&&224===t)return 57}else if(browser.isWebKit){if(91===t)return 57;if(platform.isMacintosh&&93===t)return 57;if(!platform.isMacintosh&&92===t)return 57}return EVENT_KEY_CODE_MAP[t]||0}const ctrlKeyMod=platform.isMacintosh?256:2048,altKeyMod=512,shiftKeyMod=1024,metaKeyMod=platform.isMacintosh?2048:256;export class StandardKeyboardEvent{constructor(e){this._standardKeyboardEventBrand=!0;const t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=t.getModifierState("AltGraph"),this.keyCode=extractKeyCode(t),this.code=t.code,this.ctrlKey=this.ctrlKey||5===this.keyCode,this.altKey=this.altKey||6===this.keyCode,this.shiftKey=this.shiftKey||4===this.keyCode,this.metaKey=this.metaKey||57===this.keyCode,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=ctrlKeyMod),this.altKey&&(t|=512),this.shiftKey&&(t|=1024),this.metaKey&&(t|=metaKeyMod),t|=e,t}_computeKeyCodeChord(){let e=0;return 5!==this.keyCode&&4!==this.keyCode&&6!==this.keyCode&&57!==this.keyCode&&(e=this.keyCode),new KeyCodeChord(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as browser from './browser.js';
import { EVENT_KEY_CODE_MAP, KeyCodeUtils } from '../common/keyCodes.js';
import { KeyCodeChord } from '../common/keybindings.js';
import * as platform from '../common/platform.js';
function extractKeyCode(e) {
if (e.charCode) {
// "keypress" events mostly
const char = String.fromCharCode(e.charCode).toUpperCase();
return KeyCodeUtils.fromString(char);
}
const keyCode = e.keyCode;
// browser quirks
if (keyCode === 3) {
return 7 /* KeyCode.PauseBreak */;
}
else if (browser.isFirefox) {
if (keyCode === 59) {
return 80 /* KeyCode.Semicolon */;
}
else if (keyCode === 107) {
return 81 /* KeyCode.Equal */;
}
else if (keyCode === 109) {
return 83 /* KeyCode.Minus */;
}
else if (platform.isMacintosh && keyCode === 224) {
return 57 /* KeyCode.Meta */;
}
}
else if (browser.isWebKit) {
if (keyCode === 91) {
return 57 /* KeyCode.Meta */;
}
else if (platform.isMacintosh && keyCode === 93) {
// the two meta keys in the Mac have different key codes (91 and 93)
return 57 /* KeyCode.Meta */;
}
else if (!platform.isMacintosh && keyCode === 92) {
return 57 /* KeyCode.Meta */;
}
}
// cross browser keycodes:
return EVENT_KEY_CODE_MAP[keyCode] || 0 /* KeyCode.Unknown */;
}
const ctrlKeyMod = (platform.isMacintosh ? 256 /* KeyMod.WinCtrl */ : 2048 /* KeyMod.CtrlCmd */);
const altKeyMod = 512 /* KeyMod.Alt */;
const shiftKeyMod = 1024 /* KeyMod.Shift */;
const metaKeyMod = (platform.isMacintosh ? 2048 /* KeyMod.CtrlCmd */ : 256 /* KeyMod.WinCtrl */);
export class StandardKeyboardEvent {
constructor(source) {
this._standardKeyboardEventBrand = true;
const e = source;
this.browserEvent = e;
this.target = e.target;
this.ctrlKey = e.ctrlKey;
this.shiftKey = e.shiftKey;
this.altKey = e.altKey;
this.metaKey = e.metaKey;
this.altGraphKey = e.getModifierState('AltGraph');
this.keyCode = extractKeyCode(e);
this.code = e.code;
// console.info(e.type + ": keyCode: " + e.keyCode + ", which: " + e.which + ", charCode: " + e.charCode + ", detail: " + e.detail + " ====> " + this.keyCode + ' -- ' + KeyCode[this.keyCode]);
this.ctrlKey = this.ctrlKey || this.keyCode === 5 /* KeyCode.Ctrl */;
this.altKey = this.altKey || this.keyCode === 6 /* KeyCode.Alt */;
this.shiftKey = this.shiftKey || this.keyCode === 4 /* KeyCode.Shift */;
this.metaKey = this.metaKey || this.keyCode === 57 /* KeyCode.Meta */;
this._asKeybinding = this._computeKeybinding();
this._asKeyCodeChord = this._computeKeyCodeChord();
// console.log(`code: ${e.code}, keyCode: ${e.keyCode}, key: ${e.key}`);
}
preventDefault() {
if (this.browserEvent && this.browserEvent.preventDefault) {
this.browserEvent.preventDefault();
}
}
stopPropagation() {
if (this.browserEvent && this.browserEvent.stopPropagation) {
this.browserEvent.stopPropagation();
}
}
toKeyCodeChord() {
return this._asKeyCodeChord;
}
equals(other) {
return this._asKeybinding === other;
}
_computeKeybinding() {
let key = 0 /* KeyCode.Unknown */;
if (this.keyCode !== 5 /* KeyCode.Ctrl */ && this.keyCode !== 4 /* KeyCode.Shift */ && this.keyCode !== 6 /* KeyCode.Alt */ && this.keyCode !== 57 /* KeyCode.Meta */) {
key = this.keyCode;
}
let result = 0;
if (this.ctrlKey) {
result |= ctrlKeyMod;
}
if (this.altKey) {
result |= altKeyMod;
}
if (this.shiftKey) {
result |= shiftKeyMod;
}
if (this.metaKey) {
result |= metaKeyMod;
}
result |= key;
return result;
}
_computeKeyCodeChord() {
let key = 0 /* KeyCode.Unknown */;
if (this.keyCode !== 5 /* KeyCode.Ctrl */ && this.keyCode !== 4 /* KeyCode.Shift */ && this.keyCode !== 6 /* KeyCode.Alt */ && this.keyCode !== 57 /* KeyCode.Meta */) {
key = this.keyCode;
}
return new KeyCodeChord(this.ctrlKey, this.shiftKey, this.altKey, this.metaKey, key);
}
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1,123 @@
import*as browser from"./browser.js";import{IframeUtils}from"./iframe.js";import*as platform from"../common/platform.js";export class StandardMouseEvent{constructor(t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=0===t.button,this.middleButton=1===t.button,this.rightButton=2===t.button,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,"dblclick"===t.type&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,"number"==typeof t.pageX?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,this.posy=t.clientY+document.body.scrollTop+document.documentElement.scrollTop);const e=IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow(self,t.view);this.posx-=e.left,this.posy-=e.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}}export class StandardWheelEvent{constructor(t,e=0,s=0){if(this.browserEvent=t||null,this.target=t?t.target||t.targetNode||t.srcElement:null,this.deltaY=s,this.deltaX=e,t){const e=t,s=t;if(void 0!==e.wheelDeltaY)this.deltaY=e.wheelDeltaY/120;else if(void 0!==s.VERTICAL_AXIS&&s.axis===s.VERTICAL_AXIS)this.deltaY=-s.detail/3;else if("wheel"===t.type){const e=t;e.deltaMode===e.DOM_DELTA_LINE?browser.isFirefox&&!platform.isMacintosh?this.deltaY=-t.deltaY/3:this.deltaY=-t.deltaY:this.deltaY=-t.deltaY/40}if(void 0!==e.wheelDeltaX)browser.isSafari&&platform.isWindows?this.deltaX=-e.wheelDeltaX/120:this.deltaX=e.wheelDeltaX/120;else if(void 0!==s.HORIZONTAL_AXIS&&s.axis===s.HORIZONTAL_AXIS)this.deltaX=-t.detail/3;else if("wheel"===t.type){const e=t;e.deltaMode===e.DOM_DELTA_LINE?browser.isFirefox&&!platform.isMacintosh?this.deltaX=-t.deltaX/3:this.deltaX=-t.deltaX:this.deltaX=-t.deltaX/40}0===this.deltaY&&0===this.deltaX&&t.wheelDelta&&(this.deltaY=t.wheelDelta/120)}}preventDefault(){var t;null===(t=this.browserEvent)||void 0===t||t.preventDefault()}stopPropagation(){var t;null===(t=this.browserEvent)||void 0===t||t.stopPropagation()}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as browser from './browser.js';
import { IframeUtils } from './iframe.js';
import * as platform from '../common/platform.js';
export class StandardMouseEvent {
constructor(e) {
this.timestamp = Date.now();
this.browserEvent = e;
this.leftButton = e.button === 0;
this.middleButton = e.button === 1;
this.rightButton = e.button === 2;
this.buttons = e.buttons;
this.target = e.target;
this.detail = e.detail || 1;
if (e.type === 'dblclick') {
this.detail = 2;
}
this.ctrlKey = e.ctrlKey;
this.shiftKey = e.shiftKey;
this.altKey = e.altKey;
this.metaKey = e.metaKey;
if (typeof e.pageX === 'number') {
this.posx = e.pageX;
this.posy = e.pageY;
}
else {
// Probably hit by MSGestureEvent
this.posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
this.posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
}
// Find the position of the iframe this code is executing in relative to the iframe where the event was captured.
const iframeOffsets = IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow(self, e.view);
this.posx -= iframeOffsets.left;
this.posy -= iframeOffsets.top;
}
preventDefault() {
this.browserEvent.preventDefault();
}
stopPropagation() {
this.browserEvent.stopPropagation();
}
}
export class StandardWheelEvent {
constructor(e, deltaX = 0, deltaY = 0) {
this.browserEvent = e || null;
this.target = e ? (e.target || e.targetNode || e.srcElement) : null;
this.deltaY = deltaY;
this.deltaX = deltaX;
if (e) {
// Old (deprecated) wheel events
const e1 = e;
const e2 = e;
// vertical delta scroll
if (typeof e1.wheelDeltaY !== 'undefined') {
this.deltaY = e1.wheelDeltaY / 120;
}
else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
this.deltaY = -e2.detail / 3;
}
else if (e.type === 'wheel') {
// Modern wheel event
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
const ev = e;
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
// the deltas are expressed in lines
if (browser.isFirefox && !platform.isMacintosh) {
this.deltaY = -e.deltaY / 3;
}
else {
this.deltaY = -e.deltaY;
}
}
else {
this.deltaY = -e.deltaY / 40;
}
}
// horizontal delta scroll
if (typeof e1.wheelDeltaX !== 'undefined') {
if (browser.isSafari && platform.isWindows) {
this.deltaX = -(e1.wheelDeltaX / 120);
}
else {
this.deltaX = e1.wheelDeltaX / 120;
}
}
else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
this.deltaX = -e.detail / 3;
}
else if (e.type === 'wheel') {
// Modern wheel event
// https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
const ev = e;
if (ev.deltaMode === ev.DOM_DELTA_LINE) {
// the deltas are expressed in lines
if (browser.isFirefox && !platform.isMacintosh) {
this.deltaX = -e.deltaX / 3;
}
else {
this.deltaX = -e.deltaX;
}
}
else {
this.deltaX = -e.deltaX / 40;
}
}
// Assume a vertical scroll if nothing else worked
if (this.deltaY === 0 && this.deltaX === 0 && e.wheelDelta) {
this.deltaY = e.wheelDelta / 120;
}
}
}
preventDefault() {
var _a;
(_a = this.browserEvent) === null || _a === void 0 ? void 0 : _a.preventDefault();
}
stopPropagation() {
var _a;
(_a = this.browserEvent) === null || _a === void 0 ? void 0 : _a.stopPropagation();
}
}

View file

@ -1 +1,220 @@
export var inputLatency;!function(e){const n={total:0,min:Number.MAX_VALUE,max:0},r=Object.assign({},n),t=Object.assign({},n),a=Object.assign({},n);let o=0;const c={keydown:0,input:0,render:0};function u(){1===c.keydown&&(performance.mark("keydown/end"),c.keydown=2)}function i(){performance.mark("input/start"),c.input=1,s()}function p(){1===c.input&&(performance.mark("input/end"),c.input=2)}function m(){1===c.render&&(performance.mark("render/end"),c.render=2)}function s(){setTimeout(d)}function d(){2===c.keydown&&2===c.input&&2===c.render&&(performance.mark("inputlatency/end"),performance.measure("keydown","keydown/start","keydown/end"),performance.measure("input","input/start","input/end"),performance.measure("render","render/start","render/end"),performance.measure("inputlatency","inputlatency/start","inputlatency/end"),f("keydown",n),f("input",r),f("render",t),f("inputlatency",a),o++,performance.clearMarks("keydown/start"),performance.clearMarks("keydown/end"),performance.clearMarks("input/start"),performance.clearMarks("input/end"),performance.clearMarks("render/start"),performance.clearMarks("render/end"),performance.clearMarks("inputlatency/start"),performance.clearMarks("inputlatency/end"),performance.clearMeasures("keydown"),performance.clearMeasures("input"),performance.clearMeasures("render"),performance.clearMeasures("inputlatency"),c.keydown=0,c.input=0,c.render=0)}function f(e,n){const r=performance.getEntriesByName(e)[0].duration;n.total+=r,n.min=Math.min(n.min,r),n.max=Math.max(n.max,r)}function k(e){return{average:e.total/o,max:e.max,min:e.min}}function y(e){e.total=0,e.min=Number.MAX_VALUE,e.max=0}e.onKeyDown=function(){d(),performance.mark("inputlatency/start"),performance.mark("keydown/start"),c.keydown=1,queueMicrotask(u)},e.onBeforeInput=i,e.onInput=function(){0===c.input&&i(),queueMicrotask(p)},e.onKeyUp=function(){d()},e.onSelectionChange=function(){d()},e.onRenderStart=function(){2===c.keydown&&2===c.input&&0===c.render&&(performance.mark("render/start"),c.render=1,queueMicrotask(m),s())},e.getAndClearMeasurements=function(){if(0===o)return;const e={keydown:k(n),input:k(r),render:k(t),total:k(a),sampleCount:o};return y(n),y(r),y(t),y(a),o=0,e}}(inputLatency||(inputLatency={}));
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export var inputLatency;
(function (inputLatency) {
const totalKeydownTime = { total: 0, min: Number.MAX_VALUE, max: 0 };
const totalInputTime = Object.assign({}, totalKeydownTime);
const totalRenderTime = Object.assign({}, totalKeydownTime);
const totalInputLatencyTime = Object.assign({}, totalKeydownTime);
let measurementsCount = 0;
const state = {
keydown: 0 /* EventPhase.Before */,
input: 0 /* EventPhase.Before */,
render: 0 /* EventPhase.Before */,
};
/**
* Record the start of the keydown event.
*/
function onKeyDown() {
/** Direct Check C. See explanation in {@link recordIfFinished} */
recordIfFinished();
performance.mark('inputlatency/start');
performance.mark('keydown/start');
state.keydown = 1 /* EventPhase.InProgress */;
queueMicrotask(markKeyDownEnd);
}
inputLatency.onKeyDown = onKeyDown;
/**
* Mark the end of the keydown event.
*/
function markKeyDownEnd() {
if (state.keydown === 1 /* EventPhase.InProgress */) {
performance.mark('keydown/end');
state.keydown = 2 /* EventPhase.Finished */;
}
}
/**
* Record the start of the beforeinput event.
*/
function onBeforeInput() {
performance.mark('input/start');
state.input = 1 /* EventPhase.InProgress */;
/** Schedule Task A. See explanation in {@link recordIfFinished} */
scheduleRecordIfFinishedTask();
}
inputLatency.onBeforeInput = onBeforeInput;
/**
* Record the start of the input event.
*/
function onInput() {
if (state.input === 0 /* EventPhase.Before */) {
// it looks like we didn't receive a `beforeinput`
onBeforeInput();
}
queueMicrotask(markInputEnd);
}
inputLatency.onInput = onInput;
function markInputEnd() {
if (state.input === 1 /* EventPhase.InProgress */) {
performance.mark('input/end');
state.input = 2 /* EventPhase.Finished */;
}
}
/**
* Record the start of the keyup event.
*/
function onKeyUp() {
/** Direct Check D. See explanation in {@link recordIfFinished} */
recordIfFinished();
}
inputLatency.onKeyUp = onKeyUp;
/**
* Record the start of the selectionchange event.
*/
function onSelectionChange() {
/** Direct Check E. See explanation in {@link recordIfFinished} */
recordIfFinished();
}
inputLatency.onSelectionChange = onSelectionChange;
/**
* Record the start of the animation frame performing the rendering.
*/
function onRenderStart() {
// Render may be triggered during input, but we only measure the following animation frame
if (state.keydown === 2 /* EventPhase.Finished */ && state.input === 2 /* EventPhase.Finished */ && state.render === 0 /* EventPhase.Before */) {
// Only measure the first render after keyboard input
performance.mark('render/start');
state.render = 1 /* EventPhase.InProgress */;
queueMicrotask(markRenderEnd);
/** Schedule Task B. See explanation in {@link recordIfFinished} */
scheduleRecordIfFinishedTask();
}
}
inputLatency.onRenderStart = onRenderStart;
/**
* Mark the end of the animation frame performing the rendering.
*/
function markRenderEnd() {
if (state.render === 1 /* EventPhase.InProgress */) {
performance.mark('render/end');
state.render = 2 /* EventPhase.Finished */;
}
}
function scheduleRecordIfFinishedTask() {
// Here we can safely assume that the `setTimeout` will not be
// artificially delayed by 4ms because we schedule it from
// event handlers
setTimeout(recordIfFinished);
}
/**
* Record the input latency sample if input handling and rendering are finished.
*
* The challenge here is that we want to record the latency in such a way that it includes
* also the layout and painting work the browser does during the animation frame task.
*
* Simply scheduling a new task (via `setTimeout`) from the animation frame task would
* schedule the new task at the end of the task queue (after other code that uses `setTimeout`),
* so we need to use multiple strategies to make sure our task runs before others:
*
* We schedule tasks (A and B):
* - we schedule a task A (via a `setTimeout` call) when the input starts in `markInputStart`.
* If the animation frame task is scheduled quickly by the browser, then task A has a very good
* chance of being the very first task after the animation frame and thus will record the input latency.
* - however, if the animation frame task is scheduled a bit later, then task A might execute
* before the animation frame task. We therefore schedule another task B from `markRenderStart`.
*
* We do direct checks in browser event handlers (C, D, E):
* - if the browser has multiple keydown events queued up, they will be scheduled before the `setTimeout` tasks,
* so we do a direct check in the keydown event handler (C).
* - depending on timing, sometimes the animation frame is scheduled even before the `keyup` event, so we
* do a direct check there too (E).
* - the browser oftentimes emits a `selectionchange` event after an `input`, so we do a direct check there (D).
*/
function recordIfFinished() {
if (state.keydown === 2 /* EventPhase.Finished */ && state.input === 2 /* EventPhase.Finished */ && state.render === 2 /* EventPhase.Finished */) {
performance.mark('inputlatency/end');
performance.measure('keydown', 'keydown/start', 'keydown/end');
performance.measure('input', 'input/start', 'input/end');
performance.measure('render', 'render/start', 'render/end');
performance.measure('inputlatency', 'inputlatency/start', 'inputlatency/end');
addMeasure('keydown', totalKeydownTime);
addMeasure('input', totalInputTime);
addMeasure('render', totalRenderTime);
addMeasure('inputlatency', totalInputLatencyTime);
// console.info(
// `input latency=${performance.getEntriesByName('inputlatency')[0].duration.toFixed(1)} [` +
// `keydown=${performance.getEntriesByName('keydown')[0].duration.toFixed(1)}, ` +
// `input=${performance.getEntriesByName('input')[0].duration.toFixed(1)}, ` +
// `render=${performance.getEntriesByName('render')[0].duration.toFixed(1)}` +
// `]`
// );
measurementsCount++;
reset();
}
}
function addMeasure(entryName, cumulativeMeasurement) {
const duration = performance.getEntriesByName(entryName)[0].duration;
cumulativeMeasurement.total += duration;
cumulativeMeasurement.min = Math.min(cumulativeMeasurement.min, duration);
cumulativeMeasurement.max = Math.max(cumulativeMeasurement.max, duration);
}
/**
* Clear the current sample.
*/
function reset() {
performance.clearMarks('keydown/start');
performance.clearMarks('keydown/end');
performance.clearMarks('input/start');
performance.clearMarks('input/end');
performance.clearMarks('render/start');
performance.clearMarks('render/end');
performance.clearMarks('inputlatency/start');
performance.clearMarks('inputlatency/end');
performance.clearMeasures('keydown');
performance.clearMeasures('input');
performance.clearMeasures('render');
performance.clearMeasures('inputlatency');
state.keydown = 0 /* EventPhase.Before */;
state.input = 0 /* EventPhase.Before */;
state.render = 0 /* EventPhase.Before */;
}
/**
* Gets all input latency samples and clears the internal buffers to start recording a new set
* of samples.
*/
function getAndClearMeasurements() {
if (measurementsCount === 0) {
return undefined;
}
// Assemble the result
const result = {
keydown: cumulativeToFinalMeasurement(totalKeydownTime),
input: cumulativeToFinalMeasurement(totalInputTime),
render: cumulativeToFinalMeasurement(totalRenderTime),
total: cumulativeToFinalMeasurement(totalInputLatencyTime),
sampleCount: measurementsCount
};
// Clear the cumulative measurements
clearCumulativeMeasurement(totalKeydownTime);
clearCumulativeMeasurement(totalInputTime);
clearCumulativeMeasurement(totalRenderTime);
clearCumulativeMeasurement(totalInputLatencyTime);
measurementsCount = 0;
return result;
}
inputLatency.getAndClearMeasurements = getAndClearMeasurements;
function cumulativeToFinalMeasurement(cumulative) {
return {
average: cumulative.total / measurementsCount,
max: cumulative.max,
min: cumulative.min,
};
}
function clearCumulativeMeasurement(cumulative) {
cumulative.total = 0;
cumulative.min = Number.MAX_VALUE;
cumulative.max = 0;
}
})(inputLatency || (inputLatency = {}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1,88 @@
import*as dom from"../../dom.js";import{isMacintosh}from"../../../common/platform.js";import"./aria.css";const MAX_MESSAGE_LENGTH=2e4;let ariaContainer,alertContainer,alertContainer2,statusContainer,statusContainer2;export function setARIAContainer(t){ariaContainer=document.createElement("div"),ariaContainer.className="monaco-aria-container";const e=()=>{const t=document.createElement("div");return t.className="monaco-alert",t.setAttribute("role","alert"),t.setAttribute("aria-atomic","true"),ariaContainer.appendChild(t),t};alertContainer=e(),alertContainer2=e();const a=()=>{const t=document.createElement("div");return t.className="monaco-status",t.setAttribute("role","complementary"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),ariaContainer.appendChild(t),t};statusContainer=a(),statusContainer2=a(),t.appendChild(ariaContainer)}export function alert(t){ariaContainer&&(alertContainer.textContent!==t?(dom.clearNode(alertContainer2),insertMessage(alertContainer,t)):(dom.clearNode(alertContainer),insertMessage(alertContainer2,t)))}export function status(t){ariaContainer&&(isMacintosh?alert(t):statusContainer.textContent!==t?(dom.clearNode(statusContainer2),insertMessage(statusContainer,t)):(dom.clearNode(statusContainer),insertMessage(statusContainer2,t)))}function insertMessage(t,e){dom.clearNode(t),e.length>2e4&&(e=e.substr(0,2e4)),t.textContent=e,t.style.visibility="hidden",t.style.visibility="visible"}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../dom.js';
import { isMacintosh } from '../../../common/platform.js';
import './aria.css';
// Use a max length since we are inserting the whole msg in the DOM and that can cause browsers to freeze for long messages #94233
const MAX_MESSAGE_LENGTH = 20000;
let ariaContainer;
let alertContainer;
let alertContainer2;
let statusContainer;
let statusContainer2;
export function setARIAContainer(parent) {
ariaContainer = document.createElement('div');
ariaContainer.className = 'monaco-aria-container';
const createAlertContainer = () => {
const element = document.createElement('div');
element.className = 'monaco-alert';
element.setAttribute('role', 'alert');
element.setAttribute('aria-atomic', 'true');
ariaContainer.appendChild(element);
return element;
};
alertContainer = createAlertContainer();
alertContainer2 = createAlertContainer();
const createStatusContainer = () => {
const element = document.createElement('div');
element.className = 'monaco-status';
element.setAttribute('role', 'complementary');
element.setAttribute('aria-live', 'polite');
element.setAttribute('aria-atomic', 'true');
ariaContainer.appendChild(element);
return element;
};
statusContainer = createStatusContainer();
statusContainer2 = createStatusContainer();
parent.appendChild(ariaContainer);
}
/**
* Given the provided message, will make sure that it is read as alert to screen readers.
*/
export function alert(msg) {
if (!ariaContainer) {
return;
}
// Use alternate containers such that duplicated messages get read out by screen readers #99466
if (alertContainer.textContent !== msg) {
dom.clearNode(alertContainer2);
insertMessage(alertContainer, msg);
}
else {
dom.clearNode(alertContainer);
insertMessage(alertContainer2, msg);
}
}
/**
* Given the provided message, will make sure that it is read as status to screen readers.
*/
export function status(msg) {
if (!ariaContainer) {
return;
}
if (isMacintosh) {
alert(msg); // VoiceOver does not seem to support status role
}
else {
if (statusContainer.textContent !== msg) {
dom.clearNode(statusContainer2);
insertMessage(statusContainer, msg);
}
else {
dom.clearNode(statusContainer);
insertMessage(statusContainer2, msg);
}
}
}
function insertMessage(target, msg) {
dom.clearNode(target);
if (msg.length > MAX_MESSAGE_LENGTH) {
msg = msg.substr(0, MAX_MESSAGE_LENGTH);
}
target.textContent = msg;
// See https://www.paciellogroup.com/blog/2012/06/html5-accessibility-chops-aria-rolealert-browser-support/
target.style.visibility = 'hidden';
target.style.visibility = 'visible';
}

View file

@ -1 +1 @@
import"./breadcrumbsWidget.css";
import './breadcrumbsWidget.css';

View file

@ -1 +1,150 @@
import{addDisposableListener,EventHelper,EventType,reset,trackFocus}from"../../dom.js";import{StandardKeyboardEvent}from"../../keyboardEvent.js";import{EventType as TouchEventType,Gesture}from"../../touch.js";import{renderLabelWithIcons}from"../iconLabel/iconLabels.js";import{Color}from"../../../common/color.js";import{Emitter}from"../../../common/event.js";import{Disposable}from"../../../common/lifecycle.js";import"./button.css";export const unthemedButtonStyles={buttonBackground:"#0E639C",buttonHoverBackground:"#006BB3",buttonSeparator:Color.white.toString(),buttonForeground:Color.white.toString(),buttonBorder:void 0,buttonSecondaryBackground:void 0,buttonSecondaryForeground:void 0,buttonSecondaryHoverBackground:void 0};export class Button extends Disposable{get onDidClick(){return this._onDidClick.event}constructor(t,e){super(),this._onDidClick=this._register(new Emitter),this.options=e,this._element=document.createElement("a"),this._element.classList.add("monaco-button"),this._element.tabIndex=0,this._element.setAttribute("role","button");const s=e.secondary?e.buttonSecondaryBackground:e.buttonBackground,o=e.secondary?e.buttonSecondaryForeground:e.buttonForeground;this._element.style.color=o||"",this._element.style.backgroundColor=s||"",e.supportShortLabel&&(this._labelShortElement=document.createElement("div"),this._labelShortElement.classList.add("monaco-button-label-short"),this._element.appendChild(this._labelShortElement),this._labelElement=document.createElement("div"),this._labelElement.classList.add("monaco-button-label"),this._element.appendChild(this._labelElement),this._element.classList.add("monaco-text-button-with-short-label")),t.appendChild(this._element),this._register(Gesture.addTarget(this._element)),[EventType.CLICK,TouchEventType.Tap].forEach((t=>{this._register(addDisposableListener(this._element,t,(t=>{this.enabled?this._onDidClick.fire(t):EventHelper.stop(t)})))})),this._register(addDisposableListener(this._element,EventType.KEY_DOWN,(t=>{const e=new StandardKeyboardEvent(t);let s=!1;this.enabled&&(e.equals(3)||e.equals(10))?(this._onDidClick.fire(t),s=!0):e.equals(9)&&(this._element.blur(),s=!0),s&&EventHelper.stop(e,!0)}))),this._register(addDisposableListener(this._element,EventType.MOUSE_OVER,(t=>{this._element.classList.contains("disabled")||this.updateBackground(!0)}))),this._register(addDisposableListener(this._element,EventType.MOUSE_OUT,(t=>{this.updateBackground(!1)}))),this.focusTracker=this._register(trackFocus(this._element)),this._register(this.focusTracker.onDidFocus((()=>{this.enabled&&this.updateBackground(!0)}))),this._register(this.focusTracker.onDidBlur((()=>{this.enabled&&this.updateBackground(!1)})))}getContentElements(t){const e=[];for(let s of renderLabelWithIcons(t))if("string"==typeof s){if(s=s.trim(),""===s)continue;const t=document.createElement("span");t.textContent=s,e.push(t)}else e.push(s);return e}updateBackground(t){let e;e=this.options.secondary?t?this.options.buttonSecondaryHoverBackground:this.options.buttonSecondaryBackground:t?this.options.buttonHoverBackground:this.options.buttonBackground,e&&(this._element.style.backgroundColor=e)}get element(){return this._element}set label(t){this._element.classList.add("monaco-text-button");const e=this.options.supportShortLabel?this._labelElement:this._element;this.options.supportIcons?reset(e,...this.getContentElements(t)):e.textContent=t,"string"==typeof this.options.title?this._element.title=this.options.title:this.options.title&&(this._element.title=t)}set enabled(t){t?(this._element.classList.remove("disabled"),this._element.setAttribute("aria-disabled",String(!1)),this._element.tabIndex=0):(this._element.classList.add("disabled"),this._element.setAttribute("aria-disabled",String(!0)))}get enabled(){return!this._element.classList.contains("disabled")}}
import { addDisposableListener, EventHelper, EventType, reset, trackFocus } from '../../dom.js';
import { StandardKeyboardEvent } from '../../keyboardEvent.js';
import { EventType as TouchEventType, Gesture } from '../../touch.js';
import { renderLabelWithIcons } from '../iconLabel/iconLabels.js';
import { Color } from '../../../common/color.js';
import { Emitter } from '../../../common/event.js';
import { Disposable } from '../../../common/lifecycle.js';
import './button.css';
export const unthemedButtonStyles = {
buttonBackground: '#0E639C',
buttonHoverBackground: '#006BB3',
buttonSeparator: Color.white.toString(),
buttonForeground: Color.white.toString(),
buttonBorder: undefined,
buttonSecondaryBackground: undefined,
buttonSecondaryForeground: undefined,
buttonSecondaryHoverBackground: undefined
};
export class Button extends Disposable {
get onDidClick() { return this._onDidClick.event; }
constructor(container, options) {
super();
this._onDidClick = this._register(new Emitter());
this.options = options;
this._element = document.createElement('a');
this._element.classList.add('monaco-button');
this._element.tabIndex = 0;
this._element.setAttribute('role', 'button');
const background = options.secondary ? options.buttonSecondaryBackground : options.buttonBackground;
const foreground = options.secondary ? options.buttonSecondaryForeground : options.buttonForeground;
this._element.style.color = foreground || '';
this._element.style.backgroundColor = background || '';
if (options.supportShortLabel) {
this._labelShortElement = document.createElement('div');
this._labelShortElement.classList.add('monaco-button-label-short');
this._element.appendChild(this._labelShortElement);
this._labelElement = document.createElement('div');
this._labelElement.classList.add('monaco-button-label');
this._element.appendChild(this._labelElement);
this._element.classList.add('monaco-text-button-with-short-label');
}
container.appendChild(this._element);
this._register(Gesture.addTarget(this._element));
[EventType.CLICK, TouchEventType.Tap].forEach(eventType => {
this._register(addDisposableListener(this._element, eventType, e => {
if (!this.enabled) {
EventHelper.stop(e);
return;
}
this._onDidClick.fire(e);
}));
});
this._register(addDisposableListener(this._element, EventType.KEY_DOWN, e => {
const event = new StandardKeyboardEvent(e);
let eventHandled = false;
if (this.enabled && (event.equals(3 /* KeyCode.Enter */) || event.equals(10 /* KeyCode.Space */))) {
this._onDidClick.fire(e);
eventHandled = true;
}
else if (event.equals(9 /* KeyCode.Escape */)) {
this._element.blur();
eventHandled = true;
}
if (eventHandled) {
EventHelper.stop(event, true);
}
}));
this._register(addDisposableListener(this._element, EventType.MOUSE_OVER, e => {
if (!this._element.classList.contains('disabled')) {
this.updateBackground(true);
}
}));
this._register(addDisposableListener(this._element, EventType.MOUSE_OUT, e => {
this.updateBackground(false); // restore standard styles
}));
// Also set hover background when button is focused for feedback
this.focusTracker = this._register(trackFocus(this._element));
this._register(this.focusTracker.onDidFocus(() => { if (this.enabled) {
this.updateBackground(true);
} }));
this._register(this.focusTracker.onDidBlur(() => { if (this.enabled) {
this.updateBackground(false);
} }));
}
getContentElements(content) {
const elements = [];
for (let segment of renderLabelWithIcons(content)) {
if (typeof (segment) === 'string') {
segment = segment.trim();
// Ignore empty segment
if (segment === '') {
continue;
}
// Convert string segments to <span> nodes
const node = document.createElement('span');
node.textContent = segment;
elements.push(node);
}
else {
elements.push(segment);
}
}
return elements;
}
updateBackground(hover) {
let background;
if (this.options.secondary) {
background = hover ? this.options.buttonSecondaryHoverBackground : this.options.buttonSecondaryBackground;
}
else {
background = hover ? this.options.buttonHoverBackground : this.options.buttonBackground;
}
if (background) {
this._element.style.backgroundColor = background;
}
}
get element() {
return this._element;
}
set label(value) {
this._element.classList.add('monaco-text-button');
const labelElement = this.options.supportShortLabel ? this._labelElement : this._element;
if (this.options.supportIcons) {
reset(labelElement, ...this.getContentElements(value));
}
else {
labelElement.textContent = value;
}
if (typeof this.options.title === 'string') {
this._element.title = this.options.title;
}
else if (this.options.title) {
this._element.title = value;
}
}
set enabled(value) {
if (value) {
this._element.classList.remove('disabled');
this._element.setAttribute('aria-disabled', String(false));
this._element.tabIndex = 0;
}
else {
this._element.classList.add('disabled');
this._element.setAttribute('aria-disabled', String(true));
}
}
get enabled() {
return !this._element.classList.contains('disabled');
}
}

View file

@ -1 +1,6 @@
import"./codicon/codicon.css";import"./codicon/codicon-modifiers.css";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import './codicon/codicon.css';
import './codicon/codicon-modifiers.css';

File diff suppressed because one or more lines are too long

View file

@ -1 +1,36 @@
import{$,append}from"../../dom.js";import{format}from"../../../common/strings.js";import"./countBadge.css";export class CountBadge{constructor(t,o,e){this.options=o,this.styles=e,this.count=0,this.element=append(t,$(".monaco-count-badge")),this.countFormat=this.options.countFormat||"{0}",this.titleFormat=this.options.titleFormat||"",this.setCount(this.options.count||0)}setCount(t){this.count=t,this.render()}setTitleFormat(t){this.titleFormat=t,this.render()}render(){var t,o;this.element.textContent=format(this.countFormat,this.count),this.element.title=format(this.titleFormat,this.count),this.element.style.backgroundColor=null!==(t=this.styles.badgeBackground)&&void 0!==t?t:"",this.element.style.color=null!==(o=this.styles.badgeForeground)&&void 0!==o?o:"",this.styles.badgeBorder&&(this.element.style.border=`1px solid ${this.styles.badgeBorder}`)}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { $, append } from '../../dom.js';
import { format } from '../../../common/strings.js';
import './countBadge.css';
export class CountBadge {
constructor(container, options, styles) {
this.options = options;
this.styles = styles;
this.count = 0;
this.element = append(container, $('.monaco-count-badge'));
this.countFormat = this.options.countFormat || '{0}';
this.titleFormat = this.options.titleFormat || '';
this.setCount(this.options.count || 0);
}
setCount(count) {
this.count = count;
this.render();
}
setTitleFormat(titleFormat) {
this.titleFormat = titleFormat;
this.render();
}
render() {
var _a, _b;
this.element.textContent = format(this.countFormat, this.count);
this.element.title = format(this.titleFormat, this.count);
this.element.style.backgroundColor = (_a = this.styles.badgeBackground) !== null && _a !== void 0 ? _a : '';
this.element.style.color = (_b = this.styles.badgeForeground) !== null && _b !== void 0 ? _b : '';
if (this.styles.badgeBorder) {
this.element.style.border = `1px solid ${this.styles.badgeBorder}`;
}
}
}

View file

@ -1 +1 @@
import"./dialog.css";
import './dialog.css';

View file

@ -1 +1,141 @@
import{$,addDisposableListener,append,EventHelper,EventType}from"../../dom.js";import{StandardKeyboardEvent}from"../../keyboardEvent.js";import{EventType as GestureEventType,Gesture}from"../../touch.js";import{ActionRunner}from"../../../common/actions.js";import{Emitter}from"../../../common/event.js";import"./dropdown.css";class BaseDropdown extends ActionRunner{constructor(e,t){super(),this._onDidChangeVisibility=this._register(new Emitter),this.onDidChangeVisibility=this._onDidChangeVisibility.event,this._element=append(e,$(".monaco-dropdown")),this._label=append(this._element,$(".dropdown-label"));let i=t.labelRenderer;i||(i=e=>(e.textContent=t.label||"",null));for(const e of[EventType.CLICK,EventType.MOUSE_DOWN,GestureEventType.Tap])this._register(addDisposableListener(this.element,e,(e=>EventHelper.stop(e,!0))));for(const e of[EventType.MOUSE_DOWN,GestureEventType.Tap])this._register(addDisposableListener(this._label,e,(e=>{e instanceof MouseEvent&&(e.detail>1||0!==e.button)||(this.visible?this.hide():this.show())})));this._register(addDisposableListener(this._label,EventType.KEY_UP,(e=>{const t=new StandardKeyboardEvent(e);(t.equals(3)||t.equals(10))&&(EventHelper.stop(e,!0),this.visible?this.hide():this.show())})));const s=i(this._label);s&&this._register(s),this._register(Gesture.addTarget(this._label))}get element(){return this._element}show(){this.visible||(this.visible=!0,this._onDidChangeVisibility.fire(!0))}hide(){this.visible&&(this.visible=!1,this._onDidChangeVisibility.fire(!1))}dispose(){super.dispose(),this.hide(),this.boxContainer&&(this.boxContainer.remove(),this.boxContainer=void 0),this.contents&&(this.contents.remove(),this.contents=void 0),this._label&&(this._label.remove(),this._label=void 0)}}export class DropdownMenu extends BaseDropdown{constructor(e,t){super(e,t),this._actions=[],this._contextMenuProvider=t.contextMenuProvider,this.actions=t.actions||[],this.actionProvider=t.actionProvider,this.menuClassName=t.menuClassName||"",this.menuAsChild=!!t.menuAsChild}set menuOptions(e){this._menuOptions=e}get menuOptions(){return this._menuOptions}get actions(){return this.actionProvider?this.actionProvider.getActions():this._actions}set actions(e){this._actions=e}show(){super.show(),this.element.classList.add("active"),this._contextMenuProvider.showContextMenu({getAnchor:()=>this.element,getActions:()=>this.actions,getActionsContext:()=>this.menuOptions?this.menuOptions.context:null,getActionViewItem:(e,t)=>this.menuOptions&&this.menuOptions.actionViewItemProvider?this.menuOptions.actionViewItemProvider(e,t):void 0,getKeyBinding:e=>this.menuOptions&&this.menuOptions.getKeyBinding?this.menuOptions.getKeyBinding(e):void 0,getMenuClassName:()=>this.menuClassName,onHide:()=>this.onHide(),actionRunner:this.menuOptions?this.menuOptions.actionRunner:void 0,anchorAlignment:this.menuOptions?this.menuOptions.anchorAlignment:0,domForShadowRoot:this.menuAsChild?this.element:void 0})}hide(){super.hide()}onHide(){this.hide(),this.element.classList.remove("active")}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { $, addDisposableListener, append, EventHelper, EventType } from '../../dom.js';
import { StandardKeyboardEvent } from '../../keyboardEvent.js';
import { EventType as GestureEventType, Gesture } from '../../touch.js';
import { ActionRunner } from '../../../common/actions.js';
import { Emitter } from '../../../common/event.js';
import './dropdown.css';
class BaseDropdown extends ActionRunner {
constructor(container, options) {
super();
this._onDidChangeVisibility = this._register(new Emitter());
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
this._element = append(container, $('.monaco-dropdown'));
this._label = append(this._element, $('.dropdown-label'));
let labelRenderer = options.labelRenderer;
if (!labelRenderer) {
labelRenderer = (container) => {
container.textContent = options.label || '';
return null;
};
}
for (const event of [EventType.CLICK, EventType.MOUSE_DOWN, GestureEventType.Tap]) {
this._register(addDisposableListener(this.element, event, e => EventHelper.stop(e, true))); // prevent default click behaviour to trigger
}
for (const event of [EventType.MOUSE_DOWN, GestureEventType.Tap]) {
this._register(addDisposableListener(this._label, event, e => {
if (e instanceof MouseEvent && (e.detail > 1 || e.button !== 0)) {
// prevent right click trigger to allow separate context menu (https://github.com/microsoft/vscode/issues/151064)
// prevent multiple clicks to open multiple context menus (https://github.com/microsoft/vscode/issues/41363)
return;
}
if (this.visible) {
this.hide();
}
else {
this.show();
}
}));
}
this._register(addDisposableListener(this._label, EventType.KEY_UP, e => {
const event = new StandardKeyboardEvent(e);
if (event.equals(3 /* KeyCode.Enter */) || event.equals(10 /* KeyCode.Space */)) {
EventHelper.stop(e, true); // https://github.com/microsoft/vscode/issues/57997
if (this.visible) {
this.hide();
}
else {
this.show();
}
}
}));
const cleanupFn = labelRenderer(this._label);
if (cleanupFn) {
this._register(cleanupFn);
}
this._register(Gesture.addTarget(this._label));
}
get element() {
return this._element;
}
show() {
if (!this.visible) {
this.visible = true;
this._onDidChangeVisibility.fire(true);
}
}
hide() {
if (this.visible) {
this.visible = false;
this._onDidChangeVisibility.fire(false);
}
}
dispose() {
super.dispose();
this.hide();
if (this.boxContainer) {
this.boxContainer.remove();
this.boxContainer = undefined;
}
if (this.contents) {
this.contents.remove();
this.contents = undefined;
}
if (this._label) {
this._label.remove();
this._label = undefined;
}
}
}
export class DropdownMenu extends BaseDropdown {
constructor(container, options) {
super(container, options);
this._actions = [];
this._contextMenuProvider = options.contextMenuProvider;
this.actions = options.actions || [];
this.actionProvider = options.actionProvider;
this.menuClassName = options.menuClassName || '';
this.menuAsChild = !!options.menuAsChild;
}
set menuOptions(options) {
this._menuOptions = options;
}
get menuOptions() {
return this._menuOptions;
}
get actions() {
if (this.actionProvider) {
return this.actionProvider.getActions();
}
return this._actions;
}
set actions(actions) {
this._actions = actions;
}
show() {
super.show();
this.element.classList.add('active');
this._contextMenuProvider.showContextMenu({
getAnchor: () => this.element,
getActions: () => this.actions,
getActionsContext: () => this.menuOptions ? this.menuOptions.context : null,
getActionViewItem: (action, options) => this.menuOptions && this.menuOptions.actionViewItemProvider ? this.menuOptions.actionViewItemProvider(action, options) : undefined,
getKeyBinding: action => this.menuOptions && this.menuOptions.getKeyBinding ? this.menuOptions.getKeyBinding(action) : undefined,
getMenuClassName: () => this.menuClassName,
onHide: () => this.onHide(),
actionRunner: this.menuOptions ? this.menuOptions.actionRunner : undefined,
anchorAlignment: this.menuOptions ? this.menuOptions.anchorAlignment : 0 /* AnchorAlignment.LEFT */,
domForShadowRoot: this.menuAsChild ? this.element : undefined
});
}
hide() {
super.hide();
}
onHide() {
this.hide();
this.element.classList.remove('active');
}
}

View file

@ -1 +1,102 @@
import{$,append}from"../../dom.js";import{BaseActionViewItem}from"../actionbar/actionViewItems.js";import{DropdownMenu}from"./dropdown.js";import{Emitter}from"../../../common/event.js";import"./dropdown.css";export class DropdownMenuActionViewItem extends BaseActionViewItem{constructor(t,i,e,n=Object.create(null)){super(null,t,n),this.actionItem=null,this._onDidChangeVisibility=this._register(new Emitter),this.onDidChangeVisibility=this._onDidChangeVisibility.event,this.menuActionsOrProvider=i,this.contextMenuProvider=e,this.options=n,this.options.actionRunner&&(this.actionRunner=this.options.actionRunner)}render(t){this.actionItem=t;const i=Array.isArray(this.menuActionsOrProvider),e={contextMenuProvider:this.contextMenuProvider,labelRenderer:t=>{this.element=append(t,$("a.action-label"));let i=[];return"string"==typeof this.options.classNames?i=this.options.classNames.split(/\s+/g).filter((t=>!!t)):this.options.classNames&&(i=this.options.classNames),i.find((t=>"icon"===t))||i.push("codicon"),this.element.classList.add(...i),this.element.setAttribute("role","button"),this.element.setAttribute("aria-haspopup","true"),this.element.setAttribute("aria-expanded","false"),this.element.title=this._action.label||"",this.element.ariaLabel=this._action.label||"",null},menuAsChild:this.options.menuAsChild,actions:i?this.menuActionsOrProvider:void 0,actionProvider:i?void 0:this.menuActionsOrProvider};if(this.dropdownMenu=this._register(new DropdownMenu(t,e)),this._register(this.dropdownMenu.onDidChangeVisibility((t=>{var i;null===(i=this.element)||void 0===i||i.setAttribute("aria-expanded",`${t}`),this._onDidChangeVisibility.fire(t)}))),this.dropdownMenu.menuOptions={actionViewItemProvider:this.options.actionViewItemProvider,actionRunner:this.actionRunner,getKeyBinding:this.options.keybindingProvider,context:this._context},this.options.anchorAlignmentProvider){const t=this;this.dropdownMenu.menuOptions=Object.assign(Object.assign({},this.dropdownMenu.menuOptions),{get anchorAlignment(){return t.options.anchorAlignmentProvider()}})}this.updateTooltip(),this.updateEnabled()}getTooltip(){let t=null;return this.action.tooltip?t=this.action.tooltip:this.action.label&&(t=this.action.label),null!=t?t:void 0}setActionContext(t){super.setActionContext(t),this.dropdownMenu&&(this.dropdownMenu.menuOptions?this.dropdownMenu.menuOptions.context=t:this.dropdownMenu.menuOptions={context:t})}show(){var t;null===(t=this.dropdownMenu)||void 0===t||t.show()}updateEnabled(){var t,i;const e=!this.action.enabled;null===(t=this.actionItem)||void 0===t||t.classList.toggle("disabled",e),null===(i=this.element)||void 0===i||i.classList.toggle("disabled",e)}}
import { $, append } from '../../dom.js';
import { BaseActionViewItem } from '../actionbar/actionViewItems.js';
import { DropdownMenu } from './dropdown.js';
import { Emitter } from '../../../common/event.js';
import './dropdown.css';
export class DropdownMenuActionViewItem extends BaseActionViewItem {
constructor(action, menuActionsOrProvider, contextMenuProvider, options = Object.create(null)) {
super(null, action, options);
this.actionItem = null;
this._onDidChangeVisibility = this._register(new Emitter());
this.onDidChangeVisibility = this._onDidChangeVisibility.event;
this.menuActionsOrProvider = menuActionsOrProvider;
this.contextMenuProvider = contextMenuProvider;
this.options = options;
if (this.options.actionRunner) {
this.actionRunner = this.options.actionRunner;
}
}
render(container) {
this.actionItem = container;
const labelRenderer = (el) => {
this.element = append(el, $('a.action-label'));
let classNames = [];
if (typeof this.options.classNames === 'string') {
classNames = this.options.classNames.split(/\s+/g).filter(s => !!s);
}
else if (this.options.classNames) {
classNames = this.options.classNames;
}
// todo@aeschli: remove codicon, should come through `this.options.classNames`
if (!classNames.find(c => c === 'icon')) {
classNames.push('codicon');
}
this.element.classList.add(...classNames);
this.element.setAttribute('role', 'button');
this.element.setAttribute('aria-haspopup', 'true');
this.element.setAttribute('aria-expanded', 'false');
this.element.title = this._action.label || '';
this.element.ariaLabel = this._action.label || '';
return null;
};
const isActionsArray = Array.isArray(this.menuActionsOrProvider);
const options = {
contextMenuProvider: this.contextMenuProvider,
labelRenderer: labelRenderer,
menuAsChild: this.options.menuAsChild,
actions: isActionsArray ? this.menuActionsOrProvider : undefined,
actionProvider: isActionsArray ? undefined : this.menuActionsOrProvider
};
this.dropdownMenu = this._register(new DropdownMenu(container, options));
this._register(this.dropdownMenu.onDidChangeVisibility(visible => {
var _a;
(_a = this.element) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', `${visible}`);
this._onDidChangeVisibility.fire(visible);
}));
this.dropdownMenu.menuOptions = {
actionViewItemProvider: this.options.actionViewItemProvider,
actionRunner: this.actionRunner,
getKeyBinding: this.options.keybindingProvider,
context: this._context
};
if (this.options.anchorAlignmentProvider) {
const that = this;
this.dropdownMenu.menuOptions = Object.assign(Object.assign({}, this.dropdownMenu.menuOptions), { get anchorAlignment() {
return that.options.anchorAlignmentProvider();
} });
}
this.updateTooltip();
this.updateEnabled();
}
getTooltip() {
let title = null;
if (this.action.tooltip) {
title = this.action.tooltip;
}
else if (this.action.label) {
title = this.action.label;
}
return title !== null && title !== void 0 ? title : undefined;
}
setActionContext(newContext) {
super.setActionContext(newContext);
if (this.dropdownMenu) {
if (this.dropdownMenu.menuOptions) {
this.dropdownMenu.menuOptions.context = newContext;
}
else {
this.dropdownMenu.menuOptions = { context: newContext };
}
}
}
show() {
var _a;
(_a = this.dropdownMenu) === null || _a === void 0 ? void 0 : _a.show();
}
updateEnabled() {
var _a, _b;
const disabled = !this.action.enabled;
(_a = this.actionItem) === null || _a === void 0 ? void 0 : _a.classList.toggle('disabled', disabled);
(_b = this.element) === null || _b === void 0 ? void 0 : _b.classList.toggle('disabled', disabled);
}
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1,46 @@
import{Toggle}from"../toggle/toggle.js";import{Codicon}from"../../../common/codicons.js";import*as nls from"../../../../nls.js";const NLS_CASE_SENSITIVE_TOGGLE_LABEL=nls.localize("caseDescription","Match Case"),NLS_WHOLE_WORD_TOGGLE_LABEL=nls.localize("wordsDescription","Match Whole Word"),NLS_REGEX_TOGGLE_LABEL=nls.localize("regexDescription","Use Regular Expression");export class CaseSensitiveToggle extends Toggle{constructor(e){super({icon:Codicon.caseSensitive,title:NLS_CASE_SENSITIVE_TOGGLE_LABEL+e.appendTitle,isChecked:e.isChecked,inputActiveOptionBorder:e.inputActiveOptionBorder,inputActiveOptionForeground:e.inputActiveOptionForeground,inputActiveOptionBackground:e.inputActiveOptionBackground})}}export class WholeWordsToggle extends Toggle{constructor(e){super({icon:Codicon.wholeWord,title:NLS_WHOLE_WORD_TOGGLE_LABEL+e.appendTitle,isChecked:e.isChecked,inputActiveOptionBorder:e.inputActiveOptionBorder,inputActiveOptionForeground:e.inputActiveOptionForeground,inputActiveOptionBackground:e.inputActiveOptionBackground})}}export class RegexToggle extends Toggle{constructor(e){super({icon:Codicon.regex,title:NLS_REGEX_TOGGLE_LABEL+e.appendTitle,isChecked:e.isChecked,inputActiveOptionBorder:e.inputActiveOptionBorder,inputActiveOptionForeground:e.inputActiveOptionForeground,inputActiveOptionBackground:e.inputActiveOptionBackground})}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Toggle } from '../toggle/toggle.js';
import { Codicon } from '../../../common/codicons.js';
import * as nls from '../../../../nls.js';
const NLS_CASE_SENSITIVE_TOGGLE_LABEL = nls.localize('caseDescription', "Match Case");
const NLS_WHOLE_WORD_TOGGLE_LABEL = nls.localize('wordsDescription', "Match Whole Word");
const NLS_REGEX_TOGGLE_LABEL = nls.localize('regexDescription', "Use Regular Expression");
export class CaseSensitiveToggle extends Toggle {
constructor(opts) {
super({
icon: Codicon.caseSensitive,
title: NLS_CASE_SENSITIVE_TOGGLE_LABEL + opts.appendTitle,
isChecked: opts.isChecked,
inputActiveOptionBorder: opts.inputActiveOptionBorder,
inputActiveOptionForeground: opts.inputActiveOptionForeground,
inputActiveOptionBackground: opts.inputActiveOptionBackground
});
}
}
export class WholeWordsToggle extends Toggle {
constructor(opts) {
super({
icon: Codicon.wholeWord,
title: NLS_WHOLE_WORD_TOGGLE_LABEL + opts.appendTitle,
isChecked: opts.isChecked,
inputActiveOptionBorder: opts.inputActiveOptionBorder,
inputActiveOptionForeground: opts.inputActiveOptionForeground,
inputActiveOptionBackground: opts.inputActiveOptionBackground
});
}
}
export class RegexToggle extends Toggle {
constructor(opts) {
super({
icon: Codicon.regex,
title: NLS_REGEX_TOGGLE_LABEL + opts.appendTitle,
isChecked: opts.isChecked,
inputActiveOptionBorder: opts.inputActiveOptionBorder,
inputActiveOptionForeground: opts.inputActiveOptionForeground,
inputActiveOptionBackground: opts.inputActiveOptionBackground
});
}
}

View file

@ -1 +1,168 @@
import*as dom from"../../dom.js";import{Toggle}from"../toggle/toggle.js";import{HistoryInputBox}from"../inputbox/inputBox.js";import{Widget}from"../widget.js";import{Codicon}from"../../../common/codicons.js";import{Emitter}from"../../../common/event.js";import"./findInput.css";import*as nls from"../../../../nls.js";const NLS_DEFAULT_LABEL=nls.localize("defaultLabel","input"),NLS_PRESERVE_CASE_LABEL=nls.localize("label.preserveCaseToggle","Preserve Case");class PreserveCaseToggle extends Toggle{constructor(e){super({icon:Codicon.preserveCase,title:NLS_PRESERVE_CASE_LABEL+e.appendTitle,isChecked:e.isChecked,inputActiveOptionBorder:e.inputActiveOptionBorder,inputActiveOptionForeground:e.inputActiveOptionForeground,inputActiveOptionBackground:e.inputActiveOptionBackground})}}export class ReplaceInput extends Widget{constructor(e,t,i,s){super(),this._showOptionButtons=i,this.fixFocusOnOptionClickEnabled=!0,this.cachedOptionsWidth=0,this._onDidOptionChange=this._register(new Emitter),this.onDidOptionChange=this._onDidOptionChange.event,this._onKeyDown=this._register(new Emitter),this.onKeyDown=this._onKeyDown.event,this._onMouseDown=this._register(new Emitter),this._onInput=this._register(new Emitter),this._onKeyUp=this._register(new Emitter),this._onPreserveCaseKeyDown=this._register(new Emitter),this.onPreserveCaseKeyDown=this._onPreserveCaseKeyDown.event,this.contextViewProvider=t,this.placeholder=s.placeholder||"",this.validation=s.validation,this.label=s.label||NLS_DEFAULT_LABEL;const o=s.appendPreserveCaseLabel||"",n=s.history||[],r=!!s.flexibleHeight,h=!!s.flexibleWidth,d=s.flexibleMaxHeight;this.domNode=document.createElement("div"),this.domNode.classList.add("monaco-findInput"),this.inputBox=this._register(new HistoryInputBox(this.domNode,this.contextViewProvider,{ariaLabel:this.label||"",placeholder:this.placeholder||"",validationOptions:{validation:this.validation},history:n,showHistoryHint:s.showHistoryHint,flexibleHeight:r,flexibleWidth:h,flexibleMaxHeight:d,inputBoxStyles:s.inputBoxStyles})),this.preserveCase=this._register(new PreserveCaseToggle(Object.assign({appendTitle:o,isChecked:!1},s.toggleStyles))),this._register(this.preserveCase.onChange((e=>{this._onDidOptionChange.fire(e),!e&&this.fixFocusOnOptionClickEnabled&&this.inputBox.focus(),this.validate()}))),this._register(this.preserveCase.onKeyDown((e=>{this._onPreserveCaseKeyDown.fire(e)}))),this._showOptionButtons?this.cachedOptionsWidth=this.preserveCase.width():this.cachedOptionsWidth=0;const l=[this.preserveCase.domNode];this.onkeydown(this.domNode,(e=>{if(e.equals(15)||e.equals(17)||e.equals(9)){const t=l.indexOf(document.activeElement);if(t>=0){let i=-1;e.equals(17)?i=(t+1)%l.length:e.equals(15)&&(i=0===t?l.length-1:t-1),e.equals(9)?(l[t].blur(),this.inputBox.focus()):i>=0&&l[i].focus(),dom.EventHelper.stop(e,!0)}}}));const a=document.createElement("div");a.className="controls",a.style.display=this._showOptionButtons?"block":"none",a.appendChild(this.preserveCase.domNode),this.domNode.appendChild(a),null==e||e.appendChild(this.domNode),this.onkeydown(this.inputBox.inputElement,(e=>this._onKeyDown.fire(e))),this.onkeyup(this.inputBox.inputElement,(e=>this._onKeyUp.fire(e))),this.oninput(this.inputBox.inputElement,(e=>this._onInput.fire())),this.onmousedown(this.inputBox.inputElement,(e=>this._onMouseDown.fire(e)))}enable(){this.domNode.classList.remove("disabled"),this.inputBox.enable(),this.preserveCase.enable()}disable(){this.domNode.classList.add("disabled"),this.inputBox.disable(),this.preserveCase.disable()}setEnabled(e){e?this.enable():this.disable()}select(){this.inputBox.select()}focus(){this.inputBox.focus()}getPreserveCase(){return this.preserveCase.checked}setPreserveCase(e){this.preserveCase.checked=e}focusOnPreserve(){this.preserveCase.focus()}validate(){var e;null===(e=this.inputBox)||void 0===e||e.validate()}set width(e){this.inputBox.paddingRight=this.cachedOptionsWidth,this.domNode.style.width=e+"px"}dispose(){super.dispose()}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../dom.js';
import { Toggle } from '../toggle/toggle.js';
import { HistoryInputBox } from '../inputbox/inputBox.js';
import { Widget } from '../widget.js';
import { Codicon } from '../../../common/codicons.js';
import { Emitter } from '../../../common/event.js';
import './findInput.css';
import * as nls from '../../../../nls.js';
const NLS_DEFAULT_LABEL = nls.localize('defaultLabel', "input");
const NLS_PRESERVE_CASE_LABEL = nls.localize('label.preserveCaseToggle', "Preserve Case");
class PreserveCaseToggle extends Toggle {
constructor(opts) {
super({
// TODO: does this need its own icon?
icon: Codicon.preserveCase,
title: NLS_PRESERVE_CASE_LABEL + opts.appendTitle,
isChecked: opts.isChecked,
inputActiveOptionBorder: opts.inputActiveOptionBorder,
inputActiveOptionForeground: opts.inputActiveOptionForeground,
inputActiveOptionBackground: opts.inputActiveOptionBackground
});
}
}
export class ReplaceInput extends Widget {
constructor(parent, contextViewProvider, _showOptionButtons, options) {
super();
this._showOptionButtons = _showOptionButtons;
this.fixFocusOnOptionClickEnabled = true;
this.cachedOptionsWidth = 0;
this._onDidOptionChange = this._register(new Emitter());
this.onDidOptionChange = this._onDidOptionChange.event;
this._onKeyDown = this._register(new Emitter());
this.onKeyDown = this._onKeyDown.event;
this._onMouseDown = this._register(new Emitter());
this._onInput = this._register(new Emitter());
this._onKeyUp = this._register(new Emitter());
this._onPreserveCaseKeyDown = this._register(new Emitter());
this.onPreserveCaseKeyDown = this._onPreserveCaseKeyDown.event;
this.contextViewProvider = contextViewProvider;
this.placeholder = options.placeholder || '';
this.validation = options.validation;
this.label = options.label || NLS_DEFAULT_LABEL;
const appendPreserveCaseLabel = options.appendPreserveCaseLabel || '';
const history = options.history || [];
const flexibleHeight = !!options.flexibleHeight;
const flexibleWidth = !!options.flexibleWidth;
const flexibleMaxHeight = options.flexibleMaxHeight;
this.domNode = document.createElement('div');
this.domNode.classList.add('monaco-findInput');
this.inputBox = this._register(new HistoryInputBox(this.domNode, this.contextViewProvider, {
ariaLabel: this.label || '',
placeholder: this.placeholder || '',
validationOptions: {
validation: this.validation
},
history,
showHistoryHint: options.showHistoryHint,
flexibleHeight,
flexibleWidth,
flexibleMaxHeight,
inputBoxStyles: options.inputBoxStyles
}));
this.preserveCase = this._register(new PreserveCaseToggle(Object.assign({ appendTitle: appendPreserveCaseLabel, isChecked: false }, options.toggleStyles)));
this._register(this.preserveCase.onChange(viaKeyboard => {
this._onDidOptionChange.fire(viaKeyboard);
if (!viaKeyboard && this.fixFocusOnOptionClickEnabled) {
this.inputBox.focus();
}
this.validate();
}));
this._register(this.preserveCase.onKeyDown(e => {
this._onPreserveCaseKeyDown.fire(e);
}));
if (this._showOptionButtons) {
this.cachedOptionsWidth = this.preserveCase.width();
}
else {
this.cachedOptionsWidth = 0;
}
// Arrow-Key support to navigate between options
const indexes = [this.preserveCase.domNode];
this.onkeydown(this.domNode, (event) => {
if (event.equals(15 /* KeyCode.LeftArrow */) || event.equals(17 /* KeyCode.RightArrow */) || event.equals(9 /* KeyCode.Escape */)) {
const index = indexes.indexOf(document.activeElement);
if (index >= 0) {
let newIndex = -1;
if (event.equals(17 /* KeyCode.RightArrow */)) {
newIndex = (index + 1) % indexes.length;
}
else if (event.equals(15 /* KeyCode.LeftArrow */)) {
if (index === 0) {
newIndex = indexes.length - 1;
}
else {
newIndex = index - 1;
}
}
if (event.equals(9 /* KeyCode.Escape */)) {
indexes[index].blur();
this.inputBox.focus();
}
else if (newIndex >= 0) {
indexes[newIndex].focus();
}
dom.EventHelper.stop(event, true);
}
}
});
const controls = document.createElement('div');
controls.className = 'controls';
controls.style.display = this._showOptionButtons ? 'block' : 'none';
controls.appendChild(this.preserveCase.domNode);
this.domNode.appendChild(controls);
parent === null || parent === void 0 ? void 0 : parent.appendChild(this.domNode);
this.onkeydown(this.inputBox.inputElement, (e) => this._onKeyDown.fire(e));
this.onkeyup(this.inputBox.inputElement, (e) => this._onKeyUp.fire(e));
this.oninput(this.inputBox.inputElement, (e) => this._onInput.fire());
this.onmousedown(this.inputBox.inputElement, (e) => this._onMouseDown.fire(e));
}
enable() {
this.domNode.classList.remove('disabled');
this.inputBox.enable();
this.preserveCase.enable();
}
disable() {
this.domNode.classList.add('disabled');
this.inputBox.disable();
this.preserveCase.disable();
}
setEnabled(enabled) {
if (enabled) {
this.enable();
}
else {
this.disable();
}
}
select() {
this.inputBox.select();
}
focus() {
this.inputBox.focus();
}
getPreserveCase() {
return this.preserveCase.checked;
}
setPreserveCase(value) {
this.preserveCase.checked = value;
}
focusOnPreserve() {
this.preserveCase.focus();
}
validate() {
var _a;
(_a = this.inputBox) === null || _a === void 0 ? void 0 : _a.validate();
}
set width(newWidth) {
this.inputBox.paddingRight = this.cachedOptionsWidth;
this.domNode.style.width = newWidth + 'px';
}
dispose() {
super.dispose();
}
}

View file

@ -1 +1,122 @@
import*as dom from"../../dom.js";import{renderLabelWithIcons}from"../iconLabel/iconLabels.js";import*as objects from"../../../common/objects.js";export class HighlightedLabel{constructor(t,s){var e;this.text="",this.title="",this.highlights=[],this.didEverRender=!1,this.supportIcons=null!==(e=null==s?void 0:s.supportIcons)&&void 0!==e&&e,this.domNode=dom.append(t,dom.$("span.monaco-highlighted-label"))}get element(){return this.domNode}set(t,s=[],e="",i){t||(t=""),i&&(t=HighlightedLabel.escapeNewLines(t,s)),this.didEverRender&&this.text===t&&this.title===e&&objects.equals(this.highlights,s)||(this.text=t,this.title=e,this.highlights=s,this.render())}render(){const t=[];let s=0;for(const e of this.highlights){if(e.end===e.start)continue;if(s<e.start){const i=this.text.substring(s,e.start);this.supportIcons?t.push(...renderLabelWithIcons(i)):t.push(i),s=e.start}const i=this.text.substring(s,e.end),o=dom.$("span.highlight",void 0,...this.supportIcons?renderLabelWithIcons(i):[i]);e.extraClasses&&o.classList.add(...e.extraClasses),t.push(o),s=e.end}if(s<this.text.length){const e=this.text.substring(s);this.supportIcons?t.push(...renderLabelWithIcons(e)):t.push(e)}dom.reset(this.domNode,...t),this.title?this.domNode.title=this.title:this.domNode.removeAttribute("title"),this.didEverRender=!0}static escapeNewLines(t,s){let e=0,i=0;return t.replace(/\r\n|\r|\n/g,((t,o)=>{i="\r\n"===t?-1:0,o+=e;for(const t of s)t.end<=o||(t.start>=o&&(t.start+=i),t.end>=o&&(t.end+=i));return e+=i,"⏎"}))}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../dom.js';
import { renderLabelWithIcons } from '../iconLabel/iconLabels.js';
import * as objects from '../../../common/objects.js';
/**
* A widget which can render a label with substring highlights, often
* originating from a filter function like the fuzzy matcher.
*/
export class HighlightedLabel {
/**
* Create a new {@link HighlightedLabel}.
*
* @param container The parent container to append to.
*/
constructor(container, options) {
var _a;
this.text = '';
this.title = '';
this.highlights = [];
this.didEverRender = false;
this.supportIcons = (_a = options === null || options === void 0 ? void 0 : options.supportIcons) !== null && _a !== void 0 ? _a : false;
this.domNode = dom.append(container, dom.$('span.monaco-highlighted-label'));
}
/**
* The label's DOM node.
*/
get element() {
return this.domNode;
}
/**
* Set the label and highlights.
*
* @param text The label to display.
* @param highlights The ranges to highlight.
* @param title An optional title for the hover tooltip.
* @param escapeNewLines Whether to escape new lines.
* @returns
*/
set(text, highlights = [], title = '', escapeNewLines) {
if (!text) {
text = '';
}
if (escapeNewLines) {
// adjusts highlights inplace
text = HighlightedLabel.escapeNewLines(text, highlights);
}
if (this.didEverRender && this.text === text && this.title === title && objects.equals(this.highlights, highlights)) {
return;
}
this.text = text;
this.title = title;
this.highlights = highlights;
this.render();
}
render() {
const children = [];
let pos = 0;
for (const highlight of this.highlights) {
if (highlight.end === highlight.start) {
continue;
}
if (pos < highlight.start) {
const substring = this.text.substring(pos, highlight.start);
if (this.supportIcons) {
children.push(...renderLabelWithIcons(substring));
}
else {
children.push(substring);
}
pos = highlight.start;
}
const substring = this.text.substring(pos, highlight.end);
const element = dom.$('span.highlight', undefined, ...this.supportIcons ? renderLabelWithIcons(substring) : [substring]);
if (highlight.extraClasses) {
element.classList.add(...highlight.extraClasses);
}
children.push(element);
pos = highlight.end;
}
if (pos < this.text.length) {
const substring = this.text.substring(pos);
if (this.supportIcons) {
children.push(...renderLabelWithIcons(substring));
}
else {
children.push(substring);
}
}
dom.reset(this.domNode, ...children);
if (this.title) {
this.domNode.title = this.title;
}
else {
this.domNode.removeAttribute('title');
}
this.didEverRender = true;
}
static escapeNewLines(text, highlights) {
let total = 0;
let extra = 0;
return text.replace(/\r\n|\r|\n/g, (match, offset) => {
extra = match === '\r\n' ? -1 : 0;
offset += total;
for (const highlight of highlights) {
if (highlight.end <= offset) {
continue;
}
if (highlight.start >= offset) {
highlight.start += extra;
}
if (highlight.end >= offset) {
highlight.end += extra;
}
}
total += extra;
return '\u23CE';
});
}
}

View file

@ -1 +1,69 @@
import*as dom from"../../dom.js";import{StandardKeyboardEvent}from"../../keyboardEvent.js";import{DomScrollableElement}from"../scrollbar/scrollableElement.js";import{Disposable}from"../../../common/lifecycle.js";import"./hover.css";const $=dom.$;export class HoverWidget extends Disposable{constructor(){super(),this.containerDomNode=document.createElement("div"),this.containerDomNode.className="monaco-hover",this.containerDomNode.tabIndex=0,this.containerDomNode.setAttribute("role","tooltip"),this.contentsDomNode=document.createElement("div"),this.contentsDomNode.className="monaco-hover-content",this.scrollbar=this._register(new DomScrollableElement(this.contentsDomNode,{consumeMouseWheelIfScrollbarIsNeeded:!0})),this.containerDomNode.appendChild(this.scrollbar.getDomNode())}onContentsChanged(){this.scrollbar.scanDomNode()}}export class HoverAction extends Disposable{static render(t,e,o){return new HoverAction(t,e,o)}constructor(t,e,o){super(),this.actionContainer=dom.append(t,$("div.action-container")),this.actionContainer.setAttribute("tabindex","0"),this.action=dom.append(this.actionContainer,$("a.action")),this.action.setAttribute("role","button"),e.iconClass&&dom.append(this.action,$(`span.icon.${e.iconClass}`)),dom.append(this.action,$("span")).textContent=o?`${e.label} (${o})`:e.label,this._register(dom.addDisposableListener(this.actionContainer,dom.EventType.CLICK,(t=>{t.stopPropagation(),t.preventDefault(),e.run(this.actionContainer)}))),this._register(dom.addDisposableListener(this.actionContainer,dom.EventType.KEY_DOWN,(t=>{const o=new StandardKeyboardEvent(t);(o.equals(3)||o.equals(10))&&(t.stopPropagation(),t.preventDefault(),e.run(this.actionContainer))}))),this.setEnabled(!0)}setEnabled(t){t?(this.actionContainer.classList.remove("disabled"),this.actionContainer.removeAttribute("aria-disabled")):(this.actionContainer.classList.add("disabled"),this.actionContainer.setAttribute("aria-disabled","true"))}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../dom.js';
import { StandardKeyboardEvent } from '../../keyboardEvent.js';
import { DomScrollableElement } from '../scrollbar/scrollableElement.js';
import { Disposable } from '../../../common/lifecycle.js';
import './hover.css';
const $ = dom.$;
export class HoverWidget extends Disposable {
constructor() {
super();
this.containerDomNode = document.createElement('div');
this.containerDomNode.className = 'monaco-hover';
this.containerDomNode.tabIndex = 0;
this.containerDomNode.setAttribute('role', 'tooltip');
this.contentsDomNode = document.createElement('div');
this.contentsDomNode.className = 'monaco-hover-content';
this.scrollbar = this._register(new DomScrollableElement(this.contentsDomNode, {
consumeMouseWheelIfScrollbarIsNeeded: true
}));
this.containerDomNode.appendChild(this.scrollbar.getDomNode());
}
onContentsChanged() {
this.scrollbar.scanDomNode();
}
}
export class HoverAction extends Disposable {
static render(parent, actionOptions, keybindingLabel) {
return new HoverAction(parent, actionOptions, keybindingLabel);
}
constructor(parent, actionOptions, keybindingLabel) {
super();
this.actionContainer = dom.append(parent, $('div.action-container'));
this.actionContainer.setAttribute('tabindex', '0');
this.action = dom.append(this.actionContainer, $('a.action'));
this.action.setAttribute('role', 'button');
if (actionOptions.iconClass) {
dom.append(this.action, $(`span.icon.${actionOptions.iconClass}`));
}
const label = dom.append(this.action, $('span'));
label.textContent = keybindingLabel ? `${actionOptions.label} (${keybindingLabel})` : actionOptions.label;
this._register(dom.addDisposableListener(this.actionContainer, dom.EventType.CLICK, e => {
e.stopPropagation();
e.preventDefault();
actionOptions.run(this.actionContainer);
}));
this._register(dom.addDisposableListener(this.actionContainer, dom.EventType.KEY_DOWN, e => {
const event = new StandardKeyboardEvent(e);
if (event.equals(3 /* KeyCode.Enter */) || event.equals(10 /* KeyCode.Space */)) {
e.stopPropagation();
e.preventDefault();
actionOptions.run(this.actionContainer);
}
}));
this.setEnabled(true);
}
setEnabled(enabled) {
if (enabled) {
this.actionContainer.classList.remove('disabled');
this.actionContainer.removeAttribute('aria-disabled');
}
else {
this.actionContainer.classList.add('disabled');
this.actionContainer.setAttribute('aria-disabled', 'true');
}
}
}

View file

@ -1 +1,5 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export {};

File diff suppressed because one or more lines are too long

View file

@ -1 +1,176 @@
var __awaiter=this&&this.__awaiter||function(e,o,t,i){return new(t||(t=Promise))((function(n,s){function a(e){try{d(i.next(e))}catch(e){s(e)}}function r(e){try{d(i.throw(e))}catch(e){s(e)}}function d(e){var o;e.done?n(e.value):(o=e.value,o instanceof t?o:new t((function(e){e(o)}))).then(a,r)}d((i=i.apply(e,o||[])).next())}))};import*as dom from"../../dom.js";import{TimeoutTimer}from"../../../common/async.js";import{CancellationTokenSource}from"../../../common/cancellation.js";import{isMarkdownString}from"../../../common/htmlContent.js";import{stripIcons}from"../../../common/iconLabels.js";import{DisposableStore}from"../../../common/lifecycle.js";import{isFunction,isString}from"../../../common/types.js";import{localize}from"../../../../nls.js";export function setupNativeHover(e,o){isString(o)?e.title=stripIcons(o):(null==o?void 0:o.markdownNotSupportedFallback)?e.title=o.markdownNotSupportedFallback:e.removeAttribute("title")}class UpdatableHoverWidget{constructor(e,o,t){this.hoverDelegate=e,this.target=o,this.fadeInAnimation=t}update(e,o,t){var i;return __awaiter(this,void 0,void 0,(function*(){if(this._cancellationTokenSource&&(this._cancellationTokenSource.dispose(!0),this._cancellationTokenSource=void 0),this.isDisposed)return;let n;if(void 0===e||isString(e)||e instanceof HTMLElement)n=e;else if(isFunction(e.markdown)){this._hoverWidget||this.show(localize("iconLabel.loading","Loading..."),o),this._cancellationTokenSource=new CancellationTokenSource;const t=this._cancellationTokenSource.token;if(n=yield e.markdown(t),void 0===n&&(n=e.markdownNotSupportedFallback),this.isDisposed||t.isCancellationRequested)return}else n=null!==(i=e.markdown)&&void 0!==i?i:e.markdownNotSupportedFallback;this.show(n,o,t)}))}show(e,o,t){const i=this._hoverWidget;if(this.hasContent(e)){const n=Object.assign({content:e,target:this.target,showPointer:"element"===this.hoverDelegate.placement,hoverPosition:2,skipFadeInAnimation:!this.fadeInAnimation||!!i},t);this._hoverWidget=this.hoverDelegate.showHover(n,o)}null==i||i.dispose()}hasContent(e){return!(!e||isMarkdownString(e)&&!e.value)}get isDisposed(){var e;return null===(e=this._hoverWidget)||void 0===e?void 0:e.isDisposed}dispose(){var e,o;null===(e=this._hoverWidget)||void 0===e||e.dispose(),null===(o=this._cancellationTokenSource)||void 0===o||o.dispose(!0),this._cancellationTokenSource=void 0}}export function setupCustomHover(e,o,t,i){let n,s;const a=(o,t)=>{var i;o&&(null==s||s.dispose(),s=void 0),t&&(null==n||n.dispose(),n=void 0),null===(i=e.onDidHideHover)||void 0===i||i.call(e)},r=(n,a,r)=>new TimeoutTimer((()=>__awaiter(this,void 0,void 0,(function*(){s&&!s.isDisposed||(s=new UpdatableHoverWidget(e,r||o,n>0),yield s.update(t,a,i))}))),n),d=dom.addDisposableListener(o,dom.EventType.MOUSE_OVER,(()=>{if(n)return;const t=new DisposableStore;t.add(dom.addDisposableListener(o,dom.EventType.MOUSE_LEAVE,(e=>a(!1,e.fromElement===o)),!0)),t.add(dom.addDisposableListener(o,dom.EventType.MOUSE_DOWN,(()=>a(!0,!0)),!0));const i={targetElements:[o],dispose:()=>{}};if(void 0===e.placement||"mouse"===e.placement){const e=e=>{i.x=e.x+10,e.target instanceof HTMLElement&&e.target.classList.contains("action-label")&&a(!0,!0)};t.add(dom.addDisposableListener(o,dom.EventType.MOUSE_MOVE,e,!0))}t.add(r(e.delay,!1,i)),n=t}),!0);return{show:e=>{a(!1,!0),r(0,e)},hide:()=>{a(!0,!0)},update:(e,o)=>__awaiter(this,void 0,void 0,(function*(){t=e,yield null==s?void 0:s.update(t,void 0,o)})),dispose:()=>{d.dispose(),a(!0,!0)}}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import * as dom from '../../dom.js';
import { TimeoutTimer } from '../../../common/async.js';
import { CancellationTokenSource } from '../../../common/cancellation.js';
import { isMarkdownString } from '../../../common/htmlContent.js';
import { stripIcons } from '../../../common/iconLabels.js';
import { DisposableStore } from '../../../common/lifecycle.js';
import { isFunction, isString } from '../../../common/types.js';
import { localize } from '../../../../nls.js';
export function setupNativeHover(htmlElement, tooltip) {
if (isString(tooltip)) {
// Icons don't render in the native hover so we strip them out
htmlElement.title = stripIcons(tooltip);
}
else if (tooltip === null || tooltip === void 0 ? void 0 : tooltip.markdownNotSupportedFallback) {
htmlElement.title = tooltip.markdownNotSupportedFallback;
}
else {
htmlElement.removeAttribute('title');
}
}
class UpdatableHoverWidget {
constructor(hoverDelegate, target, fadeInAnimation) {
this.hoverDelegate = hoverDelegate;
this.target = target;
this.fadeInAnimation = fadeInAnimation;
}
update(content, focus, options) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
if (this._cancellationTokenSource) {
// there's an computation ongoing, cancel it
this._cancellationTokenSource.dispose(true);
this._cancellationTokenSource = undefined;
}
if (this.isDisposed) {
return;
}
let resolvedContent;
if (content === undefined || isString(content) || content instanceof HTMLElement) {
resolvedContent = content;
}
else if (!isFunction(content.markdown)) {
resolvedContent = (_a = content.markdown) !== null && _a !== void 0 ? _a : content.markdownNotSupportedFallback;
}
else {
// compute the content, potentially long-running
// show 'Loading' if no hover is up yet
if (!this._hoverWidget) {
this.show(localize('iconLabel.loading', "Loading..."), focus);
}
// compute the content
this._cancellationTokenSource = new CancellationTokenSource();
const token = this._cancellationTokenSource.token;
resolvedContent = yield content.markdown(token);
if (resolvedContent === undefined) {
resolvedContent = content.markdownNotSupportedFallback;
}
if (this.isDisposed || token.isCancellationRequested) {
// either the widget has been closed in the meantime
// or there has been a new call to `update`
return;
}
}
this.show(resolvedContent, focus, options);
});
}
show(content, focus, options) {
const oldHoverWidget = this._hoverWidget;
if (this.hasContent(content)) {
const hoverOptions = Object.assign({ content, target: this.target, showPointer: this.hoverDelegate.placement === 'element', hoverPosition: 2 /* HoverPosition.BELOW */, skipFadeInAnimation: !this.fadeInAnimation || !!oldHoverWidget }, options);
this._hoverWidget = this.hoverDelegate.showHover(hoverOptions, focus);
}
oldHoverWidget === null || oldHoverWidget === void 0 ? void 0 : oldHoverWidget.dispose();
}
hasContent(content) {
if (!content) {
return false;
}
if (isMarkdownString(content)) {
return !!content.value;
}
return true;
}
get isDisposed() {
var _a;
return (_a = this._hoverWidget) === null || _a === void 0 ? void 0 : _a.isDisposed;
}
dispose() {
var _a, _b;
(_a = this._hoverWidget) === null || _a === void 0 ? void 0 : _a.dispose();
(_b = this._cancellationTokenSource) === null || _b === void 0 ? void 0 : _b.dispose(true);
this._cancellationTokenSource = undefined;
}
}
export function setupCustomHover(hoverDelegate, htmlElement, content, options) {
let hoverPreparation;
let hoverWidget;
const hideHover = (disposeWidget, disposePreparation) => {
var _a;
if (disposeWidget) {
hoverWidget === null || hoverWidget === void 0 ? void 0 : hoverWidget.dispose();
hoverWidget = undefined;
}
if (disposePreparation) {
hoverPreparation === null || hoverPreparation === void 0 ? void 0 : hoverPreparation.dispose();
hoverPreparation = undefined;
}
(_a = hoverDelegate.onDidHideHover) === null || _a === void 0 ? void 0 : _a.call(hoverDelegate);
};
const triggerShowHover = (delay, focus, target) => {
return new TimeoutTimer(() => __awaiter(this, void 0, void 0, function* () {
if (!hoverWidget || hoverWidget.isDisposed) {
hoverWidget = new UpdatableHoverWidget(hoverDelegate, target || htmlElement, delay > 0);
yield hoverWidget.update(content, focus, options);
}
}), delay);
};
const onMouseOver = () => {
if (hoverPreparation) {
return;
}
const toDispose = new DisposableStore();
const onMouseLeave = (e) => hideHover(false, e.fromElement === htmlElement);
toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_LEAVE, onMouseLeave, true));
const onMouseDown = () => hideHover(true, true);
toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_DOWN, onMouseDown, true));
const target = {
targetElements: [htmlElement],
dispose: () => { }
};
if (hoverDelegate.placement === undefined || hoverDelegate.placement === 'mouse') {
// track the mouse position
const onMouseMove = (e) => {
target.x = e.x + 10;
if ((e.target instanceof HTMLElement) && e.target.classList.contains('action-label')) {
hideHover(true, true);
}
};
toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_MOVE, onMouseMove, true));
}
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
hoverPreparation = toDispose;
};
const mouseOverDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_OVER, onMouseOver, true);
const hover = {
show: focus => {
hideHover(false, true); // terminate a ongoing mouse over preparation
triggerShowHover(0, focus); // show hover immediately
},
hide: () => {
hideHover(true, true);
},
update: (newContent, hoverOptions) => __awaiter(this, void 0, void 0, function* () {
content = newContent;
yield (hoverWidget === null || hoverWidget === void 0 ? void 0 : hoverWidget.update(content, undefined, hoverOptions));
}),
dispose: () => {
mouseOverDomEmitter.dispose();
hideHover(true, true);
}
};
return hover;
}

View file

@ -1 +1,30 @@
import*as dom from"../../dom.js";import{ThemeIcon}from"../../../common/themables.js";const labelWithIconsRegex=new RegExp(`(\\\\)?\\$\\((${ThemeIcon.iconNameExpression}(?:${ThemeIcon.iconModifierExpression})?)\\)`,"g");export function renderLabelWithIcons(e){const n=new Array;let o,s=0,r=0;for(;null!==(o=labelWithIconsRegex.exec(e));){r=o.index||0,s<r&&n.push(e.substring(s,r)),s=(o.index||0)+o[0].length;const[,t,c]=o;n.push(t?`$(${c})`:renderIcon({id:c}))}return s<e.length&&n.push(e.substring(s)),n}export function renderIcon(e){const n=dom.$("span");return n.classList.add(...ThemeIcon.asClassNameArray(e)),n}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../dom.js';
import { ThemeIcon } from '../../../common/themables.js';
const labelWithIconsRegex = new RegExp(`(\\\\)?\\$\\((${ThemeIcon.iconNameExpression}(?:${ThemeIcon.iconModifierExpression})?)\\)`, 'g');
export function renderLabelWithIcons(text) {
const elements = new Array();
let match;
let textStart = 0, textStop = 0;
while ((match = labelWithIconsRegex.exec(text)) !== null) {
textStop = match.index || 0;
if (textStart < textStop) {
elements.push(text.substring(textStart, textStop));
}
textStart = (match.index || 0) + match[0].length;
const [, escaped, codicon] = match;
elements.push(escaped ? `$(${codicon})` : renderIcon({ id: codicon }));
}
if (textStart < text.length) {
elements.push(text.substring(textStart));
}
return elements;
}
export function renderIcon(icon) {
const node = dom.$(`span`);
node.classList.add(...ThemeIcon.asClassNameArray(icon));
return node;
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1,119 @@
import*as dom from"../../dom.js";import{UILabelProvider}from"../../../common/keybindingLabels.js";import{equals}from"../../../common/objects.js";import"./keybindingLabel.css";import{localize}from"../../../../nls.js";const $=dom.$;export class KeybindingLabel{constructor(e,o,t){this.os=o,this.keyElements=new Set,this.options=t||Object.create(null),this.labelBackground=this.options.keybindingLabelBackground,this.labelBorder=this.options.keybindingLabelBorder,this.labelBottomBorder=this.options.keybindingLabelBottomBorder,this.labelShadow=this.options.keybindingLabelShadow;const i=this.options.keybindingLabelForeground;this.domNode=dom.append(e,$(".monaco-keybinding")),i&&(this.domNode.style.color=i),this.didEverRender=!1,e.appendChild(this.domNode)}get element(){return this.domNode}set(e,o){this.didEverRender&&this.keybinding===e&&KeybindingLabel.areSame(this.matches,o)||(this.keybinding=e,this.matches=o,this.render())}render(){var e;if(this.clear(),this.keybinding){const[o,t]=this.keybinding.getChords();o&&this.renderChord(this.domNode,o,this.matches?this.matches.firstPart:null),t&&(dom.append(this.domNode,$("span.monaco-keybinding-key-chord-separator",void 0," ")),this.renderChord(this.domNode,t,this.matches?this.matches.chordPart:null));const i=null!==(e=this.options.disableTitle)&&void 0!==e&&e?void 0:this.keybinding.getAriaLabel()||void 0;void 0!==i?this.domNode.title=i:this.domNode.removeAttribute("title")}else this.options&&this.options.renderUnboundKeybindings&&this.renderUnbound(this.domNode);this.didEverRender=!0}clear(){dom.clearNode(this.domNode),this.keyElements.clear()}renderChord(e,o,t){const i=UILabelProvider.modifierLabels[this.os];o.ctrlKey&&this.renderKey(e,i.ctrlKey,Boolean(null==t?void 0:t.ctrlKey),i.separator),o.shiftKey&&this.renderKey(e,i.shiftKey,Boolean(null==t?void 0:t.shiftKey),i.separator),o.altKey&&this.renderKey(e,i.altKey,Boolean(null==t?void 0:t.altKey),i.separator),o.metaKey&&this.renderKey(e,i.metaKey,Boolean(null==t?void 0:t.metaKey),i.separator);const d=o.keyLabel;d&&this.renderKey(e,d,Boolean(null==t?void 0:t.keyCode),"")}renderKey(e,o,t,i){dom.append(e,this.createKeyElement(o,t?".highlight":"")),i&&dom.append(e,$("span.monaco-keybinding-key-separator",void 0,i))}renderUnbound(e){dom.append(e,this.createKeyElement(localize("unbound","Unbound")))}createKeyElement(e,o=""){const t=$("span.monaco-keybinding-key"+o,void 0,e);return this.keyElements.add(t),this.labelBackground&&(t.style.backgroundColor=this.labelBackground),this.labelBorder&&(t.style.borderColor=this.labelBorder),this.labelBottomBorder&&(t.style.borderBottomColor=this.labelBottomBorder),this.labelShadow&&(t.style.boxShadow=`inset 0 -1px 0 ${this.labelShadow}`),t}static areSame(e,o){return e===o||!e&&!o||!!e&&!!o&&equals(e.firstPart,o.firstPart)&&equals(e.chordPart,o.chordPart)}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as dom from '../../dom.js';
import { UILabelProvider } from '../../../common/keybindingLabels.js';
import { equals } from '../../../common/objects.js';
import './keybindingLabel.css';
import { localize } from '../../../../nls.js';
const $ = dom.$;
export class KeybindingLabel {
constructor(container, os, options) {
this.os = os;
this.keyElements = new Set();
this.options = options || Object.create(null);
this.labelBackground = this.options.keybindingLabelBackground;
this.labelBorder = this.options.keybindingLabelBorder;
this.labelBottomBorder = this.options.keybindingLabelBottomBorder;
this.labelShadow = this.options.keybindingLabelShadow;
const labelForeground = this.options.keybindingLabelForeground;
this.domNode = dom.append(container, $('.monaco-keybinding'));
if (labelForeground) {
this.domNode.style.color = labelForeground;
}
this.didEverRender = false;
container.appendChild(this.domNode);
}
get element() {
return this.domNode;
}
set(keybinding, matches) {
if (this.didEverRender && this.keybinding === keybinding && KeybindingLabel.areSame(this.matches, matches)) {
return;
}
this.keybinding = keybinding;
this.matches = matches;
this.render();
}
render() {
var _a;
this.clear();
if (this.keybinding) {
const [firstChord, secondChord] = this.keybinding.getChords(); // TODO@chords
if (firstChord) {
this.renderChord(this.domNode, firstChord, this.matches ? this.matches.firstPart : null);
}
if (secondChord) {
dom.append(this.domNode, $('span.monaco-keybinding-key-chord-separator', undefined, ' '));
this.renderChord(this.domNode, secondChord, this.matches ? this.matches.chordPart : null);
}
const title = ((_a = this.options.disableTitle) !== null && _a !== void 0 ? _a : false) ? undefined : this.keybinding.getAriaLabel() || undefined;
if (title !== undefined) {
this.domNode.title = title;
}
else {
this.domNode.removeAttribute('title');
}
}
else if (this.options && this.options.renderUnboundKeybindings) {
this.renderUnbound(this.domNode);
}
this.didEverRender = true;
}
clear() {
dom.clearNode(this.domNode);
this.keyElements.clear();
}
renderChord(parent, chord, match) {
const modifierLabels = UILabelProvider.modifierLabels[this.os];
if (chord.ctrlKey) {
this.renderKey(parent, modifierLabels.ctrlKey, Boolean(match === null || match === void 0 ? void 0 : match.ctrlKey), modifierLabels.separator);
}
if (chord.shiftKey) {
this.renderKey(parent, modifierLabels.shiftKey, Boolean(match === null || match === void 0 ? void 0 : match.shiftKey), modifierLabels.separator);
}
if (chord.altKey) {
this.renderKey(parent, modifierLabels.altKey, Boolean(match === null || match === void 0 ? void 0 : match.altKey), modifierLabels.separator);
}
if (chord.metaKey) {
this.renderKey(parent, modifierLabels.metaKey, Boolean(match === null || match === void 0 ? void 0 : match.metaKey), modifierLabels.separator);
}
const keyLabel = chord.keyLabel;
if (keyLabel) {
this.renderKey(parent, keyLabel, Boolean(match === null || match === void 0 ? void 0 : match.keyCode), '');
}
}
renderKey(parent, label, highlight, separator) {
dom.append(parent, this.createKeyElement(label, highlight ? '.highlight' : ''));
if (separator) {
dom.append(parent, $('span.monaco-keybinding-key-separator', undefined, separator));
}
}
renderUnbound(parent) {
dom.append(parent, this.createKeyElement(localize('unbound', "Unbound")));
}
createKeyElement(label, extraClass = '') {
const keyElement = $('span.monaco-keybinding-key' + extraClass, undefined, label);
this.keyElements.add(keyElement);
if (this.labelBackground) {
keyElement.style.backgroundColor = this.labelBackground;
}
if (this.labelBorder) {
keyElement.style.borderColor = this.labelBorder;
}
if (this.labelBottomBorder) {
keyElement.style.borderBottomColor = this.labelBottomBorder;
}
if (this.labelShadow) {
keyElement.style.boxShadow = `inset 0 -1px 0 ${this.labelShadow}`;
}
return keyElement;
}
static areSame(a, b) {
if (a === b || (!a && !b)) {
return true;
}
return !!a && !!b && equals(a.firstPart, b.firstPart) && equals(a.chordPart, b.chordPart);
}
}

View file

@ -1 +1,9 @@
export class ListError extends Error{constructor(r,s){super(`ListError [${r}] ${s}`)}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export class ListError extends Error {
constructor(user, message) {
super(`ListError [${user}] ${message}`);
}
}

View file

@ -1 +1,116 @@
import{range}from"../../../common/arrays.js";import{CancellationTokenSource}from"../../../common/cancellation.js";import{Event}from"../../../common/event.js";import{Disposable}from"../../../common/lifecycle.js";import"./list.css";import{List}from"./listWidget.js";class PagedRenderer{get templateId(){return this.renderer.templateId}constructor(e,t){this.renderer=e,this.modelProvider=t}renderTemplate(e){return{data:this.renderer.renderTemplate(e),disposable:Disposable.None}}renderElement(e,t,i,s){var r;if(null===(r=i.disposable)||void 0===r||r.dispose(),!i.data)return;const o=this.modelProvider();if(o.isResolved(e))return this.renderer.renderElement(o.get(e),e,i.data,s);const n=new CancellationTokenSource,l=o.resolve(e,n.token);i.disposable={dispose:()=>n.cancel()},this.renderer.renderPlaceholder(e,i.data),l.then((t=>this.renderer.renderElement(t,e,i.data,s)))}disposeTemplate(e){e.disposable&&(e.disposable.dispose(),e.disposable=void 0),e.data&&(this.renderer.disposeTemplate(e.data),e.data=void 0)}}class PagedAccessibilityProvider{constructor(e,t){this.modelProvider=e,this.accessibilityProvider=t}getWidgetAriaLabel(){return this.accessibilityProvider.getWidgetAriaLabel()}getAriaLabel(e){const t=this.modelProvider();return t.isResolved(e)?this.accessibilityProvider.getAriaLabel(t.get(e)):null}}function fromPagedListOptions(e,t){return Object.assign(Object.assign({},t),{accessibilityProvider:t.accessibilityProvider&&new PagedAccessibilityProvider(e,t.accessibilityProvider)})}export class PagedList{constructor(e,t,i,s,r={}){const o=()=>this.model,n=s.map((e=>new PagedRenderer(e,o)));this.list=new List(e,t,i,n,fromPagedListOptions(o,r))}updateOptions(e){this.list.updateOptions(e)}getHTMLElement(){return this.list.getHTMLElement()}get onDidFocus(){return this.list.onDidFocus}get onDidDispose(){return this.list.onDidDispose}get onMouseDblClick(){return Event.map(this.list.onMouseDblClick,(({element:e,index:t,browserEvent:i})=>({element:void 0===e?void 0:this._model.get(e),index:t,browserEvent:i})))}get onPointer(){return Event.map(this.list.onPointer,(({element:e,index:t,browserEvent:i})=>({element:void 0===e?void 0:this._model.get(e),index:t,browserEvent:i})))}get onDidChangeSelection(){return Event.map(this.list.onDidChangeSelection,(({elements:e,indexes:t,browserEvent:i})=>({elements:e.map((e=>this._model.get(e))),indexes:t,browserEvent:i})))}get model(){return this._model}set model(e){this._model=e,this.list.splice(0,this.list.length,range(e.length))}getFocus(){return this.list.getFocus()}getSelection(){return this.list.getSelection()}getSelectedElements(){return this.getSelection().map((e=>this.model.get(e)))}style(e){this.list.style(e)}dispose(){this.list.dispose()}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { range } from '../../../common/arrays.js';
import { CancellationTokenSource } from '../../../common/cancellation.js';
import { Event } from '../../../common/event.js';
import { Disposable } from '../../../common/lifecycle.js';
import './list.css';
import { List } from './listWidget.js';
class PagedRenderer {
get templateId() { return this.renderer.templateId; }
constructor(renderer, modelProvider) {
this.renderer = renderer;
this.modelProvider = modelProvider;
}
renderTemplate(container) {
const data = this.renderer.renderTemplate(container);
return { data, disposable: Disposable.None };
}
renderElement(index, _, data, height) {
var _a;
(_a = data.disposable) === null || _a === void 0 ? void 0 : _a.dispose();
if (!data.data) {
return;
}
const model = this.modelProvider();
if (model.isResolved(index)) {
return this.renderer.renderElement(model.get(index), index, data.data, height);
}
const cts = new CancellationTokenSource();
const promise = model.resolve(index, cts.token);
data.disposable = { dispose: () => cts.cancel() };
this.renderer.renderPlaceholder(index, data.data);
promise.then(entry => this.renderer.renderElement(entry, index, data.data, height));
}
disposeTemplate(data) {
if (data.disposable) {
data.disposable.dispose();
data.disposable = undefined;
}
if (data.data) {
this.renderer.disposeTemplate(data.data);
data.data = undefined;
}
}
}
class PagedAccessibilityProvider {
constructor(modelProvider, accessibilityProvider) {
this.modelProvider = modelProvider;
this.accessibilityProvider = accessibilityProvider;
}
getWidgetAriaLabel() {
return this.accessibilityProvider.getWidgetAriaLabel();
}
getAriaLabel(index) {
const model = this.modelProvider();
if (!model.isResolved(index)) {
return null;
}
return this.accessibilityProvider.getAriaLabel(model.get(index));
}
}
function fromPagedListOptions(modelProvider, options) {
return Object.assign(Object.assign({}, options), { accessibilityProvider: options.accessibilityProvider && new PagedAccessibilityProvider(modelProvider, options.accessibilityProvider) });
}
export class PagedList {
constructor(user, container, virtualDelegate, renderers, options = {}) {
const modelProvider = () => this.model;
const pagedRenderers = renderers.map(r => new PagedRenderer(r, modelProvider));
this.list = new List(user, container, virtualDelegate, pagedRenderers, fromPagedListOptions(modelProvider, options));
}
updateOptions(options) {
this.list.updateOptions(options);
}
getHTMLElement() {
return this.list.getHTMLElement();
}
get onDidFocus() {
return this.list.onDidFocus;
}
get onDidDispose() {
return this.list.onDidDispose;
}
get onMouseDblClick() {
return Event.map(this.list.onMouseDblClick, ({ element, index, browserEvent }) => ({ element: element === undefined ? undefined : this._model.get(element), index, browserEvent }));
}
get onPointer() {
return Event.map(this.list.onPointer, ({ element, index, browserEvent }) => ({ element: element === undefined ? undefined : this._model.get(element), index, browserEvent }));
}
get onDidChangeSelection() {
return Event.map(this.list.onDidChangeSelection, ({ elements, indexes, browserEvent }) => ({ elements: elements.map(e => this._model.get(e)), indexes, browserEvent }));
}
get model() {
return this._model;
}
set model(model) {
this._model = model;
this.list.splice(0, this.list.length, range(model.length));
}
getFocus() {
return this.list.getFocus();
}
getSelection() {
return this.list.getSelection();
}
getSelectedElements() {
return this.getSelection().map(i => this.model.get(i));
}
style(styles) {
this.list.style(styles);
}
dispose() {
this.list.dispose();
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1,145 @@
import{Range}from"../../../common/range.js";export function groupIntersect(t,e){const n=[];for(const r of e){if(t.start>=r.range.end)continue;if(t.end<r.range.start)break;const e=Range.intersect(t,r.range);Range.isEmpty(e)||n.push({range:e,size:r.size})}return n}export function shift({start:t,end:e},n){return{start:t+n,end:e+n}}export function consolidate(t){const e=[];let n=null;for(const r of t){const t=r.range.start,s=r.range.end,o=r.size;n&&o===n.size?n.range.end=s:(n={range:{start:t,end:s},size:o},e.push(n))}return e}function concat(...t){return consolidate(t.reduce(((t,e)=>t.concat(e)),[]))}export class RangeMap{constructor(){this.groups=[],this._size=0}splice(t,e,n=[]){const r=n.length-e,s=groupIntersect({start:0,end:t},this.groups),o=groupIntersect({start:t+e,end:Number.POSITIVE_INFINITY},this.groups).map((t=>({range:shift(t.range,r),size:t.size}))),i=n.map(((e,n)=>({range:{start:t+n,end:t+n+1},size:e.size})));this.groups=concat(s,i,o),this._size=this.groups.reduce(((t,e)=>t+e.size*(e.range.end-e.range.start)),0)}get count(){const t=this.groups.length;return t?this.groups[t-1].range.end:0}get size(){return this._size}indexAt(t){if(t<0)return-1;let e=0,n=0;for(const r of this.groups){const s=r.range.end-r.range.start,o=n+s*r.size;if(t<o)return e+Math.floor((t-n)/r.size);e+=s,n=o}return e}indexAfter(t){return Math.min(this.indexAt(t)+1,this.count)}positionAt(t){if(t<0)return-1;let e=0,n=0;for(const r of this.groups){const s=r.range.end-r.range.start,o=n+s;if(t<o)return e+(t-n)*r.size;e+=s*r.size,n=o}return-1}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Range } from '../../../common/range.js';
/**
* Returns the intersection between a ranged group and a range.
* Returns `[]` if the intersection is empty.
*/
export function groupIntersect(range, groups) {
const result = [];
for (const r of groups) {
if (range.start >= r.range.end) {
continue;
}
if (range.end < r.range.start) {
break;
}
const intersection = Range.intersect(range, r.range);
if (Range.isEmpty(intersection)) {
continue;
}
result.push({
range: intersection,
size: r.size
});
}
return result;
}
/**
* Shifts a range by that `much`.
*/
export function shift({ start, end }, much) {
return { start: start + much, end: end + much };
}
/**
* Consolidates a collection of ranged groups.
*
* Consolidation is the process of merging consecutive ranged groups
* that share the same `size`.
*/
export function consolidate(groups) {
const result = [];
let previousGroup = null;
for (const group of groups) {
const start = group.range.start;
const end = group.range.end;
const size = group.size;
if (previousGroup && size === previousGroup.size) {
previousGroup.range.end = end;
continue;
}
previousGroup = { range: { start, end }, size };
result.push(previousGroup);
}
return result;
}
/**
* Concatenates several collections of ranged groups into a single
* collection.
*/
function concat(...groups) {
return consolidate(groups.reduce((r, g) => r.concat(g), []));
}
export class RangeMap {
constructor() {
this.groups = [];
this._size = 0;
}
splice(index, deleteCount, items = []) {
const diff = items.length - deleteCount;
const before = groupIntersect({ start: 0, end: index }, this.groups);
const after = groupIntersect({ start: index + deleteCount, end: Number.POSITIVE_INFINITY }, this.groups)
.map(g => ({ range: shift(g.range, diff), size: g.size }));
const middle = items.map((item, i) => ({
range: { start: index + i, end: index + i + 1 },
size: item.size
}));
this.groups = concat(before, middle, after);
this._size = this.groups.reduce((t, g) => t + (g.size * (g.range.end - g.range.start)), 0);
}
/**
* Returns the number of items in the range map.
*/
get count() {
const len = this.groups.length;
if (!len) {
return 0;
}
return this.groups[len - 1].range.end;
}
/**
* Returns the sum of the sizes of all items in the range map.
*/
get size() {
return this._size;
}
/**
* Returns the index of the item at the given position.
*/
indexAt(position) {
if (position < 0) {
return -1;
}
let index = 0;
let size = 0;
for (const group of this.groups) {
const count = group.range.end - group.range.start;
const newSize = size + (count * group.size);
if (position < newSize) {
return index + Math.floor((position - size) / group.size);
}
index += count;
size = newSize;
}
return index;
}
/**
* Returns the index of the item right after the item at the
* index of the given position.
*/
indexAfter(position) {
return Math.min(this.indexAt(position) + 1, this.count);
}
/**
* Returns the start position of the item at the given index.
*/
positionAt(index) {
if (index < 0) {
return -1;
}
let position = 0;
let count = 0;
for (const group of this.groups) {
const groupCount = group.range.end - group.range.start;
const newCount = count + groupCount;
if (index < newCount) {
return position + ((index - count) * group.size);
}
position += groupCount * group.size;
count = newCount;
}
return -1;
}
}

View file

@ -1 +1,116 @@
import{$}from"../../dom.js";function removeFromParent(e){var t;try{null===(t=e.parentElement)||void 0===t||t.removeChild(e)}catch(e){}}export class RowCache{constructor(e){this.renderers=e,this.cache=new Map,this.transactionNodesPendingRemoval=new Set,this.inTransaction=!1}alloc(e){let t=this.getTemplateCache(e).pop(),o=!1;if(t)o=this.transactionNodesPendingRemoval.has(t.domNode),o&&this.transactionNodesPendingRemoval.delete(t.domNode);else{const o=$(".monaco-list-row");t={domNode:o,templateId:e,templateData:this.getRenderer(e).renderTemplate(o)}}return{row:t,isReusingConnectedDomNode:o}}release(e){e&&this.releaseRow(e)}transact(e){if(this.inTransaction)throw new Error("Already in transaction");this.inTransaction=!0;try{e()}finally{for(const e of this.transactionNodesPendingRemoval)this.doRemoveNode(e);this.transactionNodesPendingRemoval.clear(),this.inTransaction=!1}}releaseRow(e){const{domNode:t,templateId:o}=e;t&&(this.inTransaction?this.transactionNodesPendingRemoval.add(t):this.doRemoveNode(t)),this.getTemplateCache(o).push(e)}doRemoveNode(e){e.classList.remove("scrolling"),removeFromParent(e)}getTemplateCache(e){let t=this.cache.get(e);return t||(t=[],this.cache.set(e,t)),t}dispose(){this.cache.forEach(((e,t)=>{for(const o of e)this.getRenderer(t).disposeTemplate(o.templateData),o.templateData=null})),this.cache.clear(),this.transactionNodesPendingRemoval.clear()}getRenderer(e){const t=this.renderers.get(e);if(!t)throw new Error(`No renderer found for ${e}`);return t}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { $ } from '../../dom.js';
function removeFromParent(element) {
var _a;
try {
(_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.removeChild(element);
}
catch (e) {
// this will throw if this happens due to a blur event, nasty business
}
}
export class RowCache {
constructor(renderers) {
this.renderers = renderers;
this.cache = new Map();
this.transactionNodesPendingRemoval = new Set();
this.inTransaction = false;
}
/**
* Returns a row either by creating a new one or reusing
* a previously released row which shares the same templateId.
*
* @returns A row and `isReusingConnectedDomNode` if the row's node is already in the dom in a stale position.
*/
alloc(templateId) {
let result = this.getTemplateCache(templateId).pop();
let isStale = false;
if (result) {
isStale = this.transactionNodesPendingRemoval.has(result.domNode);
if (isStale) {
this.transactionNodesPendingRemoval.delete(result.domNode);
}
}
else {
const domNode = $('.monaco-list-row');
const renderer = this.getRenderer(templateId);
const templateData = renderer.renderTemplate(domNode);
result = { domNode, templateId, templateData };
}
return { row: result, isReusingConnectedDomNode: isStale };
}
/**
* Releases the row for eventual reuse.
*/
release(row) {
if (!row) {
return;
}
this.releaseRow(row);
}
/**
* Begin a set of changes that use the cache. This lets us skip work when a row is removed and then inserted again.
*/
transact(makeChanges) {
if (this.inTransaction) {
throw new Error('Already in transaction');
}
this.inTransaction = true;
try {
makeChanges();
}
finally {
for (const domNode of this.transactionNodesPendingRemoval) {
this.doRemoveNode(domNode);
}
this.transactionNodesPendingRemoval.clear();
this.inTransaction = false;
}
}
releaseRow(row) {
const { domNode, templateId } = row;
if (domNode) {
if (this.inTransaction) {
this.transactionNodesPendingRemoval.add(domNode);
}
else {
this.doRemoveNode(domNode);
}
}
const cache = this.getTemplateCache(templateId);
cache.push(row);
}
doRemoveNode(domNode) {
domNode.classList.remove('scrolling');
removeFromParent(domNode);
}
getTemplateCache(templateId) {
let result = this.cache.get(templateId);
if (!result) {
result = [];
this.cache.set(templateId, result);
}
return result;
}
dispose() {
this.cache.forEach((cachedRows, templateId) => {
for (const cachedRow of cachedRows) {
const renderer = this.getRenderer(templateId);
renderer.disposeTemplate(cachedRow.templateData);
cachedRow.templateData = null;
}
});
this.cache.clear();
this.transactionNodesPendingRemoval.clear();
}
getRenderer(templateId) {
const renderer = this.renderers.get(templateId);
if (!renderer) {
throw new Error(`No renderer found for ${templateId}`);
}
return renderer;
}
}

View file

@ -1 +1,12 @@
export class CombinedSpliceable{constructor(s){this.spliceables=s}splice(s,e,c){this.spliceables.forEach((l=>l.splice(s,e,c)))}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export class CombinedSpliceable {
constructor(spliceables) {
this.spliceables = spliceables;
}
splice(start, deleteCount, elements) {
this.spliceables.forEach(s => s.splice(start, deleteCount, elements));
}
}

File diff suppressed because one or more lines are too long

View file

@ -1 +1,6 @@
import"./mouseCursor.css";export const MOUSE_CURSOR_TEXT_CSS_CLASS_NAME="monaco-mouse-cursor-text";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import './mouseCursor.css';
export const MOUSE_CURSOR_TEXT_CSS_CLASS_NAME = `monaco-mouse-cursor-text`;

View file

@ -1 +1,101 @@
import{show}from"../../dom.js";import{RunOnceScheduler}from"../../../common/async.js";import{Disposable}from"../../../common/lifecycle.js";import"./progressbar.css";const CSS_DONE="done",CSS_ACTIVE="active",CSS_INFINITE="infinite",CSS_INFINITE_LONG_RUNNING="infinite-long-running",CSS_DISCRETE="discrete";class ProgressBar extends Disposable{constructor(e,t){super(),this.workedVal=0,this.showDelayedScheduler=this._register(new RunOnceScheduler((()=>show(this.element)),0)),this.longRunningScheduler=this._register(new RunOnceScheduler((()=>this.infiniteLongRunning()),ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD)),this.create(e,t)}create(e,t){this.element=document.createElement("div"),this.element.classList.add("monaco-progress-container"),this.element.setAttribute("role","progressbar"),this.element.setAttribute("aria-valuemin","0"),e.appendChild(this.element),this.bit=document.createElement("div"),this.bit.classList.add("progress-bit"),this.bit.style.backgroundColor=(null==t?void 0:t.progressBarBackground)||"#0E70C0",this.element.appendChild(this.bit)}off(){this.bit.style.width="inherit",this.bit.style.opacity="1",this.element.classList.remove("active","infinite","infinite-long-running","discrete"),this.workedVal=0,this.totalWork=void 0,this.longRunningScheduler.cancel()}stop(){return this.doDone(!1)}doDone(e){return this.element.classList.add("done"),this.element.classList.contains("infinite")?(this.bit.style.opacity="0",e?setTimeout((()=>this.off()),200):this.off()):(this.bit.style.width="inherit",e?setTimeout((()=>this.off()),200):this.off()),this}infinite(){return this.bit.style.width="2%",this.bit.style.opacity="1",this.element.classList.remove("discrete","done","infinite-long-running"),this.element.classList.add("active","infinite"),this.longRunningScheduler.schedule(),this}infiniteLongRunning(){this.element.classList.add("infinite-long-running")}getContainer(){return this.element}}ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD=1e4;export{ProgressBar};
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { show } from '../../dom.js';
import { RunOnceScheduler } from '../../../common/async.js';
import { Disposable } from '../../../common/lifecycle.js';
import './progressbar.css';
const CSS_DONE = 'done';
const CSS_ACTIVE = 'active';
const CSS_INFINITE = 'infinite';
const CSS_INFINITE_LONG_RUNNING = 'infinite-long-running';
const CSS_DISCRETE = 'discrete';
/**
* A progress bar with support for infinite or discrete progress.
*/
class ProgressBar extends Disposable {
constructor(container, options) {
super();
this.workedVal = 0;
this.showDelayedScheduler = this._register(new RunOnceScheduler(() => show(this.element), 0));
this.longRunningScheduler = this._register(new RunOnceScheduler(() => this.infiniteLongRunning(), ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD));
this.create(container, options);
}
create(container, options) {
this.element = document.createElement('div');
this.element.classList.add('monaco-progress-container');
this.element.setAttribute('role', 'progressbar');
this.element.setAttribute('aria-valuemin', '0');
container.appendChild(this.element);
this.bit = document.createElement('div');
this.bit.classList.add('progress-bit');
this.bit.style.backgroundColor = (options === null || options === void 0 ? void 0 : options.progressBarBackground) || '#0E70C0';
this.element.appendChild(this.bit);
}
off() {
this.bit.style.width = 'inherit';
this.bit.style.opacity = '1';
this.element.classList.remove(CSS_ACTIVE, CSS_INFINITE, CSS_INFINITE_LONG_RUNNING, CSS_DISCRETE);
this.workedVal = 0;
this.totalWork = undefined;
this.longRunningScheduler.cancel();
}
/**
* Stops the progressbar from showing any progress instantly without fading out.
*/
stop() {
return this.doDone(false);
}
doDone(delayed) {
this.element.classList.add(CSS_DONE);
// discrete: let it grow to 100% width and hide afterwards
if (!this.element.classList.contains(CSS_INFINITE)) {
this.bit.style.width = 'inherit';
if (delayed) {
setTimeout(() => this.off(), 200);
}
else {
this.off();
}
}
// infinite: let it fade out and hide afterwards
else {
this.bit.style.opacity = '0';
if (delayed) {
setTimeout(() => this.off(), 200);
}
else {
this.off();
}
}
return this;
}
/**
* Use this mode to indicate progress that has no total number of work units.
*/
infinite() {
this.bit.style.width = '2%';
this.bit.style.opacity = '1';
this.element.classList.remove(CSS_DISCRETE, CSS_DONE, CSS_INFINITE_LONG_RUNNING);
this.element.classList.add(CSS_ACTIVE, CSS_INFINITE);
this.longRunningScheduler.schedule();
return this;
}
infiniteLongRunning() {
this.element.classList.add(CSS_INFINITE_LONG_RUNNING);
}
getContainer() {
return this.element;
}
}
/**
* After a certain time of showing the progress bar, switch
* to long-running mode and throttle animations to reduce
* the pressure on the GPU process.
*
* https://github.com/microsoft/vscode/issues/97900
* https://github.com/microsoft/vscode/issues/138396
*/
ProgressBar.LONG_RUNNING_INFINITE_THRESHOLD = 10000;
export { ProgressBar };

View file

@ -1 +1,147 @@
import{Dimension}from"../../dom.js";import{OrthogonalEdge,Sash}from"../sash/sash.js";import{Emitter,Event}from"../../../common/event.js";import{DisposableStore}from"../../../common/lifecycle.js";export class ResizableHTMLElement{constructor(){let s;this._onDidWillResize=new Emitter,this.onDidWillResize=this._onDidWillResize.event,this._onDidResize=new Emitter,this.onDidResize=this._onDidResize.event,this._sashListener=new DisposableStore,this._size=new Dimension(0,0),this._minSize=new Dimension(0,0),this._maxSize=new Dimension(Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER),this.domNode=document.createElement("div"),this._eastSash=new Sash(this.domNode,{getVerticalSashLeft:()=>this._size.width},{orientation:0}),this._westSash=new Sash(this.domNode,{getVerticalSashLeft:()=>0},{orientation:0}),this._northSash=new Sash(this.domNode,{getHorizontalSashTop:()=>0},{orientation:1,orthogonalEdge:OrthogonalEdge.North}),this._southSash=new Sash(this.domNode,{getHorizontalSashTop:()=>this._size.height},{orientation:1,orthogonalEdge:OrthogonalEdge.South}),this._northSash.orthogonalStartSash=this._westSash,this._northSash.orthogonalEndSash=this._eastSash,this._southSash.orthogonalStartSash=this._westSash,this._southSash.orthogonalEndSash=this._eastSash;let t=0,i=0;this._sashListener.add(Event.any(this._northSash.onDidStart,this._eastSash.onDidStart,this._southSash.onDidStart,this._westSash.onDidStart)((()=>{void 0===s&&(this._onDidWillResize.fire(),s=this._size,t=0,i=0)}))),this._sashListener.add(Event.any(this._northSash.onDidEnd,this._eastSash.onDidEnd,this._southSash.onDidEnd,this._westSash.onDidEnd)((()=>{void 0!==s&&(s=void 0,t=0,i=0,this._onDidResize.fire({dimension:this._size,done:!0}))}))),this._sashListener.add(this._eastSash.onDidChange((e=>{s&&(i=e.currentX-e.startX,this.layout(s.height+t,s.width+i),this._onDidResize.fire({dimension:this._size,done:!1,east:!0}))}))),this._sashListener.add(this._westSash.onDidChange((e=>{s&&(i=-(e.currentX-e.startX),this.layout(s.height+t,s.width+i),this._onDidResize.fire({dimension:this._size,done:!1,west:!0}))}))),this._sashListener.add(this._northSash.onDidChange((e=>{s&&(t=-(e.currentY-e.startY),this.layout(s.height+t,s.width+i),this._onDidResize.fire({dimension:this._size,done:!1,north:!0}))}))),this._sashListener.add(this._southSash.onDidChange((e=>{s&&(t=e.currentY-e.startY,this.layout(s.height+t,s.width+i),this._onDidResize.fire({dimension:this._size,done:!1,south:!0}))}))),this._sashListener.add(Event.any(this._eastSash.onDidReset,this._westSash.onDidReset)((s=>{this._preferredSize&&(this.layout(this._size.height,this._preferredSize.width),this._onDidResize.fire({dimension:this._size,done:!0}))}))),this._sashListener.add(Event.any(this._northSash.onDidReset,this._southSash.onDidReset)((s=>{this._preferredSize&&(this.layout(this._preferredSize.height,this._size.width),this._onDidResize.fire({dimension:this._size,done:!0}))})))}dispose(){this._northSash.dispose(),this._southSash.dispose(),this._eastSash.dispose(),this._westSash.dispose(),this._sashListener.dispose(),this._onDidResize.dispose(),this._onDidWillResize.dispose(),this.domNode.remove()}enableSashes(s,t,i,e){this._northSash.state=s?3:0,this._eastSash.state=t?3:0,this._southSash.state=i?3:0,this._westSash.state=e?3:0}layout(s=this.size.height,t=this.size.width){const{height:i,width:e}=this._minSize,{height:h,width:o}=this._maxSize;s=Math.max(i,Math.min(h,s)),t=Math.max(e,Math.min(o,t));const a=new Dimension(t,s);Dimension.equals(a,this._size)||(this.domNode.style.height=s+"px",this.domNode.style.width=t+"px",this._size=a,this._northSash.layout(),this._eastSash.layout(),this._southSash.layout(),this._westSash.layout())}clearSashHoverState(){this._eastSash.clearSashHoverState(),this._westSash.clearSashHoverState(),this._northSash.clearSashHoverState(),this._southSash.clearSashHoverState()}get size(){return this._size}set maxSize(s){this._maxSize=s}get maxSize(){return this._maxSize}set minSize(s){this._minSize=s}get minSize(){return this._minSize}set preferredSize(s){this._preferredSize=s}get preferredSize(){return this._preferredSize}}
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Dimension } from '../../dom.js';
import { OrthogonalEdge, Sash } from '../sash/sash.js';
import { Emitter, Event } from '../../../common/event.js';
import { DisposableStore } from '../../../common/lifecycle.js';
export class ResizableHTMLElement {
constructor() {
this._onDidWillResize = new Emitter();
this.onDidWillResize = this._onDidWillResize.event;
this._onDidResize = new Emitter();
this.onDidResize = this._onDidResize.event;
this._sashListener = new DisposableStore();
this._size = new Dimension(0, 0);
this._minSize = new Dimension(0, 0);
this._maxSize = new Dimension(Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);
this.domNode = document.createElement('div');
this._eastSash = new Sash(this.domNode, { getVerticalSashLeft: () => this._size.width }, { orientation: 0 /* Orientation.VERTICAL */ });
this._westSash = new Sash(this.domNode, { getVerticalSashLeft: () => 0 }, { orientation: 0 /* Orientation.VERTICAL */ });
this._northSash = new Sash(this.domNode, { getHorizontalSashTop: () => 0 }, { orientation: 1 /* Orientation.HORIZONTAL */, orthogonalEdge: OrthogonalEdge.North });
this._southSash = new Sash(this.domNode, { getHorizontalSashTop: () => this._size.height }, { orientation: 1 /* Orientation.HORIZONTAL */, orthogonalEdge: OrthogonalEdge.South });
this._northSash.orthogonalStartSash = this._westSash;
this._northSash.orthogonalEndSash = this._eastSash;
this._southSash.orthogonalStartSash = this._westSash;
this._southSash.orthogonalEndSash = this._eastSash;
let currentSize;
let deltaY = 0;
let deltaX = 0;
this._sashListener.add(Event.any(this._northSash.onDidStart, this._eastSash.onDidStart, this._southSash.onDidStart, this._westSash.onDidStart)(() => {
if (currentSize === undefined) {
this._onDidWillResize.fire();
currentSize = this._size;
deltaY = 0;
deltaX = 0;
}
}));
this._sashListener.add(Event.any(this._northSash.onDidEnd, this._eastSash.onDidEnd, this._southSash.onDidEnd, this._westSash.onDidEnd)(() => {
if (currentSize !== undefined) {
currentSize = undefined;
deltaY = 0;
deltaX = 0;
this._onDidResize.fire({ dimension: this._size, done: true });
}
}));
this._sashListener.add(this._eastSash.onDidChange(e => {
if (currentSize) {
deltaX = e.currentX - e.startX;
this.layout(currentSize.height + deltaY, currentSize.width + deltaX);
this._onDidResize.fire({ dimension: this._size, done: false, east: true });
}
}));
this._sashListener.add(this._westSash.onDidChange(e => {
if (currentSize) {
deltaX = -(e.currentX - e.startX);
this.layout(currentSize.height + deltaY, currentSize.width + deltaX);
this._onDidResize.fire({ dimension: this._size, done: false, west: true });
}
}));
this._sashListener.add(this._northSash.onDidChange(e => {
if (currentSize) {
deltaY = -(e.currentY - e.startY);
this.layout(currentSize.height + deltaY, currentSize.width + deltaX);
this._onDidResize.fire({ dimension: this._size, done: false, north: true });
}
}));
this._sashListener.add(this._southSash.onDidChange(e => {
if (currentSize) {
deltaY = e.currentY - e.startY;
this.layout(currentSize.height + deltaY, currentSize.width + deltaX);
this._onDidResize.fire({ dimension: this._size, done: false, south: true });
}
}));
this._sashListener.add(Event.any(this._eastSash.onDidReset, this._westSash.onDidReset)(e => {
if (this._preferredSize) {
this.layout(this._size.height, this._preferredSize.width);
this._onDidResize.fire({ dimension: this._size, done: true });
}
}));
this._sashListener.add(Event.any(this._northSash.onDidReset, this._southSash.onDidReset)(e => {
if (this._preferredSize) {
this.layout(this._preferredSize.height, this._size.width);
this._onDidResize.fire({ dimension: this._size, done: true });
}
}));
}
dispose() {
this._northSash.dispose();
this._southSash.dispose();
this._eastSash.dispose();
this._westSash.dispose();
this._sashListener.dispose();
this._onDidResize.dispose();
this._onDidWillResize.dispose();
this.domNode.remove();
}
enableSashes(north, east, south, west) {
this._northSash.state = north ? 3 /* SashState.Enabled */ : 0 /* SashState.Disabled */;
this._eastSash.state = east ? 3 /* SashState.Enabled */ : 0 /* SashState.Disabled */;
this._southSash.state = south ? 3 /* SashState.Enabled */ : 0 /* SashState.Disabled */;
this._westSash.state = west ? 3 /* SashState.Enabled */ : 0 /* SashState.Disabled */;
}
layout(height = this.size.height, width = this.size.width) {
const { height: minHeight, width: minWidth } = this._minSize;
const { height: maxHeight, width: maxWidth } = this._maxSize;
height = Math.max(minHeight, Math.min(maxHeight, height));
width = Math.max(minWidth, Math.min(maxWidth, width));
const newSize = new Dimension(width, height);
if (!Dimension.equals(newSize, this._size)) {
this.domNode.style.height = height + 'px';
this.domNode.style.width = width + 'px';
this._size = newSize;
this._northSash.layout();
this._eastSash.layout();
this._southSash.layout();
this._westSash.layout();
}
}
clearSashHoverState() {
this._eastSash.clearSashHoverState();
this._westSash.clearSashHoverState();
this._northSash.clearSashHoverState();
this._southSash.clearSashHoverState();
}
get size() {
return this._size;
}
set maxSize(value) {
this._maxSize = value;
}
get maxSize() {
return this._maxSize;
}
set minSize(value) {
this._minSize = value;
}
get minSize() {
return this._minSize;
}
set preferredSize(value) {
this._preferredSize = value;
}
get preferredSize() {
return this._preferredSize;
}
}

Some files were not shown because too many files have changed in this diff Show more