From 5ce99f8d1c0d72735a123e964c1aa3529243d553 Mon Sep 17 00:00:00 2001 From: Asher Date: Tue, 21 Jun 2022 16:51:46 -0500 Subject: [PATCH] chore: update Code to 1.68 (#5263) * chore: update Code to 1.67 Was able to remove our changes to common/webview.ts since they are upstream now. Other than that no serious changes, just context diffs. * chore: update Code to 1.68 - Upstream moved the web socket endpoint so change the Express route from / to *. That will let web sockets work at any endpoint. - Everything in the workbench config is basically the same but de-indented (upstream extracted it into a separate object which resulted in a de-indent), the ordering is slightly different, and instead of vscodeBase we now need vscodeBase + this._staticRoute since everything is served from a sub-path now. - Move manifest link back to the root since that is where we host our manifest. - Change RemoteAuthoritiesImpl to use the same path building method as in other places (+ instead of using URI.parse/join). - Use existing host/port in RemoteAuthoritiesImpl and BrowserSocketFactory instead of patching them to use window.location (these are set from window.location to begin with so it should be the same result but with less patching). - Since BrowserSocketFactory includes a sub-path now (endpoints were changed upstream to serve from /quality/commit instead of from the root) the patch there has changed to prepend the base to that path (instead of using the base directly). - The workbench HTML now natively supports a base URL in the form of WORKBENCH_WEB_BASE_URL so no need for VS_BASE patches there anymore. - Upstream added type="image/x-icon" so I did as well. - Move the language patch to the end of the series so it is easier to eventually remove. - Remove the existing NLS config in favor of one that supports extensions. - Upstream deleted webview main.js and inlined it into the HTML so move that code (the parent origin check) into both those HTML files (index.html and index-no-csp.html). - The remaining diff is from changes to the surrounding context or a line was changed slightly by upstream (for example renamed files or new arguments like to the remote authority resolver). * fix: modify product.json before building Code injects this into the client during the build process so it needs to be updated before we build. * fix: update inline script nonces * Update HTML base path test * fix: missing commit Code overrides it with nothing. The date is also already injected. * fix: web extensions breaking when the commit changes By just using the marketplace directly instead of going through the backend. I am not sure what the point is when searching extensions already goes directly to the marketplace anyway. But also remove the prefix that breaks this as well because otherwise existing installations will break. --- ci/build/build-release.sh | 37 ----- ci/build/build-vscode.sh | 52 +++++++ lib/vscode | 2 +- patches/base-path.diff | 173 +++++++++--------------- patches/connection-type.diff | 9 +- patches/disable-builtin-ext-update.diff | 27 ++-- patches/disable-downloads.diff | 32 ++--- patches/display-language.diff | 170 +++++++++++------------ patches/github-auth.diff | 6 +- patches/integration.diff | 60 ++++---- patches/local-storage.diff | 20 +-- patches/log-level.diff | 24 ++-- patches/logout.diff | 16 +-- patches/marketplace.diff | 72 +++++++--- patches/proposed-api.diff | 4 +- patches/proxy-uri.diff | 38 +++--- patches/series | 2 +- patches/service-worker.diff | 22 +-- patches/sourcemaps.diff | 6 +- patches/telemetry.diff | 36 ++--- patches/update-check.diff | 32 ++--- patches/webview.diff | 115 +++++++++------- src/node/routes/vscode.ts | 2 +- test/unit/node/routes/vscode.test.ts | 4 +- 24 files changed, 499 insertions(+), 462 deletions(-) diff --git a/ci/build/build-release.sh b/ci/build/build-release.sh index e484b2518..8bcf82307 100755 --- a/ci/build/build-release.sh +++ b/ci/build/build-release.sh @@ -98,43 +98,6 @@ bundle_vscode() { rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH" - # Add the commit, date, our name, links, and enable telemetry. This just makes - # telemetry available; telemetry can still be disabled by flag or setting. - jq --slurp '.[0] * .[1]' "$VSCODE_SRC_PATH/product.json" <( - cat << EOF - { - "enableTelemetry": true, - "commit": "$(cd "$VSCODE_SRC_PATH" && git rev-parse HEAD)", - "quality": "stable", - "date": $(jq -n 'now | todate'), - "codeServerVersion": "$VERSION", - "nameShort": "code-server", - "nameLong": "code-server", - "applicationName": "code-server", - "dataFolderName": ".code-server", - "win32MutexName": "codeserver", - "licenseUrl": "https://github.com/coder/code-server/blob/main/LICENSE", - "win32DirName": "code-server", - "win32NameVersion": "code-server", - "win32AppUserModelId": "coder.code-server", - "win32ShellNameShort": "c&ode-server", - "darwinBundleIdentifier": "com.coder.code.server", - "linuxIconName": "com.coder.code.server", - "reportIssueUrl": "https://github.com/coder/code-server/issues/new", - "documentationUrl": "https://go.microsoft.com/fwlink/?LinkID=533484#vscode", - "keyboardShortcutsUrlMac": "https://go.microsoft.com/fwlink/?linkid=832143", - "keyboardShortcutsUrlLinux": "https://go.microsoft.com/fwlink/?linkid=832144", - "keyboardShortcutsUrlWin": "https://go.microsoft.com/fwlink/?linkid=832145", - "introductoryVideosUrl": "https://go.microsoft.com/fwlink/?linkid=832146", - "tipsAndTricksUrl": "https://go.microsoft.com/fwlink/?linkid=852118", - "newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter", - "linkProtectionTrustedDomains": [ - "https://open-vsx.org" - ] - } -EOF - ) > "$VSCODE_OUT_PATH/product.json" - # Use the package.json for the web/remote server. It does not have the right # version though so pull that from the main package.json. jq --slurp '.[0] * {version: .[1].version}' \ diff --git a/ci/build/build-vscode.sh b/ci/build/build-vscode.sh index bb3225a2b..71d33960f 100755 --- a/ci/build/build-vscode.sh +++ b/ci/build/build-vscode.sh @@ -9,10 +9,62 @@ MINIFY=${MINIFY-true} main() { cd "$(dirname "${0}")/../.." + source ./ci/lib.sh + cd lib/vscode + # Set the commit Code will embed into the product.json. We need to do this + # since Code tries to get the commit from the `.git` directory which will fail + # as it is a submodule. + export VSCODE_DISTRO_COMMIT + VSCODE_DISTRO_COMMIT=$(git rev-parse HEAD) + + # Add the date, our name, links, and enable telemetry (this just makes + # telemetry available; telemetry can still be disabled by flag or setting). + # This needs to be done before building as Code will read this file and embed + # it into the client-side code. + git checkout product.json # Reset in case the script exited early. + cp product.json product.original.json # Since jq has no inline edit. + jq --slurp '.[0] * .[1]' product.original.json <( + cat << EOF + { + "enableTelemetry": true, + "quality": "stable", + "codeServerVersion": "$VERSION", + "nameShort": "code-server", + "nameLong": "code-server", + "applicationName": "code-server", + "dataFolderName": ".code-server", + "win32MutexName": "codeserver", + "licenseUrl": "https://github.com/coder/code-server/blob/main/LICENSE", + "win32DirName": "code-server", + "win32NameVersion": "code-server", + "win32AppUserModelId": "coder.code-server", + "win32ShellNameShort": "c&ode-server", + "darwinBundleIdentifier": "com.coder.code.server", + "linuxIconName": "com.coder.code.server", + "reportIssueUrl": "https://github.com/coder/code-server/issues/new", + "documentationUrl": "https://go.microsoft.com/fwlink/?LinkID=533484#vscode", + "keyboardShortcutsUrlMac": "https://go.microsoft.com/fwlink/?linkid=832143", + "keyboardShortcutsUrlLinux": "https://go.microsoft.com/fwlink/?linkid=832144", + "keyboardShortcutsUrlWin": "https://go.microsoft.com/fwlink/?linkid=832145", + "introductoryVideosUrl": "https://go.microsoft.com/fwlink/?linkid=832146", + "tipsAndTricksUrl": "https://go.microsoft.com/fwlink/?linkid=852118", + "newsletterSignupUrl": "https://www.research.net/r/vsc-newsletter", + "linkProtectionTrustedDomains": [ + "https://open-vsx.org" + ] + } +EOF + ) > product.json + # Any platform works since we have our own packaging step (for now). yarn gulp "vscode-reh-web-linux-x64${MINIFY:+-min}" + + # Reset so if you develop after building you will not be stuck with the wrong + # commit (the dev client will use `oss-dev` but the dev server will still use + # product.json which will have `stable-$commit`). + git checkout product.json } main "$@" diff --git a/lib/vscode b/lib/vscode index dfd34e826..30d9c6cd9 160000 --- a/lib/vscode +++ b/lib/vscode @@ -1 +1 @@ -Subproject commit dfd34e8260c270da74b5c2d86d61aee4b6d56977 +Subproject commit 30d9c6cd9483b2cc586687151bcbcd635f373630 diff --git a/patches/base-path.diff b/patches/base-path.diff index 95bb8388e..bf1698465 100644 --- a/patches/base-path.diff +++ b/patches/base-path.diff @@ -10,16 +10,14 @@ Index: code-server/lib/vscode/src/vs/base/common/network.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/base/common/network.ts +++ code-server/lib/vscode/src/vs/base/common/network.ts -@@ -151,8 +151,10 @@ class RemoteAuthoritiesImpl { - } +@@ -157,7 +157,9 @@ class RemoteAuthoritiesImpl { return URI.from({ scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource, -- authority: `${host}:${port}`, -- path: `/vscode-remote-resource`, -+ authority: platform.isWeb ? window.location.host : `${host}:${port}`, + authority: `${host}:${port}`, +- path: this._remoteResourcesPath, + path: platform.isWeb -+ ? URI.joinPath(URI.parse(window.location.href), `/vscode-remote-resource`).path -+ : `/vscode-remote-resource`, ++ ? (window.location.pathname + "/" + this._remoteResourcesPath).replace(/\/\/+/g, "/") ++ : this._remoteResourcesPath, query }); } @@ -38,40 +36,28 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench-dev.html -@@ -27,23 +27,26 @@ +@@ -27,9 +27,9 @@ - -- +- - + -+ ++ + - - - -- -- -+ -+ +@@ -39,7 +39,7 @@ + + -- -+ -+ - -- -- -- -+ -+ -+ - Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts +++ code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts -@@ -274,7 +274,7 @@ export class BrowserSocketFactory implem +@@ -274,6 +274,7 @@ export class BrowserSocketFactory implem - connect(host: string, port: number, query: string, debugLabel: string, callback: IConnectCallback): void { + connect(host: string, port: number, path: string, query: string, debugLabel: string, callback: IConnectCallback): void { const webSocketSchema = (/^https:/.test(window.location.href) ? 'wss' : 'ws'); -- const socket = this._webSocketFactory.create(`${webSocketSchema}://${/:/.test(host) ? `[${host}]` : host}:${port}/?${query}&skipWebSocketFrames=false`, debugLabel); -+ const socket = this._webSocketFactory.create(`${webSocketSchema}://${window.location.host}${window.location.pathname}?${query}&skipWebSocketFrames=false`, debugLabel); ++ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/") + const socket = this._webSocketFactory.create(`${webSocketSchema}://${/:/.test(host) ? `[${host}]` : host}:${port}${path}?${query}&skipWebSocketFrames=false`, debugLabel); const errorListener = socket.onError((err) => callback(err, undefined)); socket.onOpen(() => { - errorListener.dispose(); -@@ -282,6 +282,3 @@ export class BrowserSocketFactory implem +@@ -282,6 +283,3 @@ export class BrowserSocketFactory implem }); } } @@ -159,47 +109,56 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts +++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts -@@ -253,7 +253,10 @@ export class WebClientServer { +@@ -267,14 +267,10 @@ export class WebClientServer { return res.end(); } -- const remoteAuthority = req.headers.host; +- let originalHost = req.headers['x-original-host']; +- if (Array.isArray(originalHost)) { +- originalHost = originalHost[0]; +- } +- const remoteAuthority = originalHost || req.headers.host; +- if (!remoteAuthority) { +- return serveError(req, res, 400, `Bad request.`); +- } + // It is not possible to reliably detect the remote authority on the server + // in all cases. Set this to something invalid to make sure we catch code + // that is using this when it should not. + const remoteAuthority = 'remote'; - function escapeAttribute(value: string): string { - return value.replace(/"/g, '"'); -@@ -275,6 +278,8 @@ export class WebClientServer { - accessToken: this._environmentService.args['github-auth'], + function asJSON(value: unknown): string { + return JSON.stringify(value).replace(/"/g, '"'); +@@ -297,6 +293,8 @@ export class WebClientServer { scopes: [['user:email'], ['repo']] } : undefined; + + const base = relativeRoot(getOriginalUrl(req)) + const vscodeBase = relativePath(getOriginalUrl(req)) - const data = (await util.promisify(fs.readFile)(filePath)).toString() - .replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeAttribute(JSON.stringify({ - remoteAuthority, -@@ -285,6 +290,7 @@ export class WebClientServer { - folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), - workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']), - productConfiguration: >{ -+ rootEndpoint: base, - codeServerVersion: this._productService.codeServerVersion, - embedderIdentifier: 'server-distro', - extensionsGallery: this._webExtensionResourceUrlTemplate ? { -@@ -297,7 +303,9 @@ export class WebClientServer { - } : undefined - } - }))) -- .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : ''); -+ .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '') -+ .replace(/{{BASE}}/g, base) -+ .replace(/{{VS_BASE}}/g, vscodeBase); - const cspDirectives = [ - 'default-src \'self\';', -@@ -376,3 +384,70 @@ export class WebClientServer { + const workbenchWebConfiguration = { + remoteAuthority, +@@ -308,6 +306,7 @@ export class WebClientServer { + workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']), + productConfiguration: >{ + codeServerVersion: this._productService.codeServerVersion, ++ rootEndpoint: base, + embedderIdentifier: 'server-distro', + extensionsGallery: this._webExtensionResourceUrlTemplate ? { + ...this._productService.extensionsGallery, +@@ -328,8 +327,10 @@ export class WebClientServer { + const values: { [key: string]: string } = { + WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration), + WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '', +- WORKBENCH_WEB_BASE_URL: this._staticRoute, +- WORKBENCH_NLS_BASE_URL: nlsBaseUrl ? `${nlsBaseUrl}${this._productService.commit}/${this._productService.version}/` : '', ++ WORKBENCH_WEB_BASE_URL: vscodeBase + this._staticRoute, ++ WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${this._productService.commit}/${this._productService.version}/` : ''), ++ BASE: base, ++ VS_BASE: vscodeBase, + }; + + +@@ -419,3 +420,70 @@ export class WebClientServer { return res.end(data); } } @@ -286,7 +245,7 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts +++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts -@@ -482,6 +482,7 @@ function doCreateUri(path: string, query +@@ -485,6 +485,7 @@ function doCreateUri(path: string, query }); } @@ -294,12 +253,12 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts return URI.parse(window.location.href).with({ path, query }); } -@@ -493,7 +494,7 @@ function doCreateUri(path: string, query +@@ -496,7 +497,7 @@ function doCreateUri(path: string, query if (!configElement || !configElementAttribute) { throw new Error('Missing web configuration element'); } -- const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents } = JSON.parse(configElementAttribute); -+ const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host } +- const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = JSON.parse(configElementAttribute); ++ const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host } // Create workbench create(document.body, { @@ -312,10 +271,10 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensionResourceLoader/ import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry'; import { getTelemetryLevel, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils'; -import { RemoteAuthorities } from 'vs/base/common/network'; + import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts'; export const WEB_EXTENSION_RESOURCE_END_POINT = 'web-extension-resource'; - -@@ -72,7 +71,7 @@ export abstract class AbstractExtensionR +@@ -75,7 +74,7 @@ export abstract class AbstractExtensionR public getExtensionGalleryResourceURL(galleryExtension: { publisher: string; name: string; version: string }, path?: string): URI | undefined { if (this._extensionGalleryResourceUrlTemplate) { const uri = URI.parse(format2(this._extensionGalleryResourceUrlTemplate, { publisher: galleryExtension.publisher, name: galleryExtension.name, version: galleryExtension.version, path: 'extension' })); diff --git a/patches/connection-type.diff b/patches/connection-type.diff index 050715c90..7ea29cd07 100644 --- a/patches/connection-type.diff +++ b/patches/connection-type.diff @@ -14,12 +14,13 @@ Index: code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnectio =================================================================== --- code-server.orig/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts +++ code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts -@@ -231,7 +231,7 @@ async function connectToRemoteExtensionH - +@@ -233,7 +233,8 @@ async function connectToRemoteExtensionH + let socket: ISocket; try { -- socket = await createSocket(options.logService, options.socketFactory, options.host, options.port, `reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`, `renderer-${connectionTypeToString(connectionType)}-${options.reconnectionToken}`, timeoutCancellationToken); -+ socket = await createSocket(options.logService, options.socketFactory, options.host, options.port, `type=${connectionTypeToString(connectionType)}&reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`, `renderer-${connectionTypeToString(connectionType)}-${options.reconnectionToken}`, timeoutCancellationToken); +- socket = await createSocket(options.logService, options.socketFactory, options.host, options.port, getRemoteServerRootPath(options), `reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`, `renderer-${connectionTypeToString(connectionType)}-${options.reconnectionToken}`, timeoutCancellationToken); ++ ++ socket = await createSocket(options.logService, options.socketFactory, options.host, options.port, getRemoteServerRootPath(options), `type=${connectionTypeToString(connectionType)}&reconnectionToken=${options.reconnectionToken}&reconnection=${options.reconnectionProtocol ? 'true' : 'false'}`, `renderer-${connectionTypeToString(connectionType)}-${options.reconnectionToken}`, timeoutCancellationToken); } catch (error) { options.logService.error(`${logPrefix} socketFactory.connect() failed or timed out. Error:`); options.logService.error(error); diff --git a/patches/disable-builtin-ext-update.diff b/patches/disable-builtin-ext-update.diff index 4cee1361a..cbfd77406 100644 --- a/patches/disable-builtin-ext-update.diff +++ b/patches/disable-builtin-ext-update.diff @@ -7,17 +7,18 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts +++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts -@@ -206,6 +206,9 @@ export class Extension implements IExten - if (!this.gallery || !this.local) { - return false; - } -+ if (this.type !== ExtensionType.User) { -+ return false; -+ } - if (!this.local.preRelease && this.gallery.properties.isPreReleaseVersion) { - return false; - } -@@ -1057,6 +1060,10 @@ export class ExtensionsWorkbenchService +@@ -234,6 +234,10 @@ export class Extension implements IExten + if (this.type === ExtensionType.System && this.productService.quality === 'stable') { + return false; + } ++ // Do not update builtin extensions. ++ if (this.type !== ExtensionType.User) { ++ return false; ++ } + if (!this.local.preRelease && this.gallery.properties.isPreReleaseVersion) { + return false; + } +@@ -1088,6 +1092,10 @@ export class ExtensionsWorkbenchService // Skip if check updates only for builtin extensions and current extension is not builtin. continue; } @@ -25,6 +26,6 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens + // Never update builtin extensions. + continue; + } - if (installed.isBuiltin && !installed.local?.identifier.uuid) { - // Skip if the builtin extension does not have Marketplace id + if (installed.isBuiltin && (!installed.local?.identifier.uuid || (!isWeb && this.productService.quality === 'stable'))) { + // Skip checking updates for a builtin extension if it does not has Marketplace identifier or the current product is VS Code Desktop stable. continue; diff --git a/patches/disable-downloads.diff b/patches/disable-downloads.diff index 7568fcd0b..b5f7dc723 100644 --- a/patches/disable-downloads.diff +++ b/patches/disable-downloads.diff @@ -12,7 +12,7 @@ Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts +++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts -@@ -215,6 +215,11 @@ export interface IWorkbenchConstructionO +@@ -250,6 +250,11 @@ export interface IWorkbenchConstructionO */ readonly userDataPath?: string @@ -28,7 +28,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts +++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts -@@ -30,6 +30,11 @@ export interface IBrowserWorkbenchEnviro +@@ -31,6 +31,11 @@ export interface IBrowserWorkbenchEnviro * Options used to configure the workbench. */ readonly options?: IWorkbenchConstructionOptions; @@ -40,7 +40,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/envi } export class BrowserWorkbenchEnvironmentService implements IBrowserWorkbenchEnvironmentService { -@@ -61,6 +66,13 @@ export class BrowserWorkbenchEnvironment +@@ -62,6 +67,13 @@ export class BrowserWorkbenchEnvironment return this.options.userDataPath; } @@ -58,18 +58,18 @@ Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts +++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts -@@ -15,6 +15,7 @@ export const serverOptions: OptionDescri +@@ -14,6 +14,7 @@ export const serverOptions: OptionDescri + /* ----- code-server ----- */ 'disable-update-check': { type: 'boolean' }, 'auth': { type: 'string' }, - 'locale': { type: 'string' }, + 'disable-file-downloads': { type: 'boolean' }, /* ----- server setup ----- */ -@@ -96,6 +97,7 @@ export interface ServerParsedArgs { +@@ -94,6 +95,7 @@ export interface ServerParsedArgs { + /* ----- code-server ----- */ 'disable-update-check'?: boolean; 'auth'?: string - 'locale'?: string + 'disable-file-downloads'?: boolean; /* ----- server setup ----- */ @@ -78,14 +78,14 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts +++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts -@@ -293,6 +293,7 @@ export class WebClientServer { - logLevel: this._logService.getLevel(), - }, - userDataPath: this._environmentService.userDataPath, -+ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'], - settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, - enableWorkspaceTrust: !this._environmentService.args['disable-workspace-trust'], - folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']), +@@ -300,6 +300,7 @@ export class WebClientServer { + remoteAuthority, + webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre', + userDataPath: this._environmentService.userDataPath, ++ isEnabledFileDownloads: !this._environmentService.args['disable-file-downloads'], + _wrapWebWorkerExtHostInIframe, + developmentOptions: { + enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, Index: code-server/lib/vscode/src/vs/workbench/browser/contextkeys.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/workbench/browser/contextkeys.ts @@ -144,7 +144,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/files/browser/fileActions import { IsWebContext } from 'vs/platform/contextkey/common/contextkeys'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { ThemeIcon } from 'vs/platform/theme/common/themeService'; -@@ -476,13 +476,16 @@ MenuRegistry.appendMenuItem(MenuId.Explo +@@ -477,13 +477,16 @@ MenuRegistry.appendMenuItem(MenuId.Explo id: DOWNLOAD_COMMAND_ID, title: DOWNLOAD_LABEL }, diff --git a/patches/display-language.diff b/patches/display-language.diff index aad709545..c3de5a83f 100644 --- a/patches/display-language.diff +++ b/patches/display-language.diff @@ -1,17 +1,28 @@ Add display language support -This likely needs tweaking if we want to upstream. +We can remove this once upstream supports all language packs. + +1. Proxies language packs to the service on the backend. +2. NLS configuration is embedded into the HTML for the browser to pick up. This + code to generate this configuration is copied from the native portion. +3. Remove navigator.language default since that will prevent the argv file from + being created if you are changing the language to whatever your browser + default happens to be. +4. Move the argv.json file to the server instead of in-browser storage. This is + where the current locale is stored and currently the server needs to be able + to read it. +5. Add the locale flag. Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/server/node/serverServices.ts +++ code-server/lib/vscode/src/vs/server/node/serverServices.ts -@@ -192,6 +192,9 @@ export async function setupServerService +@@ -202,6 +202,9 @@ export async function setupServerService const channel = new ExtensionManagementChannel(extensionManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority)); socketServer.registerChannel('extensions', channel); -+ const localizationsChannel = ProxyChannel.fromService(accessor.get(ILocalizationsService)); -+ socketServer.registerChannel('localizations', localizationsChannel); ++ const languagePackChannel = ProxyChannel.fromService(accessor.get(ILanguagePackService)); ++ socketServer.registerChannel('languagePacks', languagePackChannel); + const encryptionChannel = ProxyChannel.fromService(accessor.get(IEncryptionMainService)); socketServer.registerChannel('encryption', encryptionChannel); @@ -20,9 +31,12 @@ Index: code-server/lib/vscode/src/vs/base/common/platform.ts =================================================================== --- code-server.orig/lib/vscode/src/vs/base/common/platform.ts +++ code-server/lib/vscode/src/vs/base/common/platform.ts -@@ -84,6 +84,17 @@ if (typeof navigator === 'object' && !is +@@ -80,8 +80,19 @@ if (typeof navigator === 'object' && !is + _isIOS = (_userAgent.indexOf('Macintosh') >= 0 || _userAgent.indexOf('iPad') >= 0 || _userAgent.indexOf('iPhone') >= 0) && !!navigator.maxTouchPoints && navigator.maxTouchPoints > 0; + _isLinux = _userAgent.indexOf('Linux') >= 0; _isWeb = true; - _locale = navigator.language; +- _locale = navigator.language; ++ _locale = LANGUAGE_DEFAULT; _language = _locale; + + const el = typeof document !== 'undefined' && document.getElementById('vscode-remote-nls-configuration'); @@ -51,23 +65,33 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html + - -@@ -38,6 +41,27 @@ - - - -