@codingame/monaco-vscode-host-service-override 25.1.2 → 26.0.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-host-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - host service-override",
|
|
6
6
|
"keywords": [],
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@codingame/monaco-vscode-api": "
|
|
18
|
+
"@codingame/monaco-vscode-api": "26.0.1"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -38,13 +38,25 @@ import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buf
|
|
|
38
38
|
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
39
39
|
|
|
40
40
|
var HostShutdownReason;
|
|
41
|
-
(function
|
|
41
|
+
(function(HostShutdownReason) {
|
|
42
42
|
HostShutdownReason[HostShutdownReason["Unknown"] = 1] = "Unknown";
|
|
43
43
|
HostShutdownReason[HostShutdownReason["Keyboard"] = 2] = "Keyboard";
|
|
44
44
|
HostShutdownReason[HostShutdownReason["Api"] = 3] = "Api";
|
|
45
45
|
})(HostShutdownReason || (HostShutdownReason = {}));
|
|
46
46
|
let BrowserHostService = class BrowserHostService extends Disposable {
|
|
47
|
-
constructor(
|
|
47
|
+
constructor(
|
|
48
|
+
layoutService,
|
|
49
|
+
configurationService,
|
|
50
|
+
fileService,
|
|
51
|
+
labelService,
|
|
52
|
+
environmentService,
|
|
53
|
+
instantiationService,
|
|
54
|
+
lifecycleService,
|
|
55
|
+
logService,
|
|
56
|
+
dialogService,
|
|
57
|
+
contextService,
|
|
58
|
+
userDataProfilesService
|
|
59
|
+
) {
|
|
48
60
|
super();
|
|
49
61
|
this.layoutService = layoutService;
|
|
50
62
|
this.configurationService = configurationService;
|
|
@@ -60,29 +72,33 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
60
72
|
this.shutdownReason = HostShutdownReason.Unknown;
|
|
61
73
|
if (environmentService.options?.workspaceProvider) {
|
|
62
74
|
this.workspaceProvider = environmentService.options.workspaceProvider;
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
75
|
+
} else {
|
|
65
76
|
this.workspaceProvider = new class {
|
|
66
77
|
constructor() {
|
|
67
78
|
this.workspace = undefined;
|
|
68
79
|
this.trusted = undefined;
|
|
69
80
|
}
|
|
70
|
-
async open() {
|
|
71
|
-
|
|
81
|
+
async open() {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}();
|
|
72
85
|
}
|
|
73
86
|
this.registerListeners();
|
|
74
87
|
}
|
|
75
88
|
registerListeners() {
|
|
76
89
|
this._register(this.lifecycleService.onBeforeShutdown(e => this.onBeforeShutdown(e)));
|
|
77
|
-
this._register(
|
|
90
|
+
this._register(
|
|
91
|
+
ModifierKeyEmitter.getInstance().event(() => this.updateShutdownReasonFromEvent())
|
|
92
|
+
);
|
|
78
93
|
}
|
|
79
94
|
onBeforeShutdown(e) {
|
|
80
95
|
switch (this.shutdownReason) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
96
|
+
case HostShutdownReason.Unknown:
|
|
97
|
+
case HostShutdownReason.Keyboard:
|
|
98
|
+
{
|
|
99
|
+
const confirmBeforeClose = this.configurationService.getValue("window.confirmBeforeClose");
|
|
100
|
+
if (confirmBeforeClose === "always" || (confirmBeforeClose === "keyboardOnly" && this.shutdownReason === HostShutdownReason.Keyboard)) {
|
|
101
|
+
e.veto(true, "veto.confirmBeforeClose");
|
|
86
102
|
}
|
|
87
103
|
break;
|
|
88
104
|
}
|
|
@@ -95,18 +111,25 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
95
111
|
}
|
|
96
112
|
if (ModifierKeyEmitter.getInstance().isModifierPressed) {
|
|
97
113
|
this.shutdownReason = HostShutdownReason.Keyboard;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
114
|
+
} else {
|
|
100
115
|
this.shutdownReason = HostShutdownReason.Unknown;
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
118
|
get onDidChangeFocus() {
|
|
104
119
|
const emitter = this._register(( new Emitter()));
|
|
105
|
-
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
120
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
121
|
+
{
|
|
122
|
+
window,
|
|
123
|
+
disposables
|
|
124
|
+
}
|
|
125
|
+
) => {
|
|
106
126
|
const focusTracker = disposables.add(trackFocus(window));
|
|
107
|
-
const visibilityTracker = disposables.add(( new DomEmitter(window.document,
|
|
127
|
+
const visibilityTracker = disposables.add(( new DomEmitter(window.document, "visibilitychange")));
|
|
108
128
|
Event.any(( Event.map(focusTracker.onDidFocus, () => this.hasFocus, disposables)), ( Event.map(focusTracker.onDidBlur, () => this.hasFocus, disposables)), ( Event.map(visibilityTracker.event, () => this.hasFocus, disposables)), ( Event.map(this.onDidChangeActiveWindow, () => this.hasFocus, disposables)))(focus => emitter.fire(focus), undefined, disposables);
|
|
109
|
-
}, {
|
|
129
|
+
}, {
|
|
130
|
+
window: mainWindow,
|
|
131
|
+
disposables: this._store
|
|
132
|
+
}));
|
|
110
133
|
return Event.latch(emitter.event, undefined, this._store);
|
|
111
134
|
}
|
|
112
135
|
get hasFocus() {
|
|
@@ -120,7 +143,12 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
120
143
|
}
|
|
121
144
|
get onDidChangeActiveWindow() {
|
|
122
145
|
const emitter = this._register(( new Emitter()));
|
|
123
|
-
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
146
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
147
|
+
{
|
|
148
|
+
window,
|
|
149
|
+
disposables
|
|
150
|
+
}
|
|
151
|
+
) => {
|
|
124
152
|
const windowId = getWindowId(window);
|
|
125
153
|
const focusTracker = disposables.add(trackFocus(window));
|
|
126
154
|
disposables.add(focusTracker.onDidFocus(() => emitter.fire(windowId)));
|
|
@@ -133,12 +161,20 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
133
161
|
return hasFocus;
|
|
134
162
|
}, 100, 20));
|
|
135
163
|
}
|
|
136
|
-
}, {
|
|
164
|
+
}, {
|
|
165
|
+
window: mainWindow,
|
|
166
|
+
disposables: this._store
|
|
167
|
+
}));
|
|
137
168
|
return Event.latch(emitter.event, undefined, this._store);
|
|
138
169
|
}
|
|
139
170
|
get onDidChangeFullScreen() {
|
|
140
171
|
const emitter = this._register(( new Emitter()));
|
|
141
|
-
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
172
|
+
this._register(Event.runAndSubscribe(onDidRegisterWindow, (
|
|
173
|
+
{
|
|
174
|
+
window,
|
|
175
|
+
disposables
|
|
176
|
+
}
|
|
177
|
+
) => {
|
|
142
178
|
const windowId = getWindowId(window);
|
|
143
179
|
const viewport = isIOS && window.visualViewport ? window.visualViewport : window ;
|
|
144
180
|
const isFullScreen = () => {
|
|
@@ -146,10 +182,21 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
146
182
|
return fullScreen !== null && !fullScreen.guess;
|
|
147
183
|
};
|
|
148
184
|
for (const event of [EventType.FULLSCREEN_CHANGE, EventType.WK_FULLSCREEN_CHANGE]) {
|
|
149
|
-
disposables.add(addDisposableListener(window.document, event, () => emitter.fire({
|
|
185
|
+
disposables.add(addDisposableListener(window.document, event, () => emitter.fire({
|
|
186
|
+
windowId,
|
|
187
|
+
fullscreen: isFullScreen()
|
|
188
|
+
})));
|
|
150
189
|
}
|
|
151
|
-
disposables.add(
|
|
152
|
-
|
|
190
|
+
disposables.add(
|
|
191
|
+
addDisposableThrottledListener(viewport, EventType.RESIZE, () => emitter.fire({
|
|
192
|
+
windowId,
|
|
193
|
+
fullscreen: isFullScreen()
|
|
194
|
+
}), undefined, isMacintosh ? 2000 : 800 )
|
|
195
|
+
);
|
|
196
|
+
}, {
|
|
197
|
+
window: mainWindow,
|
|
198
|
+
disposables: this._store
|
|
199
|
+
}));
|
|
153
200
|
return emitter.event;
|
|
154
201
|
}
|
|
155
202
|
openWindow(arg1, arg2) {
|
|
@@ -159,7 +206,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
159
206
|
return this.doOpenEmptyWindow(arg1);
|
|
160
207
|
}
|
|
161
208
|
async doOpenWindow(toOpen, options) {
|
|
162
|
-
const payload = this.preservePayload(false
|
|
209
|
+
const payload = this.preservePayload(false, options);
|
|
163
210
|
const fileOpenables = [];
|
|
164
211
|
const foldersToAdd = [];
|
|
165
212
|
const foldersToRemove = [];
|
|
@@ -167,24 +214,34 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
167
214
|
openable.label = openable.label || this.getRecentLabel(openable);
|
|
168
215
|
if (isFolderToOpen(openable)) {
|
|
169
216
|
if (options?.addMode) {
|
|
170
|
-
foldersToAdd.push({
|
|
171
|
-
|
|
172
|
-
|
|
217
|
+
foldersToAdd.push({
|
|
218
|
+
uri: openable.folderUri
|
|
219
|
+
});
|
|
220
|
+
} else if (options?.removeMode) {
|
|
173
221
|
foldersToRemove.push(openable.folderUri);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
222
|
+
} else {
|
|
223
|
+
this.doOpen({
|
|
224
|
+
folderUri: openable.folderUri
|
|
225
|
+
}, {
|
|
226
|
+
reuse: this.shouldReuse(options, false ),
|
|
227
|
+
payload
|
|
228
|
+
});
|
|
177
229
|
}
|
|
178
230
|
}
|
|
179
231
|
else if (isWorkspaceToOpen(openable)) {
|
|
180
|
-
this.doOpen({
|
|
232
|
+
this.doOpen({
|
|
233
|
+
workspaceUri: openable.workspaceUri
|
|
234
|
+
}, {
|
|
235
|
+
reuse: this.shouldReuse(options, false ),
|
|
236
|
+
payload
|
|
237
|
+
});
|
|
181
238
|
}
|
|
182
239
|
else if (isFileToOpen(openable)) {
|
|
183
240
|
fileOpenables.push(openable);
|
|
184
241
|
}
|
|
185
242
|
}
|
|
186
243
|
if (foldersToAdd.length > 0 || foldersToRemove.length > 0) {
|
|
187
|
-
this.withServices(async
|
|
244
|
+
this.withServices(async accessor => {
|
|
188
245
|
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
|
|
189
246
|
if (foldersToAdd.length > 0) {
|
|
190
247
|
await workspaceEditingService.addFolders(foldersToAdd);
|
|
@@ -195,7 +252,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
195
252
|
});
|
|
196
253
|
}
|
|
197
254
|
if (fileOpenables.length > 0) {
|
|
198
|
-
this.withServices(async
|
|
255
|
+
this.withServices(async accessor => {
|
|
199
256
|
const editorService = accessor.get(IEditorService);
|
|
200
257
|
if (options?.mergeMode && fileOpenables.length === 4) {
|
|
201
258
|
const editors = coalesce(await pathsToEditors(fileOpenables, this.fileService, this.logService));
|
|
@@ -204,20 +261,32 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
204
261
|
}
|
|
205
262
|
if (this.shouldReuse(options, true )) {
|
|
206
263
|
editorService.openEditor({
|
|
207
|
-
input1: {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
264
|
+
input1: {
|
|
265
|
+
resource: editors[0].resource
|
|
266
|
+
},
|
|
267
|
+
input2: {
|
|
268
|
+
resource: editors[1].resource
|
|
269
|
+
},
|
|
270
|
+
base: {
|
|
271
|
+
resource: editors[2].resource
|
|
272
|
+
},
|
|
273
|
+
result: {
|
|
274
|
+
resource: editors[3].resource
|
|
275
|
+
},
|
|
276
|
+
options: {
|
|
277
|
+
pinned: true
|
|
278
|
+
}
|
|
212
279
|
});
|
|
213
280
|
}
|
|
214
281
|
else {
|
|
215
282
|
const environment = ( new Map());
|
|
216
|
-
environment.set(
|
|
217
|
-
environment.set(
|
|
218
|
-
environment.set(
|
|
219
|
-
environment.set(
|
|
220
|
-
this.doOpen(undefined, {
|
|
283
|
+
environment.set("mergeFile1", ( editors[0].resource.toString()));
|
|
284
|
+
environment.set("mergeFile2", ( editors[1].resource.toString()));
|
|
285
|
+
environment.set("mergeFileBase", ( editors[2].resource.toString()));
|
|
286
|
+
environment.set("mergeFileResult", ( editors[3].resource.toString()));
|
|
287
|
+
this.doOpen(undefined, {
|
|
288
|
+
payload: Array.from(environment.entries())
|
|
289
|
+
});
|
|
221
290
|
}
|
|
222
291
|
}
|
|
223
292
|
else if (options?.diffMode && fileOpenables.length === 2) {
|
|
@@ -227,16 +296,24 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
227
296
|
}
|
|
228
297
|
if (this.shouldReuse(options, true )) {
|
|
229
298
|
editorService.openEditor({
|
|
230
|
-
original: {
|
|
231
|
-
|
|
232
|
-
|
|
299
|
+
original: {
|
|
300
|
+
resource: editors[0].resource
|
|
301
|
+
},
|
|
302
|
+
modified: {
|
|
303
|
+
resource: editors[1].resource
|
|
304
|
+
},
|
|
305
|
+
options: {
|
|
306
|
+
pinned: true
|
|
307
|
+
}
|
|
233
308
|
});
|
|
234
309
|
}
|
|
235
310
|
else {
|
|
236
311
|
const environment = ( new Map());
|
|
237
|
-
environment.set(
|
|
238
|
-
environment.set(
|
|
239
|
-
this.doOpen(undefined, {
|
|
312
|
+
environment.set("diffFileSecondary", ( editors[0].resource.toString()));
|
|
313
|
+
environment.set("diffFilePrimary", ( editors[1].resource.toString()));
|
|
314
|
+
this.doOpen(undefined, {
|
|
315
|
+
payload: Array.from(environment.entries())
|
|
316
|
+
});
|
|
240
317
|
}
|
|
241
318
|
}
|
|
242
319
|
else {
|
|
@@ -246,24 +323,36 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
246
323
|
if (options?.gotoLineMode) {
|
|
247
324
|
const pathColumnAware = parseLineAndColumnAware(openable.fileUri.path);
|
|
248
325
|
openables = [{
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
326
|
+
fileUri: openable.fileUri.with({
|
|
327
|
+
path: pathColumnAware.path
|
|
328
|
+
}),
|
|
329
|
+
options: {
|
|
330
|
+
selection: !isUndefined(pathColumnAware.line) ? {
|
|
331
|
+
startLineNumber: pathColumnAware.line,
|
|
332
|
+
startColumn: pathColumnAware.column || 1
|
|
333
|
+
} : undefined
|
|
334
|
+
}
|
|
335
|
+
}];
|
|
336
|
+
} else {
|
|
256
337
|
openables = [openable];
|
|
257
338
|
}
|
|
258
|
-
editorService.openEditors(
|
|
339
|
+
editorService.openEditors(
|
|
340
|
+
coalesce(await pathsToEditors(openables, this.fileService, this.logService)),
|
|
341
|
+
undefined,
|
|
342
|
+
{
|
|
343
|
+
validateTrust: true
|
|
344
|
+
}
|
|
345
|
+
);
|
|
259
346
|
}
|
|
260
347
|
else {
|
|
261
348
|
const environment = ( new Map());
|
|
262
|
-
environment.set(
|
|
349
|
+
environment.set("openFile", ( openable.fileUri.toString()));
|
|
263
350
|
if (options?.gotoLineMode) {
|
|
264
|
-
environment.set(
|
|
351
|
+
environment.set("gotoLineMode", "true");
|
|
265
352
|
}
|
|
266
|
-
this.doOpen(undefined, {
|
|
353
|
+
this.doOpen(undefined, {
|
|
354
|
+
payload: Array.from(environment.entries())
|
|
355
|
+
});
|
|
267
356
|
}
|
|
268
357
|
}
|
|
269
358
|
}
|
|
@@ -273,8 +362,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
273
362
|
const filesToWaitFor = [];
|
|
274
363
|
if (options.mergeMode) {
|
|
275
364
|
filesToWaitFor.push(fileOpenables[3].fileUri );
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
365
|
+
} else {
|
|
278
366
|
filesToWaitFor.push(...( fileOpenables.map(fileOpenable => fileOpenable.fileUri)));
|
|
279
367
|
}
|
|
280
368
|
await this.instantiationService.invokeFunction(accessor => whenEditorClosed(accessor, filesToWaitFor));
|
|
@@ -290,54 +378,63 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
290
378
|
preservePayload(isEmptyWindow, options) {
|
|
291
379
|
const newPayload = [];
|
|
292
380
|
if (!isEmptyWindow && this.environmentService.extensionDevelopmentLocationURI) {
|
|
293
|
-
newPayload.push([
|
|
381
|
+
newPayload.push(["extensionDevelopmentPath", ( this.environmentService.extensionDevelopmentLocationURI.toString())]);
|
|
294
382
|
if (this.environmentService.debugExtensionHost.debugId) {
|
|
295
|
-
newPayload.push([
|
|
383
|
+
newPayload.push(["debugId", this.environmentService.debugExtensionHost.debugId]);
|
|
296
384
|
}
|
|
297
385
|
if (this.environmentService.debugExtensionHost.port) {
|
|
298
|
-
newPayload.push([
|
|
386
|
+
newPayload.push([
|
|
387
|
+
"inspect-brk-extensions",
|
|
388
|
+
String(this.environmentService.debugExtensionHost.port)
|
|
389
|
+
]);
|
|
299
390
|
}
|
|
300
391
|
}
|
|
301
|
-
const newWindowProfile = options?.forceProfile
|
|
302
|
-
? this.userDataProfilesService.profiles.find(profile => profile.name === options?.forceProfile)
|
|
303
|
-
: undefined;
|
|
392
|
+
const newWindowProfile = options?.forceProfile ? this.userDataProfilesService.profiles.find(profile => profile.name === options?.forceProfile) : undefined;
|
|
304
393
|
if (newWindowProfile && !newWindowProfile.isDefault) {
|
|
305
|
-
newPayload.push([
|
|
394
|
+
newPayload.push(["profile", newWindowProfile.name]);
|
|
306
395
|
}
|
|
307
396
|
return newPayload.length ? newPayload : undefined;
|
|
308
397
|
}
|
|
309
398
|
getRecentLabel(openable) {
|
|
310
399
|
if (isFolderToOpen(openable)) {
|
|
311
|
-
return this.labelService.getWorkspaceLabel(openable.folderUri, {
|
|
400
|
+
return this.labelService.getWorkspaceLabel(openable.folderUri, {
|
|
401
|
+
verbose: Verbosity.LONG
|
|
402
|
+
});
|
|
312
403
|
}
|
|
313
404
|
if (isWorkspaceToOpen(openable)) {
|
|
314
|
-
return this.labelService.getWorkspaceLabel(getWorkspaceIdentifier(openable.workspaceUri), {
|
|
405
|
+
return this.labelService.getWorkspaceLabel(getWorkspaceIdentifier(openable.workspaceUri), {
|
|
406
|
+
verbose: Verbosity.LONG
|
|
407
|
+
});
|
|
315
408
|
}
|
|
316
|
-
return this.labelService.getUriLabel(openable.fileUri, {
|
|
409
|
+
return this.labelService.getUriLabel(openable.fileUri, {
|
|
410
|
+
appendWorkspaceSuffix: true
|
|
411
|
+
});
|
|
317
412
|
}
|
|
318
413
|
shouldReuse(options = Object.create(null), isFile) {
|
|
319
414
|
if (options.waitMarkerFileURI) {
|
|
320
415
|
return true;
|
|
321
416
|
}
|
|
322
|
-
const windowConfig = this.configurationService.getValue(
|
|
323
|
-
const openInNewWindowConfig = isFile ? (
|
|
417
|
+
const windowConfig = this.configurationService.getValue("window");
|
|
418
|
+
const openInNewWindowConfig = isFile ? (windowConfig?.openFilesInNewWindow || "off") : (windowConfig?.openFoldersInNewWindow || "default") ;
|
|
324
419
|
let openInNewWindow = (options.preferNewWindow || !!options.forceNewWindow) && !options.forceReuseWindow;
|
|
325
|
-
if (!options.forceNewWindow && !options.forceReuseWindow && (openInNewWindowConfig ===
|
|
326
|
-
openInNewWindow = (openInNewWindowConfig ===
|
|
420
|
+
if (!options.forceNewWindow && !options.forceReuseWindow && (openInNewWindowConfig === "on" || openInNewWindowConfig === "off")) {
|
|
421
|
+
openInNewWindow = (openInNewWindowConfig === "on");
|
|
327
422
|
}
|
|
328
423
|
return !openInNewWindow;
|
|
329
424
|
}
|
|
330
425
|
async doOpenEmptyWindow(options) {
|
|
331
426
|
return this.doOpen(undefined, {
|
|
332
427
|
reuse: options?.forceReuseWindow,
|
|
333
|
-
payload: this.preservePayload(true
|
|
428
|
+
payload: this.preservePayload(true, options)
|
|
334
429
|
});
|
|
335
430
|
}
|
|
336
431
|
async doOpen(workspace, options) {
|
|
337
432
|
if (workspace && isFolderToOpen(workspace) && workspace.folderUri.scheme === Schemas.file && isTemporaryWorkspace(this.contextService.getWorkspace())) {
|
|
338
|
-
this.withServices(async
|
|
433
|
+
this.withServices(async accessor => {
|
|
339
434
|
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
|
|
340
|
-
await workspaceEditingService.updateFolders(0, this.contextService.getWorkspace().folders.length, [{
|
|
435
|
+
await workspaceEditingService.updateFolders(0, this.contextService.getWorkspace().folders.length, [{
|
|
436
|
+
uri: workspace.folderUri
|
|
437
|
+
}]);
|
|
341
438
|
});
|
|
342
439
|
return;
|
|
343
440
|
}
|
|
@@ -348,29 +445,27 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
348
445
|
if (!opened) {
|
|
349
446
|
await this.dialogService.prompt({
|
|
350
447
|
type: Severity.Warning,
|
|
351
|
-
message: workspace ?
|
|
352
|
-
|
|
353
|
-
14112,
|
|
448
|
+
message: workspace ? ( localize(
|
|
449
|
+
14501,
|
|
354
450
|
"The browser blocked opening a new tab or window for '{0}'. Press 'Retry' to try again.",
|
|
355
451
|
this.getRecentLabel(workspace)
|
|
356
|
-
)) :
|
|
357
|
-
|
|
358
|
-
14113,
|
|
452
|
+
)) : ( localize(
|
|
453
|
+
14502,
|
|
359
454
|
"The browser blocked opening a new tab or window. Press 'Retry' to try again."
|
|
360
455
|
)),
|
|
361
456
|
custom: {
|
|
362
|
-
markdownDetails: [{
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
457
|
+
markdownDetails: [{
|
|
458
|
+
markdown: ( new MarkdownString(( localize(
|
|
459
|
+
14503,
|
|
460
|
+
"Please allow pop-ups for this website in your [browser settings]({0}).",
|
|
461
|
+
"https://aka.ms/allow-vscode-popup"
|
|
462
|
+
)), true))
|
|
463
|
+
}]
|
|
367
464
|
},
|
|
368
|
-
buttons: [
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
],
|
|
465
|
+
buttons: [{
|
|
466
|
+
label: ( localize(14504, "&&Retry")),
|
|
467
|
+
run: () => this.workspaceProvider.open(workspace, options)
|
|
468
|
+
}],
|
|
374
469
|
cancelButton: true
|
|
375
470
|
});
|
|
376
471
|
}
|
|
@@ -381,17 +476,14 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
381
476
|
if (!targetWindow.document.fullscreen) {
|
|
382
477
|
try {
|
|
383
478
|
return await target.requestFullscreen();
|
|
479
|
+
} catch (error) {
|
|
480
|
+
this.logService.warn("toggleFullScreen(): requestFullscreen failed");
|
|
384
481
|
}
|
|
385
|
-
|
|
386
|
-
this.logService.warn('toggleFullScreen(): requestFullscreen failed');
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
482
|
+
} else {
|
|
390
483
|
try {
|
|
391
484
|
return await targetWindow.document.exitFullscreen();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
this.logService.warn('toggleFullScreen(): exitFullscreen failed');
|
|
485
|
+
} catch (error) {
|
|
486
|
+
this.logService.warn("toggleFullScreen(): exitFullscreen failed");
|
|
395
487
|
}
|
|
396
488
|
}
|
|
397
489
|
}
|
|
@@ -401,18 +493,15 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
401
493
|
try {
|
|
402
494
|
if (!webkitDocument.webkitIsFullScreen) {
|
|
403
495
|
webkitElement.webkitRequestFullscreen();
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
496
|
+
} else {
|
|
406
497
|
webkitDocument.webkitExitFullscreen();
|
|
407
498
|
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
this.logService.warn('toggleFullScreen(): requestFullscreen/exitFullscreen failed');
|
|
499
|
+
} catch {
|
|
500
|
+
this.logService.warn("toggleFullScreen(): requestFullscreen/exitFullscreen failed");
|
|
411
501
|
}
|
|
412
502
|
}
|
|
413
503
|
}
|
|
414
|
-
async moveTop(targetWindow) {
|
|
415
|
-
}
|
|
504
|
+
async moveTop(targetWindow) {}
|
|
416
505
|
async getCursorScreenPoint() {
|
|
417
506
|
return undefined;
|
|
418
507
|
}
|
|
@@ -420,13 +509,15 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
420
509
|
const activeWindow = getActiveWindow();
|
|
421
510
|
const activeWindowId = getWindowId(activeWindow);
|
|
422
511
|
const result = [{
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
512
|
+
id: activeWindowId,
|
|
513
|
+
title: activeWindow.document.title,
|
|
514
|
+
workspace: toWorkspaceIdentifier(this.contextService.getWorkspace()),
|
|
515
|
+
dirty: false
|
|
516
|
+
}];
|
|
428
517
|
if (options.includeAuxiliaryWindows) {
|
|
429
|
-
for (const {
|
|
518
|
+
for (const {
|
|
519
|
+
window
|
|
520
|
+
} of getWindows()) {
|
|
430
521
|
const windowId = getWindowId(window);
|
|
431
522
|
if (windowId !== activeWindowId && isAuxiliaryWindow(window)) {
|
|
432
523
|
result.push({
|
|
@@ -455,8 +546,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
455
546
|
try {
|
|
456
547
|
this.shutdownReason = HostShutdownReason.Api;
|
|
457
548
|
return await expectedShutdownTask();
|
|
458
|
-
}
|
|
459
|
-
finally {
|
|
549
|
+
} finally {
|
|
460
550
|
this.shutdownReason = previousShutdownReason;
|
|
461
551
|
}
|
|
462
552
|
}
|
|
@@ -466,7 +556,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
466
556
|
}
|
|
467
557
|
async getScreenshot() {
|
|
468
558
|
const store = ( new DisposableStore());
|
|
469
|
-
const video = createElement(
|
|
559
|
+
const video = createElement("video");
|
|
470
560
|
store.add(toDisposable(() => video.remove()));
|
|
471
561
|
let stream;
|
|
472
562
|
try {
|
|
@@ -476,30 +566,25 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
476
566
|
});
|
|
477
567
|
video.srcObject = stream;
|
|
478
568
|
video.play();
|
|
479
|
-
await Promise.all([
|
|
480
|
-
|
|
481
|
-
( new Promise(r => store.add(addDisposableListener(video, 'canplaythrough', () => r()))))
|
|
482
|
-
]);
|
|
483
|
-
const canvas = createElement('canvas');
|
|
569
|
+
await Promise.all([( new Promise(r => store.add(addDisposableListener(video, "loadedmetadata", () => r())))), ( new Promise(r => store.add(addDisposableListener(video, "canplaythrough", () => r()))))]);
|
|
570
|
+
const canvas = createElement("canvas");
|
|
484
571
|
canvas.width = video.videoWidth;
|
|
485
572
|
canvas.height = video.videoHeight;
|
|
486
|
-
const ctx = canvas.getContext(
|
|
573
|
+
const ctx = canvas.getContext("2d");
|
|
487
574
|
if (!ctx) {
|
|
488
575
|
return undefined;
|
|
489
576
|
}
|
|
490
577
|
ctx.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
491
|
-
const blob = await ( new Promise(
|
|
578
|
+
const blob = await ( new Promise(resolve => canvas.toBlob(blob => resolve(blob), "image/jpeg", 0.95)));
|
|
492
579
|
if (!blob) {
|
|
493
|
-
throw ( new Error(
|
|
580
|
+
throw ( new Error("Failed to create blob from canvas"));
|
|
494
581
|
}
|
|
495
582
|
const buf = await blob.bytes();
|
|
496
583
|
return VSBuffer.wrap(buf);
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
console.error('Error taking screenshot:', error);
|
|
584
|
+
} catch (error) {
|
|
585
|
+
console.error("Error taking screenshot:", error);
|
|
500
586
|
return undefined;
|
|
501
|
-
}
|
|
502
|
-
finally {
|
|
587
|
+
} finally {
|
|
503
588
|
store.dispose();
|
|
504
589
|
if (stream) {
|
|
505
590
|
for (const track of stream.getTracks()) {
|
|
@@ -515,27 +600,9 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
515
600
|
return undefined;
|
|
516
601
|
}
|
|
517
602
|
};
|
|
518
|
-
BrowserHostService.__decorator = ( __decorate([
|
|
519
|
-
|
|
520
|
-
], BrowserHostService.prototype, "
|
|
521
|
-
BrowserHostService
|
|
522
|
-
memoize
|
|
523
|
-
], BrowserHostService.prototype, "onDidChangeActiveWindow", null));
|
|
524
|
-
BrowserHostService.__decorator = ( __decorate([
|
|
525
|
-
memoize
|
|
526
|
-
], BrowserHostService.prototype, "onDidChangeFullScreen", null));
|
|
527
|
-
BrowserHostService = ( __decorate([
|
|
528
|
-
( __param(0, ILayoutService)),
|
|
529
|
-
( __param(1, IConfigurationService)),
|
|
530
|
-
( __param(2, IFileService)),
|
|
531
|
-
( __param(3, ILabelService)),
|
|
532
|
-
( __param(4, IBrowserWorkbenchEnvironmentService)),
|
|
533
|
-
( __param(5, IInstantiationService)),
|
|
534
|
-
( __param(6, ILifecycleService)),
|
|
535
|
-
( __param(7, ILogService)),
|
|
536
|
-
( __param(8, IDialogService)),
|
|
537
|
-
( __param(9, IWorkspaceContextService)),
|
|
538
|
-
( __param(10, IUserDataProfilesService))
|
|
539
|
-
], BrowserHostService));
|
|
603
|
+
BrowserHostService.__decorator = ( __decorate([memoize], BrowserHostService.prototype, "onDidChangeFocus", null));
|
|
604
|
+
BrowserHostService.__decorator = ( __decorate([memoize], BrowserHostService.prototype, "onDidChangeActiveWindow", null));
|
|
605
|
+
BrowserHostService.__decorator = ( __decorate([memoize], BrowserHostService.prototype, "onDidChangeFullScreen", null));
|
|
606
|
+
BrowserHostService = ( __decorate([( __param(0, ILayoutService)), ( __param(1, IConfigurationService)), ( __param(2, IFileService)), ( __param(3, ILabelService)), ( __param(4, IBrowserWorkbenchEnvironmentService)), ( __param(5, IInstantiationService)), ( __param(6, ILifecycleService)), ( __param(7, ILogService)), ( __param(8, IDialogService)), ( __param(9, IWorkspaceContextService)), ( __param(10, IUserDataProfilesService))], BrowserHostService));
|
|
540
607
|
|
|
541
608
|
export { BrowserHostService };
|
|
@@ -13,10 +13,10 @@ class BrowserHostColorSchemeService extends Disposable {
|
|
|
13
13
|
this.registerListeners();
|
|
14
14
|
}
|
|
15
15
|
registerListeners() {
|
|
16
|
-
addMatchMediaChangeListener(mainWindow,
|
|
16
|
+
addMatchMediaChangeListener(mainWindow, "(prefers-color-scheme: dark)", () => {
|
|
17
17
|
this._onDidSchemeChangeEvent.fire();
|
|
18
18
|
});
|
|
19
|
-
addMatchMediaChangeListener(mainWindow,
|
|
19
|
+
addMatchMediaChangeListener(mainWindow, "(forced-colors: active)", () => {
|
|
20
20
|
this._onDidSchemeChangeEvent.fire();
|
|
21
21
|
});
|
|
22
22
|
}
|
|
@@ -26,8 +26,7 @@ class BrowserHostColorSchemeService extends Disposable {
|
|
|
26
26
|
get dark() {
|
|
27
27
|
if (mainWindow.matchMedia(`(prefers-color-scheme: light)`).matches) {
|
|
28
28
|
return false;
|
|
29
|
-
}
|
|
30
|
-
else if (mainWindow.matchMedia(`(prefers-color-scheme: dark)`).matches) {
|
|
29
|
+
} else if (mainWindow.matchMedia(`(prefers-color-scheme: dark)`).matches) {
|
|
31
30
|
return true;
|
|
32
31
|
}
|
|
33
32
|
return false;
|