@codingame/monaco-vscode-api 1.85.0-next.2 → 1.85.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -10
- package/contributions.js +1 -0
- package/missing-services.js +91 -5
- package/monaco-editor-treemending.patch +2540 -2533
- package/package.json +6 -6
- package/vscode/src/vs/base/common/jsonFormatter.js +8 -1
- package/vscode/src/vs/platform/actions/browser/buttonbar.js +128 -0
- package/vscode/src/vs/platform/extensionManagement/common/extensionManagement.js +2 -1
- package/vscode/src/vs/platform/layout/browser/zIndexRegistry.js +58 -0
- package/vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.js +56 -1
- package/vscode/src/vs/workbench/browser/actions/layoutActions.js +186 -4
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp.js +191 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatActions.js +238 -2
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.js +75 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/actions/chatQuickInputActions.js +205 -1
- package/vscode/src/vs/workbench/contrib/chat/browser/chatEditorInput.js +168 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatFollowups.js +35 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatInputPart.js +340 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatListRenderer.js +1195 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.js +115 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatOptions.js +81 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.js +62 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/chatWidget.js +583 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/codeBlockPart.js +290 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.js +167 -0
- package/vscode/src/vs/workbench/contrib/chat/browser/media/chat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatContextKeys.js +6 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatModel.js +562 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatParserTypes.js +31 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatProvider.js +24 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatRequestParser.js +193 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatService.js +22 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatSlashCommands.js +52 -1
- package/vscode/src/vs/workbench/contrib/chat/common/chatViewModel.js +258 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWidgetHistoryService.js +37 -0
- package/vscode/src/vs/workbench/contrib/chat/common/chatWordCounter.js +25 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.js +388 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentColors.js +61 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentFormActions.js +49 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentNode.js +647 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentReply.js +300 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadAdditionalActions.js +60 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadBody.js +249 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadHeader.js +107 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/commentThreadWidget.js +333 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/media/review.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/reactionsAction.js +99 -0
- package/vscode/src/vs/workbench/contrib/comments/browser/timestamp.js +55 -0
- package/vscode/src/vs/workbench/contrib/comments/common/commentsConfiguration.js +2 -0
- package/vscode/src/vs/workbench/contrib/contextmenu/browser/contextmenu.contribution.js +20 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.js +855 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointWidget.js +410 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/breakpointsView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/callStackEditorContribution.js +178 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/breakpointWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/browser/media/callStackEditorContribution.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugModel.js +1485 -0
- package/vscode/src/vs/workbench/contrib/debug/common/debugSource.js +125 -0
- package/vscode/src/vs/workbench/contrib/debug/common/disassemblyViewInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +41 -0
- package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +102 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatController.js +988 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatLivePreviewWidget.js +431 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatSession.js +417 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatStrategies.js +806 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.js +915 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/browser/utils.js +19 -0
- package/vscode/src/vs/workbench/contrib/inlineChat/common/inlineChat.js +129 -10
- package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +205 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInput.js +150 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorInputModel.js +480 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeMarkers/mergeMarkersController.js +5 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/diffComputer.js +90 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/editing.js +54 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/lineRange.js +108 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mapping.js +258 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/mergeEditorModel.js +614 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.js +307 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/rangeUtils.js +44 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs.js +165 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/telemetry.js +78 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/utils.js +169 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/common/mergeEditor.js +64 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/clipboard/cellOutputClipboard.js +49 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findFilters.js +70 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +120 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/findModel.js +416 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.js +663 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOperations.js +593 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/cellOutputActions.js +72 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/coreActions.js +326 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/editActions.js +539 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/foldingController.js +265 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/controller/insertCellActions.js +348 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebook.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellChat.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellEditorHint.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellInsertToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellOutput.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellStatusBar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookCellTitleToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookDnd.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookEditorStickyScroll.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFocusIndicator.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookFolding.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookKernelActionViewItem.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookOutline.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/media/notebookToolbar.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookBrowser.js +95 -3
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditor.js +437 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorExtensions.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +2730 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookIcons.js +139 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookLogger.js +17 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookOptions.js +564 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/notebookViewEvents.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellPart.js +119 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellActionView.js +27 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellComments.js +135 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys.js +178 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDecorations.js +35 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd.js +377 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellDragRenderer.js +97 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions.js +194 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellExecution.js +71 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocus.js +20 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellFocusIndicator.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellOutput.js +652 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellStatusPart.js +303 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbarStickyScroll.js +24 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars.js +228 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatActions.js +302 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatController.js +438 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/chat/cellChatPart.js +45 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCell.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellExecutionIcon.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/codeCellRunToolbar.js +107 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellInput.js +29 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/collapsedCellOutput.js +59 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/foldedCellHint.js +67 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/cellParts/markupCell.js +430 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellAnchor.js +54 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellList.js +1131 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/notebookCellListView.js +21 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.js +1591 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.js +341 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.js +2155 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/webviewThemeMapping.js +65 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/OutlineEntry.js +95 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.js +507 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellEditorOptions.js +85 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellOutputViewModel.js +47 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/cellSelectionCollection.js +40 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.js +435 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher.js +31 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/foldingModel.js +257 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel.js +239 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineEntryFactory.js +103 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider.js +211 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModelImpl.js +808 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewModel/viewContext.js +8 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll.js +381 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorToolbar.js +527 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookEditorWidgetContextKeys.js +163 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelQuickPickStrategy.js +651 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookKernelView.js +173 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookOverviewRuler.js +98 -0
- package/vscode/src/vs/workbench/contrib/notebook/browser/viewParts/notebookTopCellToolbar.js +62 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellOutputTextModel.js +101 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/model/notebookCellTextModel.js +346 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookCommon.js +152 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookContextKeys.js +39 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorInput.js +296 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookEditorModel.js +261 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookExecutionService.js +3 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKernelService.js +2 -1
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookKeymapService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookLoggingService.js +3 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookPerformance.js +16 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/notebookRange.js +66 -0
- package/vscode/src/vs/workbench/contrib/notebook/common/services/notebookWorkerService.js +4 -0
- package/vscode/src/vs/workbench/contrib/preferences/common/settingsEditorColorRegistry.js +130 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/media/tunnelView.css.js +4 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteExplorer.js +847 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/remoteIcons.js +89 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/tunnelView.js +1942 -0
- package/vscode/src/vs/workbench/contrib/remote/browser/urlFinder.js +107 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsBase.js +49 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchActionsFind.js +387 -0
- package/vscode/src/vs/workbench/contrib/search/browser/searchModel.js +2 -2
- package/vscode/src/vs/workbench/contrib/search/common/constants.js +66 -0
- package/vscode/src/vs/workbench/contrib/searchEditor/browser/constants.js +11 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/abstractSnippetsActions.js +24 -0
- package/vscode/src/vs/workbench/contrib/snippets/browser/commands/fileTemplateSnippets.js +95 -0
- package/vscode/src/vs/workbench/contrib/terminal/browser/terminal.js +4 -1
- package/vscode/src/vs/workbench/contrib/terminal/common/terminal.js +2 -1
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/featuredExtensionService.js +159 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +375 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +563 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +932 -0
- package/vscode/src/vs/workbench/services/layout/browser/layoutService.js +15 -1
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.d.ts +2 -2
- package/vscode/src/vs/workbench/services/remote/common/remoteExplorerService.js +190 -2
- package/vscode/src/vs/workbench/services/workingCopy/common/resourceWorkingCopy.js +77 -0
- package/assets/break.mp3 +0 -0
- package/assets/chatRequestSent.mp3 +0 -0
- package/assets/chatResponsePending.mp3 +0 -0
- package/assets/chatResponseReceived1.mp3 +0 -0
- package/assets/chatResponseReceived2.mp3 +0 -0
- package/assets/chatResponseReceived3.mp3 +0 -0
- package/assets/chatResponseReceived4.mp3 +0 -0
- package/assets/clear.mp3 +0 -0
- package/assets/defaultIcon.png +0 -0
- package/assets/diffLineDeleted.mp3 +0 -0
- package/assets/diffLineInserted.mp3 +0 -0
- package/assets/diffLineModified.mp3 +0 -0
- package/assets/error.mp3 +0 -0
- package/assets/fake.html +0 -10
- package/assets/foldedAreas.mp3 +0 -0
- package/assets/format.mp3 +0 -0
- package/assets/index-no-csp.html +0 -1226
- package/assets/index.html +0 -1227
- package/assets/quickFixes.mp3 +0 -0
- package/assets/save.mp3 +0 -0
- package/assets/service-worker.js +0 -457
- package/assets/taskCompleted.mp3 +0 -0
- package/assets/taskFailed.mp3 +0 -0
- package/assets/terminalBell.mp3 +0 -0
- package/assets/warning.mp3 +0 -0
- package/assets/webWorkerExtensionHostIframe.html +0 -123
- package/override/vs/workbench/contrib/notebook/browser/contrib/find/findMatchDecorationModel.js +0 -2
- package/override/vs/workbench/contrib/notebook/browser/notebookEditorWidget.js +0 -2
- package/override/vs/workbench/contrib/notebook/common/notebookEditorInput.js +0 -5
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
|
|
2
|
+
import * as nls from 'monaco-editor/esm/vs/nls.js';
|
|
3
|
+
import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
|
|
4
|
+
import { Extensions } from '../../../common/views.js';
|
|
5
|
+
import { TUNNEL_VIEW_ID, TUNNEL_VIEW_CONTAINER_ID, PORT_AUTO_SOURCE_SETTING, PORT_AUTO_SOURCE_SETTING_PROCESS, PORT_AUTO_SOURCE_SETTING_HYBRID, PORT_AUTO_SOURCE_SETTING_OUTPUT, PORT_AUTO_FORWARD_SETTING, IRemoteExplorerService } from '../../../services/remote/common/remoteExplorerService.js';
|
|
6
|
+
import { OnPortForward, mapHasAddressLocalhostOrAllInterfaces, TunnelCloseReason, AutoTunnelSource, forwardedPortsViewEnabled, TunnelSource, makeAddress } from '../../../services/remote/common/tunnelModel.js';
|
|
7
|
+
import { OpenPortInPreviewAction, OpenPortInBrowserAction, TunnelPanel, openPreviewEnabledContext, ForwardPortAction, TunnelPanelDescriptor, TunnelViewModel } from './tunnelView.js';
|
|
8
|
+
import { IContextKeyService } from 'monaco-editor/esm/vs/platform/contextkey/common/contextkey.js';
|
|
9
|
+
import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.js';
|
|
10
|
+
import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
|
|
11
|
+
import { IStatusbarService } from '../../../services/statusbar/browser/statusbar.js';
|
|
12
|
+
import { UrlFinder } from './urlFinder.js';
|
|
13
|
+
import Severity from 'monaco-editor/esm/vs/base/common/severity.js';
|
|
14
|
+
import { INotificationService } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
|
|
15
|
+
import { IOpenerService } from 'monaco-editor/esm/vs/platform/opener/common/opener.js';
|
|
16
|
+
import { ITerminalService } from '../../terminal/browser/terminal.js';
|
|
17
|
+
import { IDebugService } from '../../debug/common/debug.js';
|
|
18
|
+
import { IRemoteAgentService } from '../../../services/remote/common/remoteAgentService.js';
|
|
19
|
+
import { isWeb } from 'monaco-editor/esm/vs/base/common/platform.js';
|
|
20
|
+
import { TunnelPrivacyId, ITunnelService } from '../../../../platform/tunnel/common/tunnel.js';
|
|
21
|
+
import { SyncDescriptor } from 'monaco-editor/esm/vs/platform/instantiation/common/descriptors.js';
|
|
22
|
+
import { ViewPaneContainer } from '../../../browser/parts/views/viewPaneContainer.js';
|
|
23
|
+
import { NumberBadge, IActivityService } from '../../../services/activity/common/activity.js';
|
|
24
|
+
import { portsViewIcon } from './remoteIcons.js';
|
|
25
|
+
import { Event } from 'monaco-editor/esm/vs/base/common/event.js';
|
|
26
|
+
import { IExternalUriOpenerService } from '../../externalUriOpener/common/externalUriOpenerService.js';
|
|
27
|
+
import { IHostService } from '../../../services/host/browser/host.js';
|
|
28
|
+
import { Extensions as Extensions$1 } from 'monaco-editor/esm/vs/platform/configuration/common/configurationRegistry.js';
|
|
29
|
+
import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
|
|
30
|
+
import { IWorkbenchConfigurationService } from '../../../services/configuration/common/configuration.js';
|
|
31
|
+
import { Action } from 'monaco-editor/esm/vs/base/common/actions.js';
|
|
32
|
+
import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
|
|
33
|
+
import { IPreferencesService } from '../../../services/preferences/common/preferences.js';
|
|
34
|
+
const VIEWLET_ID = 'workbench.view.remote';
|
|
35
|
+
const CAN_PROC_FALLBACK = 'processPortForwardingFallback';
|
|
36
|
+
let ForwardedPortsView = class ForwardedPortsView extends Disposable {
|
|
37
|
+
constructor(contextKeyService, environmentService, remoteExplorerService, tunnelService, activityService, statusbarService) {
|
|
38
|
+
super();
|
|
39
|
+
this.contextKeyService = contextKeyService;
|
|
40
|
+
this.environmentService = environmentService;
|
|
41
|
+
this.remoteExplorerService = remoteExplorerService;
|
|
42
|
+
this.tunnelService = tunnelService;
|
|
43
|
+
this.activityService = activityService;
|
|
44
|
+
this.statusbarService = statusbarService;
|
|
45
|
+
this._register(( ( Registry.as(Extensions.ViewsRegistry)).registerViewWelcomeContent(TUNNEL_VIEW_ID, {
|
|
46
|
+
content: this.environmentService.remoteAuthority ? ( nls.localizeWithPath(
|
|
47
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
48
|
+
'remoteNoPorts',
|
|
49
|
+
"No forwarded ports. Forward a port to access your running services locally.\n[Forward a Port]({0})",
|
|
50
|
+
`command:${ForwardPortAction.INLINE_ID}`
|
|
51
|
+
))
|
|
52
|
+
: ( nls.localizeWithPath(
|
|
53
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
54
|
+
'noRemoteNoPorts',
|
|
55
|
+
"No forwarded ports. Forward a port to access your locally running services over the internet.\n[Forward a Port]({0})",
|
|
56
|
+
`command:${ForwardPortAction.INLINE_ID}`
|
|
57
|
+
)),
|
|
58
|
+
})));
|
|
59
|
+
this.enableBadgeAndStatusBar();
|
|
60
|
+
this.enableForwardedPortsView();
|
|
61
|
+
}
|
|
62
|
+
async getViewContainer() {
|
|
63
|
+
return ( Registry.as(Extensions.ViewContainersRegistry)).registerViewContainer({
|
|
64
|
+
id: TUNNEL_VIEW_CONTAINER_ID,
|
|
65
|
+
title: { value: ( nls.localizeWithPath('vs/workbench/contrib/remote/browser/remoteExplorer', 'ports', "Ports")), original: 'Ports' },
|
|
66
|
+
icon: portsViewIcon,
|
|
67
|
+
ctorDescriptor: ( new SyncDescriptor(
|
|
68
|
+
ViewPaneContainer,
|
|
69
|
+
[TUNNEL_VIEW_CONTAINER_ID, { mergeViewWithContainerWhenSingleView: true }]
|
|
70
|
+
)),
|
|
71
|
+
storageId: TUNNEL_VIEW_CONTAINER_ID,
|
|
72
|
+
hideIfEmpty: true,
|
|
73
|
+
order: 5
|
|
74
|
+
}, 1 );
|
|
75
|
+
}
|
|
76
|
+
async enableForwardedPortsView() {
|
|
77
|
+
if (this.contextKeyListener) {
|
|
78
|
+
this.contextKeyListener.dispose();
|
|
79
|
+
this.contextKeyListener = undefined;
|
|
80
|
+
}
|
|
81
|
+
const viewEnabled = !!forwardedPortsViewEnabled.getValue(this.contextKeyService);
|
|
82
|
+
if (viewEnabled) {
|
|
83
|
+
const viewContainer = await this.getViewContainer();
|
|
84
|
+
const tunnelPanelDescriptor = ( new TunnelPanelDescriptor(( new TunnelViewModel(this.remoteExplorerService, this.tunnelService)), this.environmentService));
|
|
85
|
+
const viewsRegistry = ( Registry.as(Extensions.ViewsRegistry));
|
|
86
|
+
if (viewContainer) {
|
|
87
|
+
this.remoteExplorerService.enablePortsFeatures();
|
|
88
|
+
viewsRegistry.registerViews([tunnelPanelDescriptor], viewContainer);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.contextKeyListener = this.contextKeyService.onDidChangeContext(e => {
|
|
93
|
+
if (e.affectsSome(( new Set(( forwardedPortsViewEnabled.keys()))))) {
|
|
94
|
+
this.enableForwardedPortsView();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
enableBadgeAndStatusBar() {
|
|
100
|
+
const disposable = ( Registry.as(Extensions.ViewsRegistry)).onViewsRegistered(e => {
|
|
101
|
+
if (e.find(view => view.views.find(viewDescriptor => viewDescriptor.id === TUNNEL_VIEW_ID))) {
|
|
102
|
+
this._register(Event.debounce(this.remoteExplorerService.tunnelModel.onForwardPort, (_last, e) => e, 50)(() => {
|
|
103
|
+
this.updateActivityBadge();
|
|
104
|
+
this.updateStatusBar();
|
|
105
|
+
}));
|
|
106
|
+
this._register(Event.debounce(this.remoteExplorerService.tunnelModel.onClosePort, (_last, e) => e, 50)(() => {
|
|
107
|
+
this.updateActivityBadge();
|
|
108
|
+
this.updateStatusBar();
|
|
109
|
+
}));
|
|
110
|
+
this.updateActivityBadge();
|
|
111
|
+
this.updateStatusBar();
|
|
112
|
+
disposable.dispose();
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async updateActivityBadge() {
|
|
117
|
+
this._activityBadge?.dispose();
|
|
118
|
+
if (this.remoteExplorerService.tunnelModel.forwarded.size > 0) {
|
|
119
|
+
this._activityBadge = this.activityService.showViewActivity(TUNNEL_VIEW_ID, {
|
|
120
|
+
badge: ( new NumberBadge(
|
|
121
|
+
this.remoteExplorerService.tunnelModel.forwarded.size,
|
|
122
|
+
n => n === 1 ? ( nls.localizeWithPath(
|
|
123
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
124
|
+
'1forwardedPort',
|
|
125
|
+
"1 forwarded port"
|
|
126
|
+
)) : ( nls.localizeWithPath(
|
|
127
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
128
|
+
'nForwardedPorts',
|
|
129
|
+
"{0} forwarded ports",
|
|
130
|
+
n
|
|
131
|
+
))
|
|
132
|
+
))
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
updateStatusBar() {
|
|
137
|
+
if (!this.entryAccessor) {
|
|
138
|
+
this._register(this.entryAccessor = this.statusbarService.addEntry(this.entry, 'status.forwardedPorts', 0 , 40));
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
this.entryAccessor.update(this.entry);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
get entry() {
|
|
145
|
+
let tooltip;
|
|
146
|
+
const count = this.remoteExplorerService.tunnelModel.forwarded.size + this.remoteExplorerService.tunnelModel.detected.size;
|
|
147
|
+
const text = `${count}`;
|
|
148
|
+
if (count === 0) {
|
|
149
|
+
tooltip = ( nls.localizeWithPath(
|
|
150
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
151
|
+
'remote.forwardedPorts.statusbarTextNone',
|
|
152
|
+
"No Ports Forwarded"
|
|
153
|
+
));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const allTunnels = Array.from(( this.remoteExplorerService.tunnelModel.forwarded.values()));
|
|
157
|
+
allTunnels.push(...Array.from(( this.remoteExplorerService.tunnelModel.detected.values())));
|
|
158
|
+
tooltip = ( nls.localizeWithPath(
|
|
159
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
160
|
+
'remote.forwardedPorts.statusbarTooltip',
|
|
161
|
+
"Forwarded Ports: {0}",
|
|
162
|
+
( allTunnels.map(forwarded => forwarded.remotePort)).join(', ')
|
|
163
|
+
));
|
|
164
|
+
}
|
|
165
|
+
return {
|
|
166
|
+
name: ( nls.localizeWithPath(
|
|
167
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
168
|
+
'status.forwardedPorts',
|
|
169
|
+
"Forwarded Ports"
|
|
170
|
+
)),
|
|
171
|
+
text: `$(radio-tower) ${text}`,
|
|
172
|
+
ariaLabel: tooltip,
|
|
173
|
+
tooltip,
|
|
174
|
+
command: `${TUNNEL_VIEW_ID}.focus`
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
ForwardedPortsView = ( __decorate([
|
|
179
|
+
( __param(0, IContextKeyService)),
|
|
180
|
+
( __param(1, IWorkbenchEnvironmentService)),
|
|
181
|
+
( __param(2, IRemoteExplorerService)),
|
|
182
|
+
( __param(3, ITunnelService)),
|
|
183
|
+
( __param(4, IActivityService)),
|
|
184
|
+
( __param(5, IStatusbarService))
|
|
185
|
+
], ForwardedPortsView));
|
|
186
|
+
let PortRestore = class PortRestore {
|
|
187
|
+
constructor(remoteExplorerService, logService) {
|
|
188
|
+
this.remoteExplorerService = remoteExplorerService;
|
|
189
|
+
this.logService = logService;
|
|
190
|
+
if (!this.remoteExplorerService.tunnelModel.environmentTunnelsSet) {
|
|
191
|
+
Event.once(this.remoteExplorerService.tunnelModel.onEnvironmentTunnelsSet)(async () => {
|
|
192
|
+
await this.restore();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
this.restore();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async restore() {
|
|
200
|
+
this.logService.trace('ForwardedPorts: Doing first restore.');
|
|
201
|
+
return this.remoteExplorerService.restore();
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
PortRestore = ( __decorate([
|
|
205
|
+
( __param(0, IRemoteExplorerService)),
|
|
206
|
+
( __param(1, ILogService))
|
|
207
|
+
], PortRestore));
|
|
208
|
+
let AutomaticPortForwarding = class AutomaticPortForwarding extends Disposable {
|
|
209
|
+
constructor(terminalService, notificationService, openerService, externalOpenerService, remoteExplorerService, environmentService, contextKeyService, configurationService, debugService, remoteAgentService, tunnelService, hostService, logService, storageService, preferencesService) {
|
|
210
|
+
super();
|
|
211
|
+
this.terminalService = terminalService;
|
|
212
|
+
this.notificationService = notificationService;
|
|
213
|
+
this.openerService = openerService;
|
|
214
|
+
this.externalOpenerService = externalOpenerService;
|
|
215
|
+
this.remoteExplorerService = remoteExplorerService;
|
|
216
|
+
this.environmentService = environmentService;
|
|
217
|
+
this.contextKeyService = contextKeyService;
|
|
218
|
+
this.configurationService = configurationService;
|
|
219
|
+
this.debugService = debugService;
|
|
220
|
+
this.remoteAgentService = remoteAgentService;
|
|
221
|
+
this.tunnelService = tunnelService;
|
|
222
|
+
this.hostService = hostService;
|
|
223
|
+
this.logService = logService;
|
|
224
|
+
this.storageService = storageService;
|
|
225
|
+
this.preferencesService = preferencesService;
|
|
226
|
+
if (!environmentService.remoteAuthority) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
configurationService.whenRemoteConfigurationLoaded().then(() => remoteAgentService.getEnvironment()).then(environment => {
|
|
230
|
+
this.setup(environment);
|
|
231
|
+
this._register(configurationService.onDidChangeConfiguration(e => {
|
|
232
|
+
if (e.affectsConfiguration(PORT_AUTO_SOURCE_SETTING)) {
|
|
233
|
+
this.setup(environment);
|
|
234
|
+
}
|
|
235
|
+
}));
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
canFallbackToHybrid() {
|
|
239
|
+
return this.storageService.getBoolean(CAN_PROC_FALLBACK, 1 , true);
|
|
240
|
+
}
|
|
241
|
+
listenForPorts() {
|
|
242
|
+
if (this.procForwarder && !this.portListener && this.canFallbackToHybrid() && this.configurationService.getValue(PORT_AUTO_SOURCE_SETTING) === PORT_AUTO_SOURCE_SETTING_PROCESS) {
|
|
243
|
+
this.portListener = this._register(this.remoteExplorerService.tunnelModel.onForwardPort(async () => {
|
|
244
|
+
if (Array.from(( this.remoteExplorerService.tunnelModel.forwarded.values())).filter(tunnel => tunnel.source.source === TunnelSource.Auto).length > 20) {
|
|
245
|
+
await this.configurationService.updateValue(PORT_AUTO_SOURCE_SETTING, PORT_AUTO_SOURCE_SETTING_HYBRID);
|
|
246
|
+
this.notificationService.notify({
|
|
247
|
+
message: ( nls.localizeWithPath(
|
|
248
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
249
|
+
'remote.autoForwardPortsSource.fallback',
|
|
250
|
+
"Over 20 ports have been automatically forwarded. The `process` based automatic port forwarding has been switched to `hybrid` in settings. Some ports may no longer be detected."
|
|
251
|
+
)),
|
|
252
|
+
severity: Severity.Warning,
|
|
253
|
+
actions: {
|
|
254
|
+
primary: [
|
|
255
|
+
( new Action('switchBack', ( nls.localizeWithPath(
|
|
256
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
257
|
+
'remote.autoForwardPortsSource.fallback.switchBack',
|
|
258
|
+
"Undo"
|
|
259
|
+
)), undefined, true, async () => {
|
|
260
|
+
await this.configurationService.updateValue(PORT_AUTO_SOURCE_SETTING, PORT_AUTO_SOURCE_SETTING_PROCESS);
|
|
261
|
+
this.storageService.store(CAN_PROC_FALLBACK, false, 1 , 0 );
|
|
262
|
+
this.portListener?.dispose();
|
|
263
|
+
this.portListener = undefined;
|
|
264
|
+
})),
|
|
265
|
+
( new Action('showPortSourceSetting', ( nls.localizeWithPath(
|
|
266
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
267
|
+
'remote.autoForwardPortsSource.fallback.showPortSourceSetting',
|
|
268
|
+
"Show Setting"
|
|
269
|
+
)), undefined, true, async () => {
|
|
270
|
+
await this.preferencesService.openSettings({
|
|
271
|
+
query: 'remote.autoForwardPortsSource'
|
|
272
|
+
});
|
|
273
|
+
}))
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
this.portListener?.dispose();
|
|
282
|
+
this.portListener = undefined;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
setup(environment) {
|
|
286
|
+
const alreadyForwarded = this.procForwarder?.forwarded;
|
|
287
|
+
const isSwitch = this.outputForwarder || this.procForwarder;
|
|
288
|
+
this.procForwarder?.dispose();
|
|
289
|
+
this.procForwarder = undefined;
|
|
290
|
+
this.outputForwarder?.dispose();
|
|
291
|
+
this.outputForwarder = undefined;
|
|
292
|
+
if (environment?.os !== 3 ) {
|
|
293
|
+
( Registry.as(Extensions$1.Configuration))
|
|
294
|
+
.registerDefaultConfigurations([{ overrides: { 'remote.autoForwardPortsSource': PORT_AUTO_SOURCE_SETTING_OUTPUT } }]);
|
|
295
|
+
this.outputForwarder = this._register(( new OutputAutomaticPortForwarding(
|
|
296
|
+
this.terminalService,
|
|
297
|
+
this.notificationService,
|
|
298
|
+
this.openerService,
|
|
299
|
+
this.externalOpenerService,
|
|
300
|
+
this.remoteExplorerService,
|
|
301
|
+
this.configurationService,
|
|
302
|
+
this.debugService,
|
|
303
|
+
this.tunnelService,
|
|
304
|
+
this.hostService,
|
|
305
|
+
this.logService,
|
|
306
|
+
this.contextKeyService,
|
|
307
|
+
() => false
|
|
308
|
+
)));
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
const useProc = () => (this.configurationService.getValue(PORT_AUTO_SOURCE_SETTING) === PORT_AUTO_SOURCE_SETTING_PROCESS);
|
|
312
|
+
if (useProc()) {
|
|
313
|
+
this.procForwarder = this._register(( new ProcAutomaticPortForwarding(
|
|
314
|
+
false,
|
|
315
|
+
alreadyForwarded,
|
|
316
|
+
!isSwitch,
|
|
317
|
+
this.configurationService,
|
|
318
|
+
this.remoteExplorerService,
|
|
319
|
+
this.notificationService,
|
|
320
|
+
this.openerService,
|
|
321
|
+
this.externalOpenerService,
|
|
322
|
+
this.tunnelService,
|
|
323
|
+
this.hostService,
|
|
324
|
+
this.logService,
|
|
325
|
+
this.contextKeyService
|
|
326
|
+
)));
|
|
327
|
+
}
|
|
328
|
+
else if (this.configurationService.getValue(PORT_AUTO_SOURCE_SETTING) === PORT_AUTO_SOURCE_SETTING_HYBRID) {
|
|
329
|
+
this.procForwarder = this._register(( new ProcAutomaticPortForwarding(
|
|
330
|
+
true,
|
|
331
|
+
alreadyForwarded,
|
|
332
|
+
!isSwitch,
|
|
333
|
+
this.configurationService,
|
|
334
|
+
this.remoteExplorerService,
|
|
335
|
+
this.notificationService,
|
|
336
|
+
this.openerService,
|
|
337
|
+
this.externalOpenerService,
|
|
338
|
+
this.tunnelService,
|
|
339
|
+
this.hostService,
|
|
340
|
+
this.logService,
|
|
341
|
+
this.contextKeyService
|
|
342
|
+
)));
|
|
343
|
+
}
|
|
344
|
+
this.outputForwarder = this._register(( new OutputAutomaticPortForwarding(
|
|
345
|
+
this.terminalService,
|
|
346
|
+
this.notificationService,
|
|
347
|
+
this.openerService,
|
|
348
|
+
this.externalOpenerService,
|
|
349
|
+
this.remoteExplorerService,
|
|
350
|
+
this.configurationService,
|
|
351
|
+
this.debugService,
|
|
352
|
+
this.tunnelService,
|
|
353
|
+
this.hostService,
|
|
354
|
+
this.logService,
|
|
355
|
+
this.contextKeyService,
|
|
356
|
+
useProc
|
|
357
|
+
)));
|
|
358
|
+
}
|
|
359
|
+
this.listenForPorts();
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
AutomaticPortForwarding = ( __decorate([
|
|
363
|
+
( __param(0, ITerminalService)),
|
|
364
|
+
( __param(1, INotificationService)),
|
|
365
|
+
( __param(2, IOpenerService)),
|
|
366
|
+
( __param(3, IExternalUriOpenerService)),
|
|
367
|
+
( __param(4, IRemoteExplorerService)),
|
|
368
|
+
( __param(5, IWorkbenchEnvironmentService)),
|
|
369
|
+
( __param(6, IContextKeyService)),
|
|
370
|
+
( __param(7, IWorkbenchConfigurationService)),
|
|
371
|
+
( __param(8, IDebugService)),
|
|
372
|
+
( __param(9, IRemoteAgentService)),
|
|
373
|
+
( __param(10, ITunnelService)),
|
|
374
|
+
( __param(11, IHostService)),
|
|
375
|
+
( __param(12, ILogService)),
|
|
376
|
+
( __param(13, IStorageService)),
|
|
377
|
+
( __param(14, IPreferencesService))
|
|
378
|
+
], AutomaticPortForwarding));
|
|
379
|
+
class OnAutoForwardedAction extends Disposable {
|
|
380
|
+
static { this.NOTIFY_COOL_DOWN = 5000; }
|
|
381
|
+
constructor(notificationService, remoteExplorerService, openerService, externalOpenerService, tunnelService, hostService, logService, contextKeyService) {
|
|
382
|
+
super();
|
|
383
|
+
this.notificationService = notificationService;
|
|
384
|
+
this.remoteExplorerService = remoteExplorerService;
|
|
385
|
+
this.openerService = openerService;
|
|
386
|
+
this.externalOpenerService = externalOpenerService;
|
|
387
|
+
this.tunnelService = tunnelService;
|
|
388
|
+
this.hostService = hostService;
|
|
389
|
+
this.logService = logService;
|
|
390
|
+
this.contextKeyService = contextKeyService;
|
|
391
|
+
this.alreadyOpenedOnce = ( new Set());
|
|
392
|
+
this.lastNotifyTime = ( new Date());
|
|
393
|
+
this.lastNotifyTime.setFullYear(this.lastNotifyTime.getFullYear() - 1);
|
|
394
|
+
}
|
|
395
|
+
async doAction(tunnels) {
|
|
396
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) Starting action for ${tunnels[0]?.tunnelRemotePort}`);
|
|
397
|
+
this.doActionTunnels = tunnels;
|
|
398
|
+
const tunnel = await this.portNumberHeuristicDelay();
|
|
399
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) Heuristic chose ${tunnel?.tunnelRemotePort}`);
|
|
400
|
+
if (tunnel) {
|
|
401
|
+
const allAttributes = await this.remoteExplorerService.tunnelModel.getAttributes([{ port: tunnel.tunnelRemotePort, host: tunnel.tunnelRemoteHost }]);
|
|
402
|
+
const attributes = allAttributes?.get(tunnel.tunnelRemotePort)?.onAutoForward;
|
|
403
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) onAutoForward action is ${attributes}`);
|
|
404
|
+
switch (attributes) {
|
|
405
|
+
case OnPortForward.OpenBrowserOnce: {
|
|
406
|
+
if (( this.alreadyOpenedOnce.has(tunnel.localAddress))) {
|
|
407
|
+
break;
|
|
408
|
+
}
|
|
409
|
+
this.alreadyOpenedOnce.add(tunnel.localAddress);
|
|
410
|
+
}
|
|
411
|
+
case OnPortForward.OpenBrowser: {
|
|
412
|
+
const address = makeAddress(tunnel.tunnelRemoteHost, tunnel.tunnelRemotePort);
|
|
413
|
+
await OpenPortInBrowserAction.run(this.remoteExplorerService.tunnelModel, this.openerService, address);
|
|
414
|
+
break;
|
|
415
|
+
}
|
|
416
|
+
case OnPortForward.OpenPreview: {
|
|
417
|
+
const address = makeAddress(tunnel.tunnelRemoteHost, tunnel.tunnelRemotePort);
|
|
418
|
+
await OpenPortInPreviewAction.run(this.remoteExplorerService.tunnelModel, this.openerService, this.externalOpenerService, address);
|
|
419
|
+
break;
|
|
420
|
+
}
|
|
421
|
+
case OnPortForward.Silent: break;
|
|
422
|
+
default: {
|
|
423
|
+
const elapsed = ( new Date()).getTime() - this.lastNotifyTime.getTime();
|
|
424
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) time elapsed since last notification ${elapsed} ms`);
|
|
425
|
+
if (elapsed > OnAutoForwardedAction.NOTIFY_COOL_DOWN) {
|
|
426
|
+
await this.showNotification(tunnel);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
hide(removedPorts) {
|
|
433
|
+
if (this.doActionTunnels) {
|
|
434
|
+
this.doActionTunnels = this.doActionTunnels.filter(value => !removedPorts.includes(value.tunnelRemotePort));
|
|
435
|
+
}
|
|
436
|
+
if (this.lastShownPort && removedPorts.indexOf(this.lastShownPort) >= 0) {
|
|
437
|
+
this.lastNotification?.close();
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
async portNumberHeuristicDelay() {
|
|
441
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) Starting heuristic delay`);
|
|
442
|
+
if (!this.doActionTunnels || this.doActionTunnels.length === 0) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
this.doActionTunnels = this.doActionTunnels.sort((a, b) => a.tunnelRemotePort - b.tunnelRemotePort);
|
|
446
|
+
const firstTunnel = this.doActionTunnels.shift();
|
|
447
|
+
if (firstTunnel.tunnelRemotePort % 1000 === 0) {
|
|
448
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) Heuristic chose tunnel because % 1000: ${firstTunnel.tunnelRemotePort}`);
|
|
449
|
+
this.newerTunnel = firstTunnel;
|
|
450
|
+
return firstTunnel;
|
|
451
|
+
}
|
|
452
|
+
else if (firstTunnel.tunnelRemotePort < 10000 && firstTunnel.tunnelRemotePort !== 9229) {
|
|
453
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) Heuristic chose tunnel because < 10000: ${firstTunnel.tunnelRemotePort}`);
|
|
454
|
+
this.newerTunnel = firstTunnel;
|
|
455
|
+
return firstTunnel;
|
|
456
|
+
}
|
|
457
|
+
this.logService.trace(`ForwardedPorts: (OnAutoForwardedAction) Waiting for "better" tunnel than ${firstTunnel.tunnelRemotePort}`);
|
|
458
|
+
this.newerTunnel = undefined;
|
|
459
|
+
return ( new Promise(resolve => {
|
|
460
|
+
setTimeout(() => {
|
|
461
|
+
if (this.newerTunnel) {
|
|
462
|
+
resolve(undefined);
|
|
463
|
+
}
|
|
464
|
+
else if (this.doActionTunnels?.includes(firstTunnel)) {
|
|
465
|
+
resolve(firstTunnel);
|
|
466
|
+
}
|
|
467
|
+
else {
|
|
468
|
+
resolve(undefined);
|
|
469
|
+
}
|
|
470
|
+
}, 3000);
|
|
471
|
+
}));
|
|
472
|
+
}
|
|
473
|
+
basicMessage(tunnel) {
|
|
474
|
+
return ( nls.localizeWithPath(
|
|
475
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
476
|
+
'remote.tunnelsView.automaticForward',
|
|
477
|
+
"Your application running on port {0} is available. ",
|
|
478
|
+
tunnel.tunnelRemotePort
|
|
479
|
+
));
|
|
480
|
+
}
|
|
481
|
+
linkMessage() {
|
|
482
|
+
return ( nls.localizeWithPath(
|
|
483
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
484
|
+
{ key: 'remote.tunnelsView.notificationLink2', comment: ['[See all forwarded ports]({0}) is a link. Only translate `See all forwarded ports`. Do not change brackets and parentheses or {0}'] },
|
|
485
|
+
"[See all forwarded ports]({0})",
|
|
486
|
+
`command:${TunnelPanel.ID}.focus`
|
|
487
|
+
));
|
|
488
|
+
}
|
|
489
|
+
async showNotification(tunnel) {
|
|
490
|
+
if (!(await this.hostService.hadLastFocus())) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
this.lastNotification?.close();
|
|
494
|
+
let message = this.basicMessage(tunnel);
|
|
495
|
+
const choices = [this.openBrowserChoice(tunnel)];
|
|
496
|
+
if (!isWeb || openPreviewEnabledContext.getValue(this.contextKeyService)) {
|
|
497
|
+
choices.push(this.openPreviewChoice(tunnel));
|
|
498
|
+
}
|
|
499
|
+
if ((tunnel.tunnelLocalPort !== tunnel.tunnelRemotePort) && this.tunnelService.canElevate && this.tunnelService.isPortPrivileged(tunnel.tunnelRemotePort)) {
|
|
500
|
+
message += ( nls.localizeWithPath(
|
|
501
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
502
|
+
'remote.tunnelsView.elevationMessage',
|
|
503
|
+
"You'll need to run as superuser to use port {0} locally. ",
|
|
504
|
+
tunnel.tunnelRemotePort
|
|
505
|
+
));
|
|
506
|
+
choices.unshift(this.elevateChoice(tunnel));
|
|
507
|
+
}
|
|
508
|
+
if (tunnel.privacy === TunnelPrivacyId.Private && isWeb && this.tunnelService.canChangePrivacy) {
|
|
509
|
+
choices.push(this.makePublicChoice(tunnel));
|
|
510
|
+
}
|
|
511
|
+
message += this.linkMessage();
|
|
512
|
+
this.lastNotification = this.notificationService.prompt(Severity.Info, message, choices, { neverShowAgain: { id: 'remote.tunnelsView.autoForwardNeverShow', isSecondary: true } });
|
|
513
|
+
this.lastShownPort = tunnel.tunnelRemotePort;
|
|
514
|
+
this.lastNotifyTime = ( new Date());
|
|
515
|
+
this.lastNotification.onDidClose(() => {
|
|
516
|
+
this.lastNotification = undefined;
|
|
517
|
+
this.lastShownPort = undefined;
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
makePublicChoice(tunnel) {
|
|
521
|
+
return {
|
|
522
|
+
label: ( nls.localizeWithPath(
|
|
523
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
524
|
+
'remote.tunnelsView.makePublic',
|
|
525
|
+
"Make Public"
|
|
526
|
+
)),
|
|
527
|
+
run: async () => {
|
|
528
|
+
const oldTunnelDetails = mapHasAddressLocalhostOrAllInterfaces(this.remoteExplorerService.tunnelModel.forwarded, tunnel.tunnelRemoteHost, tunnel.tunnelRemotePort);
|
|
529
|
+
await this.remoteExplorerService.close({ host: tunnel.tunnelRemoteHost, port: tunnel.tunnelRemotePort }, TunnelCloseReason.Other);
|
|
530
|
+
return this.remoteExplorerService.forward({
|
|
531
|
+
remote: { host: tunnel.tunnelRemoteHost, port: tunnel.tunnelRemotePort },
|
|
532
|
+
local: tunnel.tunnelLocalPort,
|
|
533
|
+
name: oldTunnelDetails?.name,
|
|
534
|
+
elevateIfNeeded: true,
|
|
535
|
+
privacy: TunnelPrivacyId.Public,
|
|
536
|
+
source: oldTunnelDetails?.source
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
openBrowserChoice(tunnel) {
|
|
542
|
+
const address = makeAddress(tunnel.tunnelRemoteHost, tunnel.tunnelRemotePort);
|
|
543
|
+
return {
|
|
544
|
+
label: OpenPortInBrowserAction.LABEL,
|
|
545
|
+
run: () => OpenPortInBrowserAction.run(this.remoteExplorerService.tunnelModel, this.openerService, address)
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
openPreviewChoice(tunnel) {
|
|
549
|
+
const address = makeAddress(tunnel.tunnelRemoteHost, tunnel.tunnelRemotePort);
|
|
550
|
+
return {
|
|
551
|
+
label: OpenPortInPreviewAction.LABEL,
|
|
552
|
+
run: () => OpenPortInPreviewAction.run(this.remoteExplorerService.tunnelModel, this.openerService, this.externalOpenerService, address)
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
elevateChoice(tunnel) {
|
|
556
|
+
return {
|
|
557
|
+
label: ( nls.localizeWithPath(
|
|
558
|
+
'vs/workbench/contrib/remote/browser/remoteExplorer',
|
|
559
|
+
'remote.tunnelsView.elevationButton',
|
|
560
|
+
"Use Port {0} as Sudo...",
|
|
561
|
+
tunnel.tunnelRemotePort
|
|
562
|
+
)),
|
|
563
|
+
run: async () => {
|
|
564
|
+
await this.remoteExplorerService.close({ host: tunnel.tunnelRemoteHost, port: tunnel.tunnelRemotePort }, TunnelCloseReason.Other);
|
|
565
|
+
const newTunnel = await this.remoteExplorerService.forward({
|
|
566
|
+
remote: { host: tunnel.tunnelRemoteHost, port: tunnel.tunnelRemotePort },
|
|
567
|
+
local: tunnel.tunnelRemotePort,
|
|
568
|
+
elevateIfNeeded: true,
|
|
569
|
+
source: AutoTunnelSource
|
|
570
|
+
});
|
|
571
|
+
if (!newTunnel || (typeof newTunnel === 'string')) {
|
|
572
|
+
return;
|
|
573
|
+
}
|
|
574
|
+
this.lastNotification?.close();
|
|
575
|
+
this.lastShownPort = newTunnel.tunnelRemotePort;
|
|
576
|
+
this.lastNotification = this.notificationService.prompt(Severity.Info, this.basicMessage(newTunnel) + this.linkMessage(), [this.openBrowserChoice(newTunnel), this.openPreviewChoice(tunnel)], { neverShowAgain: { id: 'remote.tunnelsView.autoForwardNeverShow', isSecondary: true } });
|
|
577
|
+
this.lastNotification.onDidClose(() => {
|
|
578
|
+
this.lastNotification = undefined;
|
|
579
|
+
this.lastShownPort = undefined;
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
class OutputAutomaticPortForwarding extends Disposable {
|
|
586
|
+
constructor(terminalService, notificationService, openerService, externalOpenerService, remoteExplorerService, configurationService, debugService, tunnelService, hostService, logService, contextKeyService, privilegedOnly) {
|
|
587
|
+
super();
|
|
588
|
+
this.terminalService = terminalService;
|
|
589
|
+
this.notificationService = notificationService;
|
|
590
|
+
this.openerService = openerService;
|
|
591
|
+
this.externalOpenerService = externalOpenerService;
|
|
592
|
+
this.remoteExplorerService = remoteExplorerService;
|
|
593
|
+
this.configurationService = configurationService;
|
|
594
|
+
this.debugService = debugService;
|
|
595
|
+
this.tunnelService = tunnelService;
|
|
596
|
+
this.hostService = hostService;
|
|
597
|
+
this.logService = logService;
|
|
598
|
+
this.contextKeyService = contextKeyService;
|
|
599
|
+
this.privilegedOnly = privilegedOnly;
|
|
600
|
+
this.notifier = ( new OnAutoForwardedAction(
|
|
601
|
+
notificationService,
|
|
602
|
+
remoteExplorerService,
|
|
603
|
+
openerService,
|
|
604
|
+
externalOpenerService,
|
|
605
|
+
tunnelService,
|
|
606
|
+
hostService,
|
|
607
|
+
logService,
|
|
608
|
+
contextKeyService
|
|
609
|
+
));
|
|
610
|
+
this._register(configurationService.onDidChangeConfiguration((e) => {
|
|
611
|
+
if (e.affectsConfiguration(PORT_AUTO_FORWARD_SETTING)) {
|
|
612
|
+
this.tryStartStopUrlFinder();
|
|
613
|
+
}
|
|
614
|
+
}));
|
|
615
|
+
this.portsFeatures = this._register(this.remoteExplorerService.onEnabledPortsFeatures(() => {
|
|
616
|
+
this.tryStartStopUrlFinder();
|
|
617
|
+
}));
|
|
618
|
+
this.tryStartStopUrlFinder();
|
|
619
|
+
if (configurationService.getValue(PORT_AUTO_SOURCE_SETTING) === PORT_AUTO_SOURCE_SETTING_HYBRID) {
|
|
620
|
+
this._register(this.tunnelService.onTunnelClosed(tunnel => this.notifier.hide([tunnel.port])));
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
tryStartStopUrlFinder() {
|
|
624
|
+
if (this.configurationService.getValue(PORT_AUTO_FORWARD_SETTING)) {
|
|
625
|
+
this.startUrlFinder();
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
this.stopUrlFinder();
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
startUrlFinder() {
|
|
632
|
+
if (!this.urlFinder && !this.remoteExplorerService.portsFeaturesEnabled) {
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
this.portsFeatures?.dispose();
|
|
636
|
+
this.urlFinder = this._register(( new UrlFinder(this.terminalService, this.debugService)));
|
|
637
|
+
this._register(this.urlFinder.onDidMatchLocalUrl(async (localUrl) => {
|
|
638
|
+
if (mapHasAddressLocalhostOrAllInterfaces(this.remoteExplorerService.tunnelModel.detected, localUrl.host, localUrl.port)) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const attributes = (await this.remoteExplorerService.tunnelModel.getAttributes([localUrl]))?.get(localUrl.port);
|
|
642
|
+
if (attributes?.onAutoForward === OnPortForward.Ignore) {
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
if (this.privilegedOnly() && !this.tunnelService.isPortPrivileged(localUrl.port)) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
const forwarded = await this.remoteExplorerService.forward({ remote: localUrl, source: AutoTunnelSource }, attributes ?? null);
|
|
649
|
+
if (forwarded && (typeof forwarded !== 'string')) {
|
|
650
|
+
this.notifier.doAction([forwarded]);
|
|
651
|
+
}
|
|
652
|
+
}));
|
|
653
|
+
}
|
|
654
|
+
stopUrlFinder() {
|
|
655
|
+
if (this.urlFinder) {
|
|
656
|
+
this.urlFinder.dispose();
|
|
657
|
+
this.urlFinder = undefined;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
class ProcAutomaticPortForwarding extends Disposable {
|
|
662
|
+
constructor(unforwardOnly, alreadyAutoForwarded, needsInitialCandidates, configurationService, remoteExplorerService, notificationService, openerService, externalOpenerService, tunnelService, hostService, logService, contextKeyService) {
|
|
663
|
+
super();
|
|
664
|
+
this.unforwardOnly = unforwardOnly;
|
|
665
|
+
this.alreadyAutoForwarded = alreadyAutoForwarded;
|
|
666
|
+
this.needsInitialCandidates = needsInitialCandidates;
|
|
667
|
+
this.configurationService = configurationService;
|
|
668
|
+
this.remoteExplorerService = remoteExplorerService;
|
|
669
|
+
this.notificationService = notificationService;
|
|
670
|
+
this.openerService = openerService;
|
|
671
|
+
this.externalOpenerService = externalOpenerService;
|
|
672
|
+
this.tunnelService = tunnelService;
|
|
673
|
+
this.hostService = hostService;
|
|
674
|
+
this.logService = logService;
|
|
675
|
+
this.contextKeyService = contextKeyService;
|
|
676
|
+
this.autoForwarded = ( new Set());
|
|
677
|
+
this.notifiedOnly = ( new Set());
|
|
678
|
+
this.initialCandidates = ( new Set());
|
|
679
|
+
this.notifier = ( new OnAutoForwardedAction(
|
|
680
|
+
notificationService,
|
|
681
|
+
remoteExplorerService,
|
|
682
|
+
openerService,
|
|
683
|
+
externalOpenerService,
|
|
684
|
+
tunnelService,
|
|
685
|
+
hostService,
|
|
686
|
+
logService,
|
|
687
|
+
contextKeyService
|
|
688
|
+
));
|
|
689
|
+
alreadyAutoForwarded?.forEach(port => this.autoForwarded.add(port));
|
|
690
|
+
this.initialize();
|
|
691
|
+
}
|
|
692
|
+
get forwarded() {
|
|
693
|
+
return this.autoForwarded;
|
|
694
|
+
}
|
|
695
|
+
async initialize() {
|
|
696
|
+
if (!this.remoteExplorerService.tunnelModel.environmentTunnelsSet) {
|
|
697
|
+
await ( new Promise(
|
|
698
|
+
resolve => this.remoteExplorerService.tunnelModel.onEnvironmentTunnelsSet(() => resolve())
|
|
699
|
+
));
|
|
700
|
+
}
|
|
701
|
+
this._register(this.configurationService.onDidChangeConfiguration(async (e) => {
|
|
702
|
+
if (e.affectsConfiguration(PORT_AUTO_FORWARD_SETTING)) {
|
|
703
|
+
await this.startStopCandidateListener();
|
|
704
|
+
}
|
|
705
|
+
}));
|
|
706
|
+
this.portsFeatures = this._register(this.remoteExplorerService.onEnabledPortsFeatures(async () => {
|
|
707
|
+
await this.startStopCandidateListener();
|
|
708
|
+
}));
|
|
709
|
+
this.startStopCandidateListener();
|
|
710
|
+
}
|
|
711
|
+
async startStopCandidateListener() {
|
|
712
|
+
if (this.configurationService.getValue(PORT_AUTO_FORWARD_SETTING)) {
|
|
713
|
+
await this.startCandidateListener();
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
this.stopCandidateListener();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
stopCandidateListener() {
|
|
720
|
+
if (this.candidateListener) {
|
|
721
|
+
this.candidateListener.dispose();
|
|
722
|
+
this.candidateListener = undefined;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
async startCandidateListener() {
|
|
726
|
+
if (this.candidateListener || !this.remoteExplorerService.portsFeaturesEnabled) {
|
|
727
|
+
return;
|
|
728
|
+
}
|
|
729
|
+
this.portsFeatures?.dispose();
|
|
730
|
+
await this.setInitialCandidates();
|
|
731
|
+
if (this.configurationService.getValue(PORT_AUTO_FORWARD_SETTING)) {
|
|
732
|
+
this.candidateListener = this._register(this.remoteExplorerService.tunnelModel.onCandidatesChanged(this.handleCandidateUpdate, this));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
async setInitialCandidates() {
|
|
736
|
+
if (!this.needsInitialCandidates) {
|
|
737
|
+
this.logService.debug(`ForwardedPorts: (ProcForwarding) Not setting initial candidates`);
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
let startingCandidates = this.remoteExplorerService.tunnelModel.candidatesOrUndefined;
|
|
741
|
+
if (!startingCandidates) {
|
|
742
|
+
await ( new Promise(
|
|
743
|
+
resolve => this.remoteExplorerService.tunnelModel.onCandidatesChanged(() => resolve())
|
|
744
|
+
));
|
|
745
|
+
startingCandidates = this.remoteExplorerService.tunnelModel.candidates;
|
|
746
|
+
}
|
|
747
|
+
for (const value of startingCandidates) {
|
|
748
|
+
this.initialCandidates.add(makeAddress(value.host, value.port));
|
|
749
|
+
}
|
|
750
|
+
this.logService.debug(`ForwardedPorts: (ProcForwarding) Initial candidates set to ${( startingCandidates.map(candidate => candidate.port)).join(', ')}`);
|
|
751
|
+
}
|
|
752
|
+
async forwardCandidates() {
|
|
753
|
+
let attributes;
|
|
754
|
+
const allTunnels = [];
|
|
755
|
+
this.logService.trace(`ForwardedPorts: (ProcForwarding) Attempting to forward ${this.remoteExplorerService.tunnelModel.candidates.length} candidates`);
|
|
756
|
+
for (const value of this.remoteExplorerService.tunnelModel.candidates) {
|
|
757
|
+
if (!value.detail) {
|
|
758
|
+
this.logService.trace(`ForwardedPorts: (ProcForwarding) Port ${value.port} missing detail`);
|
|
759
|
+
continue;
|
|
760
|
+
}
|
|
761
|
+
if (!attributes) {
|
|
762
|
+
attributes = await this.remoteExplorerService.tunnelModel.getAttributes(this.remoteExplorerService.tunnelModel.candidates);
|
|
763
|
+
}
|
|
764
|
+
const portAttributes = attributes?.get(value.port);
|
|
765
|
+
const address = makeAddress(value.host, value.port);
|
|
766
|
+
if (( this.initialCandidates.has(address)) && (portAttributes?.onAutoForward === undefined)) {
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (( this.notifiedOnly.has(address)) || ( this.autoForwarded.has(address))) {
|
|
770
|
+
continue;
|
|
771
|
+
}
|
|
772
|
+
const alreadyForwarded = mapHasAddressLocalhostOrAllInterfaces(this.remoteExplorerService.tunnelModel.forwarded, value.host, value.port);
|
|
773
|
+
if (mapHasAddressLocalhostOrAllInterfaces(this.remoteExplorerService.tunnelModel.detected, value.host, value.port)) {
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
if (portAttributes?.onAutoForward === OnPortForward.Ignore) {
|
|
777
|
+
this.logService.trace(`ForwardedPorts: (ProcForwarding) Port ${value.port} is ignored`);
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
const forwarded = await this.remoteExplorerService.forward({ remote: value, source: AutoTunnelSource }, portAttributes ?? null);
|
|
781
|
+
if (!alreadyForwarded && forwarded) {
|
|
782
|
+
this.logService.trace(`ForwardedPorts: (ProcForwarding) Port ${value.port} has been forwarded`);
|
|
783
|
+
this.autoForwarded.add(address);
|
|
784
|
+
}
|
|
785
|
+
else if (forwarded) {
|
|
786
|
+
this.logService.trace(`ForwardedPorts: (ProcForwarding) Port ${value.port} has been notified`);
|
|
787
|
+
this.notifiedOnly.add(address);
|
|
788
|
+
}
|
|
789
|
+
if (forwarded && (typeof forwarded !== 'string')) {
|
|
790
|
+
allTunnels.push(forwarded);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
this.logService.trace(`ForwardedPorts: (ProcForwarding) Forwarded ${allTunnels.length} candidates`);
|
|
794
|
+
if (allTunnels.length === 0) {
|
|
795
|
+
return undefined;
|
|
796
|
+
}
|
|
797
|
+
return allTunnels;
|
|
798
|
+
}
|
|
799
|
+
async handleCandidateUpdate(removed) {
|
|
800
|
+
const removedPorts = [];
|
|
801
|
+
let autoForwarded;
|
|
802
|
+
if (this.unforwardOnly) {
|
|
803
|
+
autoForwarded = ( new Map());
|
|
804
|
+
for (const entry of this.remoteExplorerService.tunnelModel.forwarded.entries()) {
|
|
805
|
+
if (entry[1].source.source === TunnelSource.Auto) {
|
|
806
|
+
autoForwarded.set(entry[0], entry[1]);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
autoForwarded = ( new Map(this.autoForwarded.entries()));
|
|
812
|
+
}
|
|
813
|
+
for (const removedPort of removed) {
|
|
814
|
+
const key = removedPort[0];
|
|
815
|
+
let value = removedPort[1];
|
|
816
|
+
const forwardedValue = mapHasAddressLocalhostOrAllInterfaces(autoForwarded, value.host, value.port);
|
|
817
|
+
if (forwardedValue) {
|
|
818
|
+
if (typeof forwardedValue === 'string') {
|
|
819
|
+
this.autoForwarded.delete(key);
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
value = { host: forwardedValue.remoteHost, port: forwardedValue.remotePort };
|
|
823
|
+
}
|
|
824
|
+
await this.remoteExplorerService.close(value, TunnelCloseReason.AutoForwardEnd);
|
|
825
|
+
removedPorts.push(value.port);
|
|
826
|
+
}
|
|
827
|
+
else if (( this.notifiedOnly.has(key))) {
|
|
828
|
+
this.notifiedOnly.delete(key);
|
|
829
|
+
removedPorts.push(value.port);
|
|
830
|
+
}
|
|
831
|
+
else if (( this.initialCandidates.has(key))) {
|
|
832
|
+
this.initialCandidates.delete(key);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
if (this.unforwardOnly) {
|
|
836
|
+
return;
|
|
837
|
+
}
|
|
838
|
+
if (removedPorts.length > 0) {
|
|
839
|
+
await this.notifier.hide(removedPorts);
|
|
840
|
+
}
|
|
841
|
+
const tunnels = await this.forwardCandidates();
|
|
842
|
+
if (tunnels) {
|
|
843
|
+
await this.notifier.doAction(tunnels);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
export { AutomaticPortForwarding, CAN_PROC_FALLBACK, ForwardedPortsView, PortRestore, VIEWLET_ID };
|