1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
(()=>{"use strict";var e={689:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.VIEW_ID=void 0,t.VIEW_ID="remoteTargets"},352:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DeferredPromise=void 0,t.DeferredPromise=class{get isRejected(){return 1===this.outcome?.outcome}get isResolved(){return 0===this.outcome?.outcome}get isSettled(){return!!this.outcome}get value(){return 0===this.outcome?.outcome?this.outcome?.value:void 0}constructor(){this.p=new Promise(((e,t)=>{this.completeCallback=e,this.errorCallback=t}))}complete(e){return new Promise((t=>{this.completeCallback(e),this.outcome={outcome:0,value:e},t()}))}error(e){return new Promise((t=>{this.errorCallback(e),this.outcome={outcome:1,value:e},t()}))}}},970:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RemoteTreeDataProvider=void 0;const o=n(496),s=n(496),r=n(689),i=n(352),l=n(236),a=n(413),m=n(286),c="remote-internal.getSshFoldersHistory",u="ms-vscode-remote.remote-ssh",h="remote-tunnels.internal.getFoldersHistory",d="remote-tunnels.internal.getTunnelsList",p="ms-vscode.remote-server";function f(e){const t=(0,a.getTunnelTags)(e);if(t?.includes("vscode-server-launcher"))return t.length>=2?t.find((e=>"vscode-server-launcher"!==e&&!/^protocolv\d+$/.test(e)&&!e.startsWith("_"))):e.name||e.tunnelId}function g(e){const t=new i.DeferredPromise;return e.then((e=>t.complete(e)),(e=>t.error(e))),t}t.RemoteTreeDataProvider=class{constructor(e){this.tunnelAuthState={},this.tunnels=[],this.sshHosts={},this.onDidChangeTreeDataEmitter=new s.EventEmitter,this.onDidChangeTreeData=this.onDidChangeTreeDataEmitter.event,e.subscriptions.push(this.onDidChangeTreeDataEmitter),e.subscriptions.push(o.commands.registerCommand("remote-explorer.signIntoTunnelGithub",(()=>this.tunnelSignIn("github"))),o.commands.registerCommand("remote-explorer.signIntoTunnelMicrosoft",(()=>this.tunnelSignIn("microsoft"))),o.commands.registerCommand("remote-explorer.refresh",this.refresh,this),o.commands.registerCommand("remote-explorer.add",this.add,this),o.commands.registerCommand("remote-explorer.configureSsh",this.configure,this),o.commands.registerCommand("remote-explorer.deleteFolderHistoryItem",this.deleteFolderFromHistory,this),o.commands.registerCommand("remote-explorer.unregisterTunnel",this.unregisterTunnel,this),o.commands.registerCommand("remote-explorer.connectToRemoteInCurrentWindow",this.openRemoteInCurrentWindow,this),o.commands.registerCommand("remote-explorer.connectToRemoteInNewWindow",this.openRemoteInNewWindow,this),o.commands.registerCommand("remote-explorer.connectToFolderInCurrentWindow",this.openFolderCurrentWindow,this),o.commands.registerCommand("remote-explorer.connectToFolderInNewWindow",this.openFolderInNewWindow,this),o.commands.registerCommand("remote-explorer.connectToWslUsingDistro",this.connectToWslUsingDistro,this),o.commands.registerCommand("remote-explorer.connectToWslUsingDistroInNewWindow",this.connectToWslUsingDistroInNewWindow,this));const t=()=>o.extensions.allAcrossExtensionHosts.filter((e=>e.id===p)).length>0,n=()=>o.extensions.allAcrossExtensionHosts.filter((e=>e.id===u)).length>0;e.subscriptions.push(o.extensions.onDidChange((async()=>{this.tunnelExtInstalled=t(),this.sshExtInstalled=n(),await this.refresh()}))),this.tunnelExtInstalled=t(),this.sshExtInstalled=n(),this.refreshSshHostsPromise=this.refreshSshHosts(),this.refreshTunnelsPromise=this.refreshTunnels()}getTreeItem(e){return e.getTreeItem()}async getChildren(e){if(void 0===e){const e=[];return this.tunnelExtInstalled&&e.push(new a.RemoteGroupItem(a.RemoteGroupType.tunnels,this.refreshTunnelsPromise)),this.sshExtInstalled&&e.push(new a.RemoteGroupItem(a.RemoteGroupType.ssh,this.refreshSshHostsPromise)),e}if(e instanceof a.RemoteGroupItem&&e.type===a.RemoteGroupType.tunnels){const e=[],t=[];for(const n of this.tunnels){const s=n,r=f(s);if(void 0===r)continue;const i=void 0!==s.status.hostConnectionCount&&0!==s.status.hostConnectionCount,l=s.tunnelId===this.activeTunnel?.tunnelId,m=(await o.commands.executeCommand(h,r)).length>0;i?e.push(new a.RemoteTunnelItem(s,r,l,i,m)):t.push(new a.RemoteTunnelItem(s,r,l,i,m))}return[...e.sort(a.RemoteTunnelItem.compare),...t.sort(a.RemoteTunnelItem.compare),...a.allTunnelSignInProviders.filter((e=>!1===this.tunnelAuthState[e])).map((e=>new a.RemoteTunnelNotAuthenticated(e)))]}if(e instanceof a.RemoteGroupItem&&e.type===a.RemoteGroupType.ssh){const e=[],t=Object.keys(this.sshHosts);for(const n of t){const t=n===this.activeSshHost?.hostName,s=(await o.commands.executeCommand(c,n)).length>0;e.push(new a.RemoteSshItem(n,n,t,s))}return e}if(e instanceof a.RemoteTargetItem){const t=[];if(e.hasFolders){const n=e instanceof a.RemoteTunnelItem,s=await o.commands.executeCommand(n?h:c,e.label),r=(0,l.getActiveFolders)();for(const e of s)t.push(new a.FolderItem(e,n?a.RemoteProtocol.tunnel:a.RemoteProtocol.ssh,r.includes(e)));(0,m.explorerFolderSortOrder)()===m.FolderSortOrder.alphabetical&&t.sort(a.FolderItem.compare)}return e instanceof a.RemoteTunnelItem&&e.hasWsl?[...t,new a.TunnelWslItem(e.tunnel,e.name)]:t}return[]}async refresh(){await o.window.withProgress({location:{viewId:r.VIEW_ID}},(()=>Promise.all([this.refreshTunnels(),this.refreshSshHosts()])))}async unregisterTunnel(e){e instanceof a.RemoteTunnelItem&&await o.window.withProgress({location:{viewId:r.VIEW_ID}},(async()=>{await o.commands.executeCommand("remote-tunnels.internal.unregisterTunnel",e.tunnel),this.tunnels=this.tunnels.filter((t=>t.tunnelId!==e.tunnel.tunnelId)),this.onDidChangeTreeDataEmitter.fire()}))}async openRemoteInCurrentWindow(e){e instanceof a.RemoteTunnelItem?this.openRemoteTunnel(e,!1):e instanceof a.RemoteSshItem&&this.openSshHost(e,!1)}async openRemoteInNewWindow(e){e instanceof a.RemoteTunnelItem?this.openRemoteTunnel(e,!0):e instanceof a.RemoteSshItem&&this.openSshHost(e,!0)}async add(e){if(e.type===a.RemoteGroupType.ssh)try{return await o.commands.executeCommand("opensshremotes.addNewSshHost")}catch(e){o.commands.executeCommand("workbench.extensions.action.showExtensionsWithIds",[u])}else try{return await o.commands.executeCommand("remote-tunnels.connectCurrentWindowToTunnel")}catch(e){o.commands.executeCommand("workbench.extensions.action.showExtensionsWithIds",[p])}}async configure(){return await o.commands.executeCommand("opensshremotes.openConfigFile")}async openFolderCurrentWindow(e){if(e instanceof a.TunnelWslItem)return this.doWslCommandIfInstalled("remote-wsl.connect",e.hostAuthority);await o.commands.executeCommand("vscode.openFolder",e.toUri())}async openFolderInNewWindow(e){if(e instanceof a.TunnelWslItem)return this.doWslCommandIfInstalled("remote-wsl.connectInNewWindow",e.hostAuthority);await o.commands.executeCommand("vscode.openFolder",e.toUri(),!0)}async connectToWslUsingDistro(e){this.doWslCommandIfInstalled("remote-wsl.connectUsingDistro",e.hostAuthority)}async connectToWslUsingDistroInNewWindow(e){this.doWslCommandIfInstalled("remote-wsl.connectUsingDistroInNewWindow",e.hostAuthority)}async doWslCommandIfInstalled(e,...t){const n="ms-vscode-remote.remote-wsl",s="Show Extension";if(o.extensions.getExtension(n))return o.window.withProgress({location:o.ProgressLocation.Notification,title:"Tunneling to WSL..."},(()=>o.commands.executeCommand(e,...t)));await o.window.showInformationMessage('The extension "Remote - WSL" is required to use this command.',{modal:!0},s)===s&&o.commands.executeCommand("workbench.extensions.action.showExtensionsWithIds",[n])}async deleteFolderFromHistory(e){e.protocol===a.RemoteProtocol.ssh?await o.commands.executeCommand("remote-internal.deleteSshFolderFromHistory",e.fd):await o.commands.executeCommand("remote-tunnels.internal.deleteFolderFromHistory",e.fd),this.onDidChangeTreeDataEmitter.fire()}async tunnelSignIn(e){if(!this.tunnelExtInstalled)return;let t;try{t=await o.commands.executeCommand(d,e)}catch{return}this.tunnelAuthState[e]=!0,this.tunnels=this.tunnels.concat(t),this.onDidChangeTreeDataEmitter.fire()}refreshTunnels(){return this.refreshTunnelsPromise=g(this._refreshTunnels()),this.refreshTunnelsPromise.p.finally((()=>this.onDidChangeTreeDataEmitter.fire())),this.refreshTunnelsPromise}async _refreshTunnels(){if(!this.tunnelExtInstalled)return;if(void 0===this.tunnelAuthState.github){const e=await Promise.all(a.allTunnelSignInProviders.map((async e=>{let t;try{t=await o.commands.executeCommand("remote-tunnels.internal.isAuthenticated",e)}catch{t=!1}return{ok:t,provider:e}})));for(const{ok:t,provider:n}of e)this.tunnelAuthState[n]=t}const e=Promise.resolve(o.commands.executeCommand("remote-tunnels.internal.getActiveRemote")).catch((()=>{})),t=await Promise.all(a.allTunnelSignInProviders.map((e=>{if(!this.tunnelAuthState[e])return[];try{return o.commands.executeCommand(d,e)}catch(e){console.warn("error refreshing tunnels",e)}})));this.activeTunnel=await e,this.tunnels=t.flatMap((e=>e||[]))}refreshSshHosts(){return this.refreshSshHostsPromise=g(this._refreshSshHosts()),this.refreshSshHostsPromise.p.finally((()=>this.onDidChangeTreeDataEmitter.fire())),this.refreshSshHostsPromise}async _refreshSshHosts(){if(this.sshExtInstalled)try{[this.activeSshHost,this.sshHosts]=await Promise.all([o.commands.executeCommand("remote-internal.getActiveSshRemote"),o.commands.executeCommand("remote-internal.getConfiguredHostnames")])}catch(e){}}async openRemoteTunnel(e,t){await o.commands.executeCommand("remote-tunnels.internal.connectToRemote",e.label,t)}async openSshHost(e,t){const n={hostName:e.hostName};await o.commands.executeCommand("remote-internal.openRemoteSshTarget",n,t)}}},236:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.getActiveFolders=t.deactivate=t.activate=void 0;const o=n(496),s=n(689),r=n(970);let i=[];t.activate=async function(e){e.subscriptions.push(o.window.createTreeView(s.VIEW_ID,{treeDataProvider:new r.RemoteTreeDataProvider(e),showCollapseAll:!0}),o.commands.registerCommand("remote-internal.setActiveFolders",(e=>{i=e})))},t.deactivate=function(){},t.getActiveFolders=function(){return i}},413:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.RemoteProtocol=t.TunnelWslItem=t.FolderItem=t.RemoteSshItem=t.RemoteTunnelItem=t.RemoteTargetItem=t.getTunnelTags=t.RemoteTunnelNotAuthenticated=t.RemoteGroupItem=t.RemoteGroupType=t.allTunnelSignInProviders=void 0;const o=n(496),s=n(143);var r,i;t.allTunnelSignInProviders=["microsoft","github"],function(e){e[e.tunnels=0]="tunnels",e[e.ssh=1]="ssh"}(r=t.RemoteGroupType||(t.RemoteGroupType={})),t.RemoteGroupItem=class{constructor(e,t){this.type=e,this.busyProm=t}getTreeItem(){const e=new o.TreeItem(this.label,o.TreeItemCollapsibleState.Expanded);return this.type===r.ssh?e.contextValue="remote-explorer.sshGroup":e.contextValue="remote-explorer.tunnelGroup",this.busyProm.isSettled||(e.iconPath=new o.ThemeIcon("loading~spin")),e}get label(){return this.type===r.tunnels?"Tunnels":"SSH"}},t.RemoteTunnelNotAuthenticated=class{constructor(e){this.provider=e}getTreeItem(){let e;return"github"===this.provider?(e=new o.TreeItem(o.l10n.t("Sign in to tunnels registered with GitHub")),e.contextValue="remote-explorer.remoteTunnelSignInGithub",e.iconPath=new o.ThemeIcon("github")):(e=new o.TreeItem(o.l10n.t("Sign in to tunnels registered with Microsoft")),e.contextValue="remote-explorer.remoteTunnelSignInMicrosoft",e.iconPath=new o.ThemeIcon("azure")),e}},t.getTunnelTags=e=>e.tags||e.labels;class l{constructor(e,t,n){this.label=e,this.isActive=t,this.hasFolders=n,this.iconActive="vm-active",this.iconDefault="vm"}getTreeItem(){const e=new o.TreeItem(this.getLabel(),this.hasFolders?o.TreeItemCollapsibleState.Expanded:o.TreeItemCollapsibleState.None);return e.contextValue=this.type()===i.ssh?"remote-explorer.sshRemoteTarget":"remote-explorer.tunnelRemoteTarget",e.iconPath=new o.ThemeIcon(this.isActive?this.iconActive:this.iconDefault,this.isActive?new o.ThemeColor("debugIcon.startForeground"):this.iconColor),e.tooltip=this.tooltip,e.description=this.isActive?o.l10n.t("connected"):this.description,e}getLabel(){return this.label}get tooltip(){return this.label}get description(){return""}get iconColor(){}}t.RemoteTargetItem=l;class a extends l{constructor(e,t,n,o,s){super(t,n,s),this.tunnel=e,this.name=t,this.isOnline=o,this.iconDefault=o?"vm-running":"vm-outline"}getTreeItem(){const e=super.getTreeItem();return this.hasWsl&&(e.collapsibleState=o.TreeItemCollapsibleState.Expanded),e}get hasWsl(){const e=(0,t.getTunnelTags)(this.tunnel);if(!this.isOnline||!e)return!1;if(e.includes("_wsl"))return!0;const n="_flag",o=e.find((e=>e.startsWith(n)));return!!o&&!!(1&Number(o.slice(n.length)))}get tooltip(){return this.isOnline?`${this.label} is ready to connect to.`:`${this.label} is offline.`}get description(){return this.isOnline?o.l10n.t("running"):o.l10n.t("offline")}type(){return i.tunnel}}t.RemoteTunnelItem=a,a.compare=(e,t)=>e.label>t.label?1:e.label<t.label?-1:0,t.RemoteSshItem=class extends l{constructor(e,t,n,o){super(t,n,o),this.hostName=e}getTreeItem(){const e=super.getTreeItem();return o.workspace.getConfiguration("remote-explorer").get("collapseRecentFolders",!1)&&(e.collapsibleState=o.TreeItemCollapsibleState.Collapsed),e}type(){return i.ssh}};class m{constructor(e,t,n){this.fd=e,this.protocol=t,this.isActive=n}getTreeItem(){let e=this.fd.name??this.fd.folder.split(/[\\/]/g).pop();e.endsWith(".code-workspace")&&(e=`${e.replace(/\.code-workspace$/,"")} (Workspace)`);const t=new o.TreeItem(e),n=(0,s.clientPlatformAgnosticFsPath)(this.fd.folder);return t.description=n,t.tooltip=`'${n}' on ${this.fd.remote}`,t.contextValue="remote-explorer.remoteFolder",t.resourceUri=this.toUri(),t.iconPath=new o.ThemeIcon(this.isActive?"folder-active":"folder"),t}toUri(){return o.Uri.parse(`vscode-remote://${this.protocol}+${this.fd.remote}${this.fd.folder}`)}}t.FolderItem=m,m.compare=(e,t)=>e.fd.folder>t.fd.folder?1:e.fd.folder<t.fd.folder?-1:0,t.TunnelWslItem=class{constructor(e,t){this._tunnel=e,this.name=t}get hostAuthority(){return`tunnel+${this.name}`}getTreeItem(){const e=new o.TreeItem("Connect to WSL");return e.contextValue="remote-explorer.tunnelWsl",e.iconPath=new o.ThemeIcon("terminal-linux"),e}},function(e){e.ssh="ssh-remote",e.tunnel="tunnel"}(i=t.RemoteProtocol||(t.RemoteProtocol={}))},286:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.explorerFolderSortOrder=t.FolderSortOrder=void 0;const o=n(496);var s;!function(e){e[e.mru=1]="mru",e[e.alphabetical=2]="alphabetical"}(s=t.FolderSortOrder||(t.FolderSortOrder={}));t.explorerFolderSortOrder=function(){const e=o.l10n.t("most recently used");let t=o.workspace.getConfiguration().get("remote-explorer.foldersSortOrder")||o.workspace.getConfiguration().get("remote.SSH.foldersSortOrder")||e;return t===e&&(t="mru"),s[t]}},780:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.isWindows=void 0,t.isWindows="undefined"!=typeof process&&"win32"===process.platform},143:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.clientPlatformAgnosticFsPath=void 0;const o=n(496),s=n(780);t.clientPlatformAgnosticFsPath=function(e){const t=o.Uri.file(e);return s.isWindows&&!e.match(/^[a-z]:/i)?t.fsPath.replace(/\\/g,"/"):t.fsPath}},496:e=>{e.exports=require("vscode")}},t={},n=function n(o){var s=t[o];if(void 0!==s)return s.exports;var r=t[o]={exports:{}};return e[o](r,r.exports,n),r.exports}(236),o=exports;for(var s in n)o[s]=n[s];n.__esModule&&Object.defineProperty(o,"__esModule",{value:!0})})(); |