11import * as path from "path" ;
22
3+ import { getPathFromAmdModule } from "vs/base/common/amd" ;
34import { VSBuffer } from "vs/base/common/buffer" ;
45import { Emitter , Event } from "vs/base/common/event" ;
56import { IDisposable } from "vs/base/common/lifecycle" ;
6- import { Schemas } from "vs/base/common/network" ;
77import { OS } from "vs/base/common/platform" ;
88import { URI , UriComponents } from "vs/base/common/uri" ;
9+ import { URITransformer , IRawURITransformer , transformOutgoingURIs } from "vs/base/common/uriIpc" ;
910import { IServerChannel } from "vs/base/parts/ipc/common/ipc" ;
1011import { IDiagnosticInfo } from "vs/platform/diagnostics/common/diagnosticsService" ;
1112import { IEnvironmentService } from "vs/platform/environment/common/environment" ;
@@ -47,7 +48,7 @@ export class FileProviderChannel implements IServerChannel {
4748 this . provider = new DiskFileSystemProvider ( this . logService ) ;
4849 }
4950
50- public listen ( _ : unknown , event : string , args ?: any ) : Event < any > {
51+ public listen ( context : any , event : string , args ?: any ) : Event < any > {
5152 switch ( event ) {
5253 // This is where the actual file changes are sent. The watch method just
5354 // adds things that will fire here. That means we have to split up
@@ -61,10 +62,11 @@ export class FileProviderChannel implements IServerChannel {
6162 onFirstListenerAdd : ( ) => {
6263 const provider = new Watcher ( this . logService ) ;
6364 this . watchers . set ( session , provider ) ;
65+ const transformer = getUriTransformer ( context . remoteAuthority ) ;
6466 provider . onDidChangeFile ( ( events ) => {
6567 emitter . fire ( events . map ( ( event ) => ( {
6668 ...event ,
67- resource : event . resource . with ( { scheme : Schemas . vscodeRemote } ) ,
69+ resource : transformer . transformOutgoing ( event . resource ) ,
6870 } ) ) ) ;
6971 } ) ;
7072 provider . onDidErrorOccur ( ( event ) => emitter . fire ( event ) ) ;
@@ -157,32 +159,34 @@ export class FileProviderChannel implements IServerChannel {
157159export class ExtensionEnvironmentChannel implements IServerChannel {
158160 public constructor ( private readonly environment : IEnvironmentService ) { }
159161
160- public listen ( _context : any , event : string ) : Event < any > {
162+ public listen ( _ : unknown , event : string ) : Event < any > {
161163 throw new Error ( `Invalid listen "${ event } "` ) ;
162164 }
163165
164- public call ( _ : unknown , command : string , _args ?: any ) : Promise < any > {
166+ public async call ( context : any , command : string , _args ?: any ) : Promise < any > {
165167 switch ( command ) {
166- case "getEnvironmentData" : return this . getEnvironmentData ( ) ;
168+ case "getEnvironmentData" :
169+ return transformOutgoingURIs (
170+ await this . getEnvironmentData ( ) ,
171+ getUriTransformer ( context . remoteAuthority ) ,
172+ ) ;
167173 case "getDiagnosticInfo" : return this . getDiagnosticInfo ( ) ;
168174 case "disableTelemetry" : return this . disableTelemetry ( ) ;
169175 }
170176 throw new Error ( `Invalid call "${ command } "` ) ;
171177 }
172178
173179 private async getEnvironmentData ( ) : Promise < IRemoteAgentEnvironment > {
174- // TODO: this `with` stuff feels a bit jank.
175- // Maybe it should already come in like this instead.
176180 return {
177181 pid : process . pid ,
178- appRoot : URI . file ( this . environment . appRoot ) . with ( { scheme : Schemas . vscodeRemote } ) ,
179- appSettingsHome : this . environment . appSettingsHome . with ( { scheme : Schemas . vscodeRemote } ) ,
180- settingsPath : this . environment . machineSettingsHome . with ( { scheme : Schemas . vscodeRemote } ) ,
181- logsPath : URI . file ( this . environment . logsPath ) . with ( { scheme : Schemas . vscodeRemote } ) ,
182- extensionsPath : URI . file ( this . environment . extensionsPath ) . with ( { scheme : Schemas . vscodeRemote } ) ,
183- extensionHostLogsPath : URI . file ( path . join ( this . environment . logsPath , "extension-host" ) ) . with ( { scheme : Schemas . vscodeRemote } ) , // TODO
184- globalStorageHome : URI . file ( this . environment . globalStorageHome ) . with ( { scheme : Schemas . vscodeRemote } ) ,
185- userHome : URI . file ( this . environment . userHome ) . with ( { scheme : Schemas . vscodeRemote } ) ,
182+ appRoot : URI . file ( this . environment . appRoot ) ,
183+ appSettingsHome : this . environment . appSettingsHome ,
184+ settingsPath : this . environment . machineSettingsHome ,
185+ logsPath : URI . file ( this . environment . logsPath ) ,
186+ extensionsPath : URI . file ( this . environment . extensionsPath ) ,
187+ extensionHostLogsPath : URI . file ( path . join ( this . environment . logsPath , "extension-host" ) ) , // TODO
188+ globalStorageHome : URI . file ( this . environment . globalStorageHome ) ,
189+ userHome : URI . file ( this . environment . userHome ) ,
186190 extensions : [ ] , // TODO
187191 os : OS ,
188192 } ;
@@ -196,3 +200,11 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
196200 throw new Error ( "not implemented" ) ;
197201 }
198202}
203+
204+ export const uriTransformerPath = getPathFromAmdModule ( require , "vs/server/uriTransformer" ) ;
205+
206+ export const getUriTransformer = ( remoteAuthority : string ) : URITransformer => {
207+ const rawURITransformerFactory = < any > require . __$__nodeRequire ( uriTransformerPath ) ;
208+ const rawURITransformer = < IRawURITransformer > rawURITransformerFactory ( remoteAuthority ) ;
209+ return new URITransformer ( rawURITransformer ) ;
210+ } ;
0 commit comments