Skip to content

Commit

Permalink
Remove browser Node shim
Browse files Browse the repository at this point in the history
We used this to run vscodevim in the browser but it now has a version
that is able to run as a VS Code web extension. This does require an
update to our marketplace, however.
  • Loading branch information
code-asher committed Jan 7, 2021
1 parent a219ff7 commit 6cf2be9
Show file tree
Hide file tree
Showing 20 changed files with 7 additions and 356 deletions.
1 change: 0 additions & 1 deletion doc/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ Some noteworthy changes in our version of VS Code:
- Sending client-side telemetry through the server
- Allowing modification of the display language
- Making it possible for us to load code on the client
- Making extensions work in the browser
- Making it possible to install extensions of any kind
- Fixing issue with getting disconnected when your machine sleeps or hibernates
- Adding connection type to web socket query parameters
Expand Down
2 changes: 0 additions & 2 deletions lib/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@
"dependencies_comment": "Move rimraf to dependencies because it is used in the postinstall script.",
"dependencies": {
"@coder/logger": "1.1.16",
"@coder/node-browser": "^1.0.8",
"@coder/requirefs": "^1.1.5",
"applicationinsights": "1.0.8",
"chokidar": "3.4.3",
"graceful-fs": "4.2.3",
Expand Down
29 changes: 0 additions & 29 deletions lib/vscode/src/vs/server/browser/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Emitter } from 'vs/base/common/event';
import * as path from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
Expand All @@ -9,10 +8,8 @@ import { ILocalizationsService } from 'vs/platform/localizations/common/localiza
import { ILogService } from 'vs/platform/log/common/log';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { Registry } from 'vs/platform/registry/common/platform';
import { PersistentConnectionEventType } from 'vs/platform/remote/common/remoteAgentConnection';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { INodeProxyService, NodeProxyChannelClient } from 'vs/server/common/nodeProxy';
import { TelemetryChannelClient } from 'vs/server/common/telemetry';
import { Options } from 'vs/server/ipc.d';
import 'vs/workbench/contrib/localizations/browser/localizations.contribution';
Expand Down Expand Up @@ -63,33 +60,7 @@ Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfigurat
}
});

class NodeProxyService extends NodeProxyChannelClient implements INodeProxyService {
private readonly _onClose = new Emitter<void>();
public readonly onClose = this._onClose.event;
private readonly _onDown = new Emitter<void>();
public readonly onDown = this._onDown.event;
private readonly _onUp = new Emitter<void>();
public readonly onUp = this._onUp.event;

public constructor(
@IRemoteAgentService remoteAgentService: IRemoteAgentService,
) {
super(remoteAgentService.getConnection()!.getChannel('nodeProxy'));
remoteAgentService.getConnection()!.onDidStateChange((state) => {
switch (state.type) {
case PersistentConnectionEventType.ConnectionGain:
return this._onUp.fire();
case PersistentConnectionEventType.ConnectionLost:
return this._onDown.fire();
case PersistentConnectionEventType.ReconnectionPermanentFailure:
return this._onClose.fire();
}
});
}
}

registerSingleton(ILocalizationsService, LocalizationsService);
registerSingleton(INodeProxyService, NodeProxyService);
registerSingleton(ITelemetryService, TelemetryService);

/**
Expand Down
51 changes: 0 additions & 51 deletions lib/vscode/src/vs/server/browser/extHostNodeProxy.ts

This file was deleted.

55 changes: 0 additions & 55 deletions lib/vscode/src/vs/server/browser/mainThreadNodeProxy.ts

This file was deleted.

48 changes: 0 additions & 48 deletions lib/vscode/src/vs/server/browser/worker.ts

This file was deleted.

47 changes: 0 additions & 47 deletions lib/vscode/src/vs/server/common/nodeProxy.ts

This file was deleted.

47 changes: 1 addition & 46 deletions lib/vscode/src/vs/server/node/channel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { field, logger } from '@coder/logger';
import { Server } from '@coder/node-browser';
import * as os from 'os';
import * as path from 'path';
import { VSBuffer } from 'vs/base/common/buffer';
Expand All @@ -21,7 +20,6 @@ import { ILogService } from 'vs/platform/log/common/log';
import product from 'vs/platform/product/common/product';
import { IRemoteAgentEnvironment, RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
import { ITelemetryData, ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { INodeProxyService } from 'vs/server/common/nodeProxy';
import { getTranslations } from 'vs/server/node/nls';
import { getUriTransformer } from 'vs/server/node/util';
import { IFileChangeDto } from 'vs/workbench/api/common/extHost.protocol';
Expand Down Expand Up @@ -305,14 +303,7 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
const newPath = extension.extensionLocation.fsPath;
this.log.warn(`${oldPath} has been overridden ${newPath}`);
}
uniqueExtensions.set(id, {
...extension,
// Force extensions that should run on the client due to latency
// issues.
extensionKind: extension.identifier.value === 'vscodevim.vim'
? [ 'web' ]
: extension.extensionKind,
});
uniqueExtensions.set(id, extension)
});
});
});
Expand All @@ -337,42 +328,6 @@ export class ExtensionEnvironmentChannel implements IServerChannel {
}
}

export class NodeProxyService implements INodeProxyService {
public _serviceBrand = undefined;

public readonly server: Server;

private readonly _onMessage = new Emitter<string>();
public readonly onMessage = this._onMessage.event;
private readonly _$onMessage = new Emitter<string>();
public readonly $onMessage = this._$onMessage.event;
public readonly _onDown = new Emitter<void>();
public readonly onDown = this._onDown.event;
public readonly _onUp = new Emitter<void>();
public readonly onUp = this._onUp.event;

// Unused because the server connection will never permanently close.
private readonly _onClose = new Emitter<void>();
public readonly onClose = this._onClose.event;

public constructor() {
// TODO: down/up
this.server = new Server({
onMessage: this.$onMessage,
onClose: this.onClose,
onDown: this.onDown,
onUp: this.onUp,
send: (message: string): void => {
this._onMessage.fire(message);
}
});
}

public send(message: string): void {
this._$onMessage.fire(message);
}
}

class VariableResolverService extends AbstractVariableResolverService {
constructor(
remoteAuthority: string,
Expand Down
10 changes: 1 addition & 9 deletions lib/vscode/src/vs/server/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService'
import { combinedAppender, NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { AppInsightsAppender } from 'vs/platform/telemetry/node/appInsightsAppender';
import { resolveCommonProperties } from 'vs/platform/telemetry/node/commonProperties';
import { INodeProxyService, NodeProxyChannel } from 'vs/server/common/nodeProxy';
import { TelemetryChannel } from 'vs/server/common/telemetry';
import { Query, VscodeOptions, WorkbenchOptions } from 'vs/server/ipc';
import { ExtensionEnvironmentChannel, FileProviderChannel, NodeProxyService, TerminalProviderChannel } from 'vs/server/node/channel';
import { ExtensionEnvironmentChannel, FileProviderChannel, TerminalProviderChannel } from 'vs/server/node/channel';
import { Connection, ExtensionHostConnection, ManagementConnection } from 'vs/server/node/connection';
import { TelemetryClient } from 'vs/server/node/insights';
import { logger } from 'vs/server/node/logger';
Expand Down Expand Up @@ -180,11 +179,6 @@ export class Vscode {
this._onDidClientConnect.fire({
protocol, onDidClientDisconnect: connection.onClose,
});
// TODO: Need a way to match clients with a connection. For now
// dispose everything which only works because no extensions currently
// utilize long-running proxies.
(this.services.get(INodeProxyService) as NodeProxyService)._onUp.fire();
connection.onClose(() => (this.services.get(INodeProxyService) as NodeProxyService)._onDown.fire());
} else {
const buffer = protocol.readEntireBuffer();
connection = new ExtensionHostConnection(
Expand Down Expand Up @@ -279,7 +273,6 @@ export class Vscode {
this.services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
this.services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
this.services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));
this.services.set(INodeProxyService, new SyncDescriptor(NodeProxyService));

this.ipc.registerChannel('extensions', new ExtensionManagementChannel(
accessor.get(IExtensionManagementService),
Expand All @@ -290,7 +283,6 @@ export class Vscode {
));
this.ipc.registerChannel('request', new RequestChannel(accessor.get(IRequestService)));
this.ipc.registerChannel('telemetry', new TelemetryChannel(telemetryService));
this.ipc.registerChannel('nodeProxy', new NodeProxyChannel(accessor.get(INodeProxyService)));
this.ipc.registerChannel('localizations', <IServerChannel<any>>createChannelReceiver(accessor.get(ILocalizationsService)));
this.ipc.registerChannel(REMOTE_FILE_SYSTEM_CHANNEL_NAME, new FileProviderChannel(environmentService, logService));
this.ipc.registerChannel(REMOTE_TERMINAL_CHANNEL_NAME, new TerminalProviderChannel(logService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ import './mainThreadComments';
import './mainThreadNotebook';
import './mainThreadTask';
import './mainThreadLabelService';
import 'vs/server/browser/mainThreadNodeProxy';
import './mainThreadTunnelService';
import './mainThreadAuthentication';
import './mainThreadTimeline';
Expand Down
Loading

0 comments on commit 6cf2be9

Please sign in to comment.