Skip to content

Commit 32d5576

Browse files
committed
Serve webview resources from blobserve
1 parent 500c509 commit 32d5576

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/vs/gitpod/browser/workbench/workbench-dev.html

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<meta name="mobile-web-app-capable" content="yes" />
1212
<meta name="apple-mobile-web-app-capable" content="yes" />
1313
<meta name="apple-mobile-web-app-title" content="Code">
14-
<link rel="apple-touch-icon" href="/code-192.png" />
14+
<link rel="apple-touch-icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/code-192.png" />
1515

1616
<!-- Disable pinch zooming -->
1717
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
@@ -26,22 +26,23 @@
2626
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
2727

2828
<!-- Workbench Icon/Manifest/CSS -->
29-
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
30-
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
29+
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico" type="image/x-icon" />
30+
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json" crossorigin="use-credentials" />
3131
</head>
3232

3333
<body aria-label="">
3434
</body>
3535

3636
<!-- Startup (do not modify order of script tags!) -->
37-
<script src="./static/out/vs/loader.js"></script>
38-
<script src="./static/out/vs/webPackagePaths.js"></script>
37+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
38+
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
3939
<script>
40+
const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
4041
Object.keys(self.webPackagePaths).map(function (key, index) {
41-
self.webPackagePaths[key] = `${window.location.origin}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
42+
self.webPackagePaths[key] = `${baseUrl}/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
4243
});
4344
require.config({
44-
baseUrl: `${window.location.origin}/static/out`,
45+
baseUrl: `${baseUrl}/out`,
4546
recordStats: true,
4647
trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
4748
createScriptURL(value) {
@@ -53,9 +54,9 @@
5354
}),
5455
paths: {
5556
...self.webPackagePaths,
56-
'@gitpod/local-app-api-grpcweb': `${window.location.origin}/static/remote/web/node_modules/@gitpod/local-app-api-grpcweb/lib/localapp.js`,
57-
'@improbable-eng/grpc-web': `${window.location.origin}/static/remote/web/node_modules/@improbable-eng/grpc-web/dist/grpc-web-client.umd.js`,
58-
'@zip.js/zipjs': `${window.location.origin}/static/remote/web/node_modules/@zip.js/zip.js/dist/zip-no-worker-deflate.min.js`
57+
'@gitpod/local-app-api-grpcweb': `${baseUrl}/remote/web/node_modules/@gitpod/local-app-api-grpcweb/lib/localapp.js`,
58+
'@improbable-eng/grpc-web': `${baseUrl}/remote/web/node_modules/@improbable-eng/grpc-web/dist/grpc-web-client.umd.js`,
59+
'@zip.js/zipjs': `${baseUrl}/remote/web/node_modules/@zip.js/zip.js/dist/zip-no-worker-deflate.min.js`
5960
}
6061
});
6162
</script>

src/vs/gitpod/browser/workbench/workbench.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
1313
import { parse } from 'vs/base/common/marshalling';
1414
import { Emitter, Event } from 'vs/base/common/event';
1515
import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
16-
import { Schemas } from 'vs/base/common/network';
16+
import { FileAccess, Schemas } from 'vs/base/common/network';
1717
import { isEqual } from 'vs/base/common/resources';
1818
import { URI, UriComponents } from 'vs/base/common/uri';
1919
import { request } from 'vs/base/parts/request/browser/request';
@@ -209,6 +209,10 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
209209
private checkCallbacksTimeout: unknown | undefined = undefined;
210210
private onDidChangeLocalStorageDisposable: IDisposable | undefined;
211211

212+
constructor(private readonly _callbackRoute: string) {
213+
super();
214+
}
215+
212216
create(options: Partial<UriComponents> = {}): URI {
213217
const id = ++LocalStorageURLCallbackProvider.REQUEST_ID;
214218
const queryParams: string[] = [`vscode-reqid=${id}`];
@@ -232,7 +236,7 @@ class LocalStorageURLCallbackProvider extends Disposable implements IURLCallback
232236
this.startListening();
233237
}
234238

235-
return URI.parse(window.location.href).with({ path: '/callback', query: queryParams.join('&') });
239+
return URI.parse(window.location.href).with({ path: this._callbackRoute, query: queryParams.join('&') });
236240
}
237241

238242
private startListening(): void {
@@ -568,9 +572,12 @@ async function doStart(): Promise<IDisposable> {
568572

569573
const remoteAuthority = window.location.host;
570574

571-
const wsHostPrefix = !devMode ? info.workspaceId : remoteAuthority.substr(0, remoteAuthority.indexOf('.'));
572-
const webEndpointUrlTemplate = `https://{{uuid}}.${info.workspaceClusterHost}/${wsHostPrefix}/static`;
573-
const webviewEndpoint = `https://{{uuid}}.${info.workspaceClusterHost}/${wsHostPrefix}/static/out/vs/workbench/contrib/webview/browser/pre/`;
575+
// To make webviews work in development, go to file src/vs/workbench/contrib/webview/browser/pre/main.js
576+
// and update `signalReady` method to bypass hostname check
577+
const baseUri = FileAccess.asBrowserUri('', require);
578+
const uuidUri = `${baseUri.scheme}://${baseUri.authority.replace(/^blobserve/, '{{uuid}}')}${baseUri.path.replace(/\/out\/$/, '')}`;
579+
const webEndpointUrlTemplate = uuidUri;
580+
const webviewEndpoint = `${uuidUri}/out/vs/workbench/contrib/webview/browser/pre/`;
574581

575582
const folderUri = info.workspaceLocationFolder
576583
? URI.from({
@@ -961,13 +968,9 @@ async function doStart(): Promise<IDisposable> {
961968
'workbench.preferredLightColorTheme': 'Gitpod Light',
962969
'workbench.preferredDarkColorTheme': 'Gitpod Dark',
963970
},
964-
urlCallbackProvider: new LocalStorageURLCallbackProvider(),
971+
urlCallbackProvider: new LocalStorageURLCallbackProvider('/callback'),
965972
credentialsProvider,
966973
productConfiguration: {
967-
nameShort: product.nameShort + (info.ideAlias === 'code-latest' ? ' - Insiders' : ''),
968-
nameLong: product.nameLong + (info.ideAlias === 'code-latest' ? ' - Insiders' : ''),
969-
version: product.version + (info.ideAlias === 'code-latest' ? '-insider' : ''),
970-
quality: (info.ideAlias === 'code-latest' ? 'insider' : 'stable'),
971974
linkProtectionTrustedDomains: [
972975
...(product.linkProtectionTrustedDomains || []),
973976
gitpodDomain

0 commit comments

Comments
 (0)