@codingame/monaco-vscode-view-common-service-override 5.3.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/viewCommon.js +1 -1
- package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +2 -1
- package/vscode/src/vs/base/browser/ui/grid/grid.js +34 -24
- package/vscode/src/vs/base/browser/ui/grid/gridview.js +35 -34
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +9 -60
- package/vscode/src/vs/workbench/browser/actions/listCommands.js +119 -79
- package/vscode/src/vs/workbench/browser/actions/navigationActions.js +76 -64
- package/vscode/src/vs/workbench/browser/media/style.css.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +51 -71
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +1 -1
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +21 -18
- package/vscode/src/vs/workbench/browser/parts/compositeBar.js +6 -6
- package/vscode/src/vs/workbench/browser/parts/compositePart.js +11 -8
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +8 -7
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +112 -107
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +2 -2
- package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +36 -30
- package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +75 -69
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +143 -25
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +20 -16
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +13 -11
- package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +5 -4
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +8 -5
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +9 -6
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +51 -37
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +28 -25
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +23 -13
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +5 -5
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +3 -2
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +2 -1
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +34 -23
- package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +3 -2
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +7 -1
- package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +3 -2
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +1 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +17 -15
- package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +2 -1
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +2 -1
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +4 -3
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +7 -7
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +2 -2
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +2 -1
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +9 -8
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +2 -2
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +11 -6
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +24 -23
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +3 -2
- package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +5 -4
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +2 -1
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +26 -23
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +23 -13
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +5 -5
- package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +2 -2
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +7 -6
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +8 -6
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +10 -8
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +3 -2
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +4 -3
- package/vscode/src/vs/workbench/services/activity/browser/activityService.js +1 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorPaneService.js +1 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +21 -19
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +73 -63
- package/vscode/src/vs/workbench/services/progress/browser/progressService.js +19 -15
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +1 -0
- package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +23 -18
- package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +20 -14
- package/vscode/src/vs/base/browser/deviceAccess.js +0 -61
- package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +0 -13
- package/vscode/src/vs/workbench/browser/window.js +0 -330
- package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +0 -371
- package/vscode/src/vs/workbench/services/driver/browser/driver.js +0 -188
|
@@ -1,371 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
3
|
-
import { mark } from 'vscode/vscode/vs/base/common/performance';
|
|
4
|
-
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
5
|
-
import { addDisposableListener, EventType, EventHelper, ModifierKeyEmitter, getClientArea, getWindowId, registerWindow, getActiveWindow, createMetaElement, copyAttributes, createLinkElement, isGlobalStylesheet, cloneGlobalStylesheets, sharedMutationObserver, position, trackAttributes } from 'vscode/vscode/vs/base/browser/dom';
|
|
6
|
-
import { mainWindow, ensureCodeWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
7
|
-
import { Disposable, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
8
|
-
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
9
|
-
import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
10
|
-
import { isWeb } from 'vscode/vscode/vs/base/common/platform';
|
|
11
|
-
import { WindowMinimumSize } from 'vscode/vscode/vs/platform/window/common/window';
|
|
12
|
-
import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
13
|
-
import Severity$1 from 'vscode/vscode/vs/base/common/severity';
|
|
14
|
-
import { BaseWindow } from '../../../browser/window.js';
|
|
15
|
-
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
16
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
17
|
-
import { Barrier } from 'vscode/vscode/vs/base/common/async';
|
|
18
|
-
import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
|
|
19
|
-
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
20
|
-
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
21
|
-
import { getZoomLevel } from 'vscode/vscode/vs/base/browser/browser';
|
|
22
|
-
import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
23
|
-
|
|
24
|
-
var BrowserAuxiliaryWindowService_1;
|
|
25
|
-
const _moduleId = "vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService";
|
|
26
|
-
var AuxiliaryWindowMode;
|
|
27
|
-
( ((function(AuxiliaryWindowMode) {
|
|
28
|
-
AuxiliaryWindowMode[AuxiliaryWindowMode["Maximized"] = 0] = "Maximized";
|
|
29
|
-
AuxiliaryWindowMode[AuxiliaryWindowMode["Normal"] = 1] = "Normal";
|
|
30
|
-
AuxiliaryWindowMode[AuxiliaryWindowMode["Fullscreen"] = 2] = "Fullscreen";
|
|
31
|
-
})(AuxiliaryWindowMode || (AuxiliaryWindowMode = {}))));
|
|
32
|
-
let AuxiliaryWindow = class AuxiliaryWindow extends BaseWindow {
|
|
33
|
-
constructor(window, container, stylesHaveLoaded, configurationService, hostService, environmentService) {
|
|
34
|
-
super(window, undefined, hostService, environmentService);
|
|
35
|
-
this.window = window;
|
|
36
|
-
this.container = container;
|
|
37
|
-
this.configurationService = configurationService;
|
|
38
|
-
this._onWillLayout = this._register(( (new Emitter())));
|
|
39
|
-
this.onWillLayout = this._onWillLayout.event;
|
|
40
|
-
this._onDidLayout = this._register(( (new Emitter())));
|
|
41
|
-
this.onDidLayout = this._onDidLayout.event;
|
|
42
|
-
this._onBeforeUnload = this._register(( (new Emitter())));
|
|
43
|
-
this.onBeforeUnload = this._onBeforeUnload.event;
|
|
44
|
-
this._onUnload = this._register(( (new Emitter())));
|
|
45
|
-
this.onUnload = this._onUnload.event;
|
|
46
|
-
this._onWillDispose = this._register(( (new Emitter())));
|
|
47
|
-
this.onWillDispose = this._onWillDispose.event;
|
|
48
|
-
this.whenStylesHaveLoaded = stylesHaveLoaded.wait().then(() => undefined);
|
|
49
|
-
this.registerListeners();
|
|
50
|
-
}
|
|
51
|
-
registerListeners() {
|
|
52
|
-
this._register(addDisposableListener(this.window, EventType.BEFORE_UNLOAD, (e) => this.handleBeforeUnload(e)));
|
|
53
|
-
this._register(addDisposableListener(this.window, EventType.UNLOAD, () => this.handleUnload()));
|
|
54
|
-
this._register(addDisposableListener(this.window, 'unhandledrejection', e => {
|
|
55
|
-
onUnexpectedError(e.reason);
|
|
56
|
-
e.preventDefault();
|
|
57
|
-
}));
|
|
58
|
-
this._register(addDisposableListener(this.window, EventType.RESIZE, () => this.layout()));
|
|
59
|
-
this._register(addDisposableListener(this.container, EventType.SCROLL, () => this.container.scrollTop = 0));
|
|
60
|
-
if (isWeb) {
|
|
61
|
-
this._register(addDisposableListener(this.container, EventType.DROP, e => EventHelper.stop(e, true)));
|
|
62
|
-
this._register(addDisposableListener(this.container, EventType.WHEEL, e => e.preventDefault(), { passive: false }));
|
|
63
|
-
this._register(addDisposableListener(this.container, EventType.CONTEXT_MENU, e => EventHelper.stop(e, true)));
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this._register(addDisposableListener(this.window.document.body, EventType.DRAG_OVER, (e) => EventHelper.stop(e)));
|
|
67
|
-
this._register(addDisposableListener(this.window.document.body, EventType.DROP, (e) => EventHelper.stop(e)));
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
handleBeforeUnload(e) {
|
|
71
|
-
let veto;
|
|
72
|
-
this._onBeforeUnload.fire({
|
|
73
|
-
veto(reason) {
|
|
74
|
-
if (reason) {
|
|
75
|
-
veto = reason;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
if (veto) {
|
|
80
|
-
this.handleVetoBeforeClose(e, veto);
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const confirmBeforeCloseSetting = this.configurationService.getValue('window.confirmBeforeClose');
|
|
84
|
-
const confirmBeforeClose = confirmBeforeCloseSetting === 'always' || (confirmBeforeCloseSetting === 'keyboardOnly' && ModifierKeyEmitter.getInstance().isModifierPressed);
|
|
85
|
-
if (confirmBeforeClose) {
|
|
86
|
-
this.confirmBeforeClose(e);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
handleVetoBeforeClose(e, reason) {
|
|
90
|
-
this.preventUnload(e);
|
|
91
|
-
}
|
|
92
|
-
preventUnload(e) {
|
|
93
|
-
e.preventDefault();
|
|
94
|
-
e.returnValue = ( localizeWithPath(
|
|
95
|
-
_moduleId,
|
|
96
|
-
0,
|
|
97
|
-
"Changes that you made may not be saved. Please check press 'Cancel' and try again."
|
|
98
|
-
));
|
|
99
|
-
}
|
|
100
|
-
confirmBeforeClose(e) {
|
|
101
|
-
this.preventUnload(e);
|
|
102
|
-
}
|
|
103
|
-
handleUnload() {
|
|
104
|
-
this._onUnload.fire();
|
|
105
|
-
}
|
|
106
|
-
layout() {
|
|
107
|
-
const dimension = getClientArea(this.window.document.body, this.container);
|
|
108
|
-
this._onWillLayout.fire(dimension);
|
|
109
|
-
this._onDidLayout.fire(dimension);
|
|
110
|
-
}
|
|
111
|
-
createState() {
|
|
112
|
-
return {
|
|
113
|
-
bounds: {
|
|
114
|
-
x: this.window.screenX,
|
|
115
|
-
y: this.window.screenY,
|
|
116
|
-
width: this.window.outerWidth,
|
|
117
|
-
height: this.window.outerHeight
|
|
118
|
-
},
|
|
119
|
-
zoomLevel: getZoomLevel(this.window)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
dispose() {
|
|
123
|
-
if (this._store.isDisposed) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
this._onWillDispose.fire();
|
|
127
|
-
super.dispose();
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
AuxiliaryWindow = ( (__decorate([
|
|
131
|
-
( (__param(3, IConfigurationService))),
|
|
132
|
-
( (__param(4, IHostService))),
|
|
133
|
-
( (__param(5, IWorkbenchEnvironmentService)))
|
|
134
|
-
], AuxiliaryWindow)));
|
|
135
|
-
let BrowserAuxiliaryWindowService = class BrowserAuxiliaryWindowService extends Disposable {
|
|
136
|
-
static { BrowserAuxiliaryWindowService_1 = this; }
|
|
137
|
-
static { this.DEFAULT_SIZE = { width: 800, height: 600 }; }
|
|
138
|
-
static { this.WINDOW_IDS = getWindowId(mainWindow) + 1; }
|
|
139
|
-
constructor(layoutService, dialogService, configurationService, telemetryService, hostService, environmentService) {
|
|
140
|
-
super();
|
|
141
|
-
this.layoutService = layoutService;
|
|
142
|
-
this.dialogService = dialogService;
|
|
143
|
-
this.configurationService = configurationService;
|
|
144
|
-
this.telemetryService = telemetryService;
|
|
145
|
-
this.hostService = hostService;
|
|
146
|
-
this.environmentService = environmentService;
|
|
147
|
-
this._onDidOpenAuxiliaryWindow = this._register(( (new Emitter())));
|
|
148
|
-
this.onDidOpenAuxiliaryWindow = this._onDidOpenAuxiliaryWindow.event;
|
|
149
|
-
this.windows = ( (new Map()));
|
|
150
|
-
}
|
|
151
|
-
async open(options) {
|
|
152
|
-
mark('code/auxiliaryWindow/willOpen');
|
|
153
|
-
const targetWindow = await this.openWindow(options);
|
|
154
|
-
if (!targetWindow) {
|
|
155
|
-
throw ( (new Error(localizeWithPath(_moduleId, 1, "Unable to open a new window."))));
|
|
156
|
-
}
|
|
157
|
-
const resolvedWindowId = await this.resolveWindowId(targetWindow);
|
|
158
|
-
ensureCodeWindow(targetWindow, resolvedWindowId);
|
|
159
|
-
const containerDisposables = ( (new DisposableStore()));
|
|
160
|
-
const { container, stylesLoaded } = this.createContainer(targetWindow, containerDisposables, options);
|
|
161
|
-
const auxiliaryWindow = this.createAuxiliaryWindow(targetWindow, container, stylesLoaded);
|
|
162
|
-
const registryDisposables = ( (new DisposableStore()));
|
|
163
|
-
this.windows.set(targetWindow.vscodeWindowId, auxiliaryWindow);
|
|
164
|
-
registryDisposables.add(toDisposable(() => this.windows.delete(targetWindow.vscodeWindowId)));
|
|
165
|
-
const eventDisposables = ( (new DisposableStore()));
|
|
166
|
-
Event.once(auxiliaryWindow.onWillDispose)(() => {
|
|
167
|
-
targetWindow.close();
|
|
168
|
-
containerDisposables.dispose();
|
|
169
|
-
registryDisposables.dispose();
|
|
170
|
-
eventDisposables.dispose();
|
|
171
|
-
});
|
|
172
|
-
registryDisposables.add(registerWindow(targetWindow));
|
|
173
|
-
this._onDidOpenAuxiliaryWindow.fire({ window: auxiliaryWindow, disposables: eventDisposables });
|
|
174
|
-
mark('code/auxiliaryWindow/didOpen');
|
|
175
|
-
this.telemetryService.publicLog2('auxiliaryWindowOpen', { bounds: !!options?.bounds });
|
|
176
|
-
return auxiliaryWindow;
|
|
177
|
-
}
|
|
178
|
-
createAuxiliaryWindow(targetWindow, container, stylesLoaded) {
|
|
179
|
-
return (
|
|
180
|
-
(new AuxiliaryWindow(
|
|
181
|
-
targetWindow,
|
|
182
|
-
container,
|
|
183
|
-
stylesLoaded,
|
|
184
|
-
this.configurationService,
|
|
185
|
-
this.hostService,
|
|
186
|
-
this.environmentService
|
|
187
|
-
))
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
async openWindow(options) {
|
|
191
|
-
const activeWindow = getActiveWindow();
|
|
192
|
-
const activeWindowBounds = {
|
|
193
|
-
x: activeWindow.screenX,
|
|
194
|
-
y: activeWindow.screenY,
|
|
195
|
-
width: activeWindow.outerWidth,
|
|
196
|
-
height: activeWindow.outerHeight
|
|
197
|
-
};
|
|
198
|
-
const width = Math.max(options?.bounds?.width ?? BrowserAuxiliaryWindowService_1.DEFAULT_SIZE.width, WindowMinimumSize.WIDTH);
|
|
199
|
-
const height = Math.max(options?.bounds?.height ?? BrowserAuxiliaryWindowService_1.DEFAULT_SIZE.height, WindowMinimumSize.HEIGHT);
|
|
200
|
-
let newWindowBounds = {
|
|
201
|
-
x: options?.bounds?.x ?? Math.max(activeWindowBounds.x + activeWindowBounds.width / 2 - width / 2, 0),
|
|
202
|
-
y: options?.bounds?.y ?? Math.max(activeWindowBounds.y + activeWindowBounds.height / 2 - height / 2, 0),
|
|
203
|
-
width,
|
|
204
|
-
height
|
|
205
|
-
};
|
|
206
|
-
if (!options?.bounds && newWindowBounds.x === activeWindowBounds.x && newWindowBounds.y === activeWindowBounds.y) {
|
|
207
|
-
newWindowBounds = {
|
|
208
|
-
...newWindowBounds,
|
|
209
|
-
x: newWindowBounds.x + 30,
|
|
210
|
-
y: newWindowBounds.y + 30
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
const features = coalesce([
|
|
214
|
-
'popup=yes',
|
|
215
|
-
`left=${newWindowBounds.x}`,
|
|
216
|
-
`top=${newWindowBounds.y}`,
|
|
217
|
-
`width=${newWindowBounds.width}`,
|
|
218
|
-
`height=${newWindowBounds.height}`,
|
|
219
|
-
options?.mode === AuxiliaryWindowMode.Maximized ? 'window-maximized=yes' : undefined,
|
|
220
|
-
options?.mode === AuxiliaryWindowMode.Fullscreen ? 'window-fullscreen=yes' : undefined
|
|
221
|
-
]);
|
|
222
|
-
const auxiliaryWindow = mainWindow.open('about:blank', undefined, features.join(','));
|
|
223
|
-
if (!auxiliaryWindow && isWeb) {
|
|
224
|
-
return (await this.dialogService.prompt({
|
|
225
|
-
type: Severity$1.Warning,
|
|
226
|
-
message: ( localizeWithPath(
|
|
227
|
-
_moduleId,
|
|
228
|
-
2,
|
|
229
|
-
"The browser interrupted the opening of a new window. Press 'Retry' to try again."
|
|
230
|
-
)),
|
|
231
|
-
detail: ( localizeWithPath(
|
|
232
|
-
_moduleId,
|
|
233
|
-
3,
|
|
234
|
-
"To avoid this problem in the future, please ensure to allow popups for this website."
|
|
235
|
-
)),
|
|
236
|
-
buttons: [
|
|
237
|
-
{
|
|
238
|
-
label: ( localizeWithPath(_moduleId, 4, "&&Retry")),
|
|
239
|
-
run: () => this.openWindow(options)
|
|
240
|
-
}
|
|
241
|
-
],
|
|
242
|
-
cancelButton: true
|
|
243
|
-
})).result;
|
|
244
|
-
}
|
|
245
|
-
return auxiliaryWindow?.window;
|
|
246
|
-
}
|
|
247
|
-
async resolveWindowId(auxiliaryWindow) {
|
|
248
|
-
return BrowserAuxiliaryWindowService_1.WINDOW_IDS++;
|
|
249
|
-
}
|
|
250
|
-
createContainer(auxiliaryWindow, disposables, options) {
|
|
251
|
-
this.applyMeta(auxiliaryWindow);
|
|
252
|
-
const { stylesLoaded } = this.applyCSS(auxiliaryWindow, disposables);
|
|
253
|
-
const container = this.applyHTML(auxiliaryWindow, disposables);
|
|
254
|
-
return { stylesLoaded, container };
|
|
255
|
-
}
|
|
256
|
-
applyMeta(auxiliaryWindow) {
|
|
257
|
-
for (const metaTag of ['meta[charset="utf-8"]', 'meta[http-equiv="Content-Security-Policy"]', 'meta[name="viewport"]', 'meta[name="theme-color"]']) {
|
|
258
|
-
const metaElement = mainWindow.document.querySelector(metaTag);
|
|
259
|
-
if (metaElement) {
|
|
260
|
-
const clonedMetaElement = createMetaElement(auxiliaryWindow.document.head);
|
|
261
|
-
copyAttributes(metaElement, clonedMetaElement);
|
|
262
|
-
if (metaTag === 'meta[http-equiv="Content-Security-Policy"]') {
|
|
263
|
-
const content = clonedMetaElement.getAttribute('content');
|
|
264
|
-
if (content) {
|
|
265
|
-
clonedMetaElement.setAttribute('content', content.replace(/(script-src[^\;]*)/, `script-src 'none'`));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
const originalIconLinkTag = mainWindow.document.querySelector('link[rel="icon"]');
|
|
271
|
-
if (originalIconLinkTag) {
|
|
272
|
-
const icon = createLinkElement(auxiliaryWindow.document.head);
|
|
273
|
-
copyAttributes(originalIconLinkTag, icon);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
applyCSS(auxiliaryWindow, disposables) {
|
|
277
|
-
mark('code/auxiliaryWindow/willApplyCSS');
|
|
278
|
-
const mapOriginalToClone = ( (new Map()));
|
|
279
|
-
const stylesLoaded = ( (new Barrier()));
|
|
280
|
-
stylesLoaded.wait().then(() => mark('code/auxiliaryWindow/didLoadCSSStyles'));
|
|
281
|
-
const pendingLinksDisposables = disposables.add(( (new DisposableStore())));
|
|
282
|
-
let pendingLinksToSettle = 0;
|
|
283
|
-
function onLinkSettled() {
|
|
284
|
-
if (--pendingLinksToSettle === 0) {
|
|
285
|
-
pendingLinksDisposables.dispose();
|
|
286
|
-
stylesLoaded.open();
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
function cloneNode(originalNode) {
|
|
290
|
-
if (isGlobalStylesheet(originalNode)) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
const clonedNode = auxiliaryWindow.document.head.appendChild(originalNode.cloneNode(true));
|
|
294
|
-
if (originalNode.tagName.toLowerCase() === 'link') {
|
|
295
|
-
pendingLinksToSettle++;
|
|
296
|
-
pendingLinksDisposables.add(addDisposableListener(clonedNode, 'load', onLinkSettled));
|
|
297
|
-
pendingLinksDisposables.add(addDisposableListener(clonedNode, 'error', onLinkSettled));
|
|
298
|
-
}
|
|
299
|
-
mapOriginalToClone.set(originalNode, clonedNode);
|
|
300
|
-
}
|
|
301
|
-
pendingLinksToSettle++;
|
|
302
|
-
try {
|
|
303
|
-
for (const originalNode of mainWindow.document.head.querySelectorAll('link[rel="stylesheet"], style')) {
|
|
304
|
-
cloneNode(originalNode);
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
finally {
|
|
308
|
-
onLinkSettled();
|
|
309
|
-
}
|
|
310
|
-
disposables.add(cloneGlobalStylesheets(auxiliaryWindow));
|
|
311
|
-
disposables.add(sharedMutationObserver.observe(mainWindow.document.head, disposables, { childList: true, subtree: true })(mutations => {
|
|
312
|
-
for (const mutation of mutations) {
|
|
313
|
-
if (mutation.type !== 'childList' ||
|
|
314
|
-
mutation.target.nodeName.toLowerCase() === 'title' ||
|
|
315
|
-
mutation.target.nodeName.toLowerCase() === 'script' ||
|
|
316
|
-
mutation.target.nodeName.toLowerCase() === 'meta'
|
|
317
|
-
) {
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
for (const node of mutation.addedNodes) {
|
|
321
|
-
if (node instanceof HTMLElement && (node.tagName.toLowerCase() === 'style' || node.tagName.toLowerCase() === 'link')) {
|
|
322
|
-
cloneNode(node);
|
|
323
|
-
}
|
|
324
|
-
else if (node.nodeType === Node.TEXT_NODE && node.parentNode) {
|
|
325
|
-
const clonedNode = mapOriginalToClone.get(node.parentNode);
|
|
326
|
-
if (clonedNode) {
|
|
327
|
-
clonedNode.textContent = node.textContent;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
for (const node of mutation.removedNodes) {
|
|
332
|
-
const clonedNode = mapOriginalToClone.get(node);
|
|
333
|
-
if (clonedNode) {
|
|
334
|
-
clonedNode.parentNode?.removeChild(clonedNode);
|
|
335
|
-
mapOriginalToClone.delete(node);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
}));
|
|
340
|
-
mark('code/auxiliaryWindow/didApplyCSS');
|
|
341
|
-
return { stylesLoaded };
|
|
342
|
-
}
|
|
343
|
-
applyHTML(auxiliaryWindow, disposables) {
|
|
344
|
-
mark('code/auxiliaryWindow/willApplyHTML');
|
|
345
|
-
const container = document.createElement('div');
|
|
346
|
-
container.setAttribute('role', 'application');
|
|
347
|
-
position(container, 0, 0, 0, 0, 'relative');
|
|
348
|
-
container.style.display = 'flex';
|
|
349
|
-
container.style.height = '100%';
|
|
350
|
-
container.style.flexDirection = 'column';
|
|
351
|
-
auxiliaryWindow.document.body.append(container);
|
|
352
|
-
disposables.add(trackAttributes(mainWindow.document.documentElement, auxiliaryWindow.document.documentElement));
|
|
353
|
-
disposables.add(trackAttributes(mainWindow.document.body, auxiliaryWindow.document.body));
|
|
354
|
-
disposables.add(trackAttributes(this.layoutService.mainContainer, container, ['class']));
|
|
355
|
-
mark('code/auxiliaryWindow/didApplyHTML');
|
|
356
|
-
return container;
|
|
357
|
-
}
|
|
358
|
-
getWindow(windowId) {
|
|
359
|
-
return this.windows.get(windowId);
|
|
360
|
-
}
|
|
361
|
-
};
|
|
362
|
-
BrowserAuxiliaryWindowService = BrowserAuxiliaryWindowService_1 = ( (__decorate([
|
|
363
|
-
( (__param(0, IWorkbenchLayoutService))),
|
|
364
|
-
( (__param(1, IDialogService))),
|
|
365
|
-
( (__param(2, IConfigurationService))),
|
|
366
|
-
( (__param(3, ITelemetryService))),
|
|
367
|
-
( (__param(4, IHostService))),
|
|
368
|
-
( (__param(5, IWorkbenchEnvironmentService)))
|
|
369
|
-
], BrowserAuxiliaryWindowService)));
|
|
370
|
-
|
|
371
|
-
export { AuxiliaryWindow, AuxiliaryWindowMode, BrowserAuxiliaryWindowService };
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { getTopLeftOffset, getClientArea } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
-
import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
|
|
4
|
-
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
5
|
-
import { language, locale } from 'vscode/vscode/vs/base/common/platform';
|
|
6
|
-
import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment.service';
|
|
7
|
-
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
8
|
-
import localizedStrings from '../../../../platform/languagePacks/common/localizedStrings.js';
|
|
9
|
-
import { getLogs } from 'vscode/vscode/vs/platform/log/browser/log';
|
|
10
|
-
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
11
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
12
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
|
|
13
|
-
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
14
|
-
|
|
15
|
-
let BrowserWindowDriver = class BrowserWindowDriver {
|
|
16
|
-
constructor(fileService, environmentService, lifecycleService, logService) {
|
|
17
|
-
this.fileService = fileService;
|
|
18
|
-
this.environmentService = environmentService;
|
|
19
|
-
this.lifecycleService = lifecycleService;
|
|
20
|
-
this.logService = logService;
|
|
21
|
-
}
|
|
22
|
-
async getLogs() {
|
|
23
|
-
return getLogs(this.fileService, this.environmentService);
|
|
24
|
-
}
|
|
25
|
-
async whenWorkbenchRestored() {
|
|
26
|
-
this.logService.info('[driver] Waiting for restored lifecycle phase...');
|
|
27
|
-
await this.lifecycleService.when(3 );
|
|
28
|
-
this.logService.info('[driver] Restored lifecycle phase reached. Waiting for contributions...');
|
|
29
|
-
await ( Registry.as(Extensions.Workbench)).whenRestored;
|
|
30
|
-
this.logService.info('[driver] Workbench contributions created.');
|
|
31
|
-
}
|
|
32
|
-
async setValue(selector, text) {
|
|
33
|
-
const element = mainWindow.document.querySelector(selector);
|
|
34
|
-
if (!element) {
|
|
35
|
-
return Promise.reject(( new Error(`Element not found: ${selector}`)));
|
|
36
|
-
}
|
|
37
|
-
const inputElement = element;
|
|
38
|
-
inputElement.value = text;
|
|
39
|
-
const event = ( new Event('input', { bubbles: true, cancelable: true }));
|
|
40
|
-
inputElement.dispatchEvent(event);
|
|
41
|
-
}
|
|
42
|
-
async isActiveElement(selector) {
|
|
43
|
-
const element = mainWindow.document.querySelector(selector);
|
|
44
|
-
if (element !== mainWindow.document.activeElement) {
|
|
45
|
-
const chain = [];
|
|
46
|
-
let el = mainWindow.document.activeElement;
|
|
47
|
-
while (el) {
|
|
48
|
-
const tagName = el.tagName;
|
|
49
|
-
const id = el.id ? `#${el.id}` : '';
|
|
50
|
-
const classes = ( coalesce(( el.className.split(/\s+/g).map(c => c.trim()))).map(c => `.${c}`)).join('');
|
|
51
|
-
chain.unshift(`${tagName}${id}${classes}`);
|
|
52
|
-
el = el.parentElement;
|
|
53
|
-
}
|
|
54
|
-
throw ( new Error(
|
|
55
|
-
`Active element not found. Current active element is '${chain.join(' > ')}'. Looking for ${selector}`
|
|
56
|
-
));
|
|
57
|
-
}
|
|
58
|
-
return true;
|
|
59
|
-
}
|
|
60
|
-
async getElements(selector, recursive) {
|
|
61
|
-
const query = mainWindow.document.querySelectorAll(selector);
|
|
62
|
-
const result = [];
|
|
63
|
-
for (let i = 0; i < query.length; i++) {
|
|
64
|
-
const element = query.item(i);
|
|
65
|
-
result.push(this.serializeElement(element, recursive));
|
|
66
|
-
}
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
serializeElement(element, recursive) {
|
|
70
|
-
const attributes = Object.create(null);
|
|
71
|
-
for (let j = 0; j < element.attributes.length; j++) {
|
|
72
|
-
const attr = element.attributes.item(j);
|
|
73
|
-
if (attr) {
|
|
74
|
-
attributes[attr.name] = attr.value;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const children = [];
|
|
78
|
-
if (recursive) {
|
|
79
|
-
for (let i = 0; i < element.children.length; i++) {
|
|
80
|
-
const child = element.children.item(i);
|
|
81
|
-
if (child) {
|
|
82
|
-
children.push(this.serializeElement(child, true));
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const { left, top } = getTopLeftOffset(element);
|
|
87
|
-
return {
|
|
88
|
-
tagName: element.tagName,
|
|
89
|
-
className: element.className,
|
|
90
|
-
textContent: element.textContent || '',
|
|
91
|
-
attributes,
|
|
92
|
-
children,
|
|
93
|
-
left,
|
|
94
|
-
top
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
async getElementXY(selector, xoffset, yoffset) {
|
|
98
|
-
const offset = typeof xoffset === 'number' && typeof yoffset === 'number' ? { x: xoffset, y: yoffset } : undefined;
|
|
99
|
-
return this._getElementXY(selector, offset);
|
|
100
|
-
}
|
|
101
|
-
async typeInEditor(selector, text) {
|
|
102
|
-
const element = mainWindow.document.querySelector(selector);
|
|
103
|
-
if (!element) {
|
|
104
|
-
throw ( new Error(`Editor not found: ${selector}`));
|
|
105
|
-
}
|
|
106
|
-
const textarea = element;
|
|
107
|
-
const start = textarea.selectionStart;
|
|
108
|
-
const newStart = start + text.length;
|
|
109
|
-
const value = textarea.value;
|
|
110
|
-
const newValue = value.substr(0, start) + text + value.substr(start);
|
|
111
|
-
textarea.value = newValue;
|
|
112
|
-
textarea.setSelectionRange(newStart, newStart);
|
|
113
|
-
const event = ( new Event('input', { 'bubbles': true, 'cancelable': true }));
|
|
114
|
-
textarea.dispatchEvent(event);
|
|
115
|
-
}
|
|
116
|
-
async getTerminalBuffer(selector) {
|
|
117
|
-
const element = mainWindow.document.querySelector(selector);
|
|
118
|
-
if (!element) {
|
|
119
|
-
throw ( new Error(`Terminal not found: ${selector}`));
|
|
120
|
-
}
|
|
121
|
-
const xterm = element.xterm;
|
|
122
|
-
if (!xterm) {
|
|
123
|
-
throw ( new Error(`Xterm not found: ${selector}`));
|
|
124
|
-
}
|
|
125
|
-
const lines = [];
|
|
126
|
-
for (let i = 0; i < xterm.buffer.active.length; i++) {
|
|
127
|
-
lines.push(xterm.buffer.active.getLine(i).translateToString(true));
|
|
128
|
-
}
|
|
129
|
-
return lines;
|
|
130
|
-
}
|
|
131
|
-
async writeInTerminal(selector, text) {
|
|
132
|
-
const element = mainWindow.document.querySelector(selector);
|
|
133
|
-
if (!element) {
|
|
134
|
-
throw ( new Error(`Element not found: ${selector}`));
|
|
135
|
-
}
|
|
136
|
-
const xterm = element.xterm;
|
|
137
|
-
if (!xterm) {
|
|
138
|
-
throw ( new Error(`Xterm not found: ${selector}`));
|
|
139
|
-
}
|
|
140
|
-
xterm.input(text);
|
|
141
|
-
}
|
|
142
|
-
getLocaleInfo() {
|
|
143
|
-
return Promise.resolve({
|
|
144
|
-
language: language,
|
|
145
|
-
locale: locale
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
getLocalizedStrings() {
|
|
149
|
-
return Promise.resolve({
|
|
150
|
-
open: localizedStrings.open,
|
|
151
|
-
close: localizedStrings.close,
|
|
152
|
-
find: localizedStrings.find
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
async _getElementXY(selector, offset) {
|
|
156
|
-
const element = mainWindow.document.querySelector(selector);
|
|
157
|
-
if (!element) {
|
|
158
|
-
return Promise.reject(( new Error(`Element not found: ${selector}`)));
|
|
159
|
-
}
|
|
160
|
-
const { left, top } = getTopLeftOffset(element);
|
|
161
|
-
const { width, height } = getClientArea(element);
|
|
162
|
-
let x, y;
|
|
163
|
-
if (offset) {
|
|
164
|
-
x = left + offset.x;
|
|
165
|
-
y = top + offset.y;
|
|
166
|
-
}
|
|
167
|
-
else {
|
|
168
|
-
x = left + (width / 2);
|
|
169
|
-
y = top + (height / 2);
|
|
170
|
-
}
|
|
171
|
-
x = Math.round(x);
|
|
172
|
-
y = Math.round(y);
|
|
173
|
-
return { x, y };
|
|
174
|
-
}
|
|
175
|
-
async exitApplication() {
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
BrowserWindowDriver = ( __decorate([
|
|
179
|
-
( __param(0, IFileService)),
|
|
180
|
-
( __param(1, IEnvironmentService)),
|
|
181
|
-
( __param(2, ILifecycleService)),
|
|
182
|
-
( __param(3, ILogService))
|
|
183
|
-
], BrowserWindowDriver));
|
|
184
|
-
function registerWindowDriver(instantiationService) {
|
|
185
|
-
Object.assign(mainWindow, { driver: instantiationService.createInstance(BrowserWindowDriver) });
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export { BrowserWindowDriver, registerWindowDriver };
|