@codingame/monaco-vscode-workbench-service-override 25.1.1 → 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.
@@ -16,7 +16,7 @@ import { withSeverityPrefix } from '@codingame/monaco-vscode-api/vscode/vs/platf
16
16
  class NotificationAccessibleView {
17
17
  constructor() {
18
18
  this.priority = 90;
19
- this.name = 'notifications';
19
+ this.name = "notifications";
20
20
  this.when = NotificationFocusedContext;
21
21
  this.type = AccessibleViewType.View;
22
22
  }
@@ -30,7 +30,7 @@ class NotificationAccessibleView {
30
30
  if (!notification) {
31
31
  return;
32
32
  }
33
- commandService.executeCommand('notifications.showList');
33
+ commandService.executeCommand("notifications.showList");
34
34
  let notificationIndex;
35
35
  const list = listService.lastFocusedList;
36
36
  if (list instanceof WorkbenchList) {
@@ -40,13 +40,12 @@ class NotificationAccessibleView {
40
40
  return;
41
41
  }
42
42
  function focusList() {
43
- commandService.executeCommand('notifications.showList');
43
+ commandService.executeCommand("notifications.showList");
44
44
  if (list && notificationIndex !== undefined) {
45
45
  list.domFocus();
46
46
  try {
47
47
  list.setFocus([notificationIndex]);
48
- }
49
- catch { }
48
+ } catch {}
50
49
  }
51
50
  }
52
51
  function getContentForNotification() {
@@ -55,38 +54,30 @@ class NotificationAccessibleView {
55
54
  if (!notification || !message) {
56
55
  return;
57
56
  }
58
- return withSeverityPrefix(notification.source ? ( localize(3524, '{0} Source: {1}', message, notification.source)) : message, notification.severity);
57
+ return withSeverityPrefix(notification.source ? ( localize(3528, "{0} Source: {1}", message, notification.source)) : message, notification.severity);
59
58
  }
60
59
  const content = getContentForNotification();
61
60
  if (!content) {
62
61
  return;
63
62
  }
64
63
  notification.onDidClose(() => accessibleViewService.next());
65
- return ( new AccessibleContentProvider(
66
- AccessibleViewProviderId.Notification,
67
- { type: AccessibleViewType.View },
68
- () => content,
69
- () => focusList(),
70
- 'accessibility.verbosity.notification',
71
- undefined,
72
- getActionsFromNotification(notification, accessibilitySignalService),
73
- () => {
74
- if (!list) {
75
- return;
76
- }
77
- focusList();
78
- list.focusNext();
79
- return getContentForNotification();
80
- },
81
- () => {
82
- if (!list) {
83
- return;
84
- }
85
- focusList();
86
- list.focusPrevious();
87
- return getContentForNotification();
64
+ return ( new AccessibleContentProvider(AccessibleViewProviderId.Notification, {
65
+ type: AccessibleViewType.View
66
+ }, () => content, () => focusList(), "accessibility.verbosity.notification", undefined, getActionsFromNotification(notification, accessibilitySignalService), () => {
67
+ if (!list) {
68
+ return;
69
+ }
70
+ focusList();
71
+ list.focusNext();
72
+ return getContentForNotification();
73
+ }, () => {
74
+ if (!list) {
75
+ return;
88
76
  }
89
- ));
77
+ focusList();
78
+ list.focusPrevious();
79
+ return getContentForNotification();
80
+ }));
90
81
  }
91
82
  return getProvider();
92
83
  }
@@ -112,16 +103,21 @@ function getActionsFromNotification(notification, accessibilitySignalService) {
112
103
  };
113
104
  }
114
105
  }
115
- const manageExtension = actions?.find(a => a.label.includes('Manage Extension'));
106
+ const manageExtension = actions?.find(a => a.label.includes("Manage Extension"));
116
107
  if (manageExtension) {
117
108
  manageExtension.class = ThemeIcon.asClassName(Codicon.gear);
118
109
  }
119
110
  if (actions) {
120
111
  actions.push({
121
- id: 'clearNotification', label: ( localize(3525, "Clear Notification")), tooltip: ( localize(3525, "Clear Notification")), run: () => {
112
+ id: "clearNotification",
113
+ label: ( localize(3529, "Clear Notification")),
114
+ tooltip: ( localize(3529, "Clear Notification")),
115
+ run: () => {
122
116
  notification.close();
123
117
  accessibilitySignalService.playSignal(AccessibilitySignal.clear);
124
- }, enabled: true, class: ThemeIcon.asClassName(Codicon.clearAll)
118
+ },
119
+ enabled: true,
120
+ class: ThemeIcon.asClassName(Codicon.clearAll)
125
121
  });
126
122
  }
127
123
  return actions;
@@ -3,7 +3,7 @@ import '@codingame/monaco-vscode-api/vscode/vs/workbench/browser/style';
3
3
  import { createElement, runWhenWindowIdle } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
4
4
  import { Emitter, setGlobalLeakWarningThreshold, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
5
5
  import { timeout, RunOnceScheduler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
6
- import { isChrome, isFirefox, isSafari } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/browser';
6
+ import { isFirefox, isChrome, isSafari } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/browser';
7
7
  import { mark } from '@codingame/monaco-vscode-api/vscode/vs/base/common/performance';
8
8
  import { onUnexpectedError, setUnexpectedErrorHandler } from '@codingame/monaco-vscode-api/vscode/vs/base/common/errors';
9
9
  import { isNative, isMacintosh, isWindows, isLinux, isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
@@ -41,20 +41,29 @@ import { EditorMarkdownCodeBlockRenderer } from '@codingame/monaco-vscode-api/vs
41
41
 
42
42
  class Workbench extends Layout {
43
43
  constructor(parent, options, serviceCollection, logService) {
44
- super(parent, { resetLayout: options?.resetLayout, customEditorRestore: options?.customEditorRestore });
44
+ super(parent, {
45
+ resetLayout: options?.resetLayout,
46
+ customEditorRestore: options?.customEditorRestore
47
+ });
45
48
  this.options = options;
46
49
  this.serviceCollection = serviceCollection;
47
50
  this._onWillShutdown = this._register(( new Emitter()));
48
51
  this.onWillShutdown = this._onWillShutdown.event;
49
52
  this._onDidShutdown = this._register(( new Emitter()));
50
53
  this.onDidShutdown = this._onDidShutdown.event;
51
- this.previousUnexpectedError = { message: undefined, time: 0 };
52
- mark('code/willStartWorkbench');
54
+ this.previousUnexpectedError = {
55
+ message: undefined,
56
+ time: 0
57
+ };
58
+ mark("code/willStartWorkbench");
53
59
  this.registerErrorHandler(logService);
54
60
  this.parent.appendChild(this.mainContainer);
55
61
  }
56
62
  registerErrorHandler(logService) {
57
- mainWindow.addEventListener('unhandledrejection', (event) => {
63
+ if (!isFirefox) {
64
+ Error.stackTraceLimit = 100;
65
+ }
66
+ mainWindow.addEventListener("unhandledrejection", event => {
58
67
  onUnexpectedError(event.reason);
59
68
  event.preventDefault();
60
69
  });
@@ -87,15 +96,25 @@ class Workbench extends Layout {
87
96
  const markdownRendererService = accessor.get(IMarkdownRendererService);
88
97
  markdownRendererService.setDefaultCodeBlockRenderer(instantiationService.createInstance(EditorMarkdownCodeBlockRenderer));
89
98
  this.initLayout(accessor);
90
- this.registerListeners(lifecycleService, storageService, configurationService, hostService, dialogService);
91
- this.renderWorkbench(instantiationService, notificationService, storageService, configurationService);
99
+ this.registerListeners(
100
+ lifecycleService,
101
+ storageService,
102
+ configurationService,
103
+ hostService,
104
+ dialogService
105
+ );
106
+ this.renderWorkbench(
107
+ instantiationService,
108
+ notificationService,
109
+ storageService,
110
+ configurationService
111
+ );
92
112
  this.createWorkbenchLayout();
93
113
  this.layout();
94
114
  this.restore(instantiationService, lifecycleService);
95
115
  });
96
116
  return instantiationService;
97
- }
98
- catch (error) {
117
+ } catch (error) {
99
118
  onUnexpectedError(error);
100
119
  throw error;
101
120
  }
@@ -110,23 +129,30 @@ class Workbench extends Layout {
110
129
  instantiationService.invokeFunction(accessor => {
111
130
  const lifecycleService = accessor.get(ILifecycleService);
112
131
  const configurationService = accessor.get(IConfigurationService);
113
- if (configurationService && 'acquireInstantiationService' in configurationService) {
132
+ if (configurationService && "acquireInstantiationService" in configurationService) {
114
133
  configurationService.acquireInstantiationService(instantiationService);
115
134
  }
116
135
  lifecycleService.phase = LifecyclePhase.Ready;
117
136
  });
118
137
  return instantiationService;
119
138
  }
120
- registerListeners(lifecycleService, storageService, configurationService, hostService, dialogService) {
121
- this._register(configurationService.onDidChangeConfiguration(e => this.updateFontAliasing(e, configurationService)));
139
+ registerListeners(
140
+ lifecycleService,
141
+ storageService,
142
+ configurationService,
143
+ hostService,
144
+ dialogService
145
+ ) {
146
+ this._register(
147
+ configurationService.onDidChangeConfiguration(e => this.updateFontAliasing(e, configurationService))
148
+ );
122
149
  if (isNative) {
123
150
  this._register(storageService.onWillSaveState(e => {
124
151
  if (e.reason === WillSaveStateReason.SHUTDOWN) {
125
152
  this.storeFontInfo(storageService);
126
153
  }
127
154
  }));
128
- }
129
- else {
155
+ } else {
130
156
  this._register(lifecycleService.onWillShutdown(() => this.storeFontInfo(storageService)));
131
157
  }
132
158
  this._register(lifecycleService.onWillShutdown(event => this._onWillShutdown.fire(event)));
@@ -139,72 +165,128 @@ class Workbench extends Layout {
139
165
  storageService.flush();
140
166
  }
141
167
  }));
142
- this._register(dialogService.onWillShowDialog(() => this.mainContainer.classList.add('modal-dialog-visible')));
143
- this._register(dialogService.onDidShowDialog(() => this.mainContainer.classList.remove('modal-dialog-visible')));
168
+ this._register(
169
+ dialogService.onWillShowDialog(() => this.mainContainer.classList.add("modal-dialog-visible"))
170
+ );
171
+ this._register(
172
+ dialogService.onDidShowDialog(() => this.mainContainer.classList.remove("modal-dialog-visible"))
173
+ );
144
174
  }
145
175
  updateFontAliasing(e, configurationService) {
146
176
  if (!isMacintosh) {
147
177
  return;
148
178
  }
149
- if (e && !e.affectsConfiguration('workbench.fontAliasing')) {
179
+ if (e && !e.affectsConfiguration("workbench.fontAliasing")) {
150
180
  return;
151
181
  }
152
- const aliasing = configurationService.getValue('workbench.fontAliasing');
182
+ const aliasing = configurationService.getValue("workbench.fontAliasing");
153
183
  if (this.fontAliasing === aliasing) {
154
184
  return;
155
185
  }
156
186
  this.fontAliasing = aliasing;
157
- const fontAliasingValues = ['antialiased', 'none', 'auto'];
187
+ const fontAliasingValues = ["antialiased", "none", "auto"];
158
188
  this.mainContainer.classList.remove(...( fontAliasingValues.map(value => `monaco-font-aliasing-${value}`)));
159
189
  if (( fontAliasingValues.some(option => option === aliasing))) {
160
190
  this.mainContainer.classList.add(`monaco-font-aliasing-${aliasing}`);
161
191
  }
162
192
  }
163
193
  restoreFontInfo(storageService, configurationService) {
164
- const storedFontInfoRaw = storageService.get('editorFontInfo', StorageScope.APPLICATION);
194
+ const storedFontInfoRaw = storageService.get("editorFontInfo", StorageScope.APPLICATION);
165
195
  if (storedFontInfoRaw) {
166
196
  try {
167
197
  const storedFontInfo = JSON.parse(storedFontInfoRaw);
168
198
  if (Array.isArray(storedFontInfo)) {
169
199
  FontMeasurements.restoreFontInfo(mainWindow, storedFontInfo);
170
200
  }
171
- }
172
- catch (err) {
173
- }
201
+ } catch (err) {}
174
202
  }
175
- FontMeasurements.readFontInfo(mainWindow, createBareFontInfoFromRawSettings(configurationService.getValue('editor'), PixelRatio.getInstance(mainWindow).value));
203
+ FontMeasurements.readFontInfo(mainWindow, createBareFontInfoFromRawSettings(
204
+ configurationService.getValue("editor"),
205
+ PixelRatio.getInstance(mainWindow).value
206
+ ));
176
207
  }
177
208
  storeFontInfo(storageService) {
178
209
  const serializedFontInfo = FontMeasurements.serializeFontInfo(mainWindow);
179
210
  if (serializedFontInfo) {
180
- storageService.store('editorFontInfo', JSON.stringify(serializedFontInfo), StorageScope.APPLICATION, StorageTarget.MACHINE);
211
+ storageService.store(
212
+ "editorFontInfo",
213
+ JSON.stringify(serializedFontInfo),
214
+ StorageScope.APPLICATION,
215
+ StorageTarget.MACHINE
216
+ );
181
217
  }
182
218
  }
183
- renderWorkbench(instantiationService, notificationService, storageService, configurationService) {
219
+ renderWorkbench(
220
+ instantiationService,
221
+ notificationService,
222
+ storageService,
223
+ configurationService
224
+ ) {
184
225
  setARIAContainer(this.mainContainer);
185
- setProgressAccessibilitySignalScheduler((msDelayTime, msLoopTime) => instantiationService.createInstance(AccessibilityProgressSignalScheduler, msDelayTime, msLoopTime));
186
- const platformClass = isWindows ? 'windows' : isLinux ? 'linux' : 'mac';
226
+ setProgressAccessibilitySignalScheduler(
227
+ (msDelayTime, msLoopTime) => instantiationService.createInstance(AccessibilityProgressSignalScheduler, msDelayTime, msLoopTime)
228
+ );
229
+ const platformClass = isWindows ? "windows" : isLinux ? "linux" : "mac";
187
230
  const workbenchClasses = coalesce([
188
- 'monaco-workbench',
231
+ "monaco-workbench",
189
232
  platformClass,
190
- isWeb ? 'web' : undefined,
191
- isChrome ? 'chromium' : isFirefox ? 'firefox' : isSafari ? 'safari' : undefined,
233
+ isWeb ? "web" : undefined,
234
+ isChrome ? "chromium" : isFirefox ? "firefox" : isSafari ? "safari" : undefined,
192
235
  ...this.getLayoutClasses(),
193
236
  ...(this.options?.extraClasses ? this.options.extraClasses : [])
194
237
  ]);
195
238
  this.mainContainer.classList.add(...workbenchClasses);
196
239
  this.updateFontAliasing(undefined, configurationService);
197
240
  this.restoreFontInfo(storageService, configurationService);
198
- for (const { id, role, classes, options } of [
199
- { id: Parts.TITLEBAR_PART, role: 'none', classes: ['titlebar'] },
200
- { id: Parts.BANNER_PART, role: 'banner', classes: ['banner'] },
201
- { id: Parts.ACTIVITYBAR_PART, role: 'none', classes: ['activitybar', this.getSideBarPosition() === Position.LEFT ? 'left' : 'right'] },
202
- { id: Parts.SIDEBAR_PART, role: 'none', classes: ['sidebar', this.getSideBarPosition() === Position.LEFT ? 'left' : 'right'] },
203
- { id: Parts.EDITOR_PART, role: 'main', classes: ['editor'], options: { restorePreviousState: this.willRestoreEditors() } },
204
- { id: Parts.PANEL_PART, role: 'none', classes: ['panel', 'basepanel', positionToString(this.getPanelPosition())] },
205
- { id: Parts.AUXILIARYBAR_PART, role: 'none', classes: ['auxiliarybar', 'basepanel', this.getSideBarPosition() === Position.LEFT ? 'right' : 'left'] },
206
- { id: Parts.STATUSBAR_PART, role: 'status', classes: ['statusbar'] }
207
- ]) {
241
+ for (const {
242
+ id,
243
+ role,
244
+ classes,
245
+ options
246
+ } of [{
247
+ id: Parts.TITLEBAR_PART,
248
+ role: "none",
249
+ classes: ["titlebar"]
250
+ }, {
251
+ id: Parts.BANNER_PART,
252
+ role: "banner",
253
+ classes: ["banner"]
254
+ },
255
+ {
256
+ id: Parts.ACTIVITYBAR_PART,
257
+ role: "none",
258
+ classes: [
259
+ "activitybar",
260
+ this.getSideBarPosition() === Position.LEFT ? "left" : "right"
261
+ ]
262
+ }, {
263
+ id: Parts.SIDEBAR_PART,
264
+ role: "none",
265
+ classes: ["sidebar", this.getSideBarPosition() === Position.LEFT ? "left" : "right"]
266
+ }, {
267
+ id: Parts.EDITOR_PART,
268
+ role: "main",
269
+ classes: ["editor"],
270
+ options: {
271
+ restorePreviousState: this.willRestoreEditors()
272
+ }
273
+ }, {
274
+ id: Parts.PANEL_PART,
275
+ role: "none",
276
+ classes: ["panel", "basepanel", positionToString(this.getPanelPosition())]
277
+ }, {
278
+ id: Parts.AUXILIARYBAR_PART,
279
+ role: "none",
280
+ classes: [
281
+ "auxiliarybar",
282
+ "basepanel",
283
+ this.getSideBarPosition() === Position.LEFT ? "right" : "left"
284
+ ]
285
+ }, {
286
+ id: Parts.STATUSBAR_PART,
287
+ role: "status",
288
+ classes: ["statusbar"]
289
+ }]) {
208
290
  const partContainer = this.createPart(id, role, classes);
209
291
  mark(`code/willCreatePart/${id}`);
210
292
  this.getPart(id).create(partContainer, options);
@@ -213,19 +295,27 @@ class Workbench extends Layout {
213
295
  this.createNotificationsHandlers(instantiationService, notificationService);
214
296
  }
215
297
  createPart(id, role, classes) {
216
- const part = createElement(role === 'status' ? 'footer' : 'div');
217
- part.classList.add('part', ...classes);
298
+ const part = createElement(
299
+ role === "status" ? "footer" : "div"
300
+ );
301
+ part.classList.add("part", ...classes);
218
302
  part.id = id;
219
- part.setAttribute('role', role);
220
- if (role === 'status') {
221
- part.setAttribute('aria-live', 'off');
303
+ part.setAttribute("role", role);
304
+ if (role === "status") {
305
+ part.setAttribute("aria-live", "off");
222
306
  }
223
307
  return part;
224
308
  }
225
309
  createNotificationsHandlers(instantiationService, notificationService) {
226
- const notificationsCenter = this._register(instantiationService.createInstance(NotificationsCenter, this.mainContainer, notificationService.model));
227
- const notificationsToasts = this._register(instantiationService.createInstance(NotificationsToasts, this.mainContainer, notificationService.model));
228
- this._register(instantiationService.createInstance(NotificationsAlerts, notificationService.model));
310
+ const notificationsCenter = this._register(
311
+ instantiationService.createInstance(NotificationsCenter, this.mainContainer, notificationService.model)
312
+ );
313
+ const notificationsToasts = this._register(
314
+ instantiationService.createInstance(NotificationsToasts, this.mainContainer, notificationService.model)
315
+ );
316
+ this._register(
317
+ instantiationService.createInstance(NotificationsAlerts, notificationService.model)
318
+ );
229
319
  const notificationsStatus = instantiationService.createInstance(NotificationsStatus, notificationService.model);
230
320
  this._register(notificationsCenter.onDidChangeVisibility(() => {
231
321
  notificationsStatus.update(notificationsCenter.isVisible, notificationsToasts.isVisible);
@@ -237,36 +327,37 @@ class Workbench extends Layout {
237
327
  registerNotificationCommands(notificationsCenter, notificationsToasts, notificationService.model);
238
328
  AccessibleViewRegistry.register(( new NotificationAccessibleView()));
239
329
  this.registerNotifications({
240
- onDidChangeNotificationsVisibility: ( Event.map(
241
- Event.any(notificationsToasts.onDidChangeVisibility, notificationsCenter.onDidChangeVisibility),
242
- () => notificationsToasts.isVisible || notificationsCenter.isVisible
243
- ))
330
+ onDidChangeNotificationsVisibility: ( Event.map(Event.any(
331
+ notificationsToasts.onDidChangeVisibility,
332
+ notificationsCenter.onDidChangeVisibility
333
+ ), () => notificationsToasts.isVisible || notificationsCenter.isVisible))
244
334
  });
245
335
  }
246
336
  restore(instantiationService, lifecycleService) {
247
337
  try {
248
338
  this.restoreParts(instantiationService);
249
- }
250
- catch (error) {
339
+ } catch (error) {
251
340
  onUnexpectedError(error);
252
341
  }
253
- this.whenReady.finally(() => Promise.race([
254
- this.whenRestored,
255
- timeout(2000)
256
- ]).finally(() => {
342
+ this.whenReady.finally(() => Promise.race([this.whenRestored, timeout(2000)]).finally(() => {
257
343
  function markDidStartWorkbench() {
258
- mark('code/didStartWorkbench');
259
- performance.measure('perf: workbench create & restore', 'code/didLoadWorkbenchMain', 'code/didStartWorkbench');
344
+ mark("code/didStartWorkbench");
345
+ performance.measure(
346
+ "perf: workbench create & restore",
347
+ "code/didLoadWorkbenchMain",
348
+ "code/didStartWorkbench"
349
+ );
260
350
  }
261
351
  if (this.isRestored()) {
262
352
  markDidStartWorkbench();
263
- }
264
- else {
353
+ } else {
265
354
  this.whenRestored.finally(() => markDidStartWorkbench());
266
355
  }
267
356
  lifecycleService.phase = LifecyclePhase.Restored;
268
357
  const eventuallyPhaseScheduler = this._register(( new RunOnceScheduler(() => {
269
- this._register(runWhenWindowIdle(mainWindow, () => lifecycleService.phase = LifecyclePhase.Eventually, 2500));
358
+ this._register(
359
+ runWhenWindowIdle(mainWindow, () => lifecycleService.phase = LifecyclePhase.Eventually, 2500)
360
+ );
270
361
  }, 2500)));
271
362
  eventuallyPhaseScheduler.schedule();
272
363
  }));