@codingame/monaco-vscode-api 1.76.1 → 1.76.3-next.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.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/dist/api.js +3 -860
  3. package/dist/{extHost.js → api2.js} +16555 -13467
  4. package/dist/async.js +107 -2
  5. package/dist/audioCue.js +105 -103
  6. package/dist/button.js +1 -1
  7. package/dist/cancellation.js +3 -0
  8. package/dist/configuration.js +7 -344
  9. package/dist/configuration2.js +339 -0
  10. package/dist/configurationRegistry.js +441 -0
  11. package/dist/contextkeys.js +211 -0
  12. package/dist/debug.d.ts +22 -0
  13. package/dist/debug.js +15842 -0
  14. package/dist/dialogs.js +855 -9
  15. package/dist/extensionResourceLoader.js +96 -0
  16. package/dist/extensions.d.ts +491 -0
  17. package/dist/extensions.js +70 -0
  18. package/dist/{tools.js → extensionsRegistry.js} +2 -30
  19. package/dist/files.js +1407 -334
  20. package/dist/iconv.js +43 -0
  21. package/dist/injection.js +1 -1
  22. package/dist/jschardet.js +7 -0
  23. package/dist/keybindings.d.ts +1 -485
  24. package/dist/keybindings.js +666 -679
  25. package/dist/labels.js +14 -0
  26. package/dist/languageConfiguration.d.ts +1 -2
  27. package/dist/languageConfiguration.js +9 -16
  28. package/dist/languageService.js +112 -8
  29. package/dist/languages.d.ts +1 -473
  30. package/dist/languages.js +2 -12
  31. package/dist/layout.js +4 -3
  32. package/dist/layoutService.js +1 -1
  33. package/dist/missing-services.js +4710 -74
  34. package/dist/modelEditor.d.ts +324 -2
  35. package/dist/modelEditor.js +15 -228
  36. package/dist/monaco.js +7 -72
  37. package/dist/notifications.js +75 -232
  38. package/dist/polyfill.js +10715 -2459
  39. package/dist/resources.js +197 -0
  40. package/dist/services.d.ts +924 -3
  41. package/dist/services.js +1 -2
  42. package/dist/services2.js +2436 -18
  43. package/dist/snippets.d.ts +1 -473
  44. package/dist/snippets.js +8 -867
  45. package/dist/snippetsService.js +868 -0
  46. package/dist/textFileEditorModel.js +2985 -0
  47. package/dist/textmate.d.ts +3 -475
  48. package/dist/textmate.js +19 -29
  49. package/dist/theme.d.ts +1 -3
  50. package/dist/theme.js +24 -70
  51. package/dist/tokenClassification.d.ts +1 -475
  52. package/dist/tokenClassification.js +11 -37
  53. package/dist/tokenClassificationRegistry.js +8 -4
  54. package/dist/variableResolver.js +1711 -0
  55. package/dist/workbenchThemeService.js +1 -1
  56. package/dist/workspaceContext.js +1 -3
  57. package/package.json +27 -12
  58. package/dist/contextkey.js +0 -419
  59. package/dist/dialog.web.contribution.js +0 -945
@@ -1,945 +0,0 @@
1
- import { _ as __decorate, a as __param, E as Emitter } from './contextkey.js';
2
- import { h as IProductService } from './services2.js';
3
- import { localize } from 'monaco-editor/esm/vs/nls.js';
4
- import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
5
- import { n } from './polyfill.js';
6
- import { Widget } from 'monaco-editor/esm/vs/base/browser/ui/widget.js';
7
- import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
8
- import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
9
- import { B as ButtonBar, a as ButtonWithDescription } from './button.js';
10
- import { isMacintosh, isLinux, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
11
- import { Disposable, DisposableStore } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
12
- import { EventHelper, $, hide, addDisposableListener, EventType, clearNode, isAncestor, show } from 'monaco-editor/esm/vs/base/browser/dom.js';
13
- import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
14
- import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
15
- import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
16
- import { StandardKeyboardEvent } from 'monaco-editor/esm/vs/base/browser/keyboardEvent.js';
17
- import { MarkdownRenderer } from 'monaco-editor/esm/vs/editor/contrib/markdownRenderer/browser/markdownRenderer.js';
18
- import { defaultButtonStyles, defaultCheckboxStyles, defaultInputBoxStyles, defaultDialogStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
19
- import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
20
- import { ILayoutService } from 'monaco-editor/esm/vs/platform/layout/browser/layoutService.js';
21
- import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
22
- import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
23
- import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
24
- import { IDialogService } from 'monaco-editor/esm/vs/platform/dialogs/common/dialogs.js';
25
- function mnemonicButtonLabel(label, forceDisableMnemonics) {
26
- if (isMacintosh || forceDisableMnemonics) {
27
- return label.replace(/\(&&\w\)|&&/g, '');
28
- }
29
- if (isWindows) {
30
- return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
31
- }
32
- return label.replace(/&&/g, '_');
33
- }
34
- var DialogKind;
35
- ( (function(DialogKind) {
36
- DialogKind[DialogKind["Confirmation"] = 1] = "Confirmation";
37
- DialogKind[DialogKind["Prompt"] = 2] = "Prompt";
38
- DialogKind[DialogKind["Input"] = 3] = "Input";
39
- })(DialogKind || (DialogKind = {})));
40
- class AbstractDialogHandler {
41
- getConfirmationButtons(dialog) {
42
- return this.getButtons(dialog, DialogKind.Confirmation);
43
- }
44
- getPromptButtons(dialog) {
45
- return this.getButtons(dialog, DialogKind.Prompt);
46
- }
47
- getInputButtons(dialog) {
48
- return this.getButtons(dialog, DialogKind.Input);
49
- }
50
- getButtons(dialog, kind) {
51
- const buttons = [];
52
- switch (kind) {
53
- case DialogKind.Confirmation: {
54
- const confirmationDialog = dialog;
55
- if (confirmationDialog.primaryButton) {
56
- buttons.push(confirmationDialog.primaryButton);
57
- }
58
- else {
59
- buttons.push(( localize({ key: 'yesButton', comment: ['&& denotes a mnemonic'] }, "&&Yes")));
60
- }
61
- if (confirmationDialog.cancelButton) {
62
- buttons.push(confirmationDialog.cancelButton);
63
- }
64
- else {
65
- buttons.push(( localize('cancelButton', "Cancel")));
66
- }
67
- break;
68
- }
69
- case DialogKind.Prompt: {
70
- const promptDialog = dialog;
71
- if (Array.isArray(promptDialog.buttons) && promptDialog.buttons.length > 0) {
72
- buttons.push(...promptDialog.buttons.map(button => button.label));
73
- }
74
- if (promptDialog.cancelButton) {
75
- if (promptDialog.cancelButton === true) {
76
- buttons.push(( localize('cancelButton', "Cancel")));
77
- }
78
- else if (typeof promptDialog.cancelButton === 'string') {
79
- buttons.push(promptDialog.cancelButton);
80
- }
81
- else {
82
- if (promptDialog.cancelButton.label) {
83
- buttons.push(promptDialog.cancelButton.label);
84
- }
85
- else {
86
- buttons.push(( localize('cancelButton', "Cancel")));
87
- }
88
- }
89
- }
90
- if (buttons.length === 0) {
91
- buttons.push(( localize({ key: 'okButton', comment: ['&& denotes a mnemonic'] }, "&&OK")));
92
- }
93
- break;
94
- }
95
- case DialogKind.Input: {
96
- const inputDialog = dialog;
97
- if (inputDialog.primaryButton) {
98
- buttons.push(inputDialog.primaryButton);
99
- }
100
- else {
101
- buttons.push(( localize({ key: 'okButton', comment: ['&& denotes a mnemonic'] }, "&&OK")));
102
- }
103
- if (inputDialog.cancelButton) {
104
- buttons.push(inputDialog.cancelButton);
105
- }
106
- else {
107
- buttons.push(( localize('cancelButton', "Cancel")));
108
- }
109
- break;
110
- }
111
- }
112
- return buttons;
113
- }
114
- getDialogType(type) {
115
- if (typeof type === 'string') {
116
- return type;
117
- }
118
- if (typeof type === 'number') {
119
- return (type === Severity.Info) ? 'info' : (type === Severity.Error) ? 'error' : (type === Severity.Warning) ? 'warning' : 'none';
120
- }
121
- return undefined;
122
- }
123
- async getPromptResult(prompt, buttonIndex, checkboxChecked) {
124
- const promptButtons = [...(prompt.buttons ?? [])];
125
- if (prompt.cancelButton && typeof prompt.cancelButton !== 'string' && typeof prompt.cancelButton !== 'boolean') {
126
- promptButtons.push(prompt.cancelButton);
127
- }
128
- const result = await promptButtons[buttonIndex]?.run({ checkboxChecked });
129
- return { result, checkboxChecked };
130
- }
131
- }
132
- var css$1 = ".monaco-custom-toggle{border:1px solid transparent;border-radius:3px;box-sizing:border-box;cursor:pointer;float:left;height:20px;margin-left:2px;overflow:hidden;padding:1px;user-select:none;-webkit-user-select:none;width:20px}.monaco-custom-toggle:hover{background-color:var(--vscode-inputOption-hoverBackground)}.hc-black .monaco-custom-toggle:hover,.hc-light .monaco-custom-toggle:hover{border:1px dashed var(--vscode-focusBorder)}.hc-black .monaco-custom-toggle,.hc-black .monaco-custom-toggle:hover,.hc-light .monaco-custom-toggle,.hc-light .monaco-custom-toggle:hover{background:none}.monaco-custom-toggle.monaco-checkbox{background-size:16px!important;border:1px solid transparent;border-radius:3px;height:18px;margin-left:0;margin-right:9px;opacity:1;padding:0;width:18px}.monaco-custom-toggle.monaco-checkbox:not(.checked):before{visibility:hidden}";
133
- n(css$1,{});
134
- const unthemedToggleStyles = {
135
- inputActiveOptionBorder: '#007ACC00',
136
- inputActiveOptionForeground: '#FFFFFF',
137
- inputActiveOptionBackground: '#0E639C50'
138
- };
139
- class Toggle extends Widget {
140
- constructor(opts) {
141
- super();
142
- this._onChange = this._register(( new Emitter()));
143
- this.onChange = this._onChange.event;
144
- this._onKeyDown = this._register(( new Emitter()));
145
- this.onKeyDown = this._onKeyDown.event;
146
- this._opts = opts;
147
- this._checked = this._opts.isChecked;
148
- const classes = ['monaco-custom-toggle'];
149
- if (this._opts.icon) {
150
- this._icon = this._opts.icon;
151
- classes.push(...ThemeIcon.asClassNameArray(this._icon));
152
- }
153
- if (this._opts.actionClassName) {
154
- classes.push(...this._opts.actionClassName.split(' '));
155
- }
156
- if (this._checked) {
157
- classes.push('checked');
158
- }
159
- this.domNode = document.createElement('div');
160
- this.domNode.title = this._opts.title;
161
- this.domNode.classList.add(...classes);
162
- if (!this._opts.notFocusable) {
163
- this.domNode.tabIndex = 0;
164
- }
165
- this.domNode.setAttribute('role', 'checkbox');
166
- this.domNode.setAttribute('aria-checked', String(this._checked));
167
- this.domNode.setAttribute('aria-label', this._opts.title);
168
- this.applyStyles();
169
- this.onclick(this.domNode, (ev) => {
170
- if (this.enabled) {
171
- this.checked = !this._checked;
172
- this._onChange.fire(false);
173
- ev.preventDefault();
174
- }
175
- });
176
- this._register(this.ignoreGesture(this.domNode));
177
- this.onkeydown(this.domNode, (keyboardEvent) => {
178
- if (keyboardEvent.keyCode === 10 || keyboardEvent.keyCode === 3 ) {
179
- this.checked = !this._checked;
180
- this._onChange.fire(true);
181
- keyboardEvent.preventDefault();
182
- keyboardEvent.stopPropagation();
183
- return;
184
- }
185
- this._onKeyDown.fire(keyboardEvent);
186
- });
187
- }
188
- get enabled() {
189
- return this.domNode.getAttribute('aria-disabled') !== 'true';
190
- }
191
- focus() {
192
- this.domNode.focus();
193
- }
194
- get checked() {
195
- return this._checked;
196
- }
197
- set checked(newIsChecked) {
198
- this._checked = newIsChecked;
199
- this.domNode.setAttribute('aria-checked', String(this._checked));
200
- this.domNode.classList.toggle('checked', this._checked);
201
- this.applyStyles();
202
- }
203
- setIcon(icon) {
204
- if (this._icon) {
205
- this.domNode.classList.remove(...ThemeIcon.asClassNameArray(this._icon));
206
- }
207
- this._icon = icon;
208
- if (this._icon) {
209
- this.domNode.classList.add(...ThemeIcon.asClassNameArray(this._icon));
210
- }
211
- }
212
- width() {
213
- return 2 + 2 + 2 + 16 ;
214
- }
215
- applyStyles() {
216
- if (this.domNode) {
217
- this.domNode.style.borderColor = (this._checked && this._opts.inputActiveOptionBorder) || '';
218
- this.domNode.style.color = (this._checked && this._opts.inputActiveOptionForeground) || 'inherit';
219
- this.domNode.style.backgroundColor = (this._checked && this._opts.inputActiveOptionBackground) || '';
220
- }
221
- }
222
- enable() {
223
- this.domNode.setAttribute('aria-disabled', String(false));
224
- }
225
- disable() {
226
- this.domNode.setAttribute('aria-disabled', String(true));
227
- }
228
- setTitle(newTitle) {
229
- this.domNode.title = newTitle;
230
- this.domNode.setAttribute('aria-label', newTitle);
231
- }
232
- }
233
- class Checkbox extends Widget {
234
- constructor(title, isChecked, styles) {
235
- super();
236
- this.title = title;
237
- this.isChecked = isChecked;
238
- this.checkbox = ( new Toggle(
239
- { title: this.title, isChecked: this.isChecked, icon: Codicon.check, actionClassName: 'monaco-checkbox', ...unthemedToggleStyles }
240
- ));
241
- this.domNode = this.checkbox.domNode;
242
- this.styles = styles;
243
- this.applyStyles();
244
- this._register(this.checkbox.onChange(() => this.applyStyles()));
245
- }
246
- get checked() {
247
- return this.checkbox.checked;
248
- }
249
- set checked(newIsChecked) {
250
- this.checkbox.checked = newIsChecked;
251
- this.applyStyles();
252
- }
253
- focus() {
254
- this.domNode.focus();
255
- }
256
- hasFocus() {
257
- return this.domNode === document.activeElement;
258
- }
259
- applyStyles() {
260
- this.domNode.style.color = this.styles.checkboxForeground || '';
261
- this.domNode.style.backgroundColor = this.styles.checkboxBackground || '';
262
- this.domNode.style.borderColor = this.styles.checkboxBorder || '';
263
- }
264
- }
265
- const minute = 60;
266
- const hour = minute * 60;
267
- const day = hour * 24;
268
- const week = day * 7;
269
- const month = day * 30;
270
- const year = day * 365;
271
- function fromNow(date, appendAgoLabel, useFullTimeWords, disallowNow) {
272
- if (typeof date !== 'number') {
273
- date = date.getTime();
274
- }
275
- const seconds = Math.round((( new Date()).getTime() - date) / 1000);
276
- if (seconds < -30) {
277
- return ( localize('date.fromNow.in', 'in {0}', fromNow(( new Date()).getTime() + seconds * 1000, false)));
278
- }
279
- if (!disallowNow && seconds < 30) {
280
- return ( localize('date.fromNow.now', 'now'));
281
- }
282
- let value;
283
- if (seconds < minute) {
284
- value = seconds;
285
- if (appendAgoLabel) {
286
- if (value === 1) {
287
- return useFullTimeWords
288
- ? ( localize('date.fromNow.seconds.singular.ago.fullWord', '{0} second ago', value))
289
- : ( localize('date.fromNow.seconds.singular.ago', '{0} sec ago', value));
290
- }
291
- else {
292
- return useFullTimeWords
293
- ? ( localize('date.fromNow.seconds.plural.ago.fullWord', '{0} seconds ago', value))
294
- : ( localize('date.fromNow.seconds.plural.ago', '{0} secs ago', value));
295
- }
296
- }
297
- else {
298
- if (value === 1) {
299
- return useFullTimeWords
300
- ? ( localize('date.fromNow.seconds.singular.fullWord', '{0} second', value))
301
- : ( localize('date.fromNow.seconds.singular', '{0} sec', value));
302
- }
303
- else {
304
- return useFullTimeWords
305
- ? ( localize('date.fromNow.seconds.plural.fullWord', '{0} seconds', value))
306
- : ( localize('date.fromNow.seconds.plural', '{0} secs', value));
307
- }
308
- }
309
- }
310
- if (seconds < hour) {
311
- value = Math.floor(seconds / minute);
312
- if (appendAgoLabel) {
313
- if (value === 1) {
314
- return useFullTimeWords
315
- ? ( localize('date.fromNow.minutes.singular.ago.fullWord', '{0} minute ago', value))
316
- : ( localize('date.fromNow.minutes.singular.ago', '{0} min ago', value));
317
- }
318
- else {
319
- return useFullTimeWords
320
- ? ( localize('date.fromNow.minutes.plural.ago.fullWord', '{0} minutes ago', value))
321
- : ( localize('date.fromNow.minutes.plural.ago', '{0} mins ago', value));
322
- }
323
- }
324
- else {
325
- if (value === 1) {
326
- return useFullTimeWords
327
- ? ( localize('date.fromNow.minutes.singular.fullWord', '{0} minute', value))
328
- : ( localize('date.fromNow.minutes.singular', '{0} min', value));
329
- }
330
- else {
331
- return useFullTimeWords
332
- ? ( localize('date.fromNow.minutes.plural.fullWord', '{0} minutes', value))
333
- : ( localize('date.fromNow.minutes.plural', '{0} mins', value));
334
- }
335
- }
336
- }
337
- if (seconds < day) {
338
- value = Math.floor(seconds / hour);
339
- if (appendAgoLabel) {
340
- if (value === 1) {
341
- return useFullTimeWords
342
- ? ( localize('date.fromNow.hours.singular.ago.fullWord', '{0} hour ago', value))
343
- : ( localize('date.fromNow.hours.singular.ago', '{0} hr ago', value));
344
- }
345
- else {
346
- return useFullTimeWords
347
- ? ( localize('date.fromNow.hours.plural.ago.fullWord', '{0} hours ago', value))
348
- : ( localize('date.fromNow.hours.plural.ago', '{0} hrs ago', value));
349
- }
350
- }
351
- else {
352
- if (value === 1) {
353
- return useFullTimeWords
354
- ? ( localize('date.fromNow.hours.singular.fullWord', '{0} hour', value))
355
- : ( localize('date.fromNow.hours.singular', '{0} hr', value));
356
- }
357
- else {
358
- return useFullTimeWords
359
- ? ( localize('date.fromNow.hours.plural.fullWord', '{0} hours', value))
360
- : ( localize('date.fromNow.hours.plural', '{0} hrs', value));
361
- }
362
- }
363
- }
364
- if (seconds < week) {
365
- value = Math.floor(seconds / day);
366
- if (appendAgoLabel) {
367
- return value === 1
368
- ? ( localize('date.fromNow.days.singular.ago', '{0} day ago', value))
369
- : ( localize('date.fromNow.days.plural.ago', '{0} days ago', value));
370
- }
371
- else {
372
- return value === 1
373
- ? ( localize('date.fromNow.days.singular', '{0} day', value))
374
- : ( localize('date.fromNow.days.plural', '{0} days', value));
375
- }
376
- }
377
- if (seconds < month) {
378
- value = Math.floor(seconds / week);
379
- if (appendAgoLabel) {
380
- if (value === 1) {
381
- return useFullTimeWords
382
- ? ( localize('date.fromNow.weeks.singular.ago.fullWord', '{0} week ago', value))
383
- : ( localize('date.fromNow.weeks.singular.ago', '{0} wk ago', value));
384
- }
385
- else {
386
- return useFullTimeWords
387
- ? ( localize('date.fromNow.weeks.plural.ago.fullWord', '{0} weeks ago', value))
388
- : ( localize('date.fromNow.weeks.plural.ago', '{0} wks ago', value));
389
- }
390
- }
391
- else {
392
- if (value === 1) {
393
- return useFullTimeWords
394
- ? ( localize('date.fromNow.weeks.singular.fullWord', '{0} week', value))
395
- : ( localize('date.fromNow.weeks.singular', '{0} wk', value));
396
- }
397
- else {
398
- return useFullTimeWords
399
- ? ( localize('date.fromNow.weeks.plural.fullWord', '{0} weeks', value))
400
- : ( localize('date.fromNow.weeks.plural', '{0} wks', value));
401
- }
402
- }
403
- }
404
- if (seconds < year) {
405
- value = Math.floor(seconds / month);
406
- if (appendAgoLabel) {
407
- if (value === 1) {
408
- return useFullTimeWords
409
- ? ( localize('date.fromNow.months.singular.ago.fullWord', '{0} month ago', value))
410
- : ( localize('date.fromNow.months.singular.ago', '{0} mo ago', value));
411
- }
412
- else {
413
- return useFullTimeWords
414
- ? ( localize('date.fromNow.months.plural.ago.fullWord', '{0} months ago', value))
415
- : ( localize('date.fromNow.months.plural.ago', '{0} mos ago', value));
416
- }
417
- }
418
- else {
419
- if (value === 1) {
420
- return useFullTimeWords
421
- ? ( localize('date.fromNow.months.singular.fullWord', '{0} month', value))
422
- : ( localize('date.fromNow.months.singular', '{0} mo', value));
423
- }
424
- else {
425
- return useFullTimeWords
426
- ? ( localize('date.fromNow.months.plural.fullWord', '{0} months', value))
427
- : ( localize('date.fromNow.months.plural', '{0} mos', value));
428
- }
429
- }
430
- }
431
- value = Math.floor(seconds / year);
432
- if (appendAgoLabel) {
433
- if (value === 1) {
434
- return useFullTimeWords
435
- ? ( localize('date.fromNow.years.singular.ago.fullWord', '{0} year ago', value))
436
- : ( localize('date.fromNow.years.singular.ago', '{0} yr ago', value));
437
- }
438
- else {
439
- return useFullTimeWords
440
- ? ( localize('date.fromNow.years.plural.ago.fullWord', '{0} years ago', value))
441
- : ( localize('date.fromNow.years.plural.ago', '{0} yrs ago', value));
442
- }
443
- }
444
- else {
445
- if (value === 1) {
446
- return useFullTimeWords
447
- ? ( localize('date.fromNow.years.singular.fullWord', '{0} year', value))
448
- : ( localize('date.fromNow.years.singular', '{0} yr', value));
449
- }
450
- else {
451
- return useFullTimeWords
452
- ? ( localize('date.fromNow.years.plural.fullWord', '{0} years', value))
453
- : ( localize('date.fromNow.years.plural', '{0} yrs', value));
454
- }
455
- }
456
- }
457
- var css = ".monaco-dialog-modal-block{align-items:center;display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:2600}.monaco-dialog-modal-block.dimmed{background:rgba(0,0,0,.3)}.monaco-dialog-box{display:flex;flex-direction:column-reverse;max-width:90vw;min-height:75px;min-width:500px;padding:10px;transform:translateZ(0);width:min-content}.monaco-dialog-box .dialog-toolbar-row{height:22px;padding-bottom:4px}.monaco-dialog-box .dialog-toolbar-row .actions-container{justify-content:flex-end}.monaco-dialog-box .dialog-message-row{align-items:center;display:flex;flex-grow:1;padding:0 10px}.monaco-dialog-box .dialog-message-row>.dialog-icon.codicon{align-self:baseline;flex:0 0 48px;font-size:48px;height:48px}.monaco-dialog-box .dialog-message-row .dialog-message-container{word-wrap:break-word;display:flex;flex-direction:column;overflow:hidden;padding-left:24px;text-overflow:ellipsis;user-select:text;-webkit-user-select:text;white-space:normal}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message{word-wrap:break-word;align-items:center;display:flex;flex:1;font-size:18px;line-height:22px;margin-bottom:8px;min-height:48px;white-space:normal}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-detail{flex:1;line-height:22px}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message a:focus{outline-style:solid;outline-width:1px}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row{display:flex;padding:15px 0 0}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-checkbox-row .dialog-checkbox-message{cursor:pointer;user-select:none;-webkit-user-select:none}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input{display:flex;padding:15px 0 0}.monaco-dialog-box .dialog-message-row .dialog-message-container .dialog-message-input .monaco-inputbox{flex:1}.monaco-dialog-box code{font-family:var(--monaco-monospace-font)}.monaco-dialog-box>.dialog-buttons-row{align-items:center;display:flex;overflow:hidden;padding-right:1px;padding:20px 10px 10px;white-space:nowrap}.monaco-dialog-box>.dialog-buttons-row>.dialog-buttons{display:flex;justify-content:flex-end;margin-left:67px;overflow:hidden;width:100%}.monaco-dialog-box>.dialog-buttons-row>.dialog-buttons>.monaco-button{margin:4px 5px;outline-offset:2px!important;overflow:hidden;padding:5px 10px;text-overflow:ellipsis;width:fit-content}";
458
- n(css,{});
459
- class Dialog extends Disposable {
460
- constructor(container, message, buttons, options) {
461
- super();
462
- this.container = container;
463
- this.message = message;
464
- this.options = options;
465
- this.modalElement = this.container.appendChild($(`.monaco-dialog-modal-block.dimmed`));
466
- this.shadowElement = this.modalElement.appendChild($('.dialog-shadow'));
467
- this.element = this.shadowElement.appendChild($('.monaco-dialog-box'));
468
- this.element.setAttribute('role', 'dialog');
469
- this.element.tabIndex = -1;
470
- hide(this.element);
471
- this.buttonStyles = options.buttonStyles;
472
- if (Array.isArray(buttons) && buttons.length > 0) {
473
- this.buttons = buttons;
474
- }
475
- else if (!this.options.disableDefaultAction) {
476
- this.buttons = [( localize('ok', "OK"))];
477
- }
478
- else {
479
- this.buttons = [];
480
- }
481
- const buttonsRowElement = this.element.appendChild($('.dialog-buttons-row'));
482
- this.buttonsContainer = buttonsRowElement.appendChild($('.dialog-buttons'));
483
- const messageRowElement = this.element.appendChild($('.dialog-message-row'));
484
- this.iconElement = messageRowElement.appendChild($('#monaco-dialog-icon.dialog-icon'));
485
- this.iconElement.setAttribute('aria-label', this.getIconAriaLabel());
486
- this.messageContainer = messageRowElement.appendChild($('.dialog-message-container'));
487
- if (this.options.detail || this.options.renderBody) {
488
- const messageElement = this.messageContainer.appendChild($('.dialog-message'));
489
- const messageTextElement = messageElement.appendChild($('#monaco-dialog-message-text.dialog-message-text'));
490
- messageTextElement.innerText = this.message;
491
- }
492
- this.messageDetailElement = this.messageContainer.appendChild($('#monaco-dialog-message-detail.dialog-message-detail'));
493
- if (this.options.detail || !this.options.renderBody) {
494
- this.messageDetailElement.innerText = this.options.detail ? this.options.detail : message;
495
- }
496
- else {
497
- this.messageDetailElement.style.display = 'none';
498
- }
499
- if (this.options.renderBody) {
500
- const customBody = this.messageContainer.appendChild($('#monaco-dialog-message-body.dialog-message-body'));
501
- this.options.renderBody(customBody);
502
- for (const el of this.messageContainer.querySelectorAll('a')) {
503
- el.tabIndex = 0;
504
- }
505
- }
506
- if (this.options.inputs) {
507
- this.inputs = this.options.inputs.map(input => {
508
- const inputRowElement = this.messageContainer.appendChild($('.dialog-message-input'));
509
- const inputBox = this._register(( new InputBox(inputRowElement, undefined, {
510
- placeholder: input.placeholder,
511
- type: input.type ?? 'text',
512
- inputBoxStyles: options.inputBoxStyles
513
- })));
514
- if (input.value) {
515
- inputBox.value = input.value;
516
- }
517
- return inputBox;
518
- });
519
- }
520
- else {
521
- this.inputs = [];
522
- }
523
- if (this.options.checkboxLabel) {
524
- const checkboxRowElement = this.messageContainer.appendChild($('.dialog-checkbox-row'));
525
- const checkbox = this.checkbox = this._register(( new Checkbox(
526
- this.options.checkboxLabel,
527
- !!this.options.checkboxChecked,
528
- options.checkboxStyles
529
- )));
530
- checkboxRowElement.appendChild(checkbox.domNode);
531
- const checkboxMessageElement = checkboxRowElement.appendChild($('.dialog-checkbox-message'));
532
- checkboxMessageElement.innerText = this.options.checkboxLabel;
533
- this._register(addDisposableListener(checkboxMessageElement, EventType.CLICK, () => checkbox.checked = !checkbox.checked));
534
- }
535
- const toolbarRowElement = this.element.appendChild($('.dialog-toolbar-row'));
536
- this.toolbarContainer = toolbarRowElement.appendChild($('.dialog-toolbar'));
537
- this.applyStyles();
538
- }
539
- getIconAriaLabel() {
540
- const typeLabel = ( localize('dialogInfoMessage', 'Info'));
541
- return typeLabel;
542
- }
543
- updateMessage(message) {
544
- this.messageDetailElement.innerText = message;
545
- }
546
- async show() {
547
- this.focusToReturn = document.activeElement;
548
- return ( new Promise((resolve) => {
549
- clearNode(this.buttonsContainer);
550
- const buttonBar = this.buttonBar = this._register(( new ButtonBar(this.buttonsContainer)));
551
- const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
552
- buttonMap.forEach((entry, index) => {
553
- const primary = buttonMap[index].index === 0;
554
- const button = this.options.buttonDetails ? this._register(buttonBar.addButtonWithDescription({ title: true, secondary: !primary, ...this.buttonStyles })) : this._register(buttonBar.addButton({ title: true, secondary: !primary, ...this.buttonStyles }));
555
- button.label = mnemonicButtonLabel(buttonMap[index].label, true);
556
- if (button instanceof ButtonWithDescription) {
557
- button.description = this.options.buttonDetails[buttonMap[index].index];
558
- }
559
- this._register(button.onDidClick(e => {
560
- if (e) {
561
- EventHelper.stop(e);
562
- }
563
- resolve({
564
- button: buttonMap[index].index,
565
- checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
566
- values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
567
- });
568
- }));
569
- });
570
- this._register(addDisposableListener(window, 'keydown', e => {
571
- const evt = ( new StandardKeyboardEvent(e));
572
- if (evt.equals(512 )) {
573
- evt.preventDefault();
574
- }
575
- if (evt.equals(3 )) {
576
- if (this.inputs.some(input => input.hasFocus())) {
577
- EventHelper.stop(e);
578
- resolve({
579
- button: buttonMap.find(button => button.index !== this.options.cancelId)?.index ?? 0,
580
- checkboxChecked: this.checkbox ? this.checkbox.checked : undefined,
581
- values: this.inputs.length > 0 ? this.inputs.map(input => input.value) : undefined
582
- });
583
- }
584
- return;
585
- }
586
- if (evt.equals(10 )) {
587
- return;
588
- }
589
- let eventHandled = false;
590
- if (evt.equals(2 ) || evt.equals(17 ) || evt.equals(1024 | 2 ) || evt.equals(15 )) {
591
- const focusableElements = [];
592
- let focusedIndex = -1;
593
- if (this.messageContainer) {
594
- const links = this.messageContainer.querySelectorAll('a');
595
- for (const link of links) {
596
- focusableElements.push(link);
597
- if (link === document.activeElement) {
598
- focusedIndex = focusableElements.length - 1;
599
- }
600
- }
601
- }
602
- for (const input of this.inputs) {
603
- focusableElements.push(input);
604
- if (input.hasFocus()) {
605
- focusedIndex = focusableElements.length - 1;
606
- }
607
- }
608
- if (this.checkbox) {
609
- focusableElements.push(this.checkbox);
610
- if (this.checkbox.hasFocus()) {
611
- focusedIndex = focusableElements.length - 1;
612
- }
613
- }
614
- if (this.buttonBar) {
615
- for (const button of this.buttonBar.buttons) {
616
- focusableElements.push(button);
617
- if (button.hasFocus()) {
618
- focusedIndex = focusableElements.length - 1;
619
- }
620
- }
621
- }
622
- if (evt.equals(2 ) || evt.equals(17 )) {
623
- if (focusedIndex === -1) {
624
- focusedIndex = 0;
625
- }
626
- const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
627
- focusableElements[newFocusedIndex].focus();
628
- }
629
- else {
630
- if (focusedIndex === -1) {
631
- focusedIndex = focusableElements.length;
632
- }
633
- let newFocusedIndex = focusedIndex - 1;
634
- if (newFocusedIndex === -1) {
635
- newFocusedIndex = focusableElements.length - 1;
636
- }
637
- focusableElements[newFocusedIndex].focus();
638
- }
639
- eventHandled = true;
640
- }
641
- if (eventHandled) {
642
- EventHelper.stop(e, true);
643
- }
644
- else if (this.options.keyEventProcessor) {
645
- this.options.keyEventProcessor(evt);
646
- }
647
- }, true));
648
- this._register(addDisposableListener(window, 'keyup', e => {
649
- EventHelper.stop(e, true);
650
- const evt = ( new StandardKeyboardEvent(e));
651
- if (!this.options.disableCloseAction && evt.equals(9 )) {
652
- resolve({
653
- button: this.options.cancelId || 0,
654
- checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
655
- });
656
- }
657
- }, true));
658
- this._register(addDisposableListener(this.element, 'focusout', e => {
659
- if (!!e.relatedTarget && !!this.element) {
660
- if (!isAncestor(e.relatedTarget, this.element)) {
661
- this.focusToReturn = e.relatedTarget;
662
- if (e.target) {
663
- e.target.focus();
664
- EventHelper.stop(e, true);
665
- }
666
- }
667
- }
668
- }, false));
669
- const spinModifierClassName = 'codicon-modifier-spin';
670
- this.iconElement.classList.remove(...ThemeIcon.asClassNameArray(Codicon.dialogError), ...ThemeIcon.asClassNameArray(Codicon.dialogWarning), ...ThemeIcon.asClassNameArray(Codicon.dialogInfo), ...ThemeIcon.asClassNameArray(Codicon.loading), spinModifierClassName);
671
- if (this.options.icon) {
672
- this.iconElement.classList.add(...ThemeIcon.asClassNameArray(this.options.icon));
673
- }
674
- else {
675
- switch (this.options.type) {
676
- case 'error':
677
- this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogError));
678
- break;
679
- case 'warning':
680
- this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogWarning));
681
- break;
682
- case 'pending':
683
- this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.loading), spinModifierClassName);
684
- break;
685
- case 'none':
686
- case 'info':
687
- case 'question':
688
- default:
689
- this.iconElement.classList.add(...ThemeIcon.asClassNameArray(Codicon.dialogInfo));
690
- break;
691
- }
692
- }
693
- if (!this.options.disableCloseAction) {
694
- const actionBar = this._register(( new ActionBar(this.toolbarContainer, {})));
695
- const action = this._register(( new Action('dialog.close', ( localize('dialogClose', "Close Dialog")), ThemeIcon.asClassName(Codicon.dialogClose), true, async () => {
696
- resolve({
697
- button: this.options.cancelId || 0,
698
- checkboxChecked: this.checkbox ? this.checkbox.checked : undefined
699
- });
700
- })));
701
- actionBar.push(action, { icon: true, label: false });
702
- }
703
- this.applyStyles();
704
- this.element.setAttribute('aria-modal', 'true');
705
- this.element.setAttribute('aria-labelledby', 'monaco-dialog-icon monaco-dialog-message-text');
706
- this.element.setAttribute('aria-describedby', 'monaco-dialog-icon monaco-dialog-message-text monaco-dialog-message-detail monaco-dialog-message-body');
707
- show(this.element);
708
- if (this.inputs.length > 0) {
709
- this.inputs[0].focus();
710
- this.inputs[0].select();
711
- }
712
- else {
713
- buttonMap.forEach((value, index) => {
714
- if (value.index === 0) {
715
- buttonBar.buttons[index].focus();
716
- }
717
- });
718
- }
719
- }));
720
- }
721
- applyStyles() {
722
- const style = this.options.dialogStyles;
723
- const fgColor = style.dialogForeground;
724
- const bgColor = style.dialogBackground;
725
- const shadowColor = style.dialogShadow ? `0 0px 8px ${style.dialogShadow}` : '';
726
- const border = style.dialogBorder ? `1px solid ${style.dialogBorder}` : '';
727
- const linkFgColor = style.textLinkForeground;
728
- this.shadowElement.style.boxShadow = shadowColor;
729
- this.element.style.color = fgColor ?? '';
730
- this.element.style.backgroundColor = bgColor ?? '';
731
- this.element.style.border = border;
732
- if (linkFgColor) {
733
- for (const el of this.messageContainer.getElementsByTagName('a')) {
734
- el.style.color = linkFgColor;
735
- }
736
- }
737
- let color;
738
- switch (this.options.type) {
739
- case 'error':
740
- color = style.errorIconForeground;
741
- break;
742
- case 'warning':
743
- color = style.warningIconForeground;
744
- break;
745
- default:
746
- color = style.infoIconForeground;
747
- break;
748
- }
749
- if (color) {
750
- this.iconElement.style.color = color;
751
- }
752
- }
753
- dispose() {
754
- super.dispose();
755
- if (this.modalElement) {
756
- this.modalElement.remove();
757
- this.modalElement = undefined;
758
- }
759
- if (this.focusToReturn && isAncestor(this.focusToReturn, document.body)) {
760
- this.focusToReturn.focus();
761
- this.focusToReturn = undefined;
762
- }
763
- }
764
- rearrangeButtons(buttons, cancelId) {
765
- const buttonMap = buttons.map((label, index) => ({ label, index }));
766
- if (buttons.length < 2) {
767
- return buttonMap;
768
- }
769
- if (isMacintosh || isLinux) {
770
- if (typeof cancelId === 'number' && buttonMap[cancelId]) {
771
- const cancelButton = buttonMap.splice(cancelId, 1)[0];
772
- buttonMap.splice(1, 0, cancelButton);
773
- }
774
- buttonMap.reverse();
775
- }
776
- else if (isWindows) {
777
- if (typeof cancelId === 'number' && buttonMap[cancelId]) {
778
- const cancelButton = buttonMap.splice(cancelId, 1)[0];
779
- buttonMap.push(cancelButton);
780
- }
781
- }
782
- return buttonMap;
783
- }
784
- }
785
- let BrowserDialogHandler = class BrowserDialogHandler extends AbstractDialogHandler {
786
- constructor(logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
787
- super();
788
- this.logService = logService;
789
- this.layoutService = layoutService;
790
- this.keybindingService = keybindingService;
791
- this.instantiationService = instantiationService;
792
- this.productService = productService;
793
- this.clipboardService = clipboardService;
794
- this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
795
- }
796
- async prompt(prompt) {
797
- this.logService.trace('DialogService#prompt', prompt.message);
798
- const buttons = this.getPromptButtons(prompt);
799
- const { button, checkboxChecked } = await this.doShow(prompt.type, prompt.message, buttons, prompt.detail, prompt.cancelButton ? buttons.length - 1 : -1 , prompt.checkbox, undefined, typeof prompt?.custom === 'object' ? prompt.custom : undefined);
800
- return this.getPromptResult(prompt, button, checkboxChecked);
801
- }
802
- async confirm(confirmation) {
803
- this.logService.trace('DialogService#confirm', confirmation.message);
804
- const buttons = this.getConfirmationButtons(confirmation);
805
- const { button, checkboxChecked } = await this.doShow(confirmation.type ?? 'question', confirmation.message, buttons, confirmation.detail, buttons.length - 1, confirmation.checkbox, undefined, typeof confirmation?.custom === 'object' ? confirmation.custom : undefined);
806
- return { confirmed: button === 0, checkboxChecked };
807
- }
808
- async input(input) {
809
- this.logService.trace('DialogService#input', input.message);
810
- const buttons = this.getInputButtons(input);
811
- const { button, checkboxChecked, values } = await this.doShow(input.type ?? 'question', input.message, buttons, input.detail, buttons.length - 1, input?.checkbox, input.inputs);
812
- return { confirmed: button === 0, checkboxChecked, values };
813
- }
814
- async about() {
815
- const detailString = (useAgo) => {
816
- return ( localize(
817
- 'aboutDetail',
818
- "Version: {0}\nCommit: {1}\nDate: {2}\nBrowser: {3}",
819
- this.productService.version || 'Unknown',
820
- this.productService.commit || 'Unknown',
821
- this.productService.date ? `${this.productService.date}${useAgo ? ' (' + fromNow(( new Date(this.productService.date)), true) + ')' : ''}` : 'Unknown',
822
- navigator.userAgent
823
- ));
824
- };
825
- const detail = detailString(true);
826
- const detailToCopy = detailString(false);
827
- const { button } = await this.doShow(Severity.Info, this.productService.nameLong, [
828
- ( localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy")),
829
- ( localize('ok', "OK"))
830
- ], detail, 1);
831
- if (button === 0) {
832
- this.clipboardService.writeText(detailToCopy);
833
- }
834
- }
835
- async doShow(type, message, buttons, detail, cancelId, checkbox, inputs, customOptions) {
836
- const dialogDisposables = ( new DisposableStore());
837
- const renderBody = customOptions ? (parent) => {
838
- parent.classList.add(...(customOptions.classes || []));
839
- customOptions.markdownDetails?.forEach(markdownDetail => {
840
- const result = this.markdownRenderer.render(markdownDetail.markdown);
841
- parent.appendChild(result.element);
842
- result.element.classList.add(...(markdownDetail.classes || []));
843
- dialogDisposables.add(result);
844
- });
845
- } : undefined;
846
- const dialog = ( new Dialog(this.layoutService.container, message, buttons, {
847
- detail,
848
- cancelId,
849
- type: this.getDialogType(type),
850
- keyEventProcessor: (event) => {
851
- const resolved = this.keybindingService.softDispatch(event, this.layoutService.container);
852
- if (resolved?.commandId) {
853
- if (BrowserDialogHandler.ALLOWABLE_COMMANDS.indexOf(resolved.commandId) === -1) {
854
- EventHelper.stop(event, true);
855
- }
856
- }
857
- },
858
- renderBody,
859
- icon: customOptions?.icon,
860
- disableCloseAction: customOptions?.disableCloseAction,
861
- buttonDetails: customOptions?.buttonDetails,
862
- checkboxLabel: checkbox?.label,
863
- checkboxChecked: checkbox?.checked,
864
- inputs,
865
- buttonStyles: defaultButtonStyles,
866
- checkboxStyles: defaultCheckboxStyles,
867
- inputBoxStyles: defaultInputBoxStyles,
868
- dialogStyles: defaultDialogStyles
869
- }));
870
- dialogDisposables.add(dialog);
871
- const result = await dialog.show();
872
- dialogDisposables.dispose();
873
- return result;
874
- }
875
- };
876
- BrowserDialogHandler.ALLOWABLE_COMMANDS = [
877
- 'copy',
878
- 'cut',
879
- 'editor.action.selectAll',
880
- 'editor.action.clipboardCopyAction',
881
- 'editor.action.clipboardCutAction',
882
- 'editor.action.clipboardPasteAction'
883
- ];
884
- BrowserDialogHandler = ( __decorate([
885
- ( __param(0, ILogService)),
886
- ( __param(1, ILayoutService)),
887
- ( __param(2, IKeybindingService)),
888
- ( __param(3, IInstantiationService)),
889
- ( __param(4, IProductService)),
890
- ( __param(5, IClipboardService))
891
- ], BrowserDialogHandler));
892
- let DialogHandlerContribution = class DialogHandlerContribution extends Disposable {
893
- constructor(dialogService, logService, layoutService, keybindingService, instantiationService, productService, clipboardService) {
894
- super();
895
- this.dialogService = dialogService;
896
- this.impl = ( new BrowserDialogHandler(
897
- logService,
898
- layoutService,
899
- keybindingService,
900
- instantiationService,
901
- productService,
902
- clipboardService
903
- ));
904
- this.model = this.dialogService.model;
905
- this._register(this.model.onWillShowDialog(() => {
906
- if (!this.currentDialog) {
907
- this.processDialogs();
908
- }
909
- }));
910
- this.processDialogs();
911
- }
912
- async processDialogs() {
913
- while (this.model.dialogs.length) {
914
- this.currentDialog = this.model.dialogs[0];
915
- let result = undefined;
916
- if (this.currentDialog.args.confirmArgs) {
917
- const args = this.currentDialog.args.confirmArgs;
918
- result = await this.impl.confirm(args.confirmation);
919
- }
920
- else if (this.currentDialog.args.inputArgs) {
921
- const args = this.currentDialog.args.inputArgs;
922
- result = await this.impl.input(args.input);
923
- }
924
- else if (this.currentDialog.args.promptArgs) {
925
- const args = this.currentDialog.args.promptArgs;
926
- result = await this.impl.prompt(args.prompt);
927
- }
928
- else {
929
- await this.impl.about();
930
- }
931
- this.currentDialog.close(result);
932
- this.currentDialog = undefined;
933
- }
934
- }
935
- };
936
- DialogHandlerContribution = ( __decorate([
937
- ( __param(0, IDialogService)),
938
- ( __param(1, ILogService)),
939
- ( __param(2, ILayoutService)),
940
- ( __param(3, IKeybindingService)),
941
- ( __param(4, IInstantiationService)),
942
- ( __param(5, IProductService)),
943
- ( __param(6, IClipboardService))
944
- ], DialogHandlerContribution));
945
- export { DialogHandlerContribution as D };