mirror of
https://github.com/coder/code-server.git
synced 2024-12-24 02:01:46 +03:00
refactor: change goHome test to helpAbout
This commit is contained in:
parent
0c2708302d
commit
bcdca86539
145
lib/vscode/src/vs/server/ipc.d.ts
vendored
145
lib/vscode/src/vs/server/ipc.d.ts
vendored
@ -9,133 +9,124 @@ export interface Options {
|
||||
}
|
||||
|
||||
export interface InitMessage {
|
||||
type: 'init';
|
||||
id: string;
|
||||
options: VscodeOptions;
|
||||
type: "init"
|
||||
id: string
|
||||
options: VscodeOptions
|
||||
}
|
||||
|
||||
export type Query = { [key: string]: string | string[] | undefined | Query | Query[] };
|
||||
export type Query = { [key: string]: string | string[] | undefined | Query | Query[] }
|
||||
|
||||
export interface SocketMessage {
|
||||
type: 'socket';
|
||||
query: Query;
|
||||
permessageDeflate: boolean;
|
||||
type: "socket"
|
||||
query: Query
|
||||
permessageDeflate: boolean
|
||||
}
|
||||
|
||||
export interface CliMessage {
|
||||
type: 'cli';
|
||||
args: Args;
|
||||
type: "cli"
|
||||
args: Args
|
||||
}
|
||||
|
||||
export interface OpenCommandPipeArgs {
|
||||
type: 'open';
|
||||
fileURIs?: string[];
|
||||
folderURIs: string[];
|
||||
forceNewWindow?: boolean;
|
||||
diffMode?: boolean;
|
||||
addMode?: boolean;
|
||||
gotoLineMode?: boolean;
|
||||
forceReuseWindow?: boolean;
|
||||
waitMarkerFilePath?: string;
|
||||
type: "open"
|
||||
fileURIs?: string[]
|
||||
folderURIs: string[]
|
||||
forceNewWindow?: boolean
|
||||
diffMode?: boolean
|
||||
addMode?: boolean
|
||||
gotoLineMode?: boolean
|
||||
forceReuseWindow?: boolean
|
||||
waitMarkerFilePath?: string
|
||||
}
|
||||
|
||||
export type CodeServerMessage = InitMessage | SocketMessage | CliMessage;
|
||||
export type CodeServerMessage = InitMessage | SocketMessage | CliMessage
|
||||
|
||||
export interface ReadyMessage {
|
||||
type: 'ready';
|
||||
type: "ready"
|
||||
}
|
||||
|
||||
export interface OptionsMessage {
|
||||
id: string;
|
||||
type: 'options';
|
||||
options: WorkbenchOptions;
|
||||
id: string
|
||||
type: "options"
|
||||
options: WorkbenchOptions
|
||||
}
|
||||
|
||||
export type VscodeMessage = ReadyMessage | OptionsMessage;
|
||||
export type VscodeMessage = ReadyMessage | OptionsMessage
|
||||
|
||||
export interface StartPath {
|
||||
url: string;
|
||||
workspace: boolean;
|
||||
url: string
|
||||
workspace: boolean
|
||||
}
|
||||
|
||||
export interface Args {
|
||||
'user-data-dir'?: string;
|
||||
"user-data-dir"?: string
|
||||
|
||||
'enable-proposed-api'?: string[];
|
||||
'extensions-dir'?: string;
|
||||
'builtin-extensions-dir'?: string;
|
||||
'extra-extensions-dir'?: string[];
|
||||
'extra-builtin-extensions-dir'?: string[];
|
||||
'ignore-last-opened'?: boolean;
|
||||
"enable-proposed-api"?: string[]
|
||||
"extensions-dir"?: string
|
||||
"builtin-extensions-dir"?: string
|
||||
"extra-extensions-dir"?: string[]
|
||||
"extra-builtin-extensions-dir"?: string[]
|
||||
"ignore-last-opened"?: boolean
|
||||
|
||||
locale?: string
|
||||
|
||||
log?: string;
|
||||
verbose?: boolean;
|
||||
home?: string;
|
||||
log?: string
|
||||
verbose?: boolean
|
||||
|
||||
_: string[];
|
||||
_: string[]
|
||||
}
|
||||
|
||||
export interface VscodeOptions {
|
||||
readonly args: Args;
|
||||
readonly remoteAuthority: string;
|
||||
readonly startPath?: StartPath;
|
||||
readonly args: Args
|
||||
readonly remoteAuthority: string
|
||||
readonly startPath?: StartPath
|
||||
}
|
||||
|
||||
export interface VscodeOptionsMessage extends VscodeOptions {
|
||||
readonly id: string;
|
||||
readonly id: string
|
||||
}
|
||||
|
||||
export interface UriComponents {
|
||||
readonly scheme: string;
|
||||
readonly authority: string;
|
||||
readonly path: string;
|
||||
readonly query: string;
|
||||
readonly fragment: string;
|
||||
readonly scheme: string
|
||||
readonly authority: string
|
||||
readonly path: string
|
||||
readonly query: string
|
||||
readonly fragment: string
|
||||
}
|
||||
|
||||
export interface NLSConfiguration {
|
||||
locale: string;
|
||||
locale: string
|
||||
availableLanguages: {
|
||||
[key: string]: string;
|
||||
};
|
||||
pseudo?: boolean;
|
||||
_languagePackSupport?: boolean;
|
||||
[key: string]: string
|
||||
}
|
||||
pseudo?: boolean
|
||||
_languagePackSupport?: boolean
|
||||
}
|
||||
|
||||
export interface WorkbenchOptions {
|
||||
readonly workbenchWebConfiguration: {
|
||||
readonly remoteAuthority?: string;
|
||||
readonly folderUri?: UriComponents;
|
||||
readonly workspaceUri?: UriComponents;
|
||||
readonly logLevel?: number;
|
||||
readonly remoteAuthority?: string
|
||||
readonly folderUri?: UriComponents
|
||||
readonly workspaceUri?: UriComponents
|
||||
readonly logLevel?: number
|
||||
readonly workspaceProvider?: {
|
||||
payload: [
|
||||
['userDataPath', string],
|
||||
['enableProposedApi', string],
|
||||
];
|
||||
};
|
||||
readonly homeIndicator?: {
|
||||
href: string,
|
||||
icon: string,
|
||||
title: string,
|
||||
},
|
||||
};
|
||||
readonly remoteUserDataUri: UriComponents;
|
||||
payload: [["userDataPath", string], ["enableProposedApi", string]]
|
||||
}
|
||||
}
|
||||
readonly remoteUserDataUri: UriComponents
|
||||
readonly productConfiguration: {
|
||||
codeServerVersion?: string;
|
||||
codeServerVersion?: string
|
||||
readonly extensionsGallery?: {
|
||||
readonly serviceUrl: string;
|
||||
readonly itemUrl: string;
|
||||
readonly controlUrl: string;
|
||||
readonly recommendationsUrl: string;
|
||||
};
|
||||
};
|
||||
readonly nlsConfiguration: NLSConfiguration;
|
||||
readonly commit: string;
|
||||
readonly serviceUrl: string
|
||||
readonly itemUrl: string
|
||||
readonly controlUrl: string
|
||||
readonly recommendationsUrl: string
|
||||
}
|
||||
}
|
||||
readonly nlsConfiguration: NLSConfiguration
|
||||
readonly commit: string
|
||||
}
|
||||
|
||||
export interface WorkbenchOptionsMessage {
|
||||
id: string;
|
||||
id: string
|
||||
}
|
||||
|
@ -1,100 +1,108 @@
|
||||
import { field } from '@coder/logger';
|
||||
import { release } from 'os';
|
||||
import * as fs from 'fs';
|
||||
import * as net from 'net';
|
||||
import * as path from 'path';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { getMachineId } from 'vs/base/node/id';
|
||||
import { ClientConnectionEvent, IPCServer, IServerChannel, ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
||||
import { LogsDataCleaner } from 'vs/code/electron-browser/sharedProcess/contrib/logsDataCleaner';
|
||||
import { main } from 'vs/code/node/cliProcessMain';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationService } from 'vs/platform/configuration/common/configurationService';
|
||||
import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
|
||||
import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
|
||||
import { IEnvironmentService, INativeEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { NativeEnvironmentService } from 'vs/platform/environment/node/environmentService';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||
import { IExtensionGalleryService, IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionManagementChannel } from 'vs/platform/extensionManagement/common/extensionManagementIpc';
|
||||
import { ExtensionManagementService } from 'vs/platform/extensionManagement/node/extensionManagementService';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { FileService } from 'vs/platform/files/common/fileService';
|
||||
import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemProvider';
|
||||
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
|
||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { ILocalizationsService } from 'vs/platform/localizations/common/localizations';
|
||||
import { LocalizationsService } from 'vs/platform/localizations/node/localizations';
|
||||
import { ConsoleLogger, getLogLevel, ILoggerService, ILogService, MultiplexLogService } from 'vs/platform/log/common/log';
|
||||
import { LogLevelChannel } from 'vs/platform/log/common/logIpc';
|
||||
import { LoggerService } from 'vs/platform/log/node/loggerService';
|
||||
import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { ConnectionType, ConnectionTypeRequest } from 'vs/platform/remote/common/remoteAgentConnection';
|
||||
import { RemoteAgentConnectionContext } from 'vs/platform/remote/common/remoteAgentEnvironment';
|
||||
import { IRequestService } from 'vs/platform/request/common/request';
|
||||
import { RequestChannel } from 'vs/platform/request/common/requestIpc';
|
||||
import { RequestService } from 'vs/platform/request/node/requestService';
|
||||
import ErrorTelemetry from 'vs/platform/telemetry/browser/errorTelemetry';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { TelemetryLogAppender } from 'vs/platform/telemetry/common/telemetryLogAppender';
|
||||
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/common/commonProperties';
|
||||
import { TelemetryChannel } from 'vs/server/common/telemetry';
|
||||
import { Query, VscodeOptions, WorkbenchOptions } from 'vs/server/ipc';
|
||||
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';
|
||||
import { getLocaleFromConfig, getNlsConfiguration } from 'vs/server/node/nls';
|
||||
import { Protocol } from 'vs/server/node/protocol';
|
||||
import { getUriTransformer } from 'vs/server/node/util';
|
||||
import { REMOTE_TERMINAL_CHANNEL_NAME } from 'vs/workbench/contrib/terminal/common/remoteTerminalChannel';
|
||||
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from 'vs/workbench/services/remote/common/remoteAgentFileSystemChannel';
|
||||
import { RemoteExtensionLogFileName } from 'vs/workbench/services/remote/common/remoteAgentService';
|
||||
import { localize } from 'vs/nls';
|
||||
import { field } from "@coder/logger"
|
||||
import { release } from "os"
|
||||
import * as fs from "fs"
|
||||
import * as net from "net"
|
||||
import * as path from "path"
|
||||
import { Emitter } from "vs/base/common/event"
|
||||
import { Schemas } from "vs/base/common/network"
|
||||
import { URI } from "vs/base/common/uri"
|
||||
import { getMachineId } from "vs/base/node/id"
|
||||
import { ClientConnectionEvent, IPCServer, IServerChannel, ProxyChannel } from "vs/base/parts/ipc/common/ipc"
|
||||
import { LogsDataCleaner } from "vs/code/electron-browser/sharedProcess/contrib/logsDataCleaner"
|
||||
import { main } from "vs/code/node/cliProcessMain"
|
||||
import { IConfigurationService } from "vs/platform/configuration/common/configuration"
|
||||
import { ConfigurationService } from "vs/platform/configuration/common/configurationService"
|
||||
import { ExtensionHostDebugBroadcastChannel } from "vs/platform/debug/common/extensionHostDebugIpc"
|
||||
import { NativeParsedArgs } from "vs/platform/environment/common/argv"
|
||||
import { IEnvironmentService, INativeEnvironmentService } from "vs/platform/environment/common/environment"
|
||||
import { NativeEnvironmentService } from "vs/platform/environment/node/environmentService"
|
||||
import { ExtensionGalleryService } from "vs/platform/extensionManagement/common/extensionGalleryService"
|
||||
import {
|
||||
IExtensionGalleryService,
|
||||
IExtensionManagementService,
|
||||
} from "vs/platform/extensionManagement/common/extensionManagement"
|
||||
import { ExtensionManagementChannel } from "vs/platform/extensionManagement/common/extensionManagementIpc"
|
||||
import { ExtensionManagementService } from "vs/platform/extensionManagement/node/extensionManagementService"
|
||||
import { IFileService } from "vs/platform/files/common/files"
|
||||
import { FileService } from "vs/platform/files/common/fileService"
|
||||
import { DiskFileSystemProvider } from "vs/platform/files/node/diskFileSystemProvider"
|
||||
import { SyncDescriptor } from "vs/platform/instantiation/common/descriptors"
|
||||
import { InstantiationService } from "vs/platform/instantiation/common/instantiationService"
|
||||
import { ServiceCollection } from "vs/platform/instantiation/common/serviceCollection"
|
||||
import { ILocalizationsService } from "vs/platform/localizations/common/localizations"
|
||||
import { LocalizationsService } from "vs/platform/localizations/node/localizations"
|
||||
import {
|
||||
ConsoleLogger,
|
||||
getLogLevel,
|
||||
ILoggerService,
|
||||
ILogService,
|
||||
MultiplexLogService,
|
||||
} from "vs/platform/log/common/log"
|
||||
import { LogLevelChannel } from "vs/platform/log/common/logIpc"
|
||||
import { LoggerService } from "vs/platform/log/node/loggerService"
|
||||
import { SpdLogLogger } from "vs/platform/log/node/spdlogLog"
|
||||
import product from "vs/platform/product/common/product"
|
||||
import { IProductService } from "vs/platform/product/common/productService"
|
||||
import { ConnectionType, ConnectionTypeRequest } from "vs/platform/remote/common/remoteAgentConnection"
|
||||
import { RemoteAgentConnectionContext } from "vs/platform/remote/common/remoteAgentEnvironment"
|
||||
import { IRequestService } from "vs/platform/request/common/request"
|
||||
import { RequestChannel } from "vs/platform/request/common/requestIpc"
|
||||
import { RequestService } from "vs/platform/request/node/requestService"
|
||||
import ErrorTelemetry from "vs/platform/telemetry/browser/errorTelemetry"
|
||||
import { ITelemetryService } from "vs/platform/telemetry/common/telemetry"
|
||||
import { TelemetryLogAppender } from "vs/platform/telemetry/common/telemetryLogAppender"
|
||||
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/common/commonProperties"
|
||||
import { TelemetryChannel } from "vs/server/common/telemetry"
|
||||
import { Query, VscodeOptions, WorkbenchOptions } from "vs/server/ipc"
|
||||
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"
|
||||
import { getLocaleFromConfig, getNlsConfiguration } from "vs/server/node/nls"
|
||||
import { Protocol } from "vs/server/node/protocol"
|
||||
import { getUriTransformer } from "vs/server/node/util"
|
||||
import { REMOTE_TERMINAL_CHANNEL_NAME } from "vs/workbench/contrib/terminal/common/remoteTerminalChannel"
|
||||
import { REMOTE_FILE_SYSTEM_CHANNEL_NAME } from "vs/workbench/services/remote/common/remoteAgentFileSystemChannel"
|
||||
import { RemoteExtensionLogFileName } from "vs/workbench/services/remote/common/remoteAgentService"
|
||||
|
||||
export class Vscode {
|
||||
public readonly _onDidClientConnect = new Emitter<ClientConnectionEvent>();
|
||||
public readonly onDidClientConnect = this._onDidClientConnect.event;
|
||||
private readonly ipc = new IPCServer<RemoteAgentConnectionContext>(this.onDidClientConnect);
|
||||
public readonly _onDidClientConnect = new Emitter<ClientConnectionEvent>()
|
||||
public readonly onDidClientConnect = this._onDidClientConnect.event
|
||||
private readonly ipc = new IPCServer<RemoteAgentConnectionContext>(this.onDidClientConnect)
|
||||
|
||||
private readonly maxExtraOfflineConnections = 0;
|
||||
private readonly connections = new Map<ConnectionType, Map<string, Connection>>();
|
||||
private readonly maxExtraOfflineConnections = 0
|
||||
private readonly connections = new Map<ConnectionType, Map<string, Connection>>()
|
||||
|
||||
private readonly services = new ServiceCollection();
|
||||
private servicesPromise?: Promise<void>;
|
||||
private readonly services = new ServiceCollection()
|
||||
private servicesPromise?: Promise<void>
|
||||
|
||||
public async cli(args: NativeParsedArgs): Promise<void> {
|
||||
return main(args);
|
||||
return main(args)
|
||||
}
|
||||
|
||||
public async initialize(options: VscodeOptions): Promise<WorkbenchOptions> {
|
||||
const transformer = getUriTransformer(options.remoteAuthority);
|
||||
const transformer = getUriTransformer(options.remoteAuthority)
|
||||
if (!this.servicesPromise) {
|
||||
this.servicesPromise = this.initializeServices(options.args);
|
||||
this.servicesPromise = this.initializeServices(options.args)
|
||||
}
|
||||
await this.servicesPromise;
|
||||
const environment = this.services.get(IEnvironmentService) as INativeEnvironmentService;
|
||||
const startPath = options.startPath;
|
||||
await this.servicesPromise
|
||||
const environment = this.services.get(IEnvironmentService) as INativeEnvironmentService
|
||||
const startPath = options.startPath
|
||||
const parseUrl = (url: string): URI => {
|
||||
// This might be a fully-specified URL or just a path.
|
||||
try {
|
||||
return URI.parse(url, true);
|
||||
return URI.parse(url, true)
|
||||
} catch (error) {
|
||||
return URI.from({
|
||||
scheme: Schemas.vscodeRemote,
|
||||
authority: options.remoteAuthority,
|
||||
path: url,
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
workbenchWebConfiguration: {
|
||||
workspaceUri: startPath && startPath.workspace ? parseUrl(startPath.url) : undefined,
|
||||
@ -103,111 +111,112 @@ export class Vscode {
|
||||
logLevel: getLogLevel(environment),
|
||||
workspaceProvider: {
|
||||
payload: [
|
||||
['userDataPath', environment.userDataPath],
|
||||
['enableProposedApi', JSON.stringify(options.args['enable-proposed-api'] || [])]
|
||||
["userDataPath", environment.userDataPath],
|
||||
["enableProposedApi", JSON.stringify(options.args["enable-proposed-api"] || [])],
|
||||
],
|
||||
},
|
||||
homeIndicator: options.args.home ? {
|
||||
href: options.args.home,
|
||||
icon: 'code',
|
||||
title: localize('home', "Home"),
|
||||
} : undefined,
|
||||
},
|
||||
remoteUserDataUri: transformer.transformOutgoing(URI.file(environment.userDataPath)),
|
||||
productConfiguration: product,
|
||||
nlsConfiguration: await getNlsConfiguration(environment.args.locale || await getLocaleFromConfig(environment.userDataPath), environment.userDataPath),
|
||||
commit: product.commit || 'development',
|
||||
};
|
||||
nlsConfiguration: await getNlsConfiguration(
|
||||
environment.args.locale || (await getLocaleFromConfig(environment.userDataPath)),
|
||||
environment.userDataPath,
|
||||
),
|
||||
commit: product.commit || "development",
|
||||
}
|
||||
}
|
||||
|
||||
public async handleWebSocket(socket: net.Socket, query: Query, permessageDeflate: boolean): Promise<true> {
|
||||
if (!query.reconnectionToken) {
|
||||
throw new Error('Reconnection token is missing from query parameters');
|
||||
throw new Error("Reconnection token is missing from query parameters")
|
||||
}
|
||||
const protocol = new Protocol(socket, {
|
||||
reconnectionToken: <string>query.reconnectionToken,
|
||||
reconnection: query.reconnection === 'true',
|
||||
skipWebSocketFrames: query.skipWebSocketFrames === 'true',
|
||||
reconnection: query.reconnection === "true",
|
||||
skipWebSocketFrames: query.skipWebSocketFrames === "true",
|
||||
permessageDeflate,
|
||||
recordInflateBytes: permessageDeflate,
|
||||
});
|
||||
})
|
||||
try {
|
||||
await this.connect(await protocol.handshake(), protocol);
|
||||
await this.connect(await protocol.handshake(), protocol)
|
||||
} catch (error) {
|
||||
protocol.sendMessage({ type: 'error', reason: error.message });
|
||||
protocol.dispose();
|
||||
protocol.getSocket().dispose();
|
||||
protocol.sendMessage({ type: "error", reason: error.message })
|
||||
protocol.dispose()
|
||||
protocol.getSocket().dispose()
|
||||
}
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
private async connect(message: ConnectionTypeRequest, protocol: Protocol): Promise<void> {
|
||||
if (product.commit && message.commit !== product.commit) {
|
||||
logger.warn(`Version mismatch (${message.commit} instead of ${product.commit})`);
|
||||
logger.warn(`Version mismatch (${message.commit} instead of ${product.commit})`)
|
||||
}
|
||||
|
||||
switch (message.desiredConnectionType) {
|
||||
case ConnectionType.ExtensionHost:
|
||||
case ConnectionType.Management:
|
||||
if (!this.connections.has(message.desiredConnectionType)) {
|
||||
this.connections.set(message.desiredConnectionType, new Map());
|
||||
this.connections.set(message.desiredConnectionType, new Map())
|
||||
}
|
||||
const connections = this.connections.get(message.desiredConnectionType)!;
|
||||
const connections = this.connections.get(message.desiredConnectionType)!
|
||||
|
||||
const ok = async () => {
|
||||
return message.desiredConnectionType === ConnectionType.ExtensionHost
|
||||
? { debugPort: await this.getDebugPort() }
|
||||
: { type: 'ok' };
|
||||
};
|
||||
: { type: "ok" }
|
||||
}
|
||||
|
||||
const token = protocol.options.reconnectionToken;
|
||||
const token = protocol.options.reconnectionToken
|
||||
if (protocol.options.reconnection && connections.has(token)) {
|
||||
protocol.sendMessage(await ok());
|
||||
const buffer = protocol.readEntireBuffer();
|
||||
protocol.dispose();
|
||||
return connections.get(token)!.reconnect(protocol.getSocket(), buffer);
|
||||
protocol.sendMessage(await ok())
|
||||
const buffer = protocol.readEntireBuffer()
|
||||
protocol.dispose()
|
||||
return connections.get(token)!.reconnect(protocol.getSocket(), buffer)
|
||||
} else if (protocol.options.reconnection || connections.has(token)) {
|
||||
throw new Error(protocol.options.reconnection
|
||||
? 'Unrecognized reconnection token'
|
||||
: 'Duplicate reconnection token'
|
||||
);
|
||||
throw new Error(
|
||||
protocol.options.reconnection ? "Unrecognized reconnection token" : "Duplicate reconnection token",
|
||||
)
|
||||
}
|
||||
|
||||
logger.debug('New connection', field('token', token));
|
||||
protocol.sendMessage(await ok());
|
||||
logger.debug("New connection", field("token", token))
|
||||
protocol.sendMessage(await ok())
|
||||
|
||||
let connection: Connection;
|
||||
let connection: Connection
|
||||
if (message.desiredConnectionType === ConnectionType.Management) {
|
||||
connection = new ManagementConnection(protocol, token);
|
||||
connection = new ManagementConnection(protocol, token)
|
||||
this._onDidClientConnect.fire({
|
||||
protocol, onDidClientDisconnect: connection.onClose,
|
||||
});
|
||||
protocol,
|
||||
onDidClientDisconnect: connection.onClose,
|
||||
})
|
||||
} else {
|
||||
const buffer = protocol.readEntireBuffer();
|
||||
const buffer = protocol.readEntireBuffer()
|
||||
connection = new ExtensionHostConnection(
|
||||
message.args ? message.args.language : 'en',
|
||||
protocol, buffer, token,
|
||||
message.args ? message.args.language : "en",
|
||||
protocol,
|
||||
buffer,
|
||||
token,
|
||||
this.services.get(IEnvironmentService) as INativeEnvironmentService,
|
||||
);
|
||||
)
|
||||
}
|
||||
connections.set(token, connection);
|
||||
connections.set(token, connection)
|
||||
connection.onClose(() => {
|
||||
logger.debug('Connection closed', field('token', token));
|
||||
connections.delete(token);
|
||||
});
|
||||
this.disposeOldOfflineConnections(connections);
|
||||
break;
|
||||
case ConnectionType.Tunnel: return protocol.tunnel();
|
||||
default: throw new Error('Unrecognized connection type');
|
||||
logger.debug("Connection closed", field("token", token))
|
||||
connections.delete(token)
|
||||
})
|
||||
this.disposeOldOfflineConnections(connections)
|
||||
break
|
||||
case ConnectionType.Tunnel:
|
||||
return protocol.tunnel()
|
||||
default:
|
||||
throw new Error("Unrecognized connection type")
|
||||
}
|
||||
}
|
||||
|
||||
private disposeOldOfflineConnections(connections: Map<string, Connection>): void {
|
||||
const offline = Array.from(connections.values())
|
||||
.filter((connection) => typeof connection.offline !== 'undefined');
|
||||
const offline = Array.from(connections.values()).filter((connection) => typeof connection.offline !== "undefined")
|
||||
for (let i = 0, max = offline.length - this.maxExtraOfflineConnections; i < max; ++i) {
|
||||
logger.debug('Disposing offline connection', field('token', offline[i].token));
|
||||
offline[i].dispose();
|
||||
logger.debug("Disposing offline connection", field("token", offline[i].token))
|
||||
offline[i].dispose()
|
||||
}
|
||||
}
|
||||
|
||||
@ -219,9 +228,9 @@ export class Vscode {
|
||||
If upstream changes cause conflicts, look there ^.
|
||||
3/11/21 @jsjoeio
|
||||
*/
|
||||
const environmentService = new NativeEnvironmentService(args);
|
||||
const environmentService = new NativeEnvironmentService(args)
|
||||
// https://github.com/cdr/code-server/issues/1693
|
||||
fs.mkdirSync(environmentService.globalStorageHome.fsPath, { recursive: true });
|
||||
fs.mkdirSync(environmentService.globalStorageHome.fsPath, { recursive: true })
|
||||
/*
|
||||
NOTE@coder: Made these updates on based on this file (and lines):
|
||||
Reference: - ../../electron-browser/sharedProcess/sharedProcessMain.ts#L144-L149
|
||||
@ -234,21 +243,26 @@ export class Vscode {
|
||||
*/
|
||||
const logService = new MultiplexLogService([
|
||||
new ConsoleLogger(getLogLevel(environmentService)),
|
||||
new SpdLogLogger(RemoteExtensionLogFileName, path.join(environmentService.logsPath, `${RemoteExtensionLogFileName}.log`), false, getLogLevel(environmentService))
|
||||
]);
|
||||
const fileService = new FileService(logService);
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(logService));
|
||||
new SpdLogLogger(
|
||||
RemoteExtensionLogFileName,
|
||||
path.join(environmentService.logsPath, `${RemoteExtensionLogFileName}.log`),
|
||||
false,
|
||||
getLogLevel(environmentService),
|
||||
),
|
||||
])
|
||||
const fileService = new FileService(logService)
|
||||
fileService.registerProvider(Schemas.file, new DiskFileSystemProvider(logService))
|
||||
|
||||
const loggerService = new LoggerService(logService, fileService);
|
||||
const loggerService = new LoggerService(logService, fileService)
|
||||
|
||||
const piiPaths = [
|
||||
path.join(environmentService.userDataPath, 'clp'), // Language packs.
|
||||
path.join(environmentService.userDataPath, "clp"), // Language packs.
|
||||
environmentService.appRoot,
|
||||
environmentService.extensionsPath,
|
||||
environmentService.builtinExtensionsPath,
|
||||
...environmentService.extraExtensionPaths,
|
||||
...environmentService.extraBuiltinExtensionPaths,
|
||||
];
|
||||
]
|
||||
|
||||
/*
|
||||
NOTE@coder: we changed this channel registration from LogLevel to LogLevelChannel
|
||||
@ -256,67 +270,80 @@ export class Vscode {
|
||||
|
||||
3/15/21 jsjoeio
|
||||
*/
|
||||
this.ipc.registerChannel('logger', new LogLevelChannel(logService));
|
||||
this.ipc.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel());
|
||||
this.ipc.registerChannel("logger", new LogLevelChannel(logService))
|
||||
this.ipc.registerChannel(ExtensionHostDebugBroadcastChannel.ChannelName, new ExtensionHostDebugBroadcastChannel())
|
||||
|
||||
this.services.set(ILogService, logService);
|
||||
this.services.set(IEnvironmentService, environmentService);
|
||||
this.services.set(INativeEnvironmentService, environmentService);
|
||||
this.services.set(ILogService, logService)
|
||||
this.services.set(IEnvironmentService, environmentService)
|
||||
this.services.set(INativeEnvironmentService, environmentService)
|
||||
/*
|
||||
NOTE@coder: we changed this from LoggerService to the loggerService defined above.
|
||||
3/11/21 @jsjoeio
|
||||
*/
|
||||
this.services.set(ILoggerService, loggerService);
|
||||
this.services.set(ILoggerService, loggerService)
|
||||
|
||||
const configurationService = new ConfigurationService(environmentService.settingsResource, fileService);
|
||||
await configurationService.initialize();
|
||||
this.services.set(IConfigurationService, configurationService);
|
||||
const configurationService = new ConfigurationService(environmentService.settingsResource, fileService)
|
||||
await configurationService.initialize()
|
||||
this.services.set(IConfigurationService, configurationService)
|
||||
|
||||
this.services.set(IRequestService, new SyncDescriptor(RequestService));
|
||||
this.services.set(IFileService, fileService);
|
||||
this.services.set(IProductService, { _serviceBrand: undefined, ...product });
|
||||
this.services.set(IRequestService, new SyncDescriptor(RequestService))
|
||||
this.services.set(IFileService, fileService)
|
||||
this.services.set(IProductService, { _serviceBrand: undefined, ...product })
|
||||
|
||||
const machineId = await getMachineId();
|
||||
const machineId = await getMachineId()
|
||||
|
||||
await new Promise((resolve) => {
|
||||
const instantiationService = new InstantiationService(this.services);
|
||||
const instantiationService = new InstantiationService(this.services)
|
||||
|
||||
instantiationService.invokeFunction((accessor) => {
|
||||
instantiationService.createInstance(LogsDataCleaner);
|
||||
instantiationService.createInstance(LogsDataCleaner)
|
||||
|
||||
let telemetryService: ITelemetryService;
|
||||
let telemetryService: ITelemetryService
|
||||
if (!environmentService.disableTelemetry) {
|
||||
telemetryService = new TelemetryService({
|
||||
telemetryService = new TelemetryService(
|
||||
{
|
||||
appender: combinedAppender(
|
||||
new AppInsightsAppender('code-server', null, () => new TelemetryClient() as any),
|
||||
new TelemetryLogAppender(accessor.get(ILoggerService), environmentService)
|
||||
new AppInsightsAppender("code-server", null, () => new TelemetryClient() as any),
|
||||
new TelemetryLogAppender(accessor.get(ILoggerService), environmentService),
|
||||
),
|
||||
sendErrorTelemetry: true,
|
||||
commonProperties: resolveCommonProperties(
|
||||
fileService, release(), process.arch, product.commit, product.version, machineId,
|
||||
[], environmentService.installSourcePath, 'code-server',
|
||||
fileService,
|
||||
release(),
|
||||
process.arch,
|
||||
product.commit,
|
||||
product.version,
|
||||
machineId,
|
||||
[],
|
||||
environmentService.installSourcePath,
|
||||
"code-server",
|
||||
),
|
||||
piiPaths,
|
||||
}, configurationService);
|
||||
},
|
||||
configurationService,
|
||||
)
|
||||
} else {
|
||||
telemetryService = NullTelemetryService;
|
||||
telemetryService = NullTelemetryService
|
||||
}
|
||||
|
||||
this.services.set(ITelemetryService, telemetryService);
|
||||
this.services.set(ITelemetryService, telemetryService)
|
||||
|
||||
this.services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
|
||||
this.services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
|
||||
this.services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));
|
||||
this.services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService))
|
||||
this.services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService))
|
||||
this.services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService))
|
||||
|
||||
this.ipc.registerChannel('extensions', new ExtensionManagementChannel(
|
||||
accessor.get(IExtensionManagementService),
|
||||
(context) => getUriTransformer(context.remoteAuthority),
|
||||
));
|
||||
this.ipc.registerChannel('remoteextensionsenvironment', new ExtensionEnvironmentChannel(
|
||||
environmentService, logService, telemetryService, '',
|
||||
));
|
||||
this.ipc.registerChannel('request', new RequestChannel(accessor.get(IRequestService)));
|
||||
this.ipc.registerChannel('telemetry', new TelemetryChannel(telemetryService));
|
||||
this.ipc.registerChannel(
|
||||
"extensions",
|
||||
new ExtensionManagementChannel(accessor.get(IExtensionManagementService), (context) =>
|
||||
getUriTransformer(context.remoteAuthority),
|
||||
),
|
||||
)
|
||||
this.ipc.registerChannel(
|
||||
"remoteextensionsenvironment",
|
||||
new ExtensionEnvironmentChannel(environmentService, logService, telemetryService, ""),
|
||||
)
|
||||
this.ipc.registerChannel("request", new RequestChannel(accessor.get(IRequestService)))
|
||||
this.ipc.registerChannel("telemetry", new TelemetryChannel(telemetryService))
|
||||
/*
|
||||
NOTE@coder: they renamed createChannelReceiver and made it part of the ProxyChannel namespace
|
||||
See: https://github.com/microsoft/vscode/commit/e371faebfb679ca0dcdb61f4f2f33b3d69922a77
|
||||
@ -325,18 +352,24 @@ export class Vscode {
|
||||
https://github.com/microsoft/vscode/blob/e371faebfb679ca0dcdb61f4f2f33b3d69922a77/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts#L273
|
||||
3/11/2021 by @jsjoeio
|
||||
*/
|
||||
this.ipc.registerChannel('localizations', <IServerChannel<any>>ProxyChannel.fromService(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));
|
||||
resolve(new ErrorTelemetry(telemetryService));
|
||||
});
|
||||
});
|
||||
this.ipc.registerChannel(
|
||||
"localizations",
|
||||
<IServerChannel<any>>ProxyChannel.fromService(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))
|
||||
resolve(new ErrorTelemetry(telemetryService))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: implement.
|
||||
*/
|
||||
private async getDebugPort(): Promise<number | undefined> {
|
||||
return undefined;
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,13 @@ import { hash } from "../src/node/util"
|
||||
import { CODE_SERVER_ADDRESS, PASSWORD, STORAGE } from "./constants"
|
||||
import { createCookieIfDoesntExist } from "./helpers"
|
||||
|
||||
describe("go home", () => {
|
||||
describe("Open Help > About", () => {
|
||||
let browser: Browser
|
||||
let page: Page
|
||||
let context: BrowserContext
|
||||
|
||||
beforeAll(async () => {
|
||||
browser = await chromium.launch()
|
||||
browser = await chromium.launch({ headless: false })
|
||||
// Create a new context with the saved storage state
|
||||
const storageState = JSON.parse(STORAGE) || {}
|
||||
|
||||
@ -61,13 +61,11 @@ describe("go home", () => {
|
||||
page = await context.newPage()
|
||||
})
|
||||
|
||||
// NOTE: this test will fail if you do not run code-server with --home $CODE_SERVER_ADDRESS/healthz
|
||||
it("should see a 'Go Home' button in the Application Menu that goes to /healthz", async () => {
|
||||
const GO_HOME_URL = `${CODE_SERVER_ADDRESS}/healthz`
|
||||
it("should see a 'Help' then 'About' button in the Application Menu that opens a dialog", async () => {
|
||||
// Sometimes a dialog shows up when you navigate
|
||||
// asking if you're sure you want to leave
|
||||
// so we listen if it comes, we accept it
|
||||
page.on("dialog", (dialog) => dialog.accept())
|
||||
// page.on("dialog", (dialog) => dialog.accept())
|
||||
|
||||
// waitUntil: "domcontentloaded"
|
||||
// In case the page takes a long time to load
|
||||
@ -76,16 +74,19 @@ describe("go home", () => {
|
||||
// Make sure the editor actually loaded
|
||||
expect(await page.isVisible("div.monaco-workbench"))
|
||||
|
||||
// Click the Home menu
|
||||
// Click the Application menu
|
||||
await page.click("[aria-label='Application Menu']")
|
||||
// See the Go Home button
|
||||
const goHomeButton = "a.action-menu-item span[aria-label='Go Home']"
|
||||
expect(await page.isVisible(goHomeButton))
|
||||
// See the Help button
|
||||
const helpButton = "a.action-menu-item span[aria-label='Help']"
|
||||
expect(await page.isVisible(helpButton))
|
||||
|
||||
// Click it and navigate to /healthz
|
||||
// NOTE: ran into issues of it failing intermittently
|
||||
// without having button: "middle"
|
||||
await Promise.all([page.waitForNavigation(), page.click(goHomeButton, { button: "middle" })])
|
||||
expect(page.url()).toBe(GO_HOME_URL)
|
||||
await Promise.all([page.waitForNavigation(), page.click(helpButton, { button: "middle" })])
|
||||
|
||||
// see the About button
|
||||
const aboutButton = "a.action-menu-item span[aria-label='About']"
|
||||
expect(await page.isVisible(aboutButton))
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user