Skip to content

Commit 21d1a9e

Browse files
committed
chore: update Code to 1.68
- Web socket endpoint moved so change Express route from / to *. That will let web sockets work at any endpoint. - Workbench configuration was de-indented; everything there is basically the same but just de-indented, 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). - 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. They added type="image/x-icon" so I did as well. - Remove the language support so we can continue using ours (it is unclear to me what it would take to support both so this is the easiest solution). - The webview main.js was deleted and inlined into the HTML so move that code (the parent origin stuff) into both those HTML files (index.html and index-no-csp.html). - The remaining diff is just from changes to the surrounding context or the specific changed line (like upstream adding a new argument to the remote authority resolver).
1 parent 5a05cec commit 21d1a9e

19 files changed

+289
-332
lines changed

lib/vscode

Submodule vscode updated 1055 files

patches/base-path.diff

+58-106
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,14 @@ Index: code-server/lib/vscode/src/vs/base/common/network.ts
1010
===================================================================
1111
--- code-server.orig/lib/vscode/src/vs/base/common/network.ts
1212
+++ code-server/lib/vscode/src/vs/base/common/network.ts
13-
@@ -151,8 +151,10 @@ class RemoteAuthoritiesImpl {
14-
}
13+
@@ -157,7 +157,9 @@ class RemoteAuthoritiesImpl {
1514
return URI.from({
1615
scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource,
17-
- authority: `${host}:${port}`,
18-
- path: `/vscode-remote-resource`,
19-
+ authority: platform.isWeb ? window.location.host : `${host}:${port}`,
16+
authority: `${host}:${port}`,
17+
- path: this._remoteResourcesPath,
2018
+ path: platform.isWeb
21-
+ ? URI.joinPath(URI.parse(window.location.href), `/vscode-remote-resource`).path
22-
+ : `/vscode-remote-resource`,
19+
+ ? (window.location.pathname + "/" + this._remoteResourcesPath).replace(/\/\/+/g, "/")
20+
+ : this._remoteResourcesPath,
2321
query
2422
});
2523
}
@@ -38,40 +36,28 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench-dev.html
3836

3937
<!-- Disable pinch zooming -->
4038
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
41-
@@ -27,23 +27,26 @@
39+
@@ -27,9 +27,9 @@
4240
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
4341

4442
<!-- Workbench Icon/Manifest/CSS -->
4543
- <link rel="icon" href="/_static/src/browser/media/favicon-dark-support.svg" />
46-
- <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" />
44+
- <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" type="image/x-icon" />
4745
- <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
4846
+ <link rel="icon" href="{{BASE}}/_static/src/browser/media/favicon-dark-support.svg" />
49-
+ <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" />
47+
+ <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" type="image/x-icon" />
5048
+ <link rel="manifest" href="{{VS_BASE}}/manifest.json" crossorigin="use-credentials" />
5149
</head>
5250

5351
<body aria-label="">
54-
</body>
55-
56-
<!-- Startup (do not modify order of script tags!) -->
57-
- <script src="./static/out/vs/loader.js"></script>
58-
- <script src="./static/out/vs/webPackagePaths.js"></script>
59-
+ <script src="{{VS_BASE}}/static/out/vs/loader.js"></script>
60-
+ <script src="{{VS_BASE}}/static/out/vs/webPackagePaths.js"></script>
52+
@@ -39,7 +39,7 @@
53+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
54+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
6155
<script>
56+
- const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
57+
+ const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location).toString();
6258
Object.keys(self.webPackagePaths).map(function (key, index) {
63-
- self.webPackagePaths[key] = `${window.location.origin}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
64-
+ self.webPackagePaths[key] = new URL(
65-
+ `{{VS_BASE}}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`,
66-
+ window.location,
67-
+ ).toString();
59+
self.webPackagePaths[key] = `${baseUrl}/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
6860
});
69-
require.config({
70-
- baseUrl: `${window.location.origin}/static/out`,
71-
+ baseUrl: new URL(`{{VS_BASE}}/static/out`, window.location).toString(),
72-
recordStats: true,
73-
trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
74-
createScriptURL(value) {
7561
Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
7662
===================================================================
7763
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.html
@@ -87,68 +73,32 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
8773

8874
<!-- Disable pinch zooming -->
8975
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
90-
@@ -24,10 +24,10 @@
76+
@@ -24,9 +24,9 @@
9177
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
9278

9379
<!-- Workbench Icon/Manifest/CSS -->
9480
- <link rel="icon" href="/_static/src/browser/media/favicon-dark-support.svg" />
95-
- <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" />
81+
- <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" type="image/x-icon" />
9682
- <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
97-
- <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="./static/out/vs/workbench/workbench.web.main.css">
9883
+ <link rel="icon" href="{{BASE}}/_static/src/browser/media/favicon-dark-support.svg" />
99-
+ <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" />
84+
+ <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" type="image/x-icon" />
10085
+ <link rel="manifest" href="{{VS_BASE}}/manifest.json" crossorigin="use-credentials" />
101-
+ <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{VS_BASE}}/static/out/vs/workbench/workbench.web.main.css">
86+
<link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css">
10287

10388
</head>
104-
105-
@@ -35,14 +35,17 @@
106-
</body>
107-
108-
<!-- Startup (do not modify order of script tags!) -->
109-
- <script src="./static/out/vs/loader.js"></script>
110-
- <script src="./static/out/vs/webPackagePaths.js"></script>
111-
+ <script src="{{VS_BASE}}/static/out/vs/loader.js"></script>
112-
+ <script src="{{VS_BASE}}/static/out/vs/webPackagePaths.js"></script>
113-
<script>
114-
Object.keys(self.webPackagePaths).map(function (key, index) {
115-
- self.webPackagePaths[key] = `${window.location.origin}/static/node_modules/${key}/${self.webPackagePaths[key]}`;
116-
+ self.webPackagePaths[key] = new URL(
117-
+ `{{VS_BASE}}/static/node_modules/${key}/${self.webPackagePaths[key]}`,
118-
+ window.location,
119-
+ ).toString();
120-
});
121-
require.config({
122-
- baseUrl: `${window.location.origin}/static/out`,
123-
+ baseUrl: new URL(`{{VS_BASE}}/static/out`, window.location).toString(),
124-
recordStats: true,
125-
trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
126-
createScriptURL(value) {
127-
@@ -55,7 +58,7 @@
128-
<script>
129-
performance.mark('code/willLoadWorkbenchMain');
130-
</script>
131-
- <script src="./static/out/vs/workbench/workbench.web.main.nls.js"></script>
132-
- <script src="./static/out/vs/workbench/workbench.web.main.js"></script>
133-
- <script src="./static/out/vs/code/browser/workbench/workbench.js"></script>
134-
+ <script src="{{VS_BASE}}/static/out/vs/workbench/workbench.web.main.nls.js"></script>
135-
+ <script src="{{VS_BASE}}/static/out/vs/workbench/workbench.web.main.js"></script>
136-
+ <script src="{{VS_BASE}}/static/out/vs/code/browser/workbench/workbench.js"></script>
137-
</html>
13889
Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
13990
===================================================================
14091
--- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
14192
+++ code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
142-
@@ -274,7 +274,7 @@ export class BrowserSocketFactory implem
93+
@@ -274,6 +274,7 @@ export class BrowserSocketFactory implem
14394

144-
connect(host: string, port: number, query: string, debugLabel: string, callback: IConnectCallback): void {
95+
connect(host: string, port: number, path: string, query: string, debugLabel: string, callback: IConnectCallback): void {
14596
const webSocketSchema = (/^https:/.test(window.location.href) ? 'wss' : 'ws');
146-
- const socket = this._webSocketFactory.create(`${webSocketSchema}://${/:/.test(host) ? `[${host}]` : host}:${port}/?${query}&skipWebSocketFrames=false`, debugLabel);
147-
+ const socket = this._webSocketFactory.create(`${webSocketSchema}://${window.location.host}${window.location.pathname}?${query}&skipWebSocketFrames=false`, debugLabel);
97+
+ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/")
98+
const socket = this._webSocketFactory.create(`${webSocketSchema}://${/:/.test(host) ? `[${host}]` : host}:${port}${path}?${query}&skipWebSocketFrames=false`, debugLabel);
14899
const errorListener = socket.onError((err) => callback(err, undefined));
149100
socket.onOpen(() => {
150-
errorListener.dispose();
151-
@@ -282,6 +282,3 @@ export class BrowserSocketFactory implem
101+
@@ -282,6 +283,3 @@ export class BrowserSocketFactory implem
152102
});
153103
}
154104
}
@@ -159,7 +109,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
159109
===================================================================
160110
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
161111
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
162-
@@ -250,14 +250,10 @@ export class WebClientServer {
112+
@@ -267,14 +267,10 @@ export class WebClientServer {
163113
return res.end();
164114
}
165115

@@ -176,37 +126,39 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
176126
+ // that is using this when it should not.
177127
+ const remoteAuthority = 'remote';
178128

179-
function escapeAttribute(value: string): string {
180-
return value.replace(/"/g, '&quot;');
181-
@@ -279,6 +275,8 @@ export class WebClientServer {
182-
accessToken: this._environmentService.args['github-auth'],
129+
function asJSON(value: unknown): string {
130+
return JSON.stringify(value).replace(/"/g, '&quot;');
131+
@@ -297,6 +293,8 @@ export class WebClientServer {
183132
scopes: [['user:email'], ['repo']]
184133
} : undefined;
134+
185135
+ const base = relativeRoot(getOriginalUrl(req))
186136
+ const vscodeBase = relativePath(getOriginalUrl(req))
187-
const data = (await util.promisify(fs.readFile)(filePath)).toString()
188-
.replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeAttribute(JSON.stringify({
189-
remoteAuthority,
190-
@@ -289,6 +287,7 @@ export class WebClientServer {
191-
folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
192-
workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
193-
productConfiguration: <Partial<IProductConfiguration>>{
194-
+ rootEndpoint: base,
195-
codeServerVersion: this._productService.codeServerVersion,
196-
embedderIdentifier: 'server-distro',
197-
extensionsGallery: this._webExtensionResourceUrlTemplate ? {
198-
@@ -301,7 +300,9 @@ export class WebClientServer {
199-
} : undefined
200-
}
201-
})))
202-
- .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '');
203-
+ .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '')
204-
+ .replace(/{{BASE}}/g, base)
205-
+ .replace(/{{VS_BASE}}/g, vscodeBase);
206137

207-
const cspDirectives = [
208-
'default-src \'self\';',
209-
@@ -380,3 +381,70 @@ export class WebClientServer {
138+
const workbenchWebConfiguration = {
139+
remoteAuthority,
140+
@@ -308,6 +306,7 @@ export class WebClientServer {
141+
workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
142+
productConfiguration: <Partial<IProductConfiguration>>{
143+
codeServerVersion: this._productService.codeServerVersion,
144+
+ rootEndpoint: base,
145+
embedderIdentifier: 'server-distro',
146+
extensionsGallery: this._webExtensionResourceUrlTemplate ? {
147+
...this._productService.extensionsGallery,
148+
@@ -328,8 +327,10 @@ export class WebClientServer {
149+
const values: { [key: string]: string } = {
150+
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
151+
WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
152+
- WORKBENCH_WEB_BASE_URL: this._staticRoute,
153+
- WORKBENCH_NLS_BASE_URL: nlsBaseUrl ? `${nlsBaseUrl}${this._productService.commit}/${this._productService.version}/` : '',
154+
+ WORKBENCH_WEB_BASE_URL: vscodeBase + this._staticRoute,
155+
+ WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${this._productService.commit}/${this._productService.version}/` : ''),
156+
+ BASE: base,
157+
+ VS_BASE: vscodeBase,
158+
};
159+
160+
161+
@@ -419,3 +420,70 @@ export class WebClientServer {
210162
return res.end(data);
211163
}
212164
}
@@ -293,20 +245,20 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
293245
===================================================================
294246
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts
295247
+++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
296-
@@ -481,6 +481,7 @@ function doCreateUri(path: string, query
248+
@@ -485,6 +485,7 @@ function doCreateUri(path: string, query
297249
});
298250
}
299251

300252
+ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/")
301253
return URI.parse(window.location.href).with({ path, query });
302254
}
303255

304-
@@ -492,7 +493,7 @@ function doCreateUri(path: string, query
256+
@@ -496,7 +497,7 @@ function doCreateUri(path: string, query
305257
if (!configElement || !configElementAttribute) {
306258
throw new Error('Missing web configuration element');
307259
}
308-
- const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents } = JSON.parse(configElementAttribute);
309-
+ const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host }
260+
- const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = JSON.parse(configElementAttribute);
261+
+ const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host }
310262

311263
// Create workbench
312264
create(document.body, {
@@ -319,10 +271,10 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensionResourceLoader/
319271
import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
320272
import { getTelemetryLevel, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
321273
-import { RemoteAuthorities } from 'vs/base/common/network';
274+
import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
322275

323276
export const WEB_EXTENSION_RESOURCE_END_POINT = 'web-extension-resource';
324-
325-
@@ -72,7 +71,7 @@ export abstract class AbstractExtensionR
277+
@@ -75,7 +74,7 @@ export abstract class AbstractExtensionR
326278
public getExtensionGalleryResourceURL(galleryExtension: { publisher: string; name: string; version: string }, path?: string): URI | undefined {
327279
if (this._extensionGalleryResourceUrlTemplate) {
328280
const uri = URI.parse(format2(this._extensionGalleryResourceUrlTemplate, { publisher: galleryExtension.publisher, name: galleryExtension.name, version: galleryExtension.version, path: 'extension' }));

patches/connection-type.diff

+5-4
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ Index: code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnectio
1414
===================================================================
1515
--- code-server.orig/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts
1616
+++ code-server/lib/vscode/src/vs/platform/remote/common/remoteAgentConnection.ts
17-
@@ -231,7 +231,7 @@ async function connectToRemoteExtensionH
18-
17+
@@ -233,7 +233,8 @@ async function connectToRemoteExtensionH
18+
1919
let socket: ISocket;
2020
try {
21-
- 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);
22-
+ 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);
21+
- 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);
22+
+
23+
+ 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);
2324
} catch (error) {
2425
options.logService.error(`${logPrefix} socketFactory.connect() failed or timed out. Error:`);
2526
options.logService.error(error);

patches/disable-builtin-ext-update.diff

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens
77
===================================================================
88
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
99
+++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.ts
10-
@@ -211,6 +211,10 @@ export class Extension implements IExten
10+
@@ -234,6 +234,10 @@ export class Extension implements IExten
1111
if (this.type === ExtensionType.System && this.productService.quality === 'stable') {
1212
return false;
1313
}
@@ -18,14 +18,14 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extens
1818
if (!this.local.preRelease && this.gallery.properties.isPreReleaseVersion) {
1919
return false;
2020
}
21-
@@ -1065,6 +1069,10 @@ export class ExtensionsWorkbenchService
21+
@@ -1088,6 +1092,10 @@ export class ExtensionsWorkbenchService
2222
// Skip if check updates only for builtin extensions and current extension is not builtin.
2323
continue;
2424
}
2525
+ if (installed.type !== ExtensionType.User) {
2626
+ // Never update builtin extensions.
2727
+ continue;
2828
+ }
29-
if (installed.isBuiltin && (!installed.local?.identifier.uuid || this.productService.quality !== 'stable')) {
30-
// Skip if the builtin extension does not have Marketplace identifier or the current quality is not stable.
29+
if (installed.isBuiltin && (!installed.local?.identifier.uuid || (!isWeb && this.productService.quality === 'stable'))) {
30+
// Skip checking updates for a builtin extension if it does not has Marketplace identifier or the current product is VS Code Desktop stable.
3131
continue;

0 commit comments

Comments
 (0)