Skip to content

Commit 6255b80

Browse files
authored
Merge pull request #13 from aws-spenceng/staging_1.83.1-pr6
PR6: webview, local-storage, sagemaker-integration
2 parents 996c129 + 10886ee commit 6255b80

File tree

17 files changed

+754
-89
lines changed

17 files changed

+754
-89
lines changed

patched-vscode/extensions/git/package.nls.json

Lines changed: 26 additions & 26 deletions
Large diffs are not rendered by default.

patched-vscode/product.json

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"nameShort": "Code - OSS",
3-
"nameLong": "Code - OSS",
2+
"nameShort": "SageMaker Code Editor",
3+
"nameLong": "SageMaker Code Editor",
44
"applicationName": "code-oss",
55
"dataFolderName": ".vscode-oss",
66
"win32MutexName": "vscodeoss",
@@ -34,53 +34,17 @@
3434
"urlProtocol": "code-oss",
3535
"webviewContentExternalBaseUrlTemplate": "https://{{uuid}}.vscode-cdn.net/insider/ef65ac1ba57f57f2a3961bfe94aa20481caca4c6/out/vs/workbench/contrib/webview/browser/pre/",
3636
"builtInExtensions": [
37-
{
38-
"name": "ms-vscode.js-debug-companion",
39-
"version": "1.1.2",
40-
"sha256": "e034b8b41beb4e97e02c70f7175bd88abe66048374c2bd629f54bb33354bc2aa",
41-
"repo": "https://github.com/microsoft/vscode-js-debug-companion",
42-
"metadata": {
43-
"id": "99cb0b7f-7354-4278-b8da-6cc79972169d",
44-
"publisherId": {
45-
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
46-
"publisherName": "ms-vscode",
47-
"displayName": "Microsoft",
48-
"flags": "verified"
49-
},
50-
"publisherDisplayName": "Microsoft"
51-
}
52-
},
53-
{
54-
"name": "ms-vscode.js-debug",
55-
"version": "1.83.1",
56-
"sha256": "1452fdbab8d0d83ca5765bb66170d50b005c97ca4dcd13e154c3401d842a92d4",
57-
"repo": "https://github.com/microsoft/vscode-js-debug",
58-
"metadata": {
59-
"id": "25629058-ddac-4e17-abba-74678e126c5d",
60-
"publisherId": {
61-
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
62-
"publisherName": "ms-vscode",
63-
"displayName": "Microsoft",
64-
"flags": "verified"
65-
},
66-
"publisherDisplayName": "Microsoft"
67-
}
68-
},
69-
{
70-
"name": "ms-vscode.vscode-js-profile-table",
71-
"version": "1.0.3",
72-
"sha256": "b9dab017506d9e6a469a0f82b392e4cb1d7a25a4843f1db8ba396cbee209cfc5",
73-
"repo": "https://github.com/microsoft/vscode-js-profile-visualizer",
74-
"metadata": {
75-
"id": "7e52b41b-71ad-457b-ab7e-0620f1fc4feb",
76-
"publisherId": {
77-
"publisherId": "5f5636e7-69ed-4afe-b5d6-8d231fb3d3ee",
78-
"publisherName": "ms-vscode",
79-
"displayName": "Microsoft",
80-
"flags": "verified"
81-
},
82-
"publisherDisplayName": "Microsoft"
83-
}
84-
}
37+
],
38+
"extensionsGallery": {
39+
"serviceUrl": "https://open-vsx.org/vscode/gallery",
40+
"itemUrl": "https://open-vsx.org/vscode/item",
41+
"resourceUrlTemplate": "https://open-vsx.org/vscode/unpkg/{publisher}/{name}/{version}/{path}",
42+
"controlUrl": "",
43+
"recommendationsUrl": "",
44+
"nlsBaseUrl": "",
45+
"publisherUrl": ""
46+
},
47+
"linkProtectionTrustedDomains": [
48+
"https://open-vsx.org"
8549
]
86-
}
50+
}

patched-vscode/src/vs/platform/product/common/product.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,17 @@ else {
5959
if (Object.keys(product).length === 0) {
6060
Object.assign(product, {
6161
version: '1.82.0-dev',
62-
nameShort: 'Code - OSS Dev',
63-
nameLong: 'Code - OSS Dev',
62+
nameShort: 'CodeEditor',
63+
nameLong: 'Code Editor',
6464
applicationName: 'code-oss',
6565
dataFolderName: '.vscode-oss',
66+
commit: "hellocommit",
67+
date: "hellodate",
6668
urlProtocol: 'code-oss',
6769
reportIssueUrl: 'https://github.com/microsoft/vscode/issues/new',
6870
licenseName: 'MIT',
6971
licenseUrl: 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt',
70-
serverLicenseUrl: 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt'
72+
serverLicenseUrl: 'https://github.com/microsoft/vscode/blob/main/LICENSE.txt',
7173
});
7274
}
7375
}

patched-vscode/src/vs/server/node/webClientServer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ export class WebClientServer {
331331

332332
const workbenchWebConfiguration = {
333333
remoteAuthority,
334+
webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre',
335+
userDataPath: this._environmentService.userDataPath,
334336
_wrapWebWorkerExtHostInIframe,
335337
developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() },
336338
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Disposable } from 'vs/base/common/lifecycle';
2+
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
3+
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
4+
import { localize } from "vs/nls";
5+
import { ILogService } from "vs/platform/log/common/log";
6+
7+
export class SagemakerServerClient extends Disposable {
8+
constructor (
9+
@ILogService private logService: ILogService
10+
) {
11+
super();
12+
13+
this.logService.debug('Initializing SagemakerServerClient...');
14+
this.registerSagemakerCommands();
15+
}
16+
17+
static LOGOUT_COMMAND_ID = 'sagemaker.logout';
18+
static COOKIE_COMMAND_ID = 'sagemaker.parseCookies';
19+
20+
private registerSagemakerCommands() {
21+
const authMode: string | undefined = this.getCookieValue('authMode');
22+
const expiryTime: string | undefined = this.getCookieValue('expiryTime');
23+
const studioUserProfileName: string | undefined = this.getCookieValue('studioUserProfileName')
24+
const ssoExpiryTimestamp: string | undefined = this.getCookieValue('ssoExpiryTimestamp')
25+
const redirectURL: string | undefined = this.getCookieValue('redirectURL')
26+
27+
this.logService.debug('Registering sagemaker commands...');
28+
29+
CommandsRegistry.registerCommand(SagemakerServerClient.COOKIE_COMMAND_ID, () => {
30+
return {
31+
authMode: authMode,
32+
expiryTime: expiryTime,
33+
ssoExpiryTimestamp: ssoExpiryTimestamp,
34+
studioUserProfileName: studioUserProfileName,
35+
redirectURL: redirectURL
36+
};
37+
});
38+
39+
CommandsRegistry.registerCommand(SagemakerServerClient.LOGOUT_COMMAND_ID, () => {
40+
const currentUrl = new URL(window.location.href);
41+
const hostname = currentUrl.hostname;
42+
const pathComponents = currentUrl.pathname.split('/');
43+
const logoutUrl = `https://${hostname}/${pathComponents[1]}/${pathComponents[2]}/logout`;
44+
window.location.href = logoutUrl;
45+
});
46+
47+
for (const menuId of [MenuId.CommandPalette, MenuId.MenubarHomeMenu]) {
48+
MenuRegistry.appendMenuItem(menuId, {
49+
command: {
50+
id: SagemakerServerClient.LOGOUT_COMMAND_ID,
51+
title: localize('logout', "{0}: Log out", 'Sagemaker'),
52+
},
53+
});
54+
}
55+
}
56+
57+
private getCookieValue(name: string): string | undefined {
58+
const match = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)'); // See https://stackoverflow.com/a/25490531
59+
return match ? match.pop() : undefined;
60+
}
61+
}

patched-vscode/src/vs/workbench/browser/web.api.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,11 @@ export interface IWorkbenchConstructionOptions {
276276
*/
277277
readonly configurationDefaults?: Record<string, any>;
278278

279+
/**
280+
* Path to the user data directory.
281+
*/
282+
readonly userDataPath?: string
283+
279284
//#endregion
280285

281286
//#region Profile options

patched-vscode/src/vs/workbench/browser/web.main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import { EncryptionService } from 'vs/workbench/services/encryption/browser/encr
9595
import { IEncryptionService } from 'vs/platform/encryption/common/encryptionService';
9696
import { ISecretStorageService } from 'vs/platform/secrets/common/secrets';
9797
import { TunnelSource } from 'vs/workbench/services/remote/common/tunnelModel';
98+
import { SagemakerServerClient } from 'vs/workbench/browser/client';
9899

99100
export class BrowserMain extends Disposable {
100101

@@ -130,6 +131,9 @@ export class BrowserMain extends Disposable {
130131
// Startup
131132
const instantiationService = workbench.startup();
132133

134+
// Create instance of SagemakerServerClient
135+
this._register(instantiationService.createInstance(SagemakerServerClient));
136+
133137
// Window
134138
this._register(instantiationService.createInstance(BrowserWindow));
135139

patched-vscode/src/vs/workbench/contrib/webview/browser/pre/index-no-csp.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,12 @@
334334

335335
const hostname = location.hostname;
336336

337+
// It is safe to run if we are on the same host.
338+
const parent = new URL(parentOrigin)
339+
if (parent.hostname === hostname) {
340+
return start(parentOrigin)
341+
}
342+
337343
if (!crypto.subtle) {
338344
// cannot validate, not running in a secure context
339345
throw new Error(`'crypto.subtle' is not available so webviews will not work. This is likely because the editor is not running in a secure context (https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).`);

patched-vscode/src/vs/workbench/contrib/webview/browser/pre/index.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta charset="UTF-8">
66

77
<meta http-equiv="Content-Security-Policy"
8-
content="default-src 'none'; script-src 'sha256-QA1gXilHYAUFCvp7MpjgcmyBCFzSKV0SpiecMU8aUVc=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
8+
content="default-src 'none'; script-src 'sha256-5X5RiKYn8NTJVx919WStPrAmsV80rIIBbePhKquPcAQ=' 'self'; frame-src 'self'; style-src 'unsafe-inline';">
99

1010
<!-- Disable pinch zooming -->
1111
<meta name="viewport"
@@ -335,6 +335,12 @@
335335

336336
const hostname = location.hostname;
337337

338+
// It is safe to run if we are on the same host.
339+
const parent = new URL(parentOrigin)
340+
if (parent.hostname === hostname) {
341+
return start(parentOrigin)
342+
}
343+
338344
if (!crypto.subtle) {
339345
// cannot validate, not running in a secure context
340346
throw new Error(`'crypto.subtle' is not available so webviews will not work. This is likely because the editor is not running in a secure context (https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts).`);

patched-vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,8 @@ export class GettingStartedPage extends EditorPane {
779779
}));
780780

781781
const header = $('.header', {},
782-
$('h1.product-name.caption', {}, this.productService.nameLong),
783-
$('p.subtitle.description', {}, localize({ key: 'gettingStarted.editingEvolved', comment: ['Shown as subtitle on the Welcome page.'] }, "Editing evolved"))
782+
$('h1.product-name.caption', {}, "Code Editor"),
783+
$('p.subtitle.description', {}, localize({ key: 'gettingStarted.editingEvolved', comment: ['Shown as subtitle on the Welcome page.'] }, "Based on Code-OSS, Visual Studio Code Open Source"))
784784
);
785785

786786
const leftColumn = $('.categories-column.categories-column-left', {},);

0 commit comments

Comments
 (0)