Skip to content

Commit a20fa4a

Browse files
committed
Implement extensions channel
1 parent f51751a commit a20fa4a

4 files changed

Lines changed: 51 additions & 20 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ How to [secure your setup](/doc/security/ssl.md).
5555
export OUT=/path/to/some/directory`. Otherwise it will build in this
5656
directory which will cause issues because then `yarn watch` will try to
5757
compile the build directory as well.
58+
- For now `@coder/nbin` is a global dependency.
5859
- Run `yarn build ${vscodeVersion} ${target} ${arch}`in this directory (for example:
5960
`yarn build 1.35.0 linux x64`).
6061

channel.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Watcher extends DiskFileSystemProvider {
4444
/**
4545
* See: src/vs/platform/remote/common/remoteAgentFileSystemChannel.ts.
4646
*/
47-
export class FileProviderChannel implements IServerChannel {
47+
export class FileProviderChannel implements IServerChannel, IDisposable {
4848
private readonly provider: DiskFileSystemProvider;
4949
private readonly watchers = new Map<string, Watcher>();
5050

@@ -106,6 +106,11 @@ export class FileProviderChannel implements IServerChannel {
106106
throw new Error(`Invalid call "${command}"`);
107107
}
108108

109+
public dispose(): void {
110+
this.watchers.forEach((w) => w.dispose());
111+
this.watchers.clear();
112+
}
113+
109114
private async stat(resource: UriComponents): Promise<IStat> {
110115
return this.provider.stat(URI.from(resource));
111116
}

scripts/tasks.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ function package-task() {
200200
cd "${releasePath}"
201201
if [[ "${target}" == "linux" ]] ; then
202202
tar -czf "${archiveName}.tar.gz" "${archiveName}"
203+
log "Archive: ${archivePath}.tar.gz"
203204
else
204205
zip -r "${archiveName}.zip" "${archiveName}"
206+
log "Archive: ${archivePath}.zip"
205207
fi
206-
207-
log "Archive: ${archivePath}"
208208
}
209209

210210
# Package built code into a binary.

server.ts

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,38 @@ import { sanitizeFilePath } from "vs/base/common/extpath";
1010
import { getMediaMime } from "vs/base/common/mime";
1111
import { extname } from "vs/base/common/path";
1212
import { UriComponents, URI } from "vs/base/common/uri";
13-
import { IPCServer, ClientConnectionEvent } from "vs/base/parts/ipc/common/ipc";
13+
import { IPCServer, ClientConnectionEvent, StaticRouter } from "vs/base/parts/ipc/common/ipc";
1414
import { LogsDataCleaner } from "vs/code/electron-browser/sharedProcess/contrib/logsDataCleaner";
15+
import { IConfigurationService } from "vs/platform/configuration/common/configuration";
16+
import { ConfigurationService } from "vs/platform/configuration/node/configurationService";
17+
import { IDialogService } from "vs/platform/dialogs/common/dialogs";
18+
import { DialogChannelClient } from "vs/platform/dialogs/node/dialogIpc";
19+
import { IDownloadService } from "vs/platform/download/common/download";
20+
import { DownloadServiceChannelClient } from "vs/platform/download/node/downloadIpc";
1521
import { IEnvironmentService, ParsedArgs } from "vs/platform/environment/common/environment";
1622
import { EnvironmentService } from "vs/platform/environment/node/environmentService";
23+
import { IExtensionManagementService, IExtensionGalleryService } from "vs/platform/extensionManagement/common/extensionManagement";
24+
import { ExtensionGalleryService } from "vs/platform/extensionManagement/node/extensionGalleryService";
25+
import { ExtensionManagementChannel } from "vs/platform/extensionManagement/node/extensionManagementIpc";
26+
import { ExtensionManagementService } from "vs/platform/extensionManagement/node/extensionManagementService";
27+
import { SyncDescriptor } from "vs/platform/instantiation/common/descriptors";
1728
import { InstantiationService } from "vs/platform/instantiation/common/instantiationService";
1829
import { ServiceCollection } from "vs/platform/instantiation/common/serviceCollection";
30+
import { ILocalizationsService } from "vs/platform/localizations/common/localizations";
31+
import { LocalizationsService } from "vs/platform/localizations/node/localizations";
1932
import { getLogLevel, ILogService } from "vs/platform/log/common/log";
2033
import { LogLevelSetterChannel } from "vs/platform/log/common/logIpc";
2134
import { SpdLogService } from "vs/platform/log/node/spdlogService";
2235
import { IProductConfiguration } from "vs/platform/product/common/product";
2336
import product from "vs/platform/product/node/product";
2437
import { ConnectionType, ConnectionTypeRequest } from "vs/platform/remote/common/remoteAgentConnection";
2538
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from "vs/platform/remote/common/remoteAgentFileSystemChannel";
39+
import { IRequestService } from "vs/platform/request/node/request";
40+
import { RequestService } from "vs/platform/request/node/requestService";
41+
import { ITelemetryService } from "vs/platform/telemetry/common/telemetry";
42+
import { NullTelemetryService } from "vs/platform/telemetry/common/telemetryUtils";
2643
import { RemoteExtensionLogFileName } from "vs/workbench/services/remote/common/remoteAgentService";
44+
// import { TelemetryService } from "vs/workbench/services/telemetry/electron-browser/telemetryService";
2745
import { IWorkbenchConstructionOptions } from "vs/workbench/workbench.web.api";
2846

2947
import { Connection, ManagementConnection, ExtensionHostConnection } from "vs/server/connection";
@@ -141,28 +159,35 @@ export class MainServer extends Server {
141159
});
142160

143161
const environmentService = new EnvironmentService(args, process.execPath);
144-
this.services.set(IEnvironmentService, environmentService);
162+
const logService = new SpdLogService(RemoteExtensionLogFileName, environmentService.logsPath, getLogLevel(environmentService));
163+
this.ipc.registerChannel("loglevel", new LogLevelSetterChannel(logService));
145164

146-
const logService = new SpdLogService(
147-
RemoteExtensionLogFileName,
148-
environmentService.logsPath,
149-
getLogLevel(environmentService),
150-
);
151-
this.services.set(ILogService, logService);
165+
const router = new StaticRouter((context: any) => {
166+
console.log("static router", context);
167+
return context.clientId === "renderer";
168+
});
152169

153-
this.ipc.registerChannel("loglevel", new LogLevelSetterChannel(logService));
170+
this.services.set(ILogService, logService);
171+
this.services.set(IEnvironmentService, environmentService);
172+
this.services.set(IConfigurationService, new SyncDescriptor(ConfigurationService, [environmentService.machineSettingsResource]));
173+
this.services.set(IRequestService, new SyncDescriptor(RequestService));
174+
this.services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
175+
this.services.set(ITelemetryService, NullTelemetryService); // TODO: telemetry
176+
this.services.set(IDialogService, new DialogChannelClient(this.ipc.getChannel("dialog", router)));
177+
this.services.set(IDownloadService, new DownloadServiceChannelClient(this.ipc.getChannel("download", router), () => getUriTransformer("renderer")));
178+
this.services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
154179

155180
const instantiationService = new InstantiationService(this.services);
181+
182+
this.services.set(ILocalizationsService, instantiationService.createInstance(LocalizationsService));
183+
156184
instantiationService.invokeFunction(() => {
157185
instantiationService.createInstance(LogsDataCleaner);
158-
this.ipc.registerChannel(
159-
REMOTE_FILE_SYSTEM_CHANNEL_NAME,
160-
new FileProviderChannel(logService),
161-
);
162-
this.ipc.registerChannel(
163-
"remoteextensionsenvironment",
164-
new ExtensionEnvironmentChannel(environmentService, logService),
165-
);
186+
this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, new FileProviderChannel(logService));
187+
this.ipc.registerChannel("remoteextensionsenvironment", new ExtensionEnvironmentChannel(environmentService, logService));
188+
const extensionsService = this.services.get(IExtensionManagementService) as IExtensionManagementService;
189+
const extensionsChannel = new ExtensionManagementChannel(extensionsService, (context) => getUriTransformer(context.remoteAuthority));
190+
this.ipc.registerChannel("extensions", extensionsChannel);
166191
});
167192
}
168193

0 commit comments

Comments
 (0)