@codingame/monaco-vscode-notifications-service-override 1.85.0 → 1.85.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.
package/notifications.js CHANGED
@@ -9,6 +9,7 @@ import { NotificationsCenter } from './vscode/src/vs/workbench/browser/parts/not
9
9
  import { NotificationsAlerts } from './vscode/src/vs/workbench/browser/parts/notifications/notificationsAlerts.js';
10
10
  import { NotificationsTelemetry } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsTelemetry';
11
11
  import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
12
+ import { NotificationsStatus } from './vscode/src/vs/workbench/browser/parts/notifications/notificationsStatus.js';
12
13
  import getServiceOverride$1 from '@codingame/monaco-vscode-layout-service-override';
13
14
  import { onRenderWorkbench } from 'vscode/lifecycle';
14
15
 
@@ -20,7 +21,15 @@ onRenderWorkbench(async (accessor) => {
20
21
  const notificationsCenter = instantiationService.createInstance(NotificationsCenter, container, model);
21
22
  const notificationsToasts = instantiationService.createInstance(NotificationsToasts, container, model);
22
23
  instantiationService.createInstance(NotificationsAlerts, model);
24
+ const notificationsStatus = instantiationService.createInstance(NotificationsStatus, model);
23
25
  instantiationService.createInstance(NotificationsTelemetry);
26
+ notificationsCenter.onDidChangeVisibility(() => {
27
+ notificationsStatus.update(notificationsCenter.isVisible, notificationsToasts.isVisible);
28
+ notificationsToasts.update(notificationsCenter.isVisible);
29
+ });
30
+ notificationsToasts.onDidChangeVisibility(() => {
31
+ notificationsStatus.update(notificationsCenter.isVisible, notificationsToasts.isVisible);
32
+ });
24
33
  registerNotificationCommands(notificationsCenter, notificationsToasts, model);
25
34
  notificationsToasts.layout(dom.getClientArea(container));
26
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-notifications-service-override",
3
- "version": "1.85.0",
3
+ "version": "1.85.2",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,8 +18,8 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@1.85.0",
21
+ "vscode": "npm:@codingame/monaco-vscode-api@1.85.2",
22
22
  "monaco-editor": "0.45.0",
23
- "@codingame/monaco-vscode-layout-service-override": "1.85.0"
23
+ "@codingame/monaco-vscode-layout-service-override": "1.85.2"
24
24
  }
25
25
  }
@@ -0,0 +1,220 @@
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 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { HIDE_NOTIFICATIONS_CENTER, SHOW_NOTIFICATIONS_CENTER } from 'vscode/vscode/vs/workbench/browser/parts/notifications/notificationsCommands';
5
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
6
+ import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
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.onDidChangeDoNotDisturbMode(() => 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.doNotDisturbMode) {
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 };