@@ -10,16 +10,14 @@ Index: code-server/lib/vscode/src/vs/base/common/network.ts
10
10
===================================================================
11
11
--- code-server.orig/lib/vscode/src/vs/base/common/network.ts
12
12
+++ 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 {
15
14
return URI.from({
16
15
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,
20
18
+ 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 ,
23
21
query
24
22
});
25
23
}
@@ -38,40 +36,28 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench-dev.html
38
36
39
37
<!-- Disable pinch zooming -->
40
38
<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 @@
42
40
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
43
41
44
42
<!-- Workbench Icon/Manifest/CSS -->
45
43
- <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" />
47
45
- <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
48
46
+ <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" />
50
48
+ <link rel="manifest" href="{{VS_BASE}}/manifest.json" crossorigin="use-credentials" />
51
49
</head>
52
50
53
51
<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>
61
55
<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();
62
58
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]}`;
68
60
});
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) {
75
61
Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
76
62
===================================================================
77
63
--- 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
87
73
88
74
<!-- Disable pinch zooming -->
89
75
<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 @@
91
77
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
92
78
93
79
<!-- Workbench Icon/Manifest/CSS -->
94
80
- <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" />
96
82
- <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">
98
83
+ <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" />
100
85
+ <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">
102
87
103
88
</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>
138
89
Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
139
90
===================================================================
140
91
--- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
141
92
+++ 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
143
94
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 {
145
96
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);
148
99
const errorListener = socket.onError((err) => callback(err, undefined));
149
100
socket.onOpen(() => {
150
- errorListener.dispose();
151
- @@ -282,6 +282,3 @@ export class BrowserSocketFactory implem
101
+ @@ -282,6 +283,3 @@ export class BrowserSocketFactory implem
152
102
});
153
103
}
154
104
}
@@ -159,7 +109,7 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
159
109
===================================================================
160
110
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
161
111
+++ 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 {
163
113
return res.end();
164
114
}
165
115
@@ -176,37 +126,39 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
176
126
+ // that is using this when it should not.
177
127
+ const remoteAuthority = 'remote';
178
128
179
- function escapeAttribute(value: string): string {
180
- return value.replace(/"/g, '"');
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, '"');
131
+ @@ -297,6 +293,8 @@ export class WebClientServer {
183
132
scopes: [['user:email'], ['repo']]
184
133
} : undefined;
134
+
185
135
+ const base = relativeRoot(getOriginalUrl(req))
186
136
+ 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);
206
137
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 {
210
162
return res.end(data);
211
163
}
212
164
}
@@ -293,20 +245,20 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
293
245
===================================================================
294
246
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts
295
247
+++ 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
297
249
});
298
250
}
299
251
300
252
+ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/")
301
253
return URI.parse(window.location.href).with({ path, query });
302
254
}
303
255
304
- @@ -492 ,7 +493 ,7 @@ function doCreateUri(path: string, query
256
+ @@ -496 ,7 +497 ,7 @@ function doCreateUri(path: string, query
305
257
if (!configElement || !configElementAttribute) {
306
258
throw new Error('Missing web configuration element');
307
259
}
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 }
310
262
311
263
// Create workbench
312
264
create(document.body, {
@@ -319,10 +271,10 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensionResourceLoader/
319
271
import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
320
272
import { getTelemetryLevel, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
321
273
- import { RemoteAuthorities } from 'vs/base/common/network';
274
+ import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
322
275
323
276
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
326
278
public getExtensionGalleryResourceURL(galleryExtension: { publisher: string; name: string; version: string }, path?: string): URI | undefined {
327
279
if (this._extensionGalleryResourceUrlTemplate) {
328
280
const uri = URI.parse(format2(this._extensionGalleryResourceUrlTemplate, { publisher: galleryExtension.publisher, name: galleryExtension.name, version: galleryExtension.version, path: 'extension' }));
0 commit comments