@codingame/monaco-vscode-host-service-override 26.2.2 → 27.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 +2 -2
- package/vscode/src/vs/workbench/services/host/browser/browserHostService.d.ts +6 -0
- package/vscode/src/vs/workbench/services/host/browser/browserHostService.js +22 -5
- package/vscode/src/vs/workbench/services/host/browser/toasts.d.ts +8 -0
- package/vscode/src/vs/workbench/services/host/browser/toasts.js +74 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-host-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "27.0.0",
|
|
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": "27.0.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
|
|
2
|
+
import { IToastOptions, IToastResult } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host";
|
|
2
3
|
import { IHostService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service";
|
|
3
4
|
import { ILayoutService } from "@codingame/monaco-vscode-api/vscode/vs/platform/layout/browser/layoutService.service";
|
|
4
5
|
import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
|
|
@@ -14,6 +15,7 @@ import { IDialogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/
|
|
|
14
15
|
import { IWorkspaceContextService } from "@codingame/monaco-vscode-api/vscode/vs/platform/workspace/common/workspace.service";
|
|
15
16
|
import { IUserDataProfilesService } from "@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service";
|
|
16
17
|
import { VSBuffer } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
|
|
18
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
17
19
|
export declare class BrowserHostService extends Disposable implements IHostService {
|
|
18
20
|
private readonly layoutService;
|
|
19
21
|
private readonly configurationService;
|
|
@@ -53,6 +55,7 @@ export declare class BrowserHostService extends Disposable implements IHostServi
|
|
|
53
55
|
private doOpen;
|
|
54
56
|
toggleFullScreen(targetWindow: Window): Promise<void>;
|
|
55
57
|
moveTop(targetWindow: Window): Promise<void>;
|
|
58
|
+
setWindowDimmed(_targetWindow: Window, _dimmed: boolean): Promise<void>;
|
|
56
59
|
getCursorScreenPoint(): Promise<undefined>;
|
|
57
60
|
getWindows(options: {
|
|
58
61
|
includeAuxiliaryWindows: true;
|
|
@@ -68,4 +71,7 @@ export declare class BrowserHostService extends Disposable implements IHostServi
|
|
|
68
71
|
getScreenshot(): Promise<VSBuffer | undefined>;
|
|
69
72
|
getBrowserId(): Promise<string | undefined>;
|
|
70
73
|
getNativeWindowHandle(_windowId: number): Promise<undefined>;
|
|
74
|
+
private readonly activeToasts;
|
|
75
|
+
showToast(options: IToastOptions, token: CancellationToken): Promise<IToastResult>;
|
|
76
|
+
private clearToasts;
|
|
71
77
|
}
|
|
@@ -13,7 +13,7 @@ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/fi
|
|
|
13
13
|
import { Verbosity } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label';
|
|
14
14
|
import { ILabelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/label/common/label.service';
|
|
15
15
|
import { ModifierKeyEmitter, onDidRegisterWindow, trackFocus, getActiveDocument, getWindowId, disposableWindowInterval, detectFullscreen, EventType, addDisposableListener, addDisposableThrottledListener, getActiveWindow, getWindows, createElement } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
16
|
-
import { Disposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
16
|
+
import { Disposable, DisposableSet, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
17
17
|
import { IBrowserWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/browser/environmentService.service';
|
|
18
18
|
import { memoize } from '@codingame/monaco-vscode-api/vscode/vs/base/common/decorators';
|
|
19
19
|
import { parseLineAndColumnAware } from '@codingame/monaco-vscode-api/vscode/vs/base/common/extpath';
|
|
@@ -36,6 +36,7 @@ import { isIOS, isMacintosh } from '@codingame/monaco-vscode-api/vscode/vs/base/
|
|
|
36
36
|
import { IUserDataProfilesService } from '@codingame/monaco-vscode-api/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
37
37
|
import { VSBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
|
|
38
38
|
import { MarkdownString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/htmlContent';
|
|
39
|
+
import { showBrowserToast } from './toasts.js';
|
|
39
40
|
|
|
40
41
|
var HostShutdownReason;
|
|
41
42
|
(function(HostShutdownReason) {
|
|
@@ -70,6 +71,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
70
71
|
this.contextService = contextService;
|
|
71
72
|
this.userDataProfilesService = userDataProfilesService;
|
|
72
73
|
this.shutdownReason = HostShutdownReason.Unknown;
|
|
74
|
+
this.activeToasts = this._register(( new DisposableSet()));
|
|
73
75
|
if (environmentService.options?.workspaceProvider) {
|
|
74
76
|
this.workspaceProvider = environmentService.options.workspaceProvider;
|
|
75
77
|
} else {
|
|
@@ -90,6 +92,11 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
90
92
|
this._register(
|
|
91
93
|
ModifierKeyEmitter.getInstance().event(() => this.updateShutdownReasonFromEvent())
|
|
92
94
|
);
|
|
95
|
+
this._register(this.onDidChangeFocus(focus => {
|
|
96
|
+
if (focus) {
|
|
97
|
+
this.clearToasts();
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
93
100
|
}
|
|
94
101
|
onBeforeShutdown(e) {
|
|
95
102
|
switch (this.shutdownReason) {
|
|
@@ -446,24 +453,24 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
446
453
|
await this.dialogService.prompt({
|
|
447
454
|
type: Severity.Warning,
|
|
448
455
|
message: workspace ? ( localize(
|
|
449
|
-
|
|
456
|
+
15620,
|
|
450
457
|
"The browser blocked opening a new tab or window for '{0}'. Press 'Retry' to try again.",
|
|
451
458
|
this.getRecentLabel(workspace)
|
|
452
459
|
)) : ( localize(
|
|
453
|
-
|
|
460
|
+
15621,
|
|
454
461
|
"The browser blocked opening a new tab or window. Press 'Retry' to try again."
|
|
455
462
|
)),
|
|
456
463
|
custom: {
|
|
457
464
|
markdownDetails: [{
|
|
458
465
|
markdown: ( new MarkdownString(( localize(
|
|
459
|
-
|
|
466
|
+
15622,
|
|
460
467
|
"Please allow pop-ups for this website in your [browser settings]({0}).",
|
|
461
468
|
"https://aka.ms/allow-vscode-popup"
|
|
462
469
|
)), true))
|
|
463
470
|
}]
|
|
464
471
|
},
|
|
465
472
|
buttons: [{
|
|
466
|
-
label: ( localize(
|
|
473
|
+
label: ( localize(15623, "&&Retry")),
|
|
467
474
|
run: () => this.workspaceProvider.open(workspace, options)
|
|
468
475
|
}],
|
|
469
476
|
cancelButton: true
|
|
@@ -502,6 +509,7 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
502
509
|
}
|
|
503
510
|
}
|
|
504
511
|
async moveTop(targetWindow) {}
|
|
512
|
+
async setWindowDimmed(_targetWindow, _dimmed) {}
|
|
505
513
|
async getCursorScreenPoint() {
|
|
506
514
|
return undefined;
|
|
507
515
|
}
|
|
@@ -599,6 +607,15 @@ let BrowserHostService = class BrowserHostService extends Disposable {
|
|
|
599
607
|
async getNativeWindowHandle(_windowId) {
|
|
600
608
|
return undefined;
|
|
601
609
|
}
|
|
610
|
+
async showToast(options, token) {
|
|
611
|
+
return showBrowserToast({
|
|
612
|
+
onDidCreateToast: disposable => this.activeToasts.add(disposable),
|
|
613
|
+
onDidDisposeToast: disposable => this.activeToasts.deleteAndDispose(disposable)
|
|
614
|
+
}, options, token);
|
|
615
|
+
}
|
|
616
|
+
async clearToasts() {
|
|
617
|
+
this.activeToasts.clearAndDisposeAll();
|
|
618
|
+
}
|
|
602
619
|
};
|
|
603
620
|
BrowserHostService.__decorator = ( __decorate([memoize], BrowserHostService.prototype, "onDidChangeFocus", null));
|
|
604
621
|
BrowserHostService.__decorator = ( __decorate([memoize], BrowserHostService.prototype, "onDidChangeActiveWindow", null));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
|
|
2
|
+
import { IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
|
|
3
|
+
import { IToastOptions, IToastResult } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host";
|
|
4
|
+
export interface IShowToastController {
|
|
5
|
+
onDidCreateToast: (toast: IDisposable) => void;
|
|
6
|
+
onDidDisposeToast: (toast: IDisposable) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function showBrowserToast(controller: IShowToastController, options: IToastOptions, token: CancellationToken): Promise<IToastResult>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
|
|
2
|
+
import { addDisposableListener } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
|
|
3
|
+
import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
|
|
4
|
+
import { Event, Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
|
|
5
|
+
import { DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
|
|
6
|
+
|
|
7
|
+
async function showBrowserToast(controller, options, token) {
|
|
8
|
+
const toast = await triggerBrowserToast(options.title, {
|
|
9
|
+
detail: options.body,
|
|
10
|
+
sticky: !options.silent
|
|
11
|
+
});
|
|
12
|
+
if (!toast) {
|
|
13
|
+
return {
|
|
14
|
+
supported: false,
|
|
15
|
+
clicked: false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const disposables = ( new DisposableStore());
|
|
19
|
+
controller.onDidCreateToast(toast);
|
|
20
|
+
const cts = ( new CancellationTokenSource(token));
|
|
21
|
+
disposables.add(toDisposable(() => {
|
|
22
|
+
controller.onDidDisposeToast(toast);
|
|
23
|
+
toast.dispose();
|
|
24
|
+
cts.dispose(true);
|
|
25
|
+
}));
|
|
26
|
+
return ( new Promise(r => {
|
|
27
|
+
const resolve = result => {
|
|
28
|
+
r(result);
|
|
29
|
+
disposables.dispose();
|
|
30
|
+
};
|
|
31
|
+
disposables.add(cts.token.onCancellationRequested(() => resolve({
|
|
32
|
+
supported: true,
|
|
33
|
+
clicked: false
|
|
34
|
+
})));
|
|
35
|
+
Event.once(toast.onClick)(() => resolve({
|
|
36
|
+
supported: true,
|
|
37
|
+
clicked: true
|
|
38
|
+
}));
|
|
39
|
+
Event.once(toast.onClose)(() => resolve({
|
|
40
|
+
supported: true,
|
|
41
|
+
clicked: false
|
|
42
|
+
}));
|
|
43
|
+
Event.once(toast.onError)(() => resolve({
|
|
44
|
+
supported: false,
|
|
45
|
+
clicked: false
|
|
46
|
+
}));
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
async function triggerBrowserToast(message, options) {
|
|
50
|
+
const permission = await Notification.requestPermission();
|
|
51
|
+
if (permission !== "granted") {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const disposables = ( new DisposableStore());
|
|
55
|
+
const notification = ( new Notification(message, {
|
|
56
|
+
body: options?.detail,
|
|
57
|
+
requireInteraction: options?.sticky
|
|
58
|
+
}));
|
|
59
|
+
const onClick = disposables.add(( new Emitter()));
|
|
60
|
+
const onClose = disposables.add(( new Emitter()));
|
|
61
|
+
const onError = disposables.add(( new Emitter()));
|
|
62
|
+
disposables.add(addDisposableListener(notification, "click", () => onClick.fire()));
|
|
63
|
+
disposables.add(addDisposableListener(notification, "close", () => onClose.fire()));
|
|
64
|
+
disposables.add(addDisposableListener(notification, "error", () => onError.fire()));
|
|
65
|
+
disposables.add(toDisposable(() => notification.close()));
|
|
66
|
+
return {
|
|
67
|
+
onClick: onClick.event,
|
|
68
|
+
onClose: onClose.event,
|
|
69
|
+
onError: onError.event,
|
|
70
|
+
dispose: () => disposables.dispose()
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { showBrowserToast };
|