@codingame/monaco-vscode-notifications-service-override 25.1.2 → 26.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codingame/monaco-vscode-notifications-service-override",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "VSCode public API plugged on the monaco editor - notifications 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.0"
|
|
19
19
|
},
|
|
20
20
|
"main": "index.js",
|
|
21
21
|
"module": "index.js",
|
|
@@ -14,7 +14,9 @@ import Severity from '@codingame/monaco-vscode-api/vscode/vs/base/common/severit
|
|
|
14
14
|
|
|
15
15
|
var NotificationService_1;
|
|
16
16
|
let NotificationService = class NotificationService extends Disposable {
|
|
17
|
-
static {
|
|
17
|
+
static {
|
|
18
|
+
NotificationService_1 = this;
|
|
19
|
+
}
|
|
18
20
|
constructor(storageService) {
|
|
19
21
|
super();
|
|
20
22
|
this.storageService = storageService;
|
|
@@ -23,25 +25,39 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
23
25
|
this.onDidChangeFilter = this._onDidChangeFilter.event;
|
|
24
26
|
this.mapSourceToFilter = (() => {
|
|
25
27
|
const map = ( new Map());
|
|
26
|
-
for (const sourceFilter of this.storageService.getObject(
|
|
28
|
+
for (const sourceFilter of this.storageService.getObject(
|
|
29
|
+
NotificationService_1.PER_SOURCE_FILTER_SETTINGS_KEY,
|
|
30
|
+
StorageScope.APPLICATION,
|
|
31
|
+
[]
|
|
32
|
+
)) {
|
|
27
33
|
map.set(sourceFilter.id, sourceFilter);
|
|
28
34
|
}
|
|
29
35
|
return map;
|
|
30
36
|
})();
|
|
31
|
-
this.globalFilterEnabled = this.storageService.getBoolean(
|
|
37
|
+
this.globalFilterEnabled = this.storageService.getBoolean(
|
|
38
|
+
NotificationService_1.GLOBAL_FILTER_SETTINGS_KEY,
|
|
39
|
+
StorageScope.APPLICATION,
|
|
40
|
+
false
|
|
41
|
+
);
|
|
32
42
|
this.updateFilters();
|
|
33
43
|
this.registerListeners();
|
|
34
44
|
}
|
|
35
45
|
registerListeners() {
|
|
36
46
|
this._register(this.model.onDidChangeNotification(e => {
|
|
37
47
|
switch (e.kind) {
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
case NotificationChangeType.ADD:
|
|
49
|
+
{
|
|
50
|
+
const source = typeof e.item.sourceId === "string" && typeof e.item.source === "string" ? {
|
|
51
|
+
id: e.item.sourceId,
|
|
52
|
+
label: e.item.source
|
|
53
|
+
} : e.item.source;
|
|
40
54
|
if (isNotificationSource(source)) {
|
|
41
55
|
if (!( this.mapSourceToFilter.has(source.id))) {
|
|
42
|
-
this.setFilter({
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
this.setFilter({
|
|
57
|
+
...source,
|
|
58
|
+
filter: NotificationsFilter.OFF
|
|
59
|
+
});
|
|
60
|
+
} else {
|
|
45
61
|
this.updateSourceFilter(source);
|
|
46
62
|
}
|
|
47
63
|
}
|
|
@@ -50,24 +66,36 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
50
66
|
}
|
|
51
67
|
}));
|
|
52
68
|
}
|
|
53
|
-
static {
|
|
54
|
-
|
|
69
|
+
static {
|
|
70
|
+
this.GLOBAL_FILTER_SETTINGS_KEY = "notifications.doNotDisturbMode";
|
|
71
|
+
}
|
|
72
|
+
static {
|
|
73
|
+
this.PER_SOURCE_FILTER_SETTINGS_KEY = "notifications.perSourceDoNotDisturbMode";
|
|
74
|
+
}
|
|
55
75
|
setFilter(filter) {
|
|
56
|
-
if (typeof filter ===
|
|
76
|
+
if (typeof filter === "number") {
|
|
57
77
|
if (this.globalFilterEnabled === (filter === NotificationsFilter.ERROR)) {
|
|
58
78
|
return;
|
|
59
79
|
}
|
|
60
80
|
this.globalFilterEnabled = filter === NotificationsFilter.ERROR;
|
|
61
|
-
this.storageService.store(
|
|
81
|
+
this.storageService.store(
|
|
82
|
+
NotificationService_1.GLOBAL_FILTER_SETTINGS_KEY,
|
|
83
|
+
this.globalFilterEnabled,
|
|
84
|
+
StorageScope.APPLICATION,
|
|
85
|
+
StorageTarget.MACHINE
|
|
86
|
+
);
|
|
62
87
|
this.updateFilters();
|
|
63
88
|
this._onDidChangeFilter.fire();
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
89
|
+
} else {
|
|
66
90
|
const existing = this.mapSourceToFilter.get(filter.id);
|
|
67
91
|
if (existing?.filter === filter.filter && existing.label === filter.label) {
|
|
68
92
|
return;
|
|
69
93
|
}
|
|
70
|
-
this.mapSourceToFilter.set(filter.id, {
|
|
94
|
+
this.mapSourceToFilter.set(filter.id, {
|
|
95
|
+
id: filter.id,
|
|
96
|
+
label: filter.label,
|
|
97
|
+
filter: filter.filter
|
|
98
|
+
});
|
|
71
99
|
this.saveSourceFilters();
|
|
72
100
|
this.updateFilters();
|
|
73
101
|
}
|
|
@@ -84,12 +112,21 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
84
112
|
return;
|
|
85
113
|
}
|
|
86
114
|
if (existing.label !== source.label) {
|
|
87
|
-
this.mapSourceToFilter.set(source.id, {
|
|
115
|
+
this.mapSourceToFilter.set(source.id, {
|
|
116
|
+
id: source.id,
|
|
117
|
+
label: source.label,
|
|
118
|
+
filter: existing.filter
|
|
119
|
+
});
|
|
88
120
|
this.saveSourceFilters();
|
|
89
121
|
}
|
|
90
122
|
}
|
|
91
123
|
saveSourceFilters() {
|
|
92
|
-
this.storageService.store(
|
|
124
|
+
this.storageService.store(
|
|
125
|
+
NotificationService_1.PER_SOURCE_FILTER_SETTINGS_KEY,
|
|
126
|
+
JSON.stringify([...( this.mapSourceToFilter.values())]),
|
|
127
|
+
StorageScope.APPLICATION,
|
|
128
|
+
StorageTarget.MACHINE
|
|
129
|
+
);
|
|
93
130
|
}
|
|
94
131
|
getFilters() {
|
|
95
132
|
return [...( this.mapSourceToFilter.values())];
|
|
@@ -113,7 +150,10 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
113
150
|
}
|
|
114
151
|
return;
|
|
115
152
|
}
|
|
116
|
-
this.model.addNotification({
|
|
153
|
+
this.model.addNotification({
|
|
154
|
+
severity: Severity.Info,
|
|
155
|
+
message
|
|
156
|
+
});
|
|
117
157
|
}
|
|
118
158
|
warn(message) {
|
|
119
159
|
if (Array.isArray(message)) {
|
|
@@ -122,7 +162,10 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
122
162
|
}
|
|
123
163
|
return;
|
|
124
164
|
}
|
|
125
|
-
this.model.addNotification({
|
|
165
|
+
this.model.addNotification({
|
|
166
|
+
severity: Severity.Warning,
|
|
167
|
+
message
|
|
168
|
+
});
|
|
126
169
|
}
|
|
127
170
|
error(message) {
|
|
128
171
|
if (Array.isArray(message)) {
|
|
@@ -131,7 +174,10 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
131
174
|
}
|
|
132
175
|
return;
|
|
133
176
|
}
|
|
134
|
-
this.model.addNotification({
|
|
177
|
+
this.model.addNotification({
|
|
178
|
+
severity: Severity.Error,
|
|
179
|
+
message
|
|
180
|
+
});
|
|
135
181
|
}
|
|
136
182
|
notify(notification) {
|
|
137
183
|
const toDispose = ( new DisposableStore());
|
|
@@ -141,7 +187,7 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
141
187
|
if (this.storageService.getBoolean(id, scope)) {
|
|
142
188
|
return ( new NoOpNotification());
|
|
143
189
|
}
|
|
144
|
-
const neverShowAgainAction = toDispose.add(( new Action(
|
|
190
|
+
const neverShowAgainAction = toDispose.add(( new Action("workbench.notification.neverShowAgain", ( localize(14580, "Don't Show Again")), undefined, true, async () => {
|
|
145
191
|
handle.close();
|
|
146
192
|
this.storageService.store(id, true, scope, StorageTarget.USER);
|
|
147
193
|
})));
|
|
@@ -151,8 +197,7 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
151
197
|
};
|
|
152
198
|
if (!notification.neverShowAgain.isSecondary) {
|
|
153
199
|
actions.primary = [neverShowAgainAction, ...actions.primary];
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
200
|
+
} else {
|
|
156
201
|
actions.secondary = [...actions.secondary, neverShowAgainAction];
|
|
157
202
|
}
|
|
158
203
|
notification.actions = actions;
|
|
@@ -163,14 +208,14 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
163
208
|
}
|
|
164
209
|
toStorageScope(options) {
|
|
165
210
|
switch (options.scope) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
211
|
+
case NeverShowAgainScope.APPLICATION:
|
|
212
|
+
return StorageScope.APPLICATION;
|
|
213
|
+
case NeverShowAgainScope.PROFILE:
|
|
214
|
+
return StorageScope.PROFILE;
|
|
215
|
+
case NeverShowAgainScope.WORKSPACE:
|
|
216
|
+
return StorageScope.WORKSPACE;
|
|
217
|
+
default:
|
|
218
|
+
return StorageScope.APPLICATION;
|
|
174
219
|
}
|
|
175
220
|
}
|
|
176
221
|
prompt(severity, message, choices, options) {
|
|
@@ -181,14 +226,13 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
181
226
|
return ( new NoOpNotification());
|
|
182
227
|
}
|
|
183
228
|
const neverShowAgainChoice = {
|
|
184
|
-
label: ( localize(
|
|
229
|
+
label: ( localize(14580, "Don't Show Again")),
|
|
185
230
|
run: () => this.storageService.store(id, true, scope, StorageTarget.USER),
|
|
186
231
|
isSecondary: options.neverShowAgain.isSecondary
|
|
187
232
|
};
|
|
188
233
|
if (!options.neverShowAgain.isSecondary) {
|
|
189
234
|
choices = [neverShowAgainChoice, ...choices];
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
235
|
+
} else {
|
|
192
236
|
choices = [...choices, neverShowAgainChoice];
|
|
193
237
|
}
|
|
194
238
|
}
|
|
@@ -200,8 +244,7 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
200
244
|
const action = ( new ChoiceAction(`workbench.dialog.choice.${index}`, choice));
|
|
201
245
|
if (!choice.isSecondary) {
|
|
202
246
|
primaryActions.push(action);
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
247
|
+
} else {
|
|
205
248
|
secondaryActions.push(action);
|
|
206
249
|
}
|
|
207
250
|
toDispose.add(action.onDidRun(() => {
|
|
@@ -212,11 +255,20 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
212
255
|
}));
|
|
213
256
|
toDispose.add(action);
|
|
214
257
|
});
|
|
215
|
-
const actions = {
|
|
216
|
-
|
|
258
|
+
const actions = {
|
|
259
|
+
primary: primaryActions,
|
|
260
|
+
secondary: secondaryActions
|
|
261
|
+
};
|
|
262
|
+
const handle = this.notify({
|
|
263
|
+
severity,
|
|
264
|
+
message,
|
|
265
|
+
actions,
|
|
266
|
+
sticky: options?.sticky,
|
|
267
|
+
priority: options?.priority
|
|
268
|
+
});
|
|
217
269
|
Event.once(handle.onDidClose)(() => {
|
|
218
270
|
toDispose.dispose();
|
|
219
|
-
if (options && typeof options.onCancel ===
|
|
271
|
+
if (options && typeof options.onCancel === "function" && !choiceClicked) {
|
|
220
272
|
options.onCancel();
|
|
221
273
|
}
|
|
222
274
|
});
|
|
@@ -226,8 +278,6 @@ let NotificationService = class NotificationService extends Disposable {
|
|
|
226
278
|
return this.model.showStatusMessage(message, options);
|
|
227
279
|
}
|
|
228
280
|
};
|
|
229
|
-
NotificationService = NotificationService_1 = ( __decorate([
|
|
230
|
-
( __param(0, IStorageService))
|
|
231
|
-
], NotificationService));
|
|
281
|
+
NotificationService = NotificationService_1 = ( __decorate([( __param(0, IStorageService))], NotificationService));
|
|
232
282
|
|
|
233
283
|
export { NotificationService };
|