@codingame/monaco-vscode-views-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.
Files changed (44) hide show
  1. package/assets/index-no-csp.html +4 -0
  2. package/assets/index.html +5 -1
  3. package/index.d.ts +2 -2
  4. package/index.js +2 -2
  5. package/package.json +11 -9
  6. package/tools/editor.js +1 -1
  7. package/views.d.ts +9 -4
  8. package/views.js +32 -10
  9. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +2 -2
  10. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +1 -1
  11. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +692 -0
  12. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +240 -0
  13. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +77 -0
  14. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
  15. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +71 -0
  16. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +346 -0
  17. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +96 -0
  18. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +145 -0
  19. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +103 -0
  20. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +399 -0
  21. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +196 -0
  22. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +41 -0
  23. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +128 -0
  24. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +6 -0
  25. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +611 -0
  26. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +158 -0
  27. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +262 -0
  28. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +173 -0
  29. package/vscode/src/vs/workbench/contrib/webview/browser/webview.contribution.js +79 -0
  30. package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +1 -1
  31. package/vscode/src/vs/workbench/services/history/browser/historyService.js +3 -0
  32. package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -3
  33. package/vscode/src/vs/base/browser/ui/tree/treeDefaults.js +0 -16
  34. package/vscode/src/vs/workbench/browser/parts/views/checkbox.js +0 -107
  35. package/vscode/src/vs/workbench/browser/parts/views/media/views.css.js +0 -6
  36. package/vscode/src/vs/workbench/browser/parts/views/treeView.js +0 -1604
  37. package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +0 -6
  38. package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +0 -390
  39. package/vscode/src/vs/workbench/contrib/languageDetection/browser/languageDetection.contribution.js +0 -157
  40. package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +0 -5
  41. package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +0 -6
  42. package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +0 -217
  43. package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +0 -91
  44. package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +0 -1837
@@ -1,1837 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import './media/tunnelView.css.js';
3
- import * as nls from 'monaco-editor/esm/vs/nls.js';
4
- import * as dom from 'monaco-editor/esm/vs/base/browser/dom.js';
5
- import { IViewsService, IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views';
6
- import { IKeybindingService } from 'monaco-editor/esm/vs/platform/keybinding/common/keybinding.js';
7
- import { IContextViewService, IContextMenuService } from 'monaco-editor/esm/vs/platform/contextview/browser/contextView.js';
8
- import { RawContextKey, ContextKeyExpr, IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
9
- import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
10
- import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
11
- import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
12
- import { IQuickInputService } from 'monaco-editor/esm/vs/platform/quickinput/common/quickInput.js';
13
- import { CommandsRegistry, ICommandService } from 'monaco-editor/esm/vs/platform/commands/common/commands.js';
14
- import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
15
- import { DisposableStore, toDisposable, Disposable, dispose } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
16
- import { ActionBar } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionbar.js';
17
- import { IconLabel } from 'monaco-editor/esm/vs/base/browser/ui/iconLabel/iconLabel.js';
18
- import { ActionRunner } from 'monaco-editor/esm/vs/base/common/actions.js';
19
- import { MenuId, MenuRegistry, IMenuService } from 'monaco-editor/esm/vs/platform/actions/common/actions.js';
20
- import { createActionViewItem, createAndFillInActionBarActions } from 'monaco-editor/esm/vs/platform/actions/browser/menuEntryActionViewItem.js';
21
- import { TunnelType, TUNNEL_VIEW_ID, TunnelEditId, IRemoteExplorerService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteExplorerService';
22
- import { IClipboardService } from 'monaco-editor/esm/vs/platform/clipboard/common/clipboardService.js';
23
- import { Severity, INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
24
- import { InputBox } from 'monaco-editor/esm/vs/base/browser/ui/inputbox/inputBox.js';
25
- import { createSingleCallFunction } from 'monaco-editor/esm/vs/base/common/functional.js';
26
- import { IThemeService } from 'monaco-editor/esm/vs/platform/theme/common/themeService.js';
27
- import { ThemeIcon } from 'monaco-editor/esm/vs/base/common/themables.js';
28
- import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
29
- import { URI } from 'monaco-editor/esm/vs/base/common/uri.js';
30
- import { TunnelProtocol, isLocalhost, isAllInterfaces, TunnelPrivacyId, ITunnelService } from 'vscode/vscode/vs/platform/tunnel/common/tunnel';
31
- import { KeybindingsRegistry } from 'monaco-editor/esm/vs/platform/keybinding/common/keybindingsRegistry.js';
32
- import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
33
- import { ActionViewItem } from 'monaco-editor/esm/vs/base/browser/ui/actionbar/actionViewItems.js';
34
- import { labelPortIcon, forwardPortIcon, stopForwardIcon, copyAddressIcon, openBrowserIcon, openPreviewIcon, forwardedPortWithProcessIcon, forwardedPortWithoutProcessIcon, privatePortIcon } from './remoteIcons.js';
35
- import { IExternalUriOpenerService } from 'vscode/vscode/vs/workbench/contrib/externalUriOpener/common/externalUriOpenerService';
36
- import { CancellationTokenSource } from 'monaco-editor/esm/vs/base/common/cancellation.js';
37
- import { isMacintosh } from 'monaco-editor/esm/vs/base/common/platform.js';
38
- import { WorkbenchTable } from 'monaco-editor/esm/vs/platform/list/browser/listService.js';
39
- import { Button } from 'monaco-editor/esm/vs/base/browser/ui/button/button.js';
40
- import { registerColor } from 'monaco-editor/esm/vs/platform/theme/common/colorRegistry.js';
41
- import { MarkdownString } from 'monaco-editor/esm/vs/base/common/htmlContent.js';
42
- import { IHoverService } from 'vscode/vscode/vs/workbench/services/hover/browser/hover';
43
- import { STATUS_BAR_REMOTE_ITEM_BACKGROUND } from 'vscode/vscode/vs/workbench/common/theme';
44
- import { Codicon } from 'monaco-editor/esm/vs/base/common/codicons.js';
45
- import { defaultButtonStyles, defaultInputBoxStyles } from 'monaco-editor/esm/vs/platform/theme/browser/defaultStyles.js';
46
- import { makeAddress, forwardedPortsViewEnabled, parseAddress, TunnelCloseReason, mapHasAddressLocalhostOrAllInterfaces } from 'vscode/vscode/vs/workbench/services/remote/common/tunnelModel';
47
-
48
- var TunnelPanel_1;
49
- const openPreviewEnabledContext = ( new RawContextKey('openPreviewEnabled', false));
50
- class TunnelTreeVirtualDelegate {
51
- constructor(remoteExplorerService) {
52
- this.remoteExplorerService = remoteExplorerService;
53
- this.headerRowHeight = 22;
54
- }
55
- getHeight(row) {
56
- return (row.tunnelType === TunnelType.Add && !this.remoteExplorerService.getEditableData(undefined)) ? 30 : 22;
57
- }
58
- }
59
- function emptyCell(item) {
60
- return { label: '', tunnel: item, editId: TunnelEditId.None, tooltip: '' };
61
- }
62
- class IconColumn {
63
- constructor() {
64
- this.label = '';
65
- this.tooltip = '';
66
- this.weight = 1;
67
- this.minimumWidth = 40;
68
- this.maximumWidth = 40;
69
- this.templateId = 'actionbar';
70
- }
71
- project(row) {
72
- if (row.tunnelType === TunnelType.Add) {
73
- return emptyCell(row);
74
- }
75
- const icon = row.processDescription ? forwardedPortWithProcessIcon : forwardedPortWithoutProcessIcon;
76
- let tooltip = '';
77
- if (row instanceof TunnelItem) {
78
- tooltip = `${row.iconTooltip} ${row.tooltipPostfix}`;
79
- }
80
- return {
81
- label: '', icon, tunnel: row, editId: TunnelEditId.None, tooltip
82
- };
83
- }
84
- }
85
- class PortColumn {
86
- constructor() {
87
- this.label = ( nls.localizeWithPath(
88
- 'vs/workbench/contrib/remote/browser/tunnelView',
89
- 'tunnel.portColumn.label',
90
- "Port"
91
- ));
92
- this.tooltip = ( nls.localizeWithPath(
93
- 'vs/workbench/contrib/remote/browser/tunnelView',
94
- 'tunnel.portColumn.tooltip',
95
- "The label and remote port number of the forwarded port."
96
- ));
97
- this.weight = 1;
98
- this.templateId = 'actionbar';
99
- }
100
- project(row) {
101
- const isAdd = row.tunnelType === TunnelType.Add;
102
- const label = row.label;
103
- let tooltip = '';
104
- if (row instanceof TunnelItem && !isAdd) {
105
- tooltip = `${row.portTooltip} ${row.tooltipPostfix}`;
106
- }
107
- else {
108
- tooltip = label;
109
- }
110
- return {
111
- label, tunnel: row, menuId: MenuId.TunnelPortInline,
112
- editId: row.tunnelType === TunnelType.Add ? TunnelEditId.New : TunnelEditId.Label, tooltip
113
- };
114
- }
115
- }
116
- class LocalAddressColumn {
117
- constructor() {
118
- this.label = ( nls.localizeWithPath(
119
- 'vs/workbench/contrib/remote/browser/tunnelView',
120
- 'tunnel.addressColumn.label',
121
- "Forwarded Address"
122
- ));
123
- this.tooltip = ( nls.localizeWithPath(
124
- 'vs/workbench/contrib/remote/browser/tunnelView',
125
- 'tunnel.addressColumn.tooltip',
126
- "The address that the forwarded port is available at."
127
- ));
128
- this.weight = 1;
129
- this.templateId = 'actionbar';
130
- }
131
- project(row) {
132
- if (row.tunnelType === TunnelType.Add) {
133
- return emptyCell(row);
134
- }
135
- const label = row.localAddress ?? '';
136
- let tooltip = label;
137
- if (row instanceof TunnelItem) {
138
- tooltip = row.tooltipPostfix;
139
- }
140
- return {
141
- label,
142
- menuId: MenuId.TunnelLocalAddressInline,
143
- tunnel: row,
144
- editId: TunnelEditId.LocalPort,
145
- tooltip,
146
- markdownTooltip: label ? LocalAddressColumn.getHoverText(label) : undefined
147
- };
148
- }
149
- static getHoverText(localAddress) {
150
- return function (configurationService) {
151
- const editorConf = configurationService.getValue('editor');
152
- let clickLabel = '';
153
- if (editorConf.multiCursorModifier === 'ctrlCmd') {
154
- if (isMacintosh) {
155
- clickLabel = ( nls.localizeWithPath(
156
- 'vs/workbench/contrib/remote/browser/tunnelView',
157
- 'portsLink.followLinkAlt.mac',
158
- "option + click"
159
- ));
160
- }
161
- else {
162
- clickLabel = ( nls.localizeWithPath(
163
- 'vs/workbench/contrib/remote/browser/tunnelView',
164
- 'portsLink.followLinkAlt',
165
- "alt + click"
166
- ));
167
- }
168
- }
169
- else {
170
- if (isMacintosh) {
171
- clickLabel = ( nls.localizeWithPath(
172
- 'vs/workbench/contrib/remote/browser/tunnelView',
173
- 'portsLink.followLinkCmd',
174
- "cmd + click"
175
- ));
176
- }
177
- else {
178
- clickLabel = ( nls.localizeWithPath(
179
- 'vs/workbench/contrib/remote/browser/tunnelView',
180
- 'portsLink.followLinkCtrl',
181
- "ctrl + click"
182
- ));
183
- }
184
- }
185
- const markdown = ( new MarkdownString('', true));
186
- const uri = localAddress.startsWith('http') ? localAddress : `http://${localAddress}`;
187
- return markdown.appendLink(uri, 'Follow link').appendMarkdown(` (${clickLabel})`);
188
- };
189
- }
190
- }
191
- class RunningProcessColumn {
192
- constructor() {
193
- this.label = ( nls.localizeWithPath(
194
- 'vs/workbench/contrib/remote/browser/tunnelView',
195
- 'tunnel.processColumn.label',
196
- "Running Process"
197
- ));
198
- this.tooltip = ( nls.localizeWithPath(
199
- 'vs/workbench/contrib/remote/browser/tunnelView',
200
- 'tunnel.processColumn.tooltip',
201
- "The command line of the process that is using the port."
202
- ));
203
- this.weight = 2;
204
- this.templateId = 'actionbar';
205
- }
206
- project(row) {
207
- if (row.tunnelType === TunnelType.Add) {
208
- return emptyCell(row);
209
- }
210
- const label = row.processDescription ?? '';
211
- return { label, tunnel: row, editId: TunnelEditId.None, tooltip: row instanceof TunnelItem ? row.processTooltip : '' };
212
- }
213
- }
214
- class OriginColumn {
215
- constructor() {
216
- this.label = ( nls.localizeWithPath(
217
- 'vs/workbench/contrib/remote/browser/tunnelView',
218
- 'tunnel.originColumn.label',
219
- "Origin"
220
- ));
221
- this.tooltip = ( nls.localizeWithPath(
222
- 'vs/workbench/contrib/remote/browser/tunnelView',
223
- 'tunnel.originColumn.tooltip',
224
- "The source that a forwarded port originates from. Can be an extension, user forwarded, statically forwarded, or automatically forwarded."
225
- ));
226
- this.weight = 1;
227
- this.templateId = 'actionbar';
228
- }
229
- project(row) {
230
- if (row.tunnelType === TunnelType.Add) {
231
- return emptyCell(row);
232
- }
233
- const label = row.source.description;
234
- const tooltip = `${row instanceof TunnelItem ? row.originTooltip : ''}. ${row instanceof TunnelItem ? row.tooltipPostfix : ''}`;
235
- return { label, menuId: MenuId.TunnelOriginInline, tunnel: row, editId: TunnelEditId.None, tooltip };
236
- }
237
- }
238
- class PrivacyColumn {
239
- constructor() {
240
- this.label = ( nls.localizeWithPath(
241
- 'vs/workbench/contrib/remote/browser/tunnelView',
242
- 'tunnel.privacyColumn.label',
243
- "Visibility"
244
- ));
245
- this.tooltip = ( nls.localizeWithPath(
246
- 'vs/workbench/contrib/remote/browser/tunnelView',
247
- 'tunnel.privacyColumn.tooltip',
248
- "The availability of the forwarded port."
249
- ));
250
- this.weight = 1;
251
- this.templateId = 'actionbar';
252
- }
253
- project(row) {
254
- if (row.tunnelType === TunnelType.Add) {
255
- return emptyCell(row);
256
- }
257
- const label = row.privacy?.label;
258
- let tooltip = '';
259
- if (row instanceof TunnelItem) {
260
- tooltip = `${row.privacy.label} ${row.tooltipPostfix}`;
261
- }
262
- return { label, tunnel: row, icon: { id: row.privacy.themeIcon }, editId: TunnelEditId.None, tooltip };
263
- }
264
- }
265
- let ActionBarRenderer = class ActionBarRenderer extends Disposable {
266
- constructor(instantiationService, contextKeyService, menuService, contextViewService, remoteExplorerService, commandService, configurationService, hoverService) {
267
- super();
268
- this.instantiationService = instantiationService;
269
- this.contextKeyService = contextKeyService;
270
- this.menuService = menuService;
271
- this.contextViewService = contextViewService;
272
- this.remoteExplorerService = remoteExplorerService;
273
- this.commandService = commandService;
274
- this.configurationService = configurationService;
275
- this.hoverService = hoverService;
276
- this.templateId = 'actionbar';
277
- }
278
- set actionRunner(actionRunner) {
279
- this._actionRunner = actionRunner;
280
- }
281
- renderTemplate(container) {
282
- const cell = dom.append(container, dom.$('.ports-view-actionbar-cell'));
283
- const icon = dom.append(cell, dom.$('.ports-view-actionbar-cell-icon'));
284
- const label = ( new IconLabel(cell, {
285
- supportHighlights: true,
286
- hoverDelegate: {
287
- showHover: (options) => this.hoverService.showHover(options),
288
- delay: this.configurationService.getValue('workbench.hover.delay')
289
- }
290
- }));
291
- const actionsContainer = dom.append(cell, dom.$('.actions'));
292
- const actionBar = ( new ActionBar(actionsContainer, {
293
- actionViewItemProvider: createActionViewItem.bind(undefined, this.instantiationService)
294
- }));
295
- return { label, icon, actionBar, container: cell, elementDisposable: Disposable.None };
296
- }
297
- renderElement(element, index, templateData) {
298
- templateData.actionBar.clear();
299
- templateData.icon.className = 'ports-view-actionbar-cell-icon';
300
- templateData.icon.style.display = 'none';
301
- templateData.label.setLabel('');
302
- templateData.label.element.style.display = 'none';
303
- templateData.container.style.height = '22px';
304
- if (templateData.button) {
305
- templateData.button.element.style.display = 'none';
306
- templateData.button.dispose();
307
- }
308
- templateData.container.style.paddingLeft = '0px';
309
- templateData.elementDisposable.dispose();
310
- let editableData;
311
- if (element.editId === TunnelEditId.New && (editableData = this.remoteExplorerService.getEditableData(undefined))) {
312
- this.renderInputBox(templateData.container, editableData);
313
- }
314
- else {
315
- editableData = this.remoteExplorerService.getEditableData(element.tunnel, element.editId);
316
- if (editableData) {
317
- this.renderInputBox(templateData.container, editableData);
318
- }
319
- else if ((element.tunnel.tunnelType === TunnelType.Add) && (element.menuId === MenuId.TunnelPortInline)) {
320
- this.renderButton(element, templateData);
321
- }
322
- else {
323
- this.renderActionBarItem(element, templateData);
324
- }
325
- }
326
- }
327
- renderButton(element, templateData) {
328
- templateData.container.style.paddingLeft = '7px';
329
- templateData.container.style.height = '28px';
330
- templateData.button = this._register(( new Button(templateData.container, defaultButtonStyles)));
331
- templateData.button.label = element.label;
332
- templateData.button.element.title = element.tooltip;
333
- this._register(templateData.button.onDidClick(() => {
334
- this.commandService.executeCommand(ForwardPortAction.INLINE_ID);
335
- }));
336
- }
337
- tunnelContext(tunnel) {
338
- let context;
339
- if (tunnel instanceof TunnelItem) {
340
- context = tunnel.strip();
341
- }
342
- if (!context) {
343
- context = {
344
- tunnelType: tunnel.tunnelType,
345
- remoteHost: tunnel.remoteHost,
346
- remotePort: tunnel.remotePort,
347
- localAddress: tunnel.localAddress,
348
- protocol: tunnel.protocol,
349
- localUri: tunnel.localUri,
350
- localPort: tunnel.localPort,
351
- name: tunnel.name,
352
- closeable: tunnel.closeable,
353
- source: tunnel.source,
354
- privacy: tunnel.privacy,
355
- processDescription: tunnel.processDescription,
356
- label: tunnel.label
357
- };
358
- }
359
- return context;
360
- }
361
- renderActionBarItem(element, templateData) {
362
- templateData.label.element.style.display = 'flex';
363
- templateData.label.setLabel(element.label, undefined, {
364
- title: element.markdownTooltip ?
365
- { markdown: element.markdownTooltip(this.configurationService), markdownNotSupportedFallback: element.tooltip }
366
- : element.tooltip,
367
- extraClasses: element.menuId === MenuId.TunnelLocalAddressInline ? ['ports-view-actionbar-cell-localaddress'] : undefined
368
- });
369
- templateData.actionBar.context = this.tunnelContext(element.tunnel);
370
- templateData.container.style.paddingLeft = '10px';
371
- const context = [
372
- ['view', TUNNEL_VIEW_ID],
373
- [TunnelTypeContextKey.key, element.tunnel.tunnelType],
374
- [TunnelCloseableContextKey.key, element.tunnel.closeable],
375
- [TunnelPrivacyContextKey.key, element.tunnel.privacy.id],
376
- [TunnelProtocolContextKey.key, element.tunnel.protocol]
377
- ];
378
- const contextKeyService = this.contextKeyService.createOverlay(context);
379
- const disposableStore = ( new DisposableStore());
380
- templateData.elementDisposable = disposableStore;
381
- if (element.menuId) {
382
- const menu = disposableStore.add(this.menuService.createMenu(element.menuId, contextKeyService));
383
- let actions = [];
384
- createAndFillInActionBarActions(menu, { shouldForwardArgs: true }, actions);
385
- if (actions) {
386
- const labelActions = actions.filter(action => action.id.toLowerCase().indexOf('label') >= 0);
387
- if (labelActions.length > 1) {
388
- labelActions.sort((a, b) => a.label.length - b.label.length);
389
- labelActions.pop();
390
- actions = actions.filter(action => labelActions.indexOf(action) < 0);
391
- }
392
- templateData.actionBar.push(actions, { icon: true, label: false });
393
- if (this._actionRunner) {
394
- templateData.actionBar.actionRunner = this._actionRunner;
395
- }
396
- }
397
- }
398
- if (element.icon) {
399
- templateData.icon.className = `ports-view-actionbar-cell-icon ${ThemeIcon.asClassName(element.icon)}`;
400
- templateData.icon.title = element.tooltip;
401
- templateData.icon.style.display = 'inline';
402
- }
403
- }
404
- renderInputBox(container, editableData) {
405
- if (this.inputDone) {
406
- this.inputDone(false, false);
407
- this.inputDone = undefined;
408
- }
409
- container.style.paddingLeft = '5px';
410
- const value = editableData.startingValue || '';
411
- const inputBox = ( new InputBox(container, this.contextViewService, {
412
- ariaLabel: ( nls.localizeWithPath(
413
- 'vs/workbench/contrib/remote/browser/tunnelView',
414
- 'remote.tunnelsView.input',
415
- "Press Enter to confirm or Escape to cancel."
416
- )),
417
- validationOptions: {
418
- validation: (value) => {
419
- const message = editableData.validationMessage(value);
420
- if (!message) {
421
- return null;
422
- }
423
- return {
424
- content: message.content,
425
- formatContent: true,
426
- type: message.severity === Severity.Error ? 3 : 1
427
- };
428
- }
429
- },
430
- placeholder: editableData.placeholder || '',
431
- inputBoxStyles: defaultInputBoxStyles
432
- }));
433
- inputBox.value = value;
434
- inputBox.focus();
435
- inputBox.select({ start: 0, end: editableData.startingValue ? editableData.startingValue.length : 0 });
436
- const done = createSingleCallFunction(async (success, finishEditing) => {
437
- dispose(toDispose);
438
- if (this.inputDone) {
439
- this.inputDone = undefined;
440
- }
441
- inputBox.element.style.display = 'none';
442
- const inputValue = inputBox.value;
443
- if (finishEditing) {
444
- return editableData.onFinish(inputValue, success);
445
- }
446
- });
447
- this.inputDone = done;
448
- const toDispose = [
449
- inputBox,
450
- dom.addStandardDisposableListener(inputBox.inputElement, dom.EventType.KEY_DOWN, async (e) => {
451
- if (e.equals(3 )) {
452
- e.stopPropagation();
453
- if (inputBox.validate() !== 3 ) {
454
- return done(true, true);
455
- }
456
- else {
457
- return done(false, true);
458
- }
459
- }
460
- else if (e.equals(9 )) {
461
- e.preventDefault();
462
- e.stopPropagation();
463
- return done(false, true);
464
- }
465
- }),
466
- dom.addDisposableListener(inputBox.inputElement, dom.EventType.BLUR, () => {
467
- return done(inputBox.validate() !== 3 , true);
468
- })
469
- ];
470
- return toDisposable(() => {
471
- done(false, false);
472
- });
473
- }
474
- disposeElement(element, index, templateData, height) {
475
- templateData.elementDisposable.dispose();
476
- }
477
- disposeTemplate(templateData) {
478
- templateData.label.dispose();
479
- templateData.actionBar.dispose();
480
- templateData.elementDisposable.dispose();
481
- templateData.button?.dispose();
482
- }
483
- };
484
- ActionBarRenderer = ( __decorate([
485
- ( __param(0, IInstantiationService)),
486
- ( __param(1, IContextKeyService)),
487
- ( __param(2, IMenuService)),
488
- ( __param(3, IContextViewService)),
489
- ( __param(4, IRemoteExplorerService)),
490
- ( __param(5, ICommandService)),
491
- ( __param(6, IConfigurationService)),
492
- ( __param(7, IHoverService))
493
- ], ActionBarRenderer));
494
- class TunnelItem {
495
- static createFromTunnel(remoteExplorerService, tunnelService, tunnel, type = TunnelType.Forwarded, closeable) {
496
- return ( new TunnelItem(
497
- type,
498
- tunnel.remoteHost,
499
- tunnel.remotePort,
500
- tunnel.source,
501
- !!tunnel.hasRunningProcess,
502
- tunnel.protocol,
503
- tunnel.localUri,
504
- tunnel.localAddress,
505
- tunnel.localPort,
506
- closeable === undefined ? tunnel.closeable : closeable,
507
- tunnel.name,
508
- tunnel.runningProcess,
509
- tunnel.pid,
510
- tunnel.privacy,
511
- remoteExplorerService,
512
- tunnelService
513
- ));
514
- }
515
- strip() {
516
- return ( new TunnelItem(
517
- this.tunnelType,
518
- this.remoteHost,
519
- this.remotePort,
520
- this.source,
521
- this.hasRunningProcess,
522
- this.protocol,
523
- this.localUri,
524
- this.localAddress,
525
- this.localPort,
526
- this.closeable,
527
- this.name,
528
- this.runningProcess,
529
- this.pid,
530
- this._privacy
531
- ));
532
- }
533
- constructor(tunnelType, remoteHost, remotePort, source, hasRunningProcess, protocol, localUri, localAddress, localPort, closeable, name, runningProcess, pid, _privacy, remoteExplorerService, tunnelService) {
534
- this.tunnelType = tunnelType;
535
- this.remoteHost = remoteHost;
536
- this.remotePort = remotePort;
537
- this.source = source;
538
- this.hasRunningProcess = hasRunningProcess;
539
- this.protocol = protocol;
540
- this.localUri = localUri;
541
- this.localAddress = localAddress;
542
- this.localPort = localPort;
543
- this.closeable = closeable;
544
- this.name = name;
545
- this.runningProcess = runningProcess;
546
- this.pid = pid;
547
- this._privacy = _privacy;
548
- this.remoteExplorerService = remoteExplorerService;
549
- this.tunnelService = tunnelService;
550
- }
551
- get label() {
552
- if (this.tunnelType === TunnelType.Add && this.name) {
553
- return this.name;
554
- }
555
- const portNumberLabel = (isLocalhost(this.remoteHost) || isAllInterfaces(this.remoteHost))
556
- ? `${this.remotePort}`
557
- : `${this.remoteHost}:${this.remotePort}`;
558
- if (this.name) {
559
- return `${this.name} (${portNumberLabel})`;
560
- }
561
- else {
562
- return portNumberLabel;
563
- }
564
- }
565
- set processDescription(description) {
566
- this.runningProcess = description;
567
- }
568
- get processDescription() {
569
- let description = '';
570
- if (this.runningProcess) {
571
- if (this.pid && this.remoteExplorerService?.namedProcesses.has(this.pid)) {
572
- description = this.remoteExplorerService.namedProcesses.get(this.pid);
573
- }
574
- else {
575
- description = this.runningProcess.replace(/\0/g, ' ').trim();
576
- }
577
- if (this.pid) {
578
- description += ` (${this.pid})`;
579
- }
580
- }
581
- else if (this.hasRunningProcess) {
582
- description = ( nls.localizeWithPath(
583
- 'vs/workbench/contrib/remote/browser/tunnelView',
584
- 'tunnelView.runningProcess.inacessable',
585
- "Process information unavailable"
586
- ));
587
- }
588
- return description;
589
- }
590
- get tooltipPostfix() {
591
- let information;
592
- if (this.localAddress) {
593
- information = ( nls.localizeWithPath(
594
- 'vs/workbench/contrib/remote/browser/tunnelView',
595
- 'remote.tunnel.tooltipForwarded',
596
- "Remote port {0}:{1} forwarded to local address {2}. ",
597
- this.remoteHost,
598
- this.remotePort,
599
- this.localAddress
600
- ));
601
- }
602
- else {
603
- information = ( nls.localizeWithPath(
604
- 'vs/workbench/contrib/remote/browser/tunnelView',
605
- 'remote.tunnel.tooltipCandidate',
606
- "Remote port {0}:{1} not forwarded. ",
607
- this.remoteHost,
608
- this.remotePort
609
- ));
610
- }
611
- return information;
612
- }
613
- get iconTooltip() {
614
- const isAdd = this.tunnelType === TunnelType.Add;
615
- if (!isAdd) {
616
- return `${this.processDescription ? ( nls.localizeWithPath(
617
- 'vs/workbench/contrib/remote/browser/tunnelView',
618
- 'tunnel.iconColumn.running',
619
- "Port has running process."
620
- )) :
621
- ( nls.localizeWithPath(
622
- 'vs/workbench/contrib/remote/browser/tunnelView',
623
- 'tunnel.iconColumn.notRunning',
624
- "No running process."
625
- ))}`;
626
- }
627
- else {
628
- return this.label;
629
- }
630
- }
631
- get portTooltip() {
632
- const isAdd = this.tunnelType === TunnelType.Add;
633
- if (!isAdd) {
634
- return `${this.name ? ( nls.localizeWithPath(
635
- 'vs/workbench/contrib/remote/browser/tunnelView',
636
- 'remote.tunnel.tooltipName',
637
- "Port labeled {0}. ",
638
- this.name
639
- )) : ''}`;
640
- }
641
- else {
642
- return '';
643
- }
644
- }
645
- get processTooltip() {
646
- return this.processDescription ?? '';
647
- }
648
- get originTooltip() {
649
- return this.source.description;
650
- }
651
- get privacy() {
652
- if (this.tunnelService?.privacyOptions) {
653
- return this.tunnelService?.privacyOptions.find(element => element.id === this._privacy) ??
654
- {
655
- id: '',
656
- themeIcon: Codicon.question.id,
657
- label: ( nls.localizeWithPath(
658
- 'vs/workbench/contrib/remote/browser/tunnelView',
659
- 'tunnelPrivacy.unknown',
660
- "Unknown"
661
- ))
662
- };
663
- }
664
- else {
665
- return {
666
- id: TunnelPrivacyId.Private,
667
- themeIcon: privatePortIcon.id,
668
- label: ( nls.localizeWithPath(
669
- 'vs/workbench/contrib/remote/browser/tunnelView',
670
- 'tunnelPrivacy.private',
671
- "Private"
672
- ))
673
- };
674
- }
675
- }
676
- }
677
- const TunnelTypeContextKey = ( new RawContextKey('tunnelType', TunnelType.Add, true));
678
- const TunnelCloseableContextKey = ( new RawContextKey('tunnelCloseable', false, true));
679
- const TunnelPrivacyContextKey = ( new RawContextKey('tunnelPrivacy', undefined, true));
680
- const TunnelPrivacyEnabledContextKey = ( new RawContextKey('tunnelPrivacyEnabled', false, true));
681
- const TunnelProtocolContextKey = ( new RawContextKey('tunnelProtocol', TunnelProtocol.Http, true));
682
- const TunnelViewFocusContextKey = ( new RawContextKey('tunnelViewFocus', false, ( nls.localizeWithPath(
683
- 'vs/workbench/contrib/remote/browser/tunnelView',
684
- 'tunnel.focusContext',
685
- "Whether the Ports view has focus."
686
- ))));
687
- const TunnelViewSelectionKeyName = 'tunnelViewSelection';
688
- const TunnelViewSelectionContextKey = ( new RawContextKey(TunnelViewSelectionKeyName, undefined, true));
689
- const TunnelViewMultiSelectionKeyName = 'tunnelViewMultiSelection';
690
- const TunnelViewMultiSelectionContextKey = ( new RawContextKey(TunnelViewMultiSelectionKeyName, undefined, true));
691
- const PortChangableContextKey = ( new RawContextKey('portChangable', false, true));
692
- let TunnelPanel = class TunnelPanel extends ViewPane {
693
- static { TunnelPanel_1 = this; }
694
- static { this.ID = TUNNEL_VIEW_ID; }
695
- static { this.TITLE = ( nls.localize2WithPath('vs/workbench/contrib/remote/browser/tunnelView', 'remote.tunnel', "Ports")); }
696
- constructor(viewModel, options, keybindingService, contextMenuService, contextKeyService, configurationService, instantiationService, viewDescriptorService, openerService, quickInputService, commandService, menuService, themeService, remoteExplorerService, telemetryService, tunnelService, contextViewService, hoverService) {
697
- super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
698
- this.viewModel = viewModel;
699
- this.quickInputService = quickInputService;
700
- this.commandService = commandService;
701
- this.menuService = menuService;
702
- this.remoteExplorerService = remoteExplorerService;
703
- this.tunnelService = tunnelService;
704
- this.contextViewService = contextViewService;
705
- this.hoverService = hoverService;
706
- this.tableDisposables = this._register(( new DisposableStore()));
707
- this.isEditing = false;
708
- this.titleActions = [];
709
- this.lastFocus = [];
710
- this.height = 0;
711
- this.width = 0;
712
- this.tunnelTypeContext = TunnelTypeContextKey.bindTo(contextKeyService);
713
- this.tunnelCloseableContext = TunnelCloseableContextKey.bindTo(contextKeyService);
714
- this.tunnelPrivacyContext = TunnelPrivacyContextKey.bindTo(contextKeyService);
715
- this.tunnelPrivacyEnabledContext = TunnelPrivacyEnabledContextKey.bindTo(contextKeyService);
716
- this.tunnelPrivacyEnabledContext.set(tunnelService.canChangePrivacy);
717
- this.tunnelProtocolContext = TunnelProtocolContextKey.bindTo(contextKeyService);
718
- this.tunnelViewFocusContext = TunnelViewFocusContextKey.bindTo(contextKeyService);
719
- this.tunnelViewSelectionContext = TunnelViewSelectionContextKey.bindTo(contextKeyService);
720
- this.tunnelViewMultiSelectionContext = TunnelViewMultiSelectionContextKey.bindTo(contextKeyService);
721
- this.portChangableContextKey = PortChangableContextKey.bindTo(contextKeyService);
722
- const overlayContextKeyService = this.contextKeyService.createOverlay([['view', TunnelPanel_1.ID]]);
723
- const titleMenu = this._register(this.menuService.createMenu(MenuId.TunnelTitle, overlayContextKeyService));
724
- const updateActions = () => {
725
- this.titleActions = [];
726
- createAndFillInActionBarActions(titleMenu, undefined, this.titleActions);
727
- this.updateActions();
728
- };
729
- this._register(titleMenu.onDidChange(updateActions));
730
- updateActions();
731
- this._register(toDisposable(() => {
732
- this.titleActions = [];
733
- }));
734
- this.registerPrivacyActions();
735
- this._register(Event.once(this.tunnelService.onAddedTunnelProvider)(() => {
736
- if (this.tunnelPrivacyEnabledContext.get() === false) {
737
- this.tunnelPrivacyEnabledContext.set(tunnelService.canChangePrivacy);
738
- updateActions();
739
- this.registerPrivacyActions();
740
- this.createTable();
741
- this.table.layout(this.height, this.width);
742
- }
743
- }));
744
- }
745
- registerPrivacyActions() {
746
- for (const privacyOption of this.tunnelService.privacyOptions) {
747
- const optionId = `remote.tunnel.privacy${privacyOption.id}`;
748
- CommandsRegistry.registerCommand(optionId, ChangeTunnelPrivacyAction.handler(privacyOption.id));
749
- MenuRegistry.appendMenuItem(MenuId.TunnelPrivacy, ({
750
- order: 0,
751
- command: {
752
- id: optionId,
753
- title: privacyOption.label,
754
- toggled: ( TunnelPrivacyContextKey.isEqualTo(privacyOption.id))
755
- }
756
- }));
757
- }
758
- }
759
- get portCount() {
760
- return this.remoteExplorerService.tunnelModel.forwarded.size + this.remoteExplorerService.tunnelModel.detected.size;
761
- }
762
- createTable() {
763
- if (!this.panelContainer) {
764
- return;
765
- }
766
- this.tableDisposables.clear();
767
- dom.clearNode(this.panelContainer);
768
- const widgetContainer = dom.append(this.panelContainer, dom.$('.customview-tree'));
769
- widgetContainer.classList.add('ports-view');
770
- widgetContainer.classList.add('file-icon-themable-tree', 'show-file-icons');
771
- const actionBarRenderer = ( new ActionBarRenderer(
772
- this.instantiationService,
773
- this.contextKeyService,
774
- this.menuService,
775
- this.contextViewService,
776
- this.remoteExplorerService,
777
- this.commandService,
778
- this.configurationService,
779
- this.hoverService
780
- ));
781
- const columns = [( new IconColumn()), ( new PortColumn()), ( new LocalAddressColumn()), ( new RunningProcessColumn())];
782
- if (this.tunnelService.canChangePrivacy) {
783
- columns.push(( new PrivacyColumn()));
784
- }
785
- columns.push(( new OriginColumn()));
786
- this.table = this.instantiationService.createInstance(WorkbenchTable, 'RemoteTunnels', widgetContainer, ( new TunnelTreeVirtualDelegate(this.remoteExplorerService)), columns, [actionBarRenderer], {
787
- keyboardNavigationLabelProvider: {
788
- getKeyboardNavigationLabel: (item) => {
789
- return item.label;
790
- }
791
- },
792
- multipleSelectionSupport: true,
793
- accessibilityProvider: {
794
- getAriaLabel: (item) => {
795
- if (item instanceof TunnelItem) {
796
- return `${item.tooltipPostfix} ${item.portTooltip} ${item.iconTooltip} ${item.processTooltip} ${item.originTooltip} ${this.tunnelService.canChangePrivacy ? item.privacy.label : ''}`;
797
- }
798
- else {
799
- return item.label;
800
- }
801
- },
802
- getWidgetAriaLabel: () => ( nls.localizeWithPath(
803
- 'vs/workbench/contrib/remote/browser/tunnelView',
804
- 'tunnelView',
805
- "Tunnel View"
806
- ))
807
- },
808
- openOnSingleClick: true
809
- });
810
- const actionRunner = ( new ActionRunner());
811
- actionBarRenderer.actionRunner = actionRunner;
812
- this.tableDisposables.add(this.table);
813
- this.tableDisposables.add(this.table.onContextMenu(e => this.onContextMenu(e, actionRunner)));
814
- this.tableDisposables.add(this.table.onMouseDblClick(e => this.onMouseDblClick(e)));
815
- this.tableDisposables.add(this.table.onDidChangeFocus(e => this.onFocusChanged(e)));
816
- this.tableDisposables.add(this.table.onDidChangeSelection(e => this.onSelectionChanged(e)));
817
- this.tableDisposables.add(this.table.onDidFocus(() => this.tunnelViewFocusContext.set(true)));
818
- this.tableDisposables.add(this.table.onDidBlur(() => this.tunnelViewFocusContext.set(false)));
819
- const rerender = () => this.table.splice(0, Number.POSITIVE_INFINITY, this.viewModel.all);
820
- rerender();
821
- let lastPortCount = this.portCount;
822
- this.tableDisposables.add(Event.debounce(this.viewModel.onForwardedPortsChanged, (_last, e) => e, 50)(() => {
823
- const newPortCount = this.portCount;
824
- if (((lastPortCount === 0) || (newPortCount === 0)) && (lastPortCount !== newPortCount)) {
825
- this._onDidChangeViewWelcomeState.fire();
826
- }
827
- lastPortCount = newPortCount;
828
- rerender();
829
- }));
830
- this.tableDisposables.add(this.table.onMouseClick(e => {
831
- if (this.hasOpenLinkModifier(e.browserEvent)) {
832
- const selection = this.table.getSelectedElements();
833
- if ((selection.length === 0) ||
834
- ((selection.length === 1) && (selection[0] === e.element))) {
835
- this.commandService.executeCommand(OpenPortInBrowserAction.ID, e.element);
836
- }
837
- }
838
- }));
839
- this.tableDisposables.add(this.table.onDidOpen(e => {
840
- if (!e.element || (e.element.tunnelType !== TunnelType.Forwarded)) {
841
- return;
842
- }
843
- if (e.browserEvent?.type === 'dblclick') {
844
- this.commandService.executeCommand(LabelTunnelAction.ID);
845
- }
846
- }));
847
- this.tableDisposables.add(this.remoteExplorerService.onDidChangeEditable(e => {
848
- this.isEditing = !!this.remoteExplorerService.getEditableData(e?.tunnel, e?.editId);
849
- this._onDidChangeViewWelcomeState.fire();
850
- if (!this.isEditing) {
851
- widgetContainer.classList.remove('highlight');
852
- }
853
- rerender();
854
- if (this.isEditing) {
855
- widgetContainer.classList.add('highlight');
856
- if (!e) {
857
- this.table.reveal(this.table.indexOf(this.viewModel.input));
858
- }
859
- }
860
- else {
861
- if (e && (e.tunnel.tunnelType !== TunnelType.Add)) {
862
- this.table.setFocus(this.lastFocus);
863
- }
864
- this.focus();
865
- }
866
- }));
867
- }
868
- renderBody(container) {
869
- super.renderBody(container);
870
- this.panelContainer = dom.append(container, dom.$('.tree-explorer-viewlet-tree-view'));
871
- this.createTable();
872
- }
873
- shouldShowWelcome() {
874
- return this.viewModel.isEmpty() && !this.isEditing;
875
- }
876
- focus() {
877
- super.focus();
878
- this.table.domFocus();
879
- }
880
- onFocusChanged(event) {
881
- if (event.indexes.length > 0 && event.elements.length > 0) {
882
- this.lastFocus = [...event.indexes];
883
- }
884
- const elements = event.elements;
885
- const item = elements && elements.length ? elements[0] : undefined;
886
- if (item) {
887
- this.tunnelViewSelectionContext.set(makeAddress(item.remoteHost, item.remotePort));
888
- this.tunnelTypeContext.set(item.tunnelType);
889
- this.tunnelCloseableContext.set(!!item.closeable);
890
- this.tunnelPrivacyContext.set(item.privacy.id);
891
- this.tunnelProtocolContext.set(item.protocol === TunnelProtocol.Https ? TunnelProtocol.Https : TunnelProtocol.Https);
892
- this.portChangableContextKey.set(!!item.localPort);
893
- }
894
- else {
895
- this.tunnelTypeContext.reset();
896
- this.tunnelViewSelectionContext.reset();
897
- this.tunnelCloseableContext.reset();
898
- this.tunnelPrivacyContext.reset();
899
- this.tunnelProtocolContext.reset();
900
- this.portChangableContextKey.reset();
901
- }
902
- }
903
- hasOpenLinkModifier(e) {
904
- const editorConf = this.configurationService.getValue('editor');
905
- let modifierKey = false;
906
- if (editorConf.multiCursorModifier === 'ctrlCmd') {
907
- modifierKey = e.altKey;
908
- }
909
- else {
910
- if (isMacintosh) {
911
- modifierKey = e.metaKey;
912
- }
913
- else {
914
- modifierKey = e.ctrlKey;
915
- }
916
- }
917
- return modifierKey;
918
- }
919
- onSelectionChanged(event) {
920
- const elements = event.elements;
921
- if (elements.length > 1) {
922
- this.tunnelViewMultiSelectionContext.set(( elements.map(element => makeAddress(element.remoteHost, element.remotePort))));
923
- }
924
- else {
925
- this.tunnelViewMultiSelectionContext.set(undefined);
926
- }
927
- }
928
- onContextMenu(event, actionRunner) {
929
- if ((event.element !== undefined) && !(event.element instanceof TunnelItem)) {
930
- return;
931
- }
932
- event.browserEvent.preventDefault();
933
- event.browserEvent.stopPropagation();
934
- const node = event.element;
935
- if (node) {
936
- this.table.setFocus([this.table.indexOf(node)]);
937
- this.tunnelTypeContext.set(node.tunnelType);
938
- this.tunnelCloseableContext.set(!!node.closeable);
939
- this.tunnelPrivacyContext.set(node.privacy.id);
940
- this.tunnelProtocolContext.set(node.protocol);
941
- this.portChangableContextKey.set(!!node.localPort);
942
- }
943
- else {
944
- this.tunnelTypeContext.set(TunnelType.Add);
945
- this.tunnelCloseableContext.set(false);
946
- this.tunnelPrivacyContext.set(undefined);
947
- this.tunnelProtocolContext.set(undefined);
948
- this.portChangableContextKey.set(false);
949
- }
950
- this.contextMenuService.showContextMenu({
951
- menuId: MenuId.TunnelContext,
952
- menuActionOptions: { shouldForwardArgs: true },
953
- contextKeyService: this.table.contextKeyService,
954
- getAnchor: () => event.anchor,
955
- getActionViewItem: (action) => {
956
- const keybinding = this.keybindingService.lookupKeybinding(action.id);
957
- if (keybinding) {
958
- return ( new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() }));
959
- }
960
- return undefined;
961
- },
962
- onHide: (wasCancelled) => {
963
- if (wasCancelled) {
964
- this.table.domFocus();
965
- }
966
- },
967
- getActionsContext: () => node?.strip(),
968
- actionRunner
969
- });
970
- }
971
- onMouseDblClick(e) {
972
- if (!e.element) {
973
- this.commandService.executeCommand(ForwardPortAction.INLINE_ID);
974
- }
975
- }
976
- layoutBody(height, width) {
977
- this.height = height;
978
- this.width = width;
979
- super.layoutBody(height, width);
980
- this.table.layout(height, width);
981
- }
982
- };
983
- TunnelPanel = TunnelPanel_1 = ( __decorate([
984
- ( __param(2, IKeybindingService)),
985
- ( __param(3, IContextMenuService)),
986
- ( __param(4, IContextKeyService)),
987
- ( __param(5, IConfigurationService)),
988
- ( __param(6, IInstantiationService)),
989
- ( __param(7, IViewDescriptorService)),
990
- ( __param(8, IOpenerService)),
991
- ( __param(9, IQuickInputService)),
992
- ( __param(10, ICommandService)),
993
- ( __param(11, IMenuService)),
994
- ( __param(12, IThemeService)),
995
- ( __param(13, IRemoteExplorerService)),
996
- ( __param(14, ITelemetryService)),
997
- ( __param(15, ITunnelService)),
998
- ( __param(16, IContextViewService)),
999
- ( __param(17, IHoverService))
1000
- ], TunnelPanel));
1001
- function isITunnelItem(item) {
1002
- return item && item.tunnelType && item.remoteHost && item.source;
1003
- }
1004
- var LabelTunnelAction;
1005
- ( (function(LabelTunnelAction) {
1006
- LabelTunnelAction.ID = 'remote.tunnel.label';
1007
- LabelTunnelAction.LABEL = ( nls.localizeWithPath(
1008
- 'vs/workbench/contrib/remote/browser/tunnelView',
1009
- 'remote.tunnel.label',
1010
- "Set Port Label"
1011
- ));
1012
- LabelTunnelAction.COMMAND_ID_KEYWORD = 'label';
1013
- function handler() {
1014
- return async (accessor, arg) => {
1015
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1016
- let tunnelContext;
1017
- if (isITunnelItem(arg)) {
1018
- tunnelContext = arg;
1019
- }
1020
- else {
1021
- const context = accessor.get(IContextKeyService).getContextKeyValue(TunnelViewSelectionKeyName);
1022
- const tunnel = context ? remoteExplorerService.tunnelModel.forwarded.get(context) : undefined;
1023
- if (tunnel) {
1024
- const tunnelService = accessor.get(ITunnelService);
1025
- tunnelContext = TunnelItem.createFromTunnel(remoteExplorerService, tunnelService, tunnel);
1026
- }
1027
- }
1028
- if (tunnelContext) {
1029
- const tunnelItem = tunnelContext;
1030
- return ( new Promise(resolve => {
1031
- const startingValue = tunnelItem.name ? tunnelItem.name : `${tunnelItem.remotePort}`;
1032
- remoteExplorerService.setEditable(tunnelItem, TunnelEditId.Label, {
1033
- onFinish: async (value, success) => {
1034
- value = value.trim();
1035
- remoteExplorerService.setEditable(tunnelItem, TunnelEditId.Label, null);
1036
- const changed = success && (value !== startingValue);
1037
- if (changed) {
1038
- await remoteExplorerService.tunnelModel.name(tunnelItem.remoteHost, tunnelItem.remotePort, value);
1039
- }
1040
- resolve(changed ? { port: tunnelItem.remotePort, label: value } : undefined);
1041
- },
1042
- validationMessage: () => null,
1043
- placeholder: ( nls.localizeWithPath(
1044
- 'vs/workbench/contrib/remote/browser/tunnelView',
1045
- 'remote.tunnelsView.labelPlaceholder',
1046
- "Port label"
1047
- )),
1048
- startingValue
1049
- });
1050
- }));
1051
- }
1052
- return undefined;
1053
- };
1054
- }
1055
- LabelTunnelAction.handler = handler;
1056
- })(LabelTunnelAction || (LabelTunnelAction = {})));
1057
- const invalidPortString = ( nls.localizeWithPath(
1058
- 'vs/workbench/contrib/remote/browser/tunnelView',
1059
- 'remote.tunnelsView.portNumberValid',
1060
- "Forwarded port should be a number or a host:port."
1061
- ));
1062
- const maxPortNumber = 65536;
1063
- const invalidPortNumberString = ( nls.localizeWithPath(
1064
- 'vs/workbench/contrib/remote/browser/tunnelView',
1065
- 'remote.tunnelsView.portNumberToHigh',
1066
- "Port number must be \u2265 0 and < {0}.",
1067
- maxPortNumber
1068
- ));
1069
- const requiresSudoString = ( nls.localizeWithPath(
1070
- 'vs/workbench/contrib/remote/browser/tunnelView',
1071
- 'remote.tunnelView.inlineElevationMessage',
1072
- "May Require Sudo"
1073
- ));
1074
- const alreadyForwarded = ( nls.localizeWithPath(
1075
- 'vs/workbench/contrib/remote/browser/tunnelView',
1076
- 'remote.tunnelView.alreadyForwarded',
1077
- "Port is already forwarded"
1078
- ));
1079
- var ForwardPortAction;
1080
- ( (function(ForwardPortAction) {
1081
- ForwardPortAction.INLINE_ID = 'remote.tunnel.forwardInline';
1082
- ForwardPortAction.COMMANDPALETTE_ID = 'remote.tunnel.forwardCommandPalette';
1083
- ForwardPortAction.LABEL = { value: ( nls.localizeWithPath(
1084
- 'vs/workbench/contrib/remote/browser/tunnelView',
1085
- 'remote.tunnel.forward',
1086
- "Forward a Port"
1087
- )), original: 'Forward a Port' };
1088
- ForwardPortAction.TREEITEM_LABEL = ( nls.localizeWithPath(
1089
- 'vs/workbench/contrib/remote/browser/tunnelView',
1090
- 'remote.tunnel.forwardItem',
1091
- "Forward Port"
1092
- ));
1093
- const forwardPrompt = ( nls.localizeWithPath(
1094
- 'vs/workbench/contrib/remote/browser/tunnelView',
1095
- 'remote.tunnel.forwardPrompt',
1096
- "Port number or address (eg. 3000 or 10.10.10.10:2000)."
1097
- ));
1098
- function validateInput(remoteExplorerService, tunnelService, value, canElevate) {
1099
- const parsed = parseAddress(value);
1100
- if (!parsed) {
1101
- return { content: invalidPortString, severity: Severity.Error };
1102
- }
1103
- else if (parsed.port >= maxPortNumber) {
1104
- return { content: invalidPortNumberString, severity: Severity.Error };
1105
- }
1106
- else if (canElevate && tunnelService.isPortPrivileged(parsed.port)) {
1107
- return { content: requiresSudoString, severity: Severity.Info };
1108
- }
1109
- else if (mapHasAddressLocalhostOrAllInterfaces(remoteExplorerService.tunnelModel.forwarded, parsed.host, parsed.port)) {
1110
- return { content: alreadyForwarded, severity: Severity.Error };
1111
- }
1112
- return null;
1113
- }
1114
- function error(notificationService, tunnelOrError, host, port) {
1115
- if (!tunnelOrError) {
1116
- notificationService.warn(( nls.localizeWithPath(
1117
- 'vs/workbench/contrib/remote/browser/tunnelView',
1118
- 'remote.tunnel.forwardError',
1119
- "Unable to forward {0}:{1}. The host may not be available or that remote port may already be forwarded",
1120
- host,
1121
- port
1122
- )));
1123
- }
1124
- else if (typeof tunnelOrError === 'string') {
1125
- notificationService.warn(( nls.localizeWithPath(
1126
- 'vs/workbench/contrib/remote/browser/tunnelView',
1127
- 'remote.tunnel.forwardErrorProvided',
1128
- "Unable to forward {0}:{1}. {2}",
1129
- host,
1130
- port,
1131
- tunnelOrError
1132
- )));
1133
- }
1134
- }
1135
- function inlineHandler() {
1136
- return async (accessor, arg) => {
1137
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1138
- const notificationService = accessor.get(INotificationService);
1139
- const tunnelService = accessor.get(ITunnelService);
1140
- remoteExplorerService.setEditable(undefined, TunnelEditId.New, {
1141
- onFinish: async (value, success) => {
1142
- remoteExplorerService.setEditable(undefined, TunnelEditId.New, null);
1143
- let parsed;
1144
- if (success && (parsed = parseAddress(value))) {
1145
- remoteExplorerService.forward({
1146
- remote: { host: parsed.host, port: parsed.port },
1147
- elevateIfNeeded: true
1148
- }).then(tunnelOrError => error(notificationService, tunnelOrError, parsed.host, parsed.port));
1149
- }
1150
- },
1151
- validationMessage: (value) => validateInput(remoteExplorerService, tunnelService, value, tunnelService.canElevate),
1152
- placeholder: forwardPrompt
1153
- });
1154
- };
1155
- }
1156
- ForwardPortAction.inlineHandler = inlineHandler;
1157
- function commandPaletteHandler() {
1158
- return async (accessor, arg) => {
1159
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1160
- const notificationService = accessor.get(INotificationService);
1161
- const viewsService = accessor.get(IViewsService);
1162
- const quickInputService = accessor.get(IQuickInputService);
1163
- const tunnelService = accessor.get(ITunnelService);
1164
- await viewsService.openView(TunnelPanel.ID, true);
1165
- const value = await quickInputService.input({
1166
- prompt: forwardPrompt,
1167
- validateInput: (value) => Promise.resolve(validateInput(remoteExplorerService, tunnelService, value, tunnelService.canElevate))
1168
- });
1169
- let parsed;
1170
- if (value && (parsed = parseAddress(value))) {
1171
- remoteExplorerService.forward({
1172
- remote: { host: parsed.host, port: parsed.port },
1173
- elevateIfNeeded: true
1174
- }).then(tunnel => error(notificationService, tunnel, parsed.host, parsed.port));
1175
- }
1176
- };
1177
- }
1178
- ForwardPortAction.commandPaletteHandler = commandPaletteHandler;
1179
- })(ForwardPortAction || (ForwardPortAction = {})));
1180
- function makeTunnelPicks(tunnels, remoteExplorerService, tunnelService) {
1181
- const picks = ( tunnels.map(forwarded => {
1182
- const item = TunnelItem.createFromTunnel(remoteExplorerService, tunnelService, forwarded);
1183
- return {
1184
- label: item.label,
1185
- description: item.processDescription,
1186
- tunnel: item
1187
- };
1188
- }));
1189
- if (picks.length === 0) {
1190
- picks.push({
1191
- label: ( nls.localizeWithPath(
1192
- 'vs/workbench/contrib/remote/browser/tunnelView',
1193
- 'remote.tunnel.closeNoPorts',
1194
- "No ports currently forwarded. Try running the {0} command",
1195
- ForwardPortAction.LABEL.value
1196
- ))
1197
- });
1198
- }
1199
- return picks;
1200
- }
1201
- var ClosePortAction;
1202
- ( (function(ClosePortAction) {
1203
- ClosePortAction.INLINE_ID = 'remote.tunnel.closeInline';
1204
- ClosePortAction.COMMANDPALETTE_ID = 'remote.tunnel.closeCommandPalette';
1205
- ClosePortAction.LABEL = { value: ( nls.localizeWithPath(
1206
- 'vs/workbench/contrib/remote/browser/tunnelView',
1207
- 'remote.tunnel.close',
1208
- "Stop Forwarding Port"
1209
- )), original: 'Stop Forwarding Port' };
1210
- function inlineHandler() {
1211
- return async (accessor, arg) => {
1212
- const contextKeyService = accessor.get(IContextKeyService);
1213
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1214
- let ports = [];
1215
- const multiSelectContext = contextKeyService.getContextKeyValue(TunnelViewMultiSelectionKeyName);
1216
- if (multiSelectContext) {
1217
- multiSelectContext.forEach(context => {
1218
- const tunnel = remoteExplorerService.tunnelModel.forwarded.get(context);
1219
- if (tunnel) {
1220
- ports?.push(tunnel);
1221
- }
1222
- });
1223
- }
1224
- else if (isITunnelItem(arg)) {
1225
- ports = [arg];
1226
- }
1227
- else {
1228
- const context = contextKeyService.getContextKeyValue(TunnelViewSelectionKeyName);
1229
- const tunnel = context ? remoteExplorerService.tunnelModel.forwarded.get(context) : undefined;
1230
- if (tunnel) {
1231
- ports = [tunnel];
1232
- }
1233
- }
1234
- if (!ports || ports.length === 0) {
1235
- return;
1236
- }
1237
- return Promise.all(( ports.map(
1238
- port => remoteExplorerService.close({ host: port.remoteHost, port: port.remotePort }, TunnelCloseReason.User)
1239
- )));
1240
- };
1241
- }
1242
- ClosePortAction.inlineHandler = inlineHandler;
1243
- function commandPaletteHandler() {
1244
- return async (accessor) => {
1245
- const quickInputService = accessor.get(IQuickInputService);
1246
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1247
- const tunnelService = accessor.get(ITunnelService);
1248
- const commandService = accessor.get(ICommandService);
1249
- const picks = makeTunnelPicks(Array.from(( remoteExplorerService.tunnelModel.forwarded.values())).filter(tunnel => tunnel.closeable), remoteExplorerService, tunnelService);
1250
- const result = await quickInputService.pick(picks, { placeHolder: ( nls.localizeWithPath(
1251
- 'vs/workbench/contrib/remote/browser/tunnelView',
1252
- 'remote.tunnel.closePlaceholder',
1253
- "Choose a port to stop forwarding"
1254
- )) });
1255
- if (result && result.tunnel) {
1256
- await remoteExplorerService.close({ host: result.tunnel.remoteHost, port: result.tunnel.remotePort }, TunnelCloseReason.User);
1257
- }
1258
- else if (result) {
1259
- await commandService.executeCommand(ForwardPortAction.COMMANDPALETTE_ID);
1260
- }
1261
- };
1262
- }
1263
- ClosePortAction.commandPaletteHandler = commandPaletteHandler;
1264
- })(ClosePortAction || (ClosePortAction = {})));
1265
- var OpenPortInBrowserAction;
1266
- ( (function(OpenPortInBrowserAction) {
1267
- OpenPortInBrowserAction.ID = 'remote.tunnel.open';
1268
- OpenPortInBrowserAction.LABEL = ( nls.localizeWithPath(
1269
- 'vs/workbench/contrib/remote/browser/tunnelView',
1270
- 'remote.tunnel.open',
1271
- "Open in Browser"
1272
- ));
1273
- function handler() {
1274
- return async (accessor, arg) => {
1275
- let key;
1276
- if (isITunnelItem(arg)) {
1277
- key = makeAddress(arg.remoteHost, arg.remotePort);
1278
- }
1279
- else if (arg.tunnelRemoteHost && arg.tunnelRemotePort) {
1280
- key = makeAddress(arg.tunnelRemoteHost, arg.tunnelRemotePort);
1281
- }
1282
- if (key) {
1283
- const model = accessor.get(IRemoteExplorerService).tunnelModel;
1284
- const openerService = accessor.get(IOpenerService);
1285
- return run(model, openerService, key);
1286
- }
1287
- };
1288
- }
1289
- OpenPortInBrowserAction.handler = handler;
1290
- function run(model, openerService, key) {
1291
- const tunnel = model.forwarded.get(key) || model.detected.get(key);
1292
- if (tunnel) {
1293
- return openerService.open(tunnel.localUri, { allowContributedOpeners: false });
1294
- }
1295
- return Promise.resolve();
1296
- }
1297
- OpenPortInBrowserAction.run = run;
1298
- })(OpenPortInBrowserAction || (OpenPortInBrowserAction = {})));
1299
- var OpenPortInPreviewAction;
1300
- ( (function(OpenPortInPreviewAction) {
1301
- OpenPortInPreviewAction.ID = 'remote.tunnel.openPreview';
1302
- OpenPortInPreviewAction.LABEL = ( nls.localizeWithPath(
1303
- 'vs/workbench/contrib/remote/browser/tunnelView',
1304
- 'remote.tunnel.openPreview',
1305
- "Preview in Editor"
1306
- ));
1307
- function handler() {
1308
- return async (accessor, arg) => {
1309
- let key;
1310
- if (isITunnelItem(arg)) {
1311
- key = makeAddress(arg.remoteHost, arg.remotePort);
1312
- }
1313
- else if (arg.tunnelRemoteHost && arg.tunnelRemotePort) {
1314
- key = makeAddress(arg.tunnelRemoteHost, arg.tunnelRemotePort);
1315
- }
1316
- if (key) {
1317
- const model = accessor.get(IRemoteExplorerService).tunnelModel;
1318
- const openerService = accessor.get(IOpenerService);
1319
- const externalOpenerService = accessor.get(IExternalUriOpenerService);
1320
- return run(model, openerService, externalOpenerService, key);
1321
- }
1322
- };
1323
- }
1324
- OpenPortInPreviewAction.handler = handler;
1325
- async function run(model, openerService, externalOpenerService, key) {
1326
- const tunnel = model.forwarded.get(key) || model.detected.get(key);
1327
- if (tunnel) {
1328
- const remoteHost = tunnel.remoteHost.includes(':') ? `[${tunnel.remoteHost}]` : tunnel.remoteHost;
1329
- const sourceUri = ( URI.parse(`http://${remoteHost}:${tunnel.remotePort}`));
1330
- const opener = await externalOpenerService.getOpener(tunnel.localUri, { sourceUri }, ( new CancellationTokenSource()).token);
1331
- if (opener) {
1332
- return opener.openExternalUri(tunnel.localUri, { sourceUri }, ( new CancellationTokenSource()).token);
1333
- }
1334
- return openerService.open(tunnel.localUri);
1335
- }
1336
- return Promise.resolve();
1337
- }
1338
- OpenPortInPreviewAction.run = run;
1339
- })(OpenPortInPreviewAction || (OpenPortInPreviewAction = {})));
1340
- var OpenPortInBrowserCommandPaletteAction;
1341
- ( (function(OpenPortInBrowserCommandPaletteAction) {
1342
- OpenPortInBrowserCommandPaletteAction.ID = 'remote.tunnel.openCommandPalette';
1343
- OpenPortInBrowserCommandPaletteAction.LABEL = ( nls.localizeWithPath(
1344
- 'vs/workbench/contrib/remote/browser/tunnelView',
1345
- 'remote.tunnel.openCommandPalette',
1346
- "Open Port in Browser"
1347
- ));
1348
- function handler() {
1349
- return async (accessor, arg) => {
1350
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1351
- const tunnelService = accessor.get(ITunnelService);
1352
- const model = remoteExplorerService.tunnelModel;
1353
- const quickPickService = accessor.get(IQuickInputService);
1354
- const openerService = accessor.get(IOpenerService);
1355
- const commandService = accessor.get(ICommandService);
1356
- const options = ( [...model.forwarded, ...model.detected].map(value => {
1357
- const tunnelItem = TunnelItem.createFromTunnel(remoteExplorerService, tunnelService, value[1]);
1358
- return {
1359
- label: tunnelItem.label,
1360
- description: tunnelItem.processDescription,
1361
- tunnel: tunnelItem
1362
- };
1363
- }));
1364
- if (options.length === 0) {
1365
- options.push({
1366
- label: ( nls.localizeWithPath(
1367
- 'vs/workbench/contrib/remote/browser/tunnelView',
1368
- 'remote.tunnel.openCommandPaletteNone',
1369
- "No ports currently forwarded. Open the Ports view to get started."
1370
- ))
1371
- });
1372
- }
1373
- else {
1374
- options.push({
1375
- label: ( nls.localizeWithPath(
1376
- 'vs/workbench/contrib/remote/browser/tunnelView',
1377
- 'remote.tunnel.openCommandPaletteView',
1378
- "Open the Ports view..."
1379
- ))
1380
- });
1381
- }
1382
- const picked = await quickPickService.pick(options, { placeHolder: ( nls.localizeWithPath(
1383
- 'vs/workbench/contrib/remote/browser/tunnelView',
1384
- 'remote.tunnel.openCommandPalettePick',
1385
- "Choose the port to open"
1386
- )) });
1387
- if (picked && picked.tunnel) {
1388
- return OpenPortInBrowserAction.run(model, openerService, makeAddress(picked.tunnel.remoteHost, picked.tunnel.remotePort));
1389
- }
1390
- else if (picked) {
1391
- return commandService.executeCommand(`${TUNNEL_VIEW_ID}.focus`);
1392
- }
1393
- };
1394
- }
1395
- OpenPortInBrowserCommandPaletteAction.handler = handler;
1396
- })(
1397
- OpenPortInBrowserCommandPaletteAction || (OpenPortInBrowserCommandPaletteAction = {})
1398
- ));
1399
- var CopyAddressAction;
1400
- ( (function(CopyAddressAction) {
1401
- CopyAddressAction.INLINE_ID = 'remote.tunnel.copyAddressInline';
1402
- CopyAddressAction.COMMANDPALETTE_ID = 'remote.tunnel.copyAddressCommandPalette';
1403
- CopyAddressAction.INLINE_LABEL = ( nls.localizeWithPath(
1404
- 'vs/workbench/contrib/remote/browser/tunnelView',
1405
- 'remote.tunnel.copyAddressInline',
1406
- "Copy Local Address"
1407
- ));
1408
- CopyAddressAction.COMMANDPALETTE_LABEL = ( nls.localizeWithPath(
1409
- 'vs/workbench/contrib/remote/browser/tunnelView',
1410
- 'remote.tunnel.copyAddressCommandPalette',
1411
- "Copy Forwarded Port Address"
1412
- ));
1413
- async function copyAddress(remoteExplorerService, clipboardService, tunnelItem) {
1414
- const address = remoteExplorerService.tunnelModel.address(tunnelItem.remoteHost, tunnelItem.remotePort);
1415
- if (address) {
1416
- await clipboardService.writeText(( address.toString()));
1417
- }
1418
- }
1419
- function inlineHandler() {
1420
- return async (accessor, arg) => {
1421
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1422
- let tunnelItem;
1423
- if (isITunnelItem(arg)) {
1424
- tunnelItem = arg;
1425
- }
1426
- else {
1427
- const context = accessor.get(IContextKeyService).getContextKeyValue(TunnelViewSelectionKeyName);
1428
- tunnelItem = context ? remoteExplorerService.tunnelModel.forwarded.get(context) : undefined;
1429
- }
1430
- if (tunnelItem) {
1431
- return copyAddress(remoteExplorerService, accessor.get(IClipboardService), tunnelItem);
1432
- }
1433
- };
1434
- }
1435
- CopyAddressAction.inlineHandler = inlineHandler;
1436
- function commandPaletteHandler() {
1437
- return async (accessor, arg) => {
1438
- const quickInputService = accessor.get(IQuickInputService);
1439
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1440
- const tunnelService = accessor.get(ITunnelService);
1441
- const commandService = accessor.get(ICommandService);
1442
- const clipboardService = accessor.get(IClipboardService);
1443
- const tunnels = Array.from(( remoteExplorerService.tunnelModel.forwarded.values())).concat(Array.from(( remoteExplorerService.tunnelModel.detected.values())));
1444
- const result = await quickInputService.pick(makeTunnelPicks(tunnels, remoteExplorerService, tunnelService), { placeHolder: ( nls.localizeWithPath(
1445
- 'vs/workbench/contrib/remote/browser/tunnelView',
1446
- 'remote.tunnel.copyAddressPlaceholdter',
1447
- "Choose a forwarded port"
1448
- )) });
1449
- if (result && result.tunnel) {
1450
- await copyAddress(remoteExplorerService, clipboardService, result.tunnel);
1451
- }
1452
- else if (result) {
1453
- await commandService.executeCommand(ForwardPortAction.COMMANDPALETTE_ID);
1454
- }
1455
- };
1456
- }
1457
- CopyAddressAction.commandPaletteHandler = commandPaletteHandler;
1458
- })(CopyAddressAction || (CopyAddressAction = {})));
1459
- var ChangeLocalPortAction;
1460
- ( (function(ChangeLocalPortAction) {
1461
- ChangeLocalPortAction.ID = 'remote.tunnel.changeLocalPort';
1462
- ChangeLocalPortAction.LABEL = ( nls.localizeWithPath(
1463
- 'vs/workbench/contrib/remote/browser/tunnelView',
1464
- 'remote.tunnel.changeLocalPort',
1465
- "Change Local Address Port"
1466
- ));
1467
- function validateInput(tunnelService, value, canElevate) {
1468
- if (!value.match(/^[0-9]+$/)) {
1469
- return { content: ( nls.localizeWithPath(
1470
- 'vs/workbench/contrib/remote/browser/tunnelView',
1471
- 'remote.tunnelsView.portShouldBeNumber',
1472
- "Local port should be a number."
1473
- )), severity: Severity.Error };
1474
- }
1475
- else if (Number(value) >= maxPortNumber) {
1476
- return { content: invalidPortNumberString, severity: Severity.Error };
1477
- }
1478
- else if (canElevate && tunnelService.isPortPrivileged(Number(value))) {
1479
- return { content: requiresSudoString, severity: Severity.Info };
1480
- }
1481
- return null;
1482
- }
1483
- function handler() {
1484
- return async (accessor, arg) => {
1485
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1486
- const notificationService = accessor.get(INotificationService);
1487
- const tunnelService = accessor.get(ITunnelService);
1488
- let tunnelContext;
1489
- if (isITunnelItem(arg)) {
1490
- tunnelContext = arg;
1491
- }
1492
- else {
1493
- const context = accessor.get(IContextKeyService).getContextKeyValue(TunnelViewSelectionKeyName);
1494
- const tunnel = context ? remoteExplorerService.tunnelModel.forwarded.get(context) : undefined;
1495
- if (tunnel) {
1496
- const tunnelService = accessor.get(ITunnelService);
1497
- tunnelContext = TunnelItem.createFromTunnel(remoteExplorerService, tunnelService, tunnel);
1498
- }
1499
- }
1500
- if (tunnelContext) {
1501
- const tunnelItem = tunnelContext;
1502
- remoteExplorerService.setEditable(tunnelItem, TunnelEditId.LocalPort, {
1503
- onFinish: async (value, success) => {
1504
- remoteExplorerService.setEditable(tunnelItem, TunnelEditId.LocalPort, null);
1505
- if (success) {
1506
- await remoteExplorerService.close({ host: tunnelItem.remoteHost, port: tunnelItem.remotePort }, TunnelCloseReason.Other);
1507
- const numberValue = Number(value);
1508
- const newForward = await remoteExplorerService.forward({
1509
- remote: { host: tunnelItem.remoteHost, port: tunnelItem.remotePort },
1510
- local: numberValue,
1511
- name: tunnelItem.name,
1512
- elevateIfNeeded: true,
1513
- source: tunnelItem.source
1514
- });
1515
- if (newForward && (typeof newForward !== 'string') && newForward.tunnelLocalPort !== numberValue) {
1516
- notificationService.warn(( nls.localizeWithPath(
1517
- 'vs/workbench/contrib/remote/browser/tunnelView',
1518
- 'remote.tunnel.changeLocalPortNumber',
1519
- "The local port {0} is not available. Port number {1} has been used instead",
1520
- value,
1521
- newForward.tunnelLocalPort ?? newForward.localAddress
1522
- )));
1523
- }
1524
- }
1525
- },
1526
- validationMessage: (value) => validateInput(tunnelService, value, tunnelService.canElevate),
1527
- placeholder: ( nls.localizeWithPath(
1528
- 'vs/workbench/contrib/remote/browser/tunnelView',
1529
- 'remote.tunnelsView.changePort',
1530
- "New local port"
1531
- ))
1532
- });
1533
- }
1534
- };
1535
- }
1536
- ChangeLocalPortAction.handler = handler;
1537
- })(ChangeLocalPortAction || (ChangeLocalPortAction = {})));
1538
- var ChangeTunnelPrivacyAction;
1539
- ( (function(ChangeTunnelPrivacyAction) {
1540
- function handler(privacyId) {
1541
- return async (accessor, arg) => {
1542
- if (isITunnelItem(arg)) {
1543
- const remoteExplorerService = accessor.get(IRemoteExplorerService);
1544
- await remoteExplorerService.close({ host: arg.remoteHost, port: arg.remotePort }, TunnelCloseReason.Other);
1545
- return remoteExplorerService.forward({
1546
- remote: { host: arg.remoteHost, port: arg.remotePort },
1547
- local: arg.localPort,
1548
- name: arg.name,
1549
- elevateIfNeeded: true,
1550
- privacy: privacyId,
1551
- source: arg.source
1552
- });
1553
- }
1554
- return undefined;
1555
- };
1556
- }
1557
- ChangeTunnelPrivacyAction.handler = handler;
1558
- })(ChangeTunnelPrivacyAction || (ChangeTunnelPrivacyAction = {})));
1559
- var SetTunnelProtocolAction;
1560
- ( (function(SetTunnelProtocolAction) {
1561
- SetTunnelProtocolAction.ID_HTTP = 'remote.tunnel.setProtocolHttp';
1562
- SetTunnelProtocolAction.ID_HTTPS = 'remote.tunnel.setProtocolHttps';
1563
- SetTunnelProtocolAction.LABEL_HTTP = ( nls.localizeWithPath(
1564
- 'vs/workbench/contrib/remote/browser/tunnelView',
1565
- 'remote.tunnel.protocolHttp',
1566
- "HTTP"
1567
- ));
1568
- SetTunnelProtocolAction.LABEL_HTTPS = ( nls.localizeWithPath(
1569
- 'vs/workbench/contrib/remote/browser/tunnelView',
1570
- 'remote.tunnel.protocolHttps',
1571
- "HTTPS"
1572
- ));
1573
- async function handler(arg, protocol, remoteExplorerService) {
1574
- if (isITunnelItem(arg)) {
1575
- const attributes = {
1576
- protocol
1577
- };
1578
- return remoteExplorerService.tunnelModel.configPortsAttributes.addAttributes(arg.remotePort, attributes, 4 );
1579
- }
1580
- }
1581
- function handlerHttp() {
1582
- return async (accessor, arg) => {
1583
- return handler(arg, TunnelProtocol.Http, accessor.get(IRemoteExplorerService));
1584
- };
1585
- }
1586
- SetTunnelProtocolAction.handlerHttp = handlerHttp;
1587
- function handlerHttps() {
1588
- return async (accessor, arg) => {
1589
- return handler(arg, TunnelProtocol.Https, accessor.get(IRemoteExplorerService));
1590
- };
1591
- }
1592
- SetTunnelProtocolAction.handlerHttps = handlerHttps;
1593
- })(SetTunnelProtocolAction || (SetTunnelProtocolAction = {})));
1594
- const tunnelViewCommandsWeightBonus = 10;
1595
- const isForwardedExpr = ( TunnelTypeContextKey.isEqualTo(TunnelType.Forwarded));
1596
- const isForwardedOrDetectedExpr = ( ContextKeyExpr.or(isForwardedExpr, ( TunnelTypeContextKey.isEqualTo(TunnelType.Detected))));
1597
- const isNotMultiSelectionExpr = ( TunnelViewMultiSelectionContextKey.isEqualTo(undefined));
1598
- KeybindingsRegistry.registerCommandAndKeybindingRule({
1599
- id: LabelTunnelAction.ID,
1600
- weight: 200 + tunnelViewCommandsWeightBonus,
1601
- when: ( ContextKeyExpr.and(TunnelViewFocusContextKey, isForwardedExpr, isNotMultiSelectionExpr)),
1602
- primary: 60 ,
1603
- mac: {
1604
- primary: 3
1605
- },
1606
- handler: LabelTunnelAction.handler()
1607
- });
1608
- CommandsRegistry.registerCommand(ForwardPortAction.INLINE_ID, ForwardPortAction.inlineHandler());
1609
- CommandsRegistry.registerCommand(ForwardPortAction.COMMANDPALETTE_ID, ForwardPortAction.commandPaletteHandler());
1610
- KeybindingsRegistry.registerCommandAndKeybindingRule({
1611
- id: ClosePortAction.INLINE_ID,
1612
- weight: 200 + tunnelViewCommandsWeightBonus,
1613
- when: ( ContextKeyExpr.and(TunnelCloseableContextKey, TunnelViewFocusContextKey)),
1614
- primary: 20 ,
1615
- mac: {
1616
- primary: 2048 | 1 ,
1617
- secondary: [20 ]
1618
- },
1619
- handler: ClosePortAction.inlineHandler()
1620
- });
1621
- CommandsRegistry.registerCommand(ClosePortAction.COMMANDPALETTE_ID, ClosePortAction.commandPaletteHandler());
1622
- CommandsRegistry.registerCommand(OpenPortInBrowserAction.ID, OpenPortInBrowserAction.handler());
1623
- CommandsRegistry.registerCommand(OpenPortInPreviewAction.ID, OpenPortInPreviewAction.handler());
1624
- CommandsRegistry.registerCommand(OpenPortInBrowserCommandPaletteAction.ID, OpenPortInBrowserCommandPaletteAction.handler());
1625
- KeybindingsRegistry.registerCommandAndKeybindingRule({
1626
- id: CopyAddressAction.INLINE_ID,
1627
- weight: 200 + tunnelViewCommandsWeightBonus,
1628
- when: ( ContextKeyExpr.and(
1629
- TunnelViewFocusContextKey,
1630
- isForwardedOrDetectedExpr,
1631
- isNotMultiSelectionExpr
1632
- )),
1633
- primary: 2048 | 33 ,
1634
- handler: CopyAddressAction.inlineHandler()
1635
- });
1636
- CommandsRegistry.registerCommand(CopyAddressAction.COMMANDPALETTE_ID, CopyAddressAction.commandPaletteHandler());
1637
- CommandsRegistry.registerCommand(ChangeLocalPortAction.ID, ChangeLocalPortAction.handler());
1638
- CommandsRegistry.registerCommand(SetTunnelProtocolAction.ID_HTTP, SetTunnelProtocolAction.handlerHttp());
1639
- CommandsRegistry.registerCommand(SetTunnelProtocolAction.ID_HTTPS, SetTunnelProtocolAction.handlerHttps());
1640
- MenuRegistry.appendMenuItem(MenuId.CommandPalette, ({
1641
- command: {
1642
- id: ClosePortAction.COMMANDPALETTE_ID,
1643
- title: ClosePortAction.LABEL
1644
- },
1645
- when: forwardedPortsViewEnabled
1646
- }));
1647
- MenuRegistry.appendMenuItem(MenuId.CommandPalette, ({
1648
- command: {
1649
- id: ForwardPortAction.COMMANDPALETTE_ID,
1650
- title: ForwardPortAction.LABEL
1651
- },
1652
- when: forwardedPortsViewEnabled
1653
- }));
1654
- MenuRegistry.appendMenuItem(MenuId.CommandPalette, ({
1655
- command: {
1656
- id: CopyAddressAction.COMMANDPALETTE_ID,
1657
- title: CopyAddressAction.COMMANDPALETTE_LABEL
1658
- },
1659
- when: forwardedPortsViewEnabled
1660
- }));
1661
- MenuRegistry.appendMenuItem(MenuId.CommandPalette, ({
1662
- command: {
1663
- id: OpenPortInBrowserCommandPaletteAction.ID,
1664
- title: OpenPortInBrowserCommandPaletteAction.LABEL
1665
- },
1666
- when: forwardedPortsViewEnabled
1667
- }));
1668
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1669
- group: '._open',
1670
- order: 0,
1671
- command: {
1672
- id: OpenPortInBrowserAction.ID,
1673
- title: OpenPortInBrowserAction.LABEL,
1674
- },
1675
- when: ( ContextKeyExpr.and(isForwardedOrDetectedExpr, isNotMultiSelectionExpr))
1676
- }));
1677
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1678
- group: '._open',
1679
- order: 1,
1680
- command: {
1681
- id: OpenPortInPreviewAction.ID,
1682
- title: OpenPortInPreviewAction.LABEL,
1683
- },
1684
- when: ( ContextKeyExpr.and(isForwardedOrDetectedExpr, isNotMultiSelectionExpr))
1685
- }));
1686
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1687
- group: '0_manage',
1688
- order: 1,
1689
- command: {
1690
- id: LabelTunnelAction.ID,
1691
- title: LabelTunnelAction.LABEL,
1692
- icon: labelPortIcon
1693
- },
1694
- when: ( ContextKeyExpr.and(isForwardedExpr, isNotMultiSelectionExpr))
1695
- }));
1696
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1697
- group: '2_localaddress',
1698
- order: 0,
1699
- command: {
1700
- id: CopyAddressAction.INLINE_ID,
1701
- title: CopyAddressAction.INLINE_LABEL,
1702
- },
1703
- when: ( ContextKeyExpr.and(isForwardedOrDetectedExpr, isNotMultiSelectionExpr))
1704
- }));
1705
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1706
- group: '2_localaddress',
1707
- order: 1,
1708
- command: {
1709
- id: ChangeLocalPortAction.ID,
1710
- title: ChangeLocalPortAction.LABEL,
1711
- },
1712
- when: ( ContextKeyExpr.and(isForwardedExpr, PortChangableContextKey, isNotMultiSelectionExpr))
1713
- }));
1714
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1715
- group: '2_localaddress',
1716
- order: 2,
1717
- submenu: MenuId.TunnelPrivacy,
1718
- title: ( nls.localizeWithPath(
1719
- 'vs/workbench/contrib/remote/browser/tunnelView',
1720
- 'tunnelContext.privacyMenu',
1721
- "Port Visibility"
1722
- )),
1723
- when: ( ContextKeyExpr.and(isForwardedExpr, TunnelPrivacyEnabledContextKey))
1724
- }));
1725
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1726
- group: '2_localaddress',
1727
- order: 3,
1728
- submenu: MenuId.TunnelProtocol,
1729
- title: ( nls.localizeWithPath(
1730
- 'vs/workbench/contrib/remote/browser/tunnelView',
1731
- 'tunnelContext.protocolMenu',
1732
- "Change Port Protocol"
1733
- )),
1734
- when: ( ContextKeyExpr.and(isForwardedExpr, isNotMultiSelectionExpr))
1735
- }));
1736
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1737
- group: '3_forward',
1738
- order: 0,
1739
- command: {
1740
- id: ClosePortAction.INLINE_ID,
1741
- title: ClosePortAction.LABEL,
1742
- },
1743
- when: TunnelCloseableContextKey
1744
- }));
1745
- MenuRegistry.appendMenuItem(MenuId.TunnelContext, ({
1746
- group: '3_forward',
1747
- order: 1,
1748
- command: {
1749
- id: ForwardPortAction.INLINE_ID,
1750
- title: ForwardPortAction.LABEL,
1751
- },
1752
- }));
1753
- MenuRegistry.appendMenuItem(MenuId.TunnelProtocol, ({
1754
- order: 0,
1755
- command: {
1756
- id: SetTunnelProtocolAction.ID_HTTP,
1757
- title: SetTunnelProtocolAction.LABEL_HTTP,
1758
- toggled: ( TunnelProtocolContextKey.isEqualTo(TunnelProtocol.Http))
1759
- }
1760
- }));
1761
- MenuRegistry.appendMenuItem(MenuId.TunnelProtocol, ({
1762
- order: 1,
1763
- command: {
1764
- id: SetTunnelProtocolAction.ID_HTTPS,
1765
- title: SetTunnelProtocolAction.LABEL_HTTPS,
1766
- toggled: ( TunnelProtocolContextKey.isEqualTo(TunnelProtocol.Https))
1767
- }
1768
- }));
1769
- MenuRegistry.appendMenuItem(MenuId.TunnelPortInline, ({
1770
- group: '0_manage',
1771
- order: 0,
1772
- command: {
1773
- id: ForwardPortAction.INLINE_ID,
1774
- title: ForwardPortAction.TREEITEM_LABEL,
1775
- icon: forwardPortIcon
1776
- },
1777
- when: ( TunnelTypeContextKey.isEqualTo(TunnelType.Candidate))
1778
- }));
1779
- MenuRegistry.appendMenuItem(MenuId.TunnelPortInline, ({
1780
- group: '0_manage',
1781
- order: 4,
1782
- command: {
1783
- id: LabelTunnelAction.ID,
1784
- title: LabelTunnelAction.LABEL,
1785
- icon: labelPortIcon
1786
- },
1787
- when: isForwardedExpr
1788
- }));
1789
- MenuRegistry.appendMenuItem(MenuId.TunnelPortInline, ({
1790
- group: '0_manage',
1791
- order: 5,
1792
- command: {
1793
- id: ClosePortAction.INLINE_ID,
1794
- title: ClosePortAction.LABEL,
1795
- icon: stopForwardIcon
1796
- },
1797
- when: TunnelCloseableContextKey
1798
- }));
1799
- MenuRegistry.appendMenuItem(MenuId.TunnelLocalAddressInline, ({
1800
- order: -1,
1801
- command: {
1802
- id: CopyAddressAction.INLINE_ID,
1803
- title: CopyAddressAction.INLINE_LABEL,
1804
- icon: copyAddressIcon
1805
- },
1806
- when: isForwardedOrDetectedExpr
1807
- }));
1808
- MenuRegistry.appendMenuItem(MenuId.TunnelLocalAddressInline, ({
1809
- order: 0,
1810
- command: {
1811
- id: OpenPortInBrowserAction.ID,
1812
- title: OpenPortInBrowserAction.LABEL,
1813
- icon: openBrowserIcon
1814
- },
1815
- when: isForwardedOrDetectedExpr
1816
- }));
1817
- MenuRegistry.appendMenuItem(MenuId.TunnelLocalAddressInline, ({
1818
- order: 1,
1819
- command: {
1820
- id: OpenPortInPreviewAction.ID,
1821
- title: OpenPortInPreviewAction.LABEL,
1822
- icon: openPreviewIcon
1823
- },
1824
- when: isForwardedOrDetectedExpr
1825
- }));
1826
- registerColor('ports.iconRunningProcessForeground', {
1827
- light: STATUS_BAR_REMOTE_ITEM_BACKGROUND,
1828
- dark: STATUS_BAR_REMOTE_ITEM_BACKGROUND,
1829
- hcDark: STATUS_BAR_REMOTE_ITEM_BACKGROUND,
1830
- hcLight: STATUS_BAR_REMOTE_ITEM_BACKGROUND
1831
- }, ( nls.localizeWithPath(
1832
- 'vs/workbench/contrib/remote/browser/tunnelView',
1833
- 'portWithRunningProcess.foreground',
1834
- "The color of the icon for a port that has an associated running process."
1835
- )));
1836
-
1837
- export { ForwardPortAction, OpenPortInBrowserAction, OpenPortInPreviewAction, TunnelPanel, openPreviewEnabledContext };