@codingame/monaco-vscode-notifications-service-override 2.1.4 → 2.2.0-next.2

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.
@@ -1,220 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { IStatusbarService } from 'vscode/vscode/vs/workbench/services/statusbar/browser/statusbar';
3
- import { Disposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
4
- import { HIDE_NOTIFICATIONS_CENTER, SHOW_NOTIFICATIONS_CENTER } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
5
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
6
- import { NotificationsFilter, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
7
-
8
- let NotificationsStatus = class NotificationsStatus extends Disposable {
9
- constructor(model, statusbarService, notificationService) {
10
- super();
11
- this.model = model;
12
- this.statusbarService = statusbarService;
13
- this.notificationService = notificationService;
14
- this.newNotificationsCount = 0;
15
- this.isNotificationsCenterVisible = false;
16
- this.isNotificationsToastsVisible = false;
17
- this.updateNotificationsCenterStatusItem();
18
- if (model.statusMessage) {
19
- this.doSetStatusMessage(model.statusMessage);
20
- }
21
- this.registerListeners();
22
- }
23
- registerListeners() {
24
- this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
25
- this._register(this.model.onDidChangeStatusMessage(e => this.onDidChangeStatusMessage(e)));
26
- this._register(this.notificationService.onDidChangeFilter(() => this.updateNotificationsCenterStatusItem()));
27
- }
28
- onDidChangeNotification(e) {
29
- if (!this.isNotificationsCenterVisible) {
30
- if (e.kind === 0 ) {
31
- this.newNotificationsCount++;
32
- }
33
- else if (e.kind === 3 && this.newNotificationsCount > 0) {
34
- this.newNotificationsCount--;
35
- }
36
- }
37
- this.updateNotificationsCenterStatusItem();
38
- }
39
- updateNotificationsCenterStatusItem() {
40
- let notificationsInProgress = 0;
41
- if (!this.isNotificationsCenterVisible && !this.isNotificationsToastsVisible) {
42
- for (const notification of this.model.notifications) {
43
- if (notification.hasProgress) {
44
- notificationsInProgress++;
45
- }
46
- }
47
- }
48
- let statusProperties = {
49
- name: ( localizeWithPath(
50
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
51
- 'status.notifications',
52
- "Notifications"
53
- )),
54
- text: `${notificationsInProgress > 0 || this.newNotificationsCount > 0 ? '$(bell-dot)' : '$(bell)'}`,
55
- ariaLabel: ( localizeWithPath(
56
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
57
- 'status.notifications',
58
- "Notifications"
59
- )),
60
- command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER : SHOW_NOTIFICATIONS_CENTER,
61
- tooltip: this.getTooltip(notificationsInProgress),
62
- showBeak: this.isNotificationsCenterVisible
63
- };
64
- if (this.notificationService.getFilter() === NotificationsFilter.ERROR) {
65
- statusProperties = {
66
- ...statusProperties,
67
- text: `${notificationsInProgress > 0 || this.newNotificationsCount > 0 ? '$(bell-slash-dot)' : '$(bell-slash)'}`,
68
- ariaLabel: ( localizeWithPath(
69
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
70
- 'status.doNotDisturb',
71
- "Do Not Disturb"
72
- )),
73
- tooltip: ( localizeWithPath(
74
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
75
- 'status.doNotDisturbTooltip',
76
- "Do Not Disturb Mode is Enabled"
77
- ))
78
- };
79
- }
80
- if (!this.notificationsCenterStatusItem) {
81
- this.notificationsCenterStatusItem = this.statusbarService.addEntry(statusProperties, 'status.notifications', 1 , -Number.MAX_VALUE );
82
- }
83
- else {
84
- this.notificationsCenterStatusItem.update(statusProperties);
85
- }
86
- }
87
- getTooltip(notificationsInProgress) {
88
- if (this.isNotificationsCenterVisible) {
89
- return ( localizeWithPath(
90
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
91
- 'hideNotifications',
92
- "Hide Notifications"
93
- ));
94
- }
95
- if (this.model.notifications.length === 0) {
96
- return ( localizeWithPath(
97
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
98
- 'zeroNotifications',
99
- "No Notifications"
100
- ));
101
- }
102
- if (notificationsInProgress === 0) {
103
- if (this.newNotificationsCount === 0) {
104
- return ( localizeWithPath(
105
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
106
- 'noNotifications',
107
- "No New Notifications"
108
- ));
109
- }
110
- if (this.newNotificationsCount === 1) {
111
- return ( localizeWithPath(
112
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
113
- 'oneNotification',
114
- "1 New Notification"
115
- ));
116
- }
117
- return ( localizeWithPath(
118
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
119
- { key: 'notifications', comment: ['{0} will be replaced by a number'] },
120
- "{0} New Notifications",
121
- this.newNotificationsCount
122
- ));
123
- }
124
- if (this.newNotificationsCount === 0) {
125
- return ( localizeWithPath(
126
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
127
- { key: 'noNotificationsWithProgress', comment: ['{0} will be replaced by a number'] },
128
- "No New Notifications ({0} in progress)",
129
- notificationsInProgress
130
- ));
131
- }
132
- if (this.newNotificationsCount === 1) {
133
- return ( localizeWithPath(
134
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
135
- { key: 'oneNotificationWithProgress', comment: ['{0} will be replaced by a number'] },
136
- "1 New Notification ({0} in progress)",
137
- notificationsInProgress
138
- ));
139
- }
140
- return ( localizeWithPath(
141
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
142
- { key: 'notificationsWithProgress', comment: ['{0} and {1} will be replaced by a number'] },
143
- "{0} New Notifications ({1} in progress)",
144
- this.newNotificationsCount,
145
- notificationsInProgress
146
- ));
147
- }
148
- update(isCenterVisible, isToastsVisible) {
149
- let updateNotificationsCenterStatusItem = false;
150
- if (this.isNotificationsCenterVisible !== isCenterVisible) {
151
- this.isNotificationsCenterVisible = isCenterVisible;
152
- this.newNotificationsCount = 0;
153
- updateNotificationsCenterStatusItem = true;
154
- }
155
- if (this.isNotificationsToastsVisible !== isToastsVisible) {
156
- this.isNotificationsToastsVisible = isToastsVisible;
157
- updateNotificationsCenterStatusItem = true;
158
- }
159
- if (updateNotificationsCenterStatusItem) {
160
- this.updateNotificationsCenterStatusItem();
161
- }
162
- }
163
- onDidChangeStatusMessage(e) {
164
- const statusItem = e.item;
165
- switch (e.kind) {
166
- case 0 :
167
- this.doSetStatusMessage(statusItem);
168
- break;
169
- case 1 :
170
- if (this.currentStatusMessage && this.currentStatusMessage[0] === statusItem) {
171
- dispose(this.currentStatusMessage[1]);
172
- this.currentStatusMessage = undefined;
173
- }
174
- break;
175
- }
176
- }
177
- doSetStatusMessage(item) {
178
- const message = item.message;
179
- const showAfter = item.options && typeof item.options.showAfter === 'number' ? item.options.showAfter : 0;
180
- const hideAfter = item.options && typeof item.options.hideAfter === 'number' ? item.options.hideAfter : -1;
181
- if (this.currentStatusMessage) {
182
- dispose(this.currentStatusMessage[1]);
183
- }
184
- let statusMessageEntry;
185
- let showHandle = setTimeout(() => {
186
- statusMessageEntry = this.statusbarService.addEntry({
187
- name: ( localizeWithPath(
188
- 'vs/workbench/browser/parts/notifications/notificationsStatus',
189
- 'status.message',
190
- "Status Message"
191
- )),
192
- text: message,
193
- ariaLabel: message
194
- }, 'status.message', 0 , -Number.MAX_VALUE );
195
- showHandle = null;
196
- }, showAfter);
197
- let hideHandle;
198
- const statusMessageDispose = {
199
- dispose: () => {
200
- if (showHandle) {
201
- clearTimeout(showHandle);
202
- }
203
- if (hideHandle) {
204
- clearTimeout(hideHandle);
205
- }
206
- statusMessageEntry?.dispose();
207
- }
208
- };
209
- if (hideAfter > 0) {
210
- hideHandle = setTimeout(() => statusMessageDispose.dispose(), hideAfter);
211
- }
212
- this.currentStatusMessage = [item, statusMessageDispose];
213
- }
214
- };
215
- NotificationsStatus = ( __decorate([
216
- ( __param(1, IStatusbarService)),
217
- ( __param(2, INotificationService))
218
- ], NotificationsStatus));
219
-
220
- export { NotificationsStatus };
@@ -1,435 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import './media/notificationsToasts.css.js';
3
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
4
- import { DisposableStore, toDisposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
5
- import { Dimension, scheduleAtNextAnimationFrame, getWindow, addDisposableListener, EventType, isAncestorOfActiveElement } from 'vscode/vscode/vs/base/browser/dom';
6
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
- import { NotificationsList } from './notificationsList.js';
8
- import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
9
- import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
10
- import { NOTIFICATIONS_BACKGROUND, NOTIFICATIONS_TOAST_BORDER } from 'vscode/vscode/vs/workbench/common/theme';
11
- import { Themable, IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
12
- import { widgetShadow } from 'vscode/vscode/vs/platform/theme/common/colorRegistry';
13
- import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
14
- import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
15
- import { Severity, NotificationsFilter, NotificationPriority } from 'vscode/vscode/vs/platform/notification/common/notification';
16
- import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
17
- import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
18
- import { IntervalCounter } from 'vscode/vscode/vs/base/common/async';
19
- import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
20
- import { NotificationsToastsVisibleContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
21
- import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
22
-
23
- var NotificationsToasts_1;
24
- var ToastVisibility;
25
- ( (function(ToastVisibility) {
26
- ToastVisibility[ToastVisibility["HIDDEN_OR_VISIBLE"] = 0] = "HIDDEN_OR_VISIBLE";
27
- ToastVisibility[ToastVisibility["HIDDEN"] = 1] = "HIDDEN";
28
- ToastVisibility[ToastVisibility["VISIBLE"] = 2] = "VISIBLE";
29
- })(ToastVisibility || (ToastVisibility = {})));
30
- let NotificationsToasts = class NotificationsToasts extends Themable {
31
- static { NotificationsToasts_1 = this; }
32
- static { this.MAX_WIDTH = 450; }
33
- static { this.MAX_NOTIFICATIONS = 3; }
34
- static { this.PURGE_TIMEOUT = {
35
- [Severity.Info]: 15000,
36
- [Severity.Warning]: 18000,
37
- [Severity.Error]: 20000
38
- }; }
39
- static { this.SPAM_PROTECTION = {
40
- interval: 800,
41
- limit: NotificationsToasts_1.MAX_NOTIFICATIONS
42
- }; }
43
- get isVisible() { return !!this._isVisible; }
44
- constructor(container, model, instantiationService, layoutService, themeService, editorGroupService, contextKeyService, lifecycleService, hostService) {
45
- super(themeService);
46
- this.container = container;
47
- this.model = model;
48
- this.instantiationService = instantiationService;
49
- this.layoutService = layoutService;
50
- this.editorGroupService = editorGroupService;
51
- this.contextKeyService = contextKeyService;
52
- this.lifecycleService = lifecycleService;
53
- this.hostService = hostService;
54
- this._onDidChangeVisibility = this._register(( new Emitter()));
55
- this.onDidChangeVisibility = this._onDidChangeVisibility.event;
56
- this._isVisible = false;
57
- this.mapNotificationToToast = ( new Map());
58
- this.mapNotificationToDisposable = ( new Map());
59
- this.notificationsToastsVisibleContextKey = NotificationsToastsVisibleContext.bindTo(this.contextKeyService);
60
- this.addedToastsIntervalCounter = ( new IntervalCounter(NotificationsToasts_1.SPAM_PROTECTION.interval));
61
- this.registerListeners();
62
- }
63
- registerListeners() {
64
- this._register(this.layoutService.onDidLayoutMainContainer(dimension => this.layout(Dimension.lift(dimension))));
65
- this.lifecycleService.when(3 ).then(() => {
66
- this.model.notifications.forEach(notification => this.addToast(notification));
67
- this._register(this.model.onDidChangeNotification(e => this.onDidChangeNotification(e)));
68
- });
69
- this._register(this.model.onDidChangeFilter(({ global, sources }) => {
70
- if (global === NotificationsFilter.ERROR) {
71
- this.hide();
72
- }
73
- else if (sources) {
74
- for (const [notification] of this.mapNotificationToToast) {
75
- if (typeof notification.sourceId === 'string' && sources.get(notification.sourceId) === NotificationsFilter.ERROR && notification.severity !== Severity.Error && notification.priority !== NotificationPriority.URGENT) {
76
- this.removeToast(notification);
77
- }
78
- }
79
- }
80
- }));
81
- }
82
- onDidChangeNotification(e) {
83
- switch (e.kind) {
84
- case 0 :
85
- return this.addToast(e.item);
86
- case 3 :
87
- return this.removeToast(e.item);
88
- }
89
- }
90
- addToast(item) {
91
- if (this.isNotificationsCenterVisible) {
92
- return;
93
- }
94
- if (item.priority === NotificationPriority.SILENT) {
95
- return;
96
- }
97
- if (this.addedToastsIntervalCounter.increment() > NotificationsToasts_1.SPAM_PROTECTION.limit) {
98
- return;
99
- }
100
- const itemDisposables = ( new DisposableStore());
101
- this.mapNotificationToDisposable.set(item, itemDisposables);
102
- itemDisposables.add(scheduleAtNextAnimationFrame(getWindow(this.container), () => this.doAddToast(item, itemDisposables)));
103
- }
104
- doAddToast(item, itemDisposables) {
105
- let notificationsToastsContainer = this.notificationsToastsContainer;
106
- if (!notificationsToastsContainer) {
107
- notificationsToastsContainer = this.notificationsToastsContainer = document.createElement('div');
108
- notificationsToastsContainer.classList.add('notifications-toasts');
109
- this.container.appendChild(notificationsToastsContainer);
110
- }
111
- notificationsToastsContainer.classList.add('visible');
112
- const notificationToastContainer = document.createElement('div');
113
- notificationToastContainer.classList.add('notification-toast-container');
114
- const firstToast = notificationsToastsContainer.firstChild;
115
- if (firstToast) {
116
- notificationsToastsContainer.insertBefore(notificationToastContainer, firstToast);
117
- }
118
- else {
119
- notificationsToastsContainer.appendChild(notificationToastContainer);
120
- }
121
- const notificationToast = document.createElement('div');
122
- notificationToast.classList.add('notification-toast');
123
- notificationToastContainer.appendChild(notificationToast);
124
- const notificationList = this.instantiationService.createInstance(NotificationsList, notificationToast, {
125
- verticalScrollMode: 2 ,
126
- widgetAriaLabel: (() => {
127
- if (!item.source) {
128
- return ( localizeWithPath(
129
- 'vs/workbench/browser/parts/notifications/notificationsToasts',
130
- 'notificationAriaLabel',
131
- "{0}, notification",
132
- item.message.raw
133
- ));
134
- }
135
- return ( localizeWithPath(
136
- 'vs/workbench/browser/parts/notifications/notificationsToasts',
137
- 'notificationWithSourceAriaLabel',
138
- "{0}, source: {1}, notification",
139
- item.message.raw,
140
- item.source
141
- ));
142
- })()
143
- });
144
- itemDisposables.add(notificationList);
145
- const toast = { item, list: notificationList, container: notificationToastContainer, toast: notificationToast };
146
- this.mapNotificationToToast.set(item, toast);
147
- itemDisposables.add(toDisposable(() => this.updateToastVisibility(toast, false)));
148
- notificationList.show();
149
- const maxDimensions = this.computeMaxDimensions();
150
- this.layoutLists(maxDimensions.width);
151
- notificationList.updateNotificationsList(0, 0, [item]);
152
- this.layoutContainer(maxDimensions.height);
153
- itemDisposables.add(item.onDidChangeExpansion(() => {
154
- notificationList.updateNotificationsList(0, 1, [item]);
155
- }));
156
- itemDisposables.add(item.onDidChangeContent(e => {
157
- switch (e.kind) {
158
- case 2 :
159
- notificationList.updateNotificationsList(0, 1, [item]);
160
- break;
161
- case 1 :
162
- if (item.expanded) {
163
- notificationList.updateNotificationHeight(item);
164
- }
165
- break;
166
- }
167
- }));
168
- Event.once(item.onDidClose)(() => {
169
- this.removeToast(item);
170
- });
171
- this.purgeNotification(item, notificationToastContainer, notificationList, itemDisposables);
172
- this.updateStyles();
173
- this.notificationsToastsVisibleContextKey.set(true);
174
- notificationToast.classList.add('notification-fade-in');
175
- itemDisposables.add(addDisposableListener(notificationToast, 'transitionend', () => {
176
- notificationToast.classList.remove('notification-fade-in');
177
- notificationToast.classList.add('notification-fade-in-done');
178
- }));
179
- item.updateVisibility(true);
180
- if (!this._isVisible) {
181
- this._isVisible = true;
182
- this._onDidChangeVisibility.fire();
183
- }
184
- }
185
- purgeNotification(item, notificationToastContainer, notificationList, disposables) {
186
- let isMouseOverToast = false;
187
- disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OVER, () => isMouseOverToast = true));
188
- disposables.add(addDisposableListener(notificationToastContainer, EventType.MOUSE_OUT, () => isMouseOverToast = false));
189
- let purgeTimeoutHandle;
190
- let listener;
191
- const hideAfterTimeout = () => {
192
- purgeTimeoutHandle = setTimeout(() => {
193
- if (!this.hostService.hasFocus) {
194
- if (!listener) {
195
- listener = this.hostService.onDidChangeFocus(focus => {
196
- if (focus) {
197
- hideAfterTimeout();
198
- }
199
- });
200
- disposables.add(listener);
201
- }
202
- }
203
- else if (item.sticky ||
204
- notificationList.hasFocus() ||
205
- isMouseOverToast
206
- ) {
207
- hideAfterTimeout();
208
- }
209
- else {
210
- this.removeToast(item);
211
- }
212
- }, NotificationsToasts_1.PURGE_TIMEOUT[item.severity]);
213
- };
214
- hideAfterTimeout();
215
- disposables.add(toDisposable(() => clearTimeout(purgeTimeoutHandle)));
216
- }
217
- removeToast(item) {
218
- let focusEditor = false;
219
- const notificationToast = this.mapNotificationToToast.get(item);
220
- if (notificationToast) {
221
- const toastHasDOMFocus = isAncestorOfActiveElement(notificationToast.container);
222
- if (toastHasDOMFocus) {
223
- focusEditor = !(this.focusNext() || this.focusPrevious());
224
- }
225
- this.mapNotificationToToast.delete(item);
226
- }
227
- const notificationDisposables = this.mapNotificationToDisposable.get(item);
228
- if (notificationDisposables) {
229
- dispose(notificationDisposables);
230
- this.mapNotificationToDisposable.delete(item);
231
- }
232
- if (this.mapNotificationToToast.size > 0) {
233
- this.layout(this.workbenchDimensions);
234
- }
235
- else {
236
- this.doHide();
237
- if (focusEditor) {
238
- this.editorGroupService.activeGroup.focus();
239
- }
240
- }
241
- }
242
- removeToasts() {
243
- this.mapNotificationToToast.clear();
244
- this.mapNotificationToDisposable.forEach(disposable => dispose(disposable));
245
- this.mapNotificationToDisposable.clear();
246
- this.doHide();
247
- }
248
- doHide() {
249
- this.notificationsToastsContainer?.classList.remove('visible');
250
- this.notificationsToastsVisibleContextKey.set(false);
251
- if (this._isVisible) {
252
- this._isVisible = false;
253
- this._onDidChangeVisibility.fire();
254
- }
255
- }
256
- hide() {
257
- const focusEditor = this.notificationsToastsContainer ? isAncestorOfActiveElement(this.notificationsToastsContainer) : false;
258
- this.removeToasts();
259
- if (focusEditor) {
260
- this.editorGroupService.activeGroup.focus();
261
- }
262
- }
263
- focus() {
264
- const toasts = this.getToasts(ToastVisibility.VISIBLE);
265
- if (toasts.length > 0) {
266
- toasts[0].list.focusFirst();
267
- return true;
268
- }
269
- return false;
270
- }
271
- focusNext() {
272
- const toasts = this.getToasts(ToastVisibility.VISIBLE);
273
- for (let i = 0; i < toasts.length; i++) {
274
- const toast = toasts[i];
275
- if (toast.list.hasFocus()) {
276
- const nextToast = toasts[i + 1];
277
- if (nextToast) {
278
- nextToast.list.focusFirst();
279
- return true;
280
- }
281
- break;
282
- }
283
- }
284
- return false;
285
- }
286
- focusPrevious() {
287
- const toasts = this.getToasts(ToastVisibility.VISIBLE);
288
- for (let i = 0; i < toasts.length; i++) {
289
- const toast = toasts[i];
290
- if (toast.list.hasFocus()) {
291
- const previousToast = toasts[i - 1];
292
- if (previousToast) {
293
- previousToast.list.focusFirst();
294
- return true;
295
- }
296
- break;
297
- }
298
- }
299
- return false;
300
- }
301
- focusFirst() {
302
- const toast = this.getToasts(ToastVisibility.VISIBLE)[0];
303
- if (toast) {
304
- toast.list.focusFirst();
305
- return true;
306
- }
307
- return false;
308
- }
309
- focusLast() {
310
- const toasts = this.getToasts(ToastVisibility.VISIBLE);
311
- if (toasts.length > 0) {
312
- toasts[toasts.length - 1].list.focusFirst();
313
- return true;
314
- }
315
- return false;
316
- }
317
- update(isCenterVisible) {
318
- if (this.isNotificationsCenterVisible !== isCenterVisible) {
319
- this.isNotificationsCenterVisible = isCenterVisible;
320
- if (this.isNotificationsCenterVisible) {
321
- this.removeToasts();
322
- }
323
- }
324
- }
325
- updateStyles() {
326
- this.mapNotificationToToast.forEach(({ toast }) => {
327
- const backgroundColor = this.getColor(NOTIFICATIONS_BACKGROUND);
328
- toast.style.background = backgroundColor ? backgroundColor : '';
329
- const widgetShadowColor = this.getColor(widgetShadow);
330
- toast.style.boxShadow = widgetShadowColor ? `0 0 8px 2px ${widgetShadowColor}` : '';
331
- const borderColor = this.getColor(NOTIFICATIONS_TOAST_BORDER);
332
- toast.style.border = borderColor ? `1px solid ${borderColor}` : '';
333
- });
334
- }
335
- getToasts(state) {
336
- const notificationToasts = [];
337
- this.mapNotificationToToast.forEach(toast => {
338
- switch (state) {
339
- case ToastVisibility.HIDDEN_OR_VISIBLE:
340
- notificationToasts.push(toast);
341
- break;
342
- case ToastVisibility.HIDDEN:
343
- if (!this.isToastInDOM(toast)) {
344
- notificationToasts.push(toast);
345
- }
346
- break;
347
- case ToastVisibility.VISIBLE:
348
- if (this.isToastInDOM(toast)) {
349
- notificationToasts.push(toast);
350
- }
351
- break;
352
- }
353
- });
354
- return notificationToasts.reverse();
355
- }
356
- layout(dimension) {
357
- this.workbenchDimensions = dimension;
358
- const maxDimensions = this.computeMaxDimensions();
359
- if (maxDimensions.height) {
360
- this.layoutContainer(maxDimensions.height);
361
- }
362
- this.layoutLists(maxDimensions.width);
363
- }
364
- computeMaxDimensions() {
365
- const maxWidth = NotificationsToasts_1.MAX_WIDTH;
366
- let availableWidth = maxWidth;
367
- let availableHeight;
368
- if (this.workbenchDimensions) {
369
- availableWidth = this.workbenchDimensions.width;
370
- availableWidth -= (2 * 8);
371
- availableHeight = this.workbenchDimensions.height;
372
- if (this.layoutService.isVisible("workbench.parts.statusbar" , mainWindow)) {
373
- availableHeight -= 22;
374
- }
375
- if (this.layoutService.isVisible("workbench.parts.titlebar" , mainWindow)) {
376
- availableHeight -= 22;
377
- }
378
- availableHeight -= (2 * 12);
379
- }
380
- availableHeight = typeof availableHeight === 'number'
381
- ? Math.round(availableHeight * 0.618)
382
- : 0;
383
- return ( new Dimension(Math.min(maxWidth, availableWidth), availableHeight));
384
- }
385
- layoutLists(width) {
386
- this.mapNotificationToToast.forEach(({ list }) => list.layout(width));
387
- }
388
- layoutContainer(heightToGive) {
389
- let visibleToasts = 0;
390
- for (const toast of this.getToasts(ToastVisibility.HIDDEN_OR_VISIBLE)) {
391
- toast.container.style.opacity = '0';
392
- this.updateToastVisibility(toast, true);
393
- heightToGive -= toast.container.offsetHeight;
394
- let makeVisible = false;
395
- if (visibleToasts === NotificationsToasts_1.MAX_NOTIFICATIONS) {
396
- makeVisible = false;
397
- }
398
- else if (heightToGive >= 0) {
399
- makeVisible = true;
400
- }
401
- this.updateToastVisibility(toast, makeVisible);
402
- toast.container.style.opacity = '';
403
- if (makeVisible) {
404
- visibleToasts++;
405
- }
406
- }
407
- }
408
- updateToastVisibility(toast, visible) {
409
- if (this.isToastInDOM(toast) === visible) {
410
- return;
411
- }
412
- const notificationsToastsContainer = assertIsDefined(this.notificationsToastsContainer);
413
- if (visible) {
414
- notificationsToastsContainer.appendChild(toast.container);
415
- }
416
- else {
417
- notificationsToastsContainer.removeChild(toast.container);
418
- }
419
- toast.item.updateVisibility(visible);
420
- }
421
- isToastInDOM(toast) {
422
- return !!toast.container.parentElement;
423
- }
424
- };
425
- NotificationsToasts = NotificationsToasts_1 = ( __decorate([
426
- ( __param(2, IInstantiationService)),
427
- ( __param(3, IWorkbenchLayoutService)),
428
- ( __param(4, IThemeService)),
429
- ( __param(5, IEditorGroupsService)),
430
- ( __param(6, IContextKeyService)),
431
- ( __param(7, ILifecycleService)),
432
- ( __param(8, IHostService))
433
- ], NotificationsToasts));
434
-
435
- export { NotificationsToasts };