feat: apply patch after setting up subtree
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, IHomeIndicator, IProductQualityChangeHandler, ISettingsSyncOptions } from 'vs/workbench/workbench.web.api';
|
||||
import { IWorkbenchConstructionOptions, create, ICredentialsProvider, IURLCallbackProvider, IWorkspaceProvider, IWorkspace, IWindowIndicator, IProductQualityChangeHandler, ISettingsSyncOptions } from 'vs/workbench/workbench.web.api';
|
||||
import { URI, UriComponents } from 'vs/base/common/uri';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
@ -17,6 +17,7 @@ import { isStandalone } from 'vs/base/browser/browser';
|
||||
import { localize } from 'vs/nls';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { encodePath } from 'vs/server/node/util';
|
||||
|
||||
function doCreateUri(path: string, queryValues: Map<string, string>): URI {
|
||||
let query: string | undefined = undefined;
|
||||
@ -309,12 +310,18 @@ class WorkspaceProvider implements IWorkspaceProvider {
|
||||
|
||||
// Folder
|
||||
else if (isFolderToOpen(workspace)) {
|
||||
targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_FOLDER}=${encodeURIComponent(workspace.folderUri.toString())}`;
|
||||
const target = workspace.folderUri.scheme === Schemas.vscodeRemote
|
||||
? encodePath(workspace.folderUri.path)
|
||||
: encodeURIComponent(workspace.folderUri.toString());
|
||||
targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_FOLDER}=${target}`;
|
||||
}
|
||||
|
||||
// Workspace
|
||||
else if (isWorkspaceToOpen(workspace)) {
|
||||
targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_WORKSPACE}=${encodeURIComponent(workspace.workspaceUri.toString())}`;
|
||||
const target = workspace.workspaceUri.scheme === Schemas.vscodeRemote
|
||||
? encodePath(workspace.workspaceUri.path)
|
||||
: encodeURIComponent(workspace.workspaceUri.toString());
|
||||
targetHref = `${document.location.origin}${document.location.pathname}?${WorkspaceProvider.QUERY_PARAM_WORKSPACE}=${target}`;
|
||||
}
|
||||
|
||||
// Append payload if any
|
||||
@ -404,7 +411,22 @@ class WindowIndicator implements IWindowIndicator {
|
||||
throw new Error('Missing web configuration element');
|
||||
}
|
||||
|
||||
const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = JSON.parse(configElementAttribute);
|
||||
const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = {
|
||||
webviewEndpoint: `${window.location.origin}${window.location.pathname.replace(/\/+$/, '')}/webview`,
|
||||
...JSON.parse(configElementAttribute),
|
||||
};
|
||||
|
||||
// Strip the protocol from the authority if it exists.
|
||||
const normalizeAuthority = (authority: string): string => authority.replace(/^https?:\/\//, '');
|
||||
if (config.remoteAuthority) {
|
||||
(config as any).remoteAuthority = normalizeAuthority(config.remoteAuthority);
|
||||
}
|
||||
if (config.workspaceUri && config.workspaceUri.authority) {
|
||||
config.workspaceUri.authority = normalizeAuthority(config.workspaceUri.authority);
|
||||
}
|
||||
if (config.folderUri && config.folderUri.authority) {
|
||||
config.folderUri.authority = normalizeAuthority(config.folderUri.authority);
|
||||
}
|
||||
|
||||
// Revive static extension locations
|
||||
if (Array.isArray(config.staticExtensions)) {
|
||||
@ -416,40 +438,7 @@ class WindowIndicator implements IWindowIndicator {
|
||||
// Find workspace to open and payload
|
||||
let foundWorkspace = false;
|
||||
let workspace: IWorkspace;
|
||||
let payload = Object.create(null);
|
||||
|
||||
const query = new URL(document.location.href).searchParams;
|
||||
query.forEach((value, key) => {
|
||||
switch (key) {
|
||||
|
||||
// Folder
|
||||
case WorkspaceProvider.QUERY_PARAM_FOLDER:
|
||||
workspace = { folderUri: URI.parse(value) };
|
||||
foundWorkspace = true;
|
||||
break;
|
||||
|
||||
// Workspace
|
||||
case WorkspaceProvider.QUERY_PARAM_WORKSPACE:
|
||||
workspace = { workspaceUri: URI.parse(value) };
|
||||
foundWorkspace = true;
|
||||
break;
|
||||
|
||||
// Empty
|
||||
case WorkspaceProvider.QUERY_PARAM_EMPTY_WINDOW:
|
||||
workspace = undefined;
|
||||
foundWorkspace = true;
|
||||
break;
|
||||
|
||||
// Payload
|
||||
case WorkspaceProvider.QUERY_PARAM_PAYLOAD:
|
||||
try {
|
||||
payload = JSON.parse(value);
|
||||
} catch (error) {
|
||||
console.error(error); // possible invalid JSON
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
let payload = config.workspaceProvider?.payload || Object.create(null);
|
||||
|
||||
// If no workspace is provided through the URL, check for config attribute from server
|
||||
if (!foundWorkspace) {
|
||||
@ -465,13 +454,6 @@ class WindowIndicator implements IWindowIndicator {
|
||||
// Workspace Provider
|
||||
const workspaceProvider = new WorkspaceProvider(workspace, payload);
|
||||
|
||||
// Home Indicator
|
||||
const homeIndicator: IHomeIndicator = {
|
||||
href: 'https://github.com/microsoft/vscode',
|
||||
icon: 'code',
|
||||
title: localize('home', "Home")
|
||||
};
|
||||
|
||||
// Window indicator (unless connected to a remote)
|
||||
let windowIndicator: WindowIndicator | undefined = undefined;
|
||||
if (!workspaceProvider.hasRemote()) {
|
||||
@ -515,7 +497,6 @@ class WindowIndicator implements IWindowIndicator {
|
||||
create(document.body, {
|
||||
...config,
|
||||
settingsSyncOptions,
|
||||
homeIndicator,
|
||||
windowIndicator,
|
||||
productQualityChangeHandler,
|
||||
workspaceProvider,
|
||||
|
Reference in New Issue
Block a user