diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index c31367128..ffad55380 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -25,12 +25,6 @@ main() { rsync README.md "$RELEASE_PATH" rsync LICENSE.txt "$RELEASE_PATH" rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH" - - # code-server exports types which can be imported and used by plugins. Those - # types import ipc.d.ts but it isn't included in the final vscode build so - # we'll copy it ourselves here. - mkdir -p "$RELEASE_PATH/lib/vscode/src/vs/server" - rsync ./lib/vscode/src/vs/server/ipc.d.ts "$RELEASE_PATH/lib/vscode/src/vs/server" } bundle_code_server() { diff --git a/lib/vscode/.eslintignore b/lib/vscode/.eslintignore index d3c20fa50..be2d47d3f 100644 --- a/lib/vscode/.eslintignore +++ b/lib/vscode/.eslintignore @@ -16,5 +16,6 @@ **/extensions/markdown-language-features/notebook-out/** **/extensions/typescript-basics/test/colorize-fixtures/** **/extensions/**/dist/** -# This is a code-server code symlink. +# These are code-server code symlinks. src/vs/base/node/proxy_agent.ts +src/vs/ipc.d.ts diff --git a/lib/vscode/src/vs/ipc.d.ts b/lib/vscode/src/vs/ipc.d.ts new file mode 120000 index 000000000..dff4f400f --- /dev/null +++ b/lib/vscode/src/vs/ipc.d.ts @@ -0,0 +1 @@ +../../../../typings/ipc.d.ts \ No newline at end of file diff --git a/lib/vscode/src/vs/server/browser/client.ts b/lib/vscode/src/vs/server/browser/client.ts index d7e3d5436..ebd939bcb 100644 --- a/lib/vscode/src/vs/server/browser/client.ts +++ b/lib/vscode/src/vs/server/browser/client.ts @@ -1,5 +1,6 @@ import * as path from 'vs/base/common/path'; import { URI } from 'vs/base/common/uri'; +import { Options } from 'vs/ipc'; import { localize } from 'vs/nls'; import { Extensions, IConfigurationRegistry } from 'vs/platform/configuration/common/configurationRegistry'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; @@ -11,7 +12,6 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryChannelClient } from 'vs/server/common/telemetry'; -import { Options } from 'vs/server/ipc.d'; import 'vs/workbench/contrib/localizations/browser/localizations.contribution'; import { LocalizationsService } from 'vs/workbench/services/localizations/electron-sandbox/localizationsService'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; diff --git a/lib/vscode/src/vs/server/entry.ts b/lib/vscode/src/vs/server/entry.ts index 89a872d45..901bcda63 100644 --- a/lib/vscode/src/vs/server/entry.ts +++ b/lib/vscode/src/vs/server/entry.ts @@ -1,10 +1,10 @@ import { field } from '@coder/logger'; import { setUnexpectedErrorHandler } from 'vs/base/common/errors'; -import { CodeServerMessage, VscodeMessage } from 'vs/server/ipc'; +import * as proxyAgent from 'vs/base/node/proxy_agent'; +import { CodeServerMessage, VscodeMessage } from 'vs/ipc'; import { logger } from 'vs/server/node/logger'; import { enableCustomMarketplace } from 'vs/server/node/marketplace'; import { Vscode } from 'vs/server/node/server'; -import * as proxyAgent from 'vs/base/node/proxy_agent'; setUnexpectedErrorHandler((error) => logger.warn(error instanceof Error ? error.message : error)); enableCustomMarketplace(); diff --git a/lib/vscode/src/vs/server/ipc.d.ts b/lib/vscode/src/vs/server/ipc.d.ts deleted file mode 100644 index 613d1e0e9..000000000 --- a/lib/vscode/src/vs/server/ipc.d.ts +++ /dev/null @@ -1,132 +0,0 @@ -/** - * External interfaces for integration into code-server over IPC. No vs imports - * should be made in this file. - */ -export interface Options { - base: string - disableTelemetry: boolean - disableUpdateCheck: boolean -} - -export interface InitMessage { - type: "init" - id: string - options: VscodeOptions -} - -export type Query = { [key: string]: string | string[] | undefined | Query | Query[] } - -export interface SocketMessage { - type: "socket" - query: Query - permessageDeflate: boolean -} - -export interface CliMessage { - 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 -} - -export type CodeServerMessage = InitMessage | SocketMessage | CliMessage - -export interface ReadyMessage { - type: "ready" -} - -export interface OptionsMessage { - id: string - type: "options" - options: WorkbenchOptions -} - -export type VscodeMessage = ReadyMessage | OptionsMessage - -export interface StartPath { - url: string - workspace: boolean -} - -export interface Args { - "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 - - locale?: string - - log?: string - verbose?: boolean - - _: string[] -} - -export interface VscodeOptions { - readonly args: Args - readonly remoteAuthority: string - readonly startPath?: StartPath -} - -export interface VscodeOptionsMessage extends VscodeOptions { - readonly id: string -} - -export interface UriComponents { - readonly scheme: string - readonly authority: string - readonly path: string - readonly query: string - readonly fragment: string -} - -export interface NLSConfiguration { - locale: string - availableLanguages: { - [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 workspaceProvider?: { - payload: [["userDataPath", string], ["enableProposedApi", string]] - } - } - readonly remoteUserDataUri: UriComponents - readonly productConfiguration: { - codeServerVersion?: string - readonly extensionsGallery?: { - readonly serviceUrl: string - readonly itemUrl: string - readonly controlUrl: string - readonly recommendationsUrl: string - } - } - readonly nlsConfiguration: NLSConfiguration - readonly commit: string -} - -export interface WorkbenchOptionsMessage { - id: string -} diff --git a/lib/vscode/src/vs/server/node/server.ts b/lib/vscode/src/vs/server/node/server.ts index 1626373e6..3c99d415e 100644 --- a/lib/vscode/src/vs/server/node/server.ts +++ b/lib/vscode/src/vs/server/node/server.ts @@ -1,7 +1,7 @@ import { field } from '@coder/logger'; -import { release } from 'os'; import * as fs from 'fs'; import * as net from 'net'; +import { release } from 'os'; import * as path from 'path'; import { Emitter } from 'vs/base/common/event'; import { Schemas } from 'vs/base/common/network'; @@ -10,6 +10,7 @@ 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 { Query, VscodeOptions, WorkbenchOptions } from 'vs/ipc'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ConfigurationService } from 'vs/platform/configuration/common/configurationService'; import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc'; @@ -40,14 +41,13 @@ 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 { resolveCommonProperties } from 'vs/platform/telemetry/common/commonProperties'; 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'; diff --git a/src/node/cli.ts b/src/node/cli.ts index 09542f0b9..461a2e186 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -3,7 +3,7 @@ import { promises as fs } from "fs" import yaml from "js-yaml" import * as os from "os" import * as path from "path" -import { Args as VsArgs } from "../../lib/vscode/src/vs/server/ipc" +import { Args as VsArgs } from "../../typings/ipc" import { canConnect, generateCertificate, generatePassword, humanPath, paths } from "./util" export enum AuthType { diff --git a/src/node/entry.ts b/src/node/entry.ts index 2f569b4ef..b7b61b8f4 100644 --- a/src/node/entry.ts +++ b/src/node/entry.ts @@ -2,7 +2,7 @@ import { field, logger } from "@coder/logger" import * as cp from "child_process" import http from "http" import * as path from "path" -import { CliMessage, OpenCommandPipeArgs } from "../../lib/vscode/src/vs/server/ipc" +import { CliMessage, OpenCommandPipeArgs } from "../../typings/ipc" import { plural } from "../common/util" import { createApp, ensureAddress } from "./app" import { diff --git a/src/node/vscode.ts b/src/node/vscode.ts index 44b46ec71..a69253fb2 100644 --- a/src/node/vscode.ts +++ b/src/node/vscode.ts @@ -2,7 +2,7 @@ import { logger } from "@coder/logger" import * as cp from "child_process" import * as net from "net" import * as path from "path" -import * as ipc from "../../lib/vscode/src/vs/server/ipc" +import * as ipc from "../../typings/ipc" import { arrayify, generateUuid } from "../common/util" import { rootPath } from "./constants" import { settings } from "./settings" diff --git a/typings/ipc.d.ts b/typings/ipc.d.ts new file mode 100644 index 000000000..f31e1d45a --- /dev/null +++ b/typings/ipc.d.ts @@ -0,0 +1,135 @@ +/** + * External interfaces for integration into code-server over IPC. + * This file exists in two locations: + * - typings/ipc.d.ts + * - lib/vscode/src/typings/ipc.d.ts + * The second is a symlink to the first. + */ +export interface Options { + base: string + disableTelemetry: boolean + disableUpdateCheck: boolean +} + +export interface InitMessage { + type: "init" + id: string + options: VscodeOptions +} + +export type Query = { [key: string]: string | string[] | undefined | Query | Query[] } + +export interface SocketMessage { + type: "socket" + query: Query + permessageDeflate: boolean +} + +export interface CliMessage { + 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 +} + +export type CodeServerMessage = InitMessage | SocketMessage | CliMessage + +export interface ReadyMessage { + type: "ready" +} + +export interface OptionsMessage { + id: string + type: "options" + options: WorkbenchOptions +} + +export type VscodeMessage = ReadyMessage | OptionsMessage + +export interface StartPath { + url: string + workspace: boolean +} + +export interface Args { + "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 + + locale?: string + + log?: string + verbose?: boolean + + _: string[] +} + +export interface VscodeOptions { + readonly args: Args + readonly remoteAuthority: string + readonly startPath?: StartPath +} + +export interface VscodeOptionsMessage extends VscodeOptions { + readonly id: string +} + +export interface UriComponents { + readonly scheme: string + readonly authority: string + readonly path: string + readonly query: string + readonly fragment: string +} + +export interface NLSConfiguration { + locale: string + availableLanguages: { + [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 workspaceProvider?: { + payload: [["userDataPath", string], ["enableProposedApi", string]] + } + } + readonly remoteUserDataUri: UriComponents + readonly productConfiguration: { + codeServerVersion?: string + readonly extensionsGallery?: { + readonly serviceUrl: string + readonly itemUrl: string + readonly controlUrl: string + readonly recommendationsUrl: string + } + } + readonly nlsConfiguration: NLSConfiguration + readonly commit: string +} + +export interface WorkbenchOptionsMessage { + id: string +}