mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 17:23:35 -05:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -9,7 +9,7 @@ import { IProcessEnvironment } from 'vs/base/common/platform';
|
||||
import { joinPath } from 'vs/base/common/resources';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { BACKUPS, IDebugParams, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
|
||||
import { BACKUPS, IExtensionHostDebugParams } from 'vs/platform/environment/common/environment';
|
||||
import { LogLevel } from 'vs/platform/log/common/log';
|
||||
import { IPath, IPathsToWaitFor, IWindowConfiguration } from 'vs/platform/windows/common/windows';
|
||||
import { ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
|
||||
@@ -17,104 +17,294 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
|
||||
import { IWorkbenchConstructionOptions } from 'vs/workbench/workbench.web.api';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { serializableToMap } from 'vs/base/common/map';
|
||||
import { memoize } from 'vs/base/common/decorators';
|
||||
|
||||
// TODO@ben remove properties that are node/electron only
|
||||
export class BrowserWindowConfiguration implements IWindowConfiguration {
|
||||
|
||||
constructor(
|
||||
private readonly options: IBrowserWorkbenchEnvironmentConstructionOptions,
|
||||
private readonly payload: Map<string, string> | undefined,
|
||||
private readonly environment: IWorkbenchEnvironmentService
|
||||
) { }
|
||||
|
||||
//#region PROPERLY CONFIGURED IN DESKTOP + WEB
|
||||
|
||||
@memoize
|
||||
get sessionId(): string { return generateUuid(); }
|
||||
|
||||
@memoize
|
||||
get remoteAuthority(): string | undefined { return this.options.remoteAuthority; }
|
||||
|
||||
@memoize
|
||||
get connectionToken(): string | undefined { return this.options.connectionToken || this.getCookieValue('vscode-tkn'); }
|
||||
|
||||
@memoize
|
||||
get backupWorkspaceResource(): URI { return joinPath(this.environment.backupHome, this.options.workspaceId); }
|
||||
|
||||
@memoize
|
||||
get filesToOpenOrCreate(): IPath[] | undefined {
|
||||
if (this.payload) {
|
||||
const fileToOpen = this.payload.get('openFile');
|
||||
if (fileToOpen) {
|
||||
return [{ fileUri: URI.parse(fileToOpen) }];
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Currently unsupported in web
|
||||
get filesToDiff(): IPath[] | undefined { return undefined; }
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region TODO MOVE TO NODE LAYER
|
||||
|
||||
_!: any[];
|
||||
|
||||
machineId!: string;
|
||||
windowId!: number;
|
||||
logLevel!: LogLevel;
|
||||
|
||||
mainPid!: number;
|
||||
|
||||
logLevel!: LogLevel;
|
||||
|
||||
appRoot!: string;
|
||||
execPath!: string;
|
||||
isInitialStartup?: boolean;
|
||||
|
||||
userEnv!: IProcessEnvironment;
|
||||
backupPath?: string;
|
||||
nodeCachedDataDir?: string;
|
||||
|
||||
backupPath?: string;
|
||||
backupWorkspaceResource?: URI;
|
||||
userEnv!: IProcessEnvironment;
|
||||
|
||||
workspace?: IWorkspaceIdentifier;
|
||||
folderUri?: ISingleFolderWorkspaceIdentifier;
|
||||
|
||||
remoteAuthority?: string;
|
||||
connectionToken?: string;
|
||||
|
||||
zoomLevel?: number;
|
||||
fullscreen?: boolean;
|
||||
maximized?: boolean;
|
||||
highContrast?: boolean;
|
||||
frameless?: boolean;
|
||||
accessibilitySupport?: boolean;
|
||||
partsSplashPath?: string;
|
||||
|
||||
perfStartTime?: number;
|
||||
perfAppReady?: number;
|
||||
perfWindowLoadTime?: number;
|
||||
isInitialStartup?: boolean;
|
||||
perfEntries!: ExportData;
|
||||
|
||||
filesToOpenOrCreate?: IPath[];
|
||||
filesToDiff?: IPath[];
|
||||
filesToWait?: IPathsToWaitFor;
|
||||
termProgram?: string;
|
||||
|
||||
//#endregion
|
||||
|
||||
private getCookieValue(name: string): string | undefined {
|
||||
const m = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)'); // See https://stackoverflow.com/a/25490531
|
||||
|
||||
return m ? m.pop() : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
interface IBrowserWorkbenchEnvironemntConstructionOptions extends IWorkbenchConstructionOptions {
|
||||
interface IBrowserWorkbenchEnvironmentConstructionOptions extends IWorkbenchConstructionOptions {
|
||||
workspaceId: string;
|
||||
logsPath: URI;
|
||||
}
|
||||
|
||||
interface IExtensionHostDebugEnvironment {
|
||||
params: IExtensionHostDebugParams;
|
||||
isExtensionDevelopment: boolean;
|
||||
extensionDevelopmentLocationURI: URI[];
|
||||
extensionTestsLocationURI?: URI;
|
||||
}
|
||||
|
||||
export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironmentService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
readonly configuration: IWindowConfiguration = new BrowserWindowConfiguration();
|
||||
//#region PROPERLY CONFIGURED IN DESKTOP + WEB
|
||||
|
||||
constructor(readonly options: IBrowserWorkbenchEnvironemntConstructionOptions) {
|
||||
this.args = { _: [] };
|
||||
this.logsPath = options.logsPath.path;
|
||||
this.logFile = joinPath(options.logsPath, 'window.log');
|
||||
this.appRoot = '/web/';
|
||||
this.appNameLong = 'Azure Data Studio - Web'; // {{SQL CARBON EDIT}} vscode to ads
|
||||
@memoize
|
||||
get isBuilt(): boolean { return !!product.commit; }
|
||||
|
||||
this.configuration.remoteAuthority = options.remoteAuthority;
|
||||
this.configuration.machineId = generateUuid();
|
||||
this.userRoamingDataHome = URI.file('/User').with({ scheme: Schemas.userData });
|
||||
this.settingsResource = joinPath(this.userRoamingDataHome, 'settings.json');
|
||||
this.settingsSyncPreviewResource = joinPath(this.userRoamingDataHome, '.settings.json');
|
||||
this.userDataSyncLogResource = joinPath(options.logsPath, 'userDataSync.log');
|
||||
this.keybindingsResource = joinPath(this.userRoamingDataHome, 'keybindings.json');
|
||||
this.keyboardLayoutResource = joinPath(this.userRoamingDataHome, 'keyboardLayout.json');
|
||||
this.argvResource = joinPath(this.userRoamingDataHome, 'argv.json');
|
||||
this.backupHome = joinPath(this.userRoamingDataHome, BACKUPS);
|
||||
this.untitledWorkspacesHome = joinPath(this.userRoamingDataHome, 'Workspaces');
|
||||
this.configuration.backupWorkspaceResource = joinPath(this.backupHome, options.workspaceId);
|
||||
this.configuration.connectionToken = options.connectionToken || getCookieValue('vscode-tkn');
|
||||
@memoize
|
||||
get logsPath(): string { return this.options.logsPath.path; }
|
||||
|
||||
this.debugExtensionHost = {
|
||||
port: null,
|
||||
break: false
|
||||
@memoize
|
||||
get logFile(): URI { return joinPath(this.options.logsPath, 'window.log'); }
|
||||
|
||||
@memoize
|
||||
get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.userData }); }
|
||||
|
||||
@memoize
|
||||
get settingsResource(): URI { return joinPath(this.userRoamingDataHome, 'settings.json'); }
|
||||
|
||||
@memoize
|
||||
get settingsSyncPreviewResource(): URI { return joinPath(this.userRoamingDataHome, '.settings.json'); }
|
||||
|
||||
@memoize
|
||||
get keybindingsSyncPreviewResource(): URI { return joinPath(this.userRoamingDataHome, '.keybindings.json'); }
|
||||
|
||||
@memoize
|
||||
get userDataSyncLogResource(): URI { return joinPath(this.options.logsPath, 'userDataSync.log'); }
|
||||
|
||||
@memoize
|
||||
get keybindingsResource(): URI { return joinPath(this.userRoamingDataHome, 'keybindings.json'); }
|
||||
|
||||
@memoize
|
||||
get keyboardLayoutResource(): URI { return joinPath(this.userRoamingDataHome, 'keyboardLayout.json'); }
|
||||
|
||||
@memoize
|
||||
get backupHome(): URI { return joinPath(this.userRoamingDataHome, BACKUPS); }
|
||||
|
||||
@memoize
|
||||
get untitledWorkspacesHome(): URI { return joinPath(this.userRoamingDataHome, 'Workspaces'); }
|
||||
|
||||
private _extensionHostDebugEnvironment: IExtensionHostDebugEnvironment | undefined = undefined;
|
||||
get debugExtensionHost(): IExtensionHostDebugParams {
|
||||
if (!this._extensionHostDebugEnvironment) {
|
||||
this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment();
|
||||
}
|
||||
|
||||
return this._extensionHostDebugEnvironment.params;
|
||||
}
|
||||
|
||||
get isExtensionDevelopment(): boolean {
|
||||
if (!this._extensionHostDebugEnvironment) {
|
||||
this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment();
|
||||
}
|
||||
|
||||
return this._extensionHostDebugEnvironment.isExtensionDevelopment;
|
||||
}
|
||||
|
||||
get extensionDevelopmentLocationURI(): URI[] {
|
||||
if (!this._extensionHostDebugEnvironment) {
|
||||
this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment();
|
||||
}
|
||||
|
||||
return this._extensionHostDebugEnvironment.extensionDevelopmentLocationURI;
|
||||
}
|
||||
|
||||
get extensionTestsLocationURI(): URI | undefined {
|
||||
if (!this._extensionHostDebugEnvironment) {
|
||||
this._extensionHostDebugEnvironment = this.resolveExtensionHostDebugEnvironment();
|
||||
}
|
||||
|
||||
return this._extensionHostDebugEnvironment.extensionTestsLocationURI;
|
||||
}
|
||||
|
||||
@memoize
|
||||
get webviewExternalEndpoint(): string {
|
||||
// TODO: get fallback from product.json
|
||||
return (this.options.webviewEndpoint || 'https://{{uuid}}.vscode-webview-test.com/{{commit}}').replace('{{commit}}', product.commit || '0d728c31ebdf03869d2687d9be0b017667c9ff37');
|
||||
}
|
||||
|
||||
@memoize
|
||||
get webviewResourceRoot(): string {
|
||||
return `${this.webviewExternalEndpoint}/vscode-resource/{{resource}}`;
|
||||
}
|
||||
|
||||
@memoize
|
||||
get webviewCspSource(): string {
|
||||
return this.webviewExternalEndpoint.replace('{{uuid}}', '*');
|
||||
}
|
||||
|
||||
// Currently not configurable in web
|
||||
get disableExtensions() { return false; }
|
||||
get extensionsPath(): string | undefined { return undefined; }
|
||||
get verbose(): boolean { return false; }
|
||||
get disableUpdates(): boolean { return false; }
|
||||
get logExtensionHostCommunication(): boolean { return false; }
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region TODO MOVE TO NODE LAYER
|
||||
|
||||
private _configuration: IWindowConfiguration | undefined = undefined;
|
||||
get configuration(): IWindowConfiguration {
|
||||
if (!this._configuration) {
|
||||
this._configuration = new BrowserWindowConfiguration(this.options, this.payload, this);
|
||||
}
|
||||
|
||||
return this._configuration;
|
||||
}
|
||||
|
||||
args = { _: [] };
|
||||
|
||||
wait!: boolean;
|
||||
status!: boolean;
|
||||
log?: string;
|
||||
|
||||
mainIPCHandle!: string;
|
||||
sharedIPCHandle!: string;
|
||||
|
||||
nodeCachedDataDir?: string;
|
||||
|
||||
argvResource!: URI;
|
||||
|
||||
disableCrashReporter!: boolean;
|
||||
|
||||
driverHandle?: string;
|
||||
driverVerbose!: boolean;
|
||||
|
||||
installSourcePath!: string;
|
||||
|
||||
builtinExtensionsPath!: string;
|
||||
|
||||
globalStorageHome!: string;
|
||||
workspaceStorageHome!: string;
|
||||
|
||||
backupWorkspacesPath!: string;
|
||||
|
||||
machineSettingsHome!: URI;
|
||||
machineSettingsResource!: URI;
|
||||
|
||||
userHome!: string;
|
||||
userDataPath!: string;
|
||||
appRoot!: string;
|
||||
appSettingsHome!: URI;
|
||||
execPath!: string;
|
||||
cliPath!: string;
|
||||
|
||||
//#endregion
|
||||
|
||||
|
||||
//#region TODO ENABLE IN WEB
|
||||
|
||||
galleryMachineIdResource?: URI;
|
||||
|
||||
//#endregion
|
||||
|
||||
private payload: Map<string, string> | undefined;
|
||||
|
||||
constructor(readonly options: IBrowserWorkbenchEnvironmentConstructionOptions) {
|
||||
if (options.workspaceProvider && Array.isArray(options.workspaceProvider.payload)) {
|
||||
this.payload = serializableToMap(options.workspaceProvider.payload);
|
||||
}
|
||||
}
|
||||
|
||||
private resolveExtensionHostDebugEnvironment(): IExtensionHostDebugEnvironment {
|
||||
const extensionHostDebugEnvironment: IExtensionHostDebugEnvironment = {
|
||||
params: {
|
||||
port: null,
|
||||
break: false
|
||||
},
|
||||
isExtensionDevelopment: false,
|
||||
extensionDevelopmentLocationURI: []
|
||||
};
|
||||
|
||||
// Fill in selected extra environmental properties
|
||||
if (options.workspaceProvider && Array.isArray(options.workspaceProvider.payload)) {
|
||||
const environment = serializableToMap(options.workspaceProvider.payload);
|
||||
for (const [key, value] of environment) {
|
||||
if (this.payload) {
|
||||
for (const [key, value] of this.payload) {
|
||||
switch (key) {
|
||||
case 'extensionDevelopmentPath':
|
||||
this.extensionDevelopmentLocationURI = [URI.parse(value)];
|
||||
this.isExtensionDevelopment = true;
|
||||
extensionHostDebugEnvironment.extensionDevelopmentLocationURI = [URI.parse(value)];
|
||||
extensionHostDebugEnvironment.isExtensionDevelopment = true;
|
||||
break;
|
||||
case 'extensionTestsPath':
|
||||
extensionHostDebugEnvironment.extensionTestsLocationURI = URI.parse(value);
|
||||
break;
|
||||
case 'debugId':
|
||||
this.debugExtensionHost.debugId = value;
|
||||
extensionHostDebugEnvironment.params.debugId = value;
|
||||
break;
|
||||
case 'inspect-brk-extensions':
|
||||
this.debugExtensionHost.port = parseInt(value);
|
||||
this.debugExtensionHost.break = false;
|
||||
extensionHostDebugEnvironment.params.port = parseInt(value);
|
||||
extensionHostDebugEnvironment.params.break = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -133,96 +323,23 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
|
||||
|
||||
const edp = map.get('extensionDevelopmentPath');
|
||||
if (edp) {
|
||||
this.extensionDevelopmentLocationURI = [URI.parse(edp)];
|
||||
this.isExtensionDevelopment = true;
|
||||
extensionHostDebugEnvironment.extensionDevelopmentLocationURI = [URI.parse(edp)];
|
||||
extensionHostDebugEnvironment.isExtensionDevelopment = true;
|
||||
}
|
||||
|
||||
const di = map.get('debugId');
|
||||
if (di) {
|
||||
this.debugExtensionHost.debugId = di;
|
||||
extensionHostDebugEnvironment.params.debugId = di;
|
||||
}
|
||||
|
||||
const ibe = map.get('inspect-brk-extensions');
|
||||
if (ibe) {
|
||||
this.debugExtensionHost.port = parseInt(ibe);
|
||||
this.debugExtensionHost.break = false;
|
||||
extensionHostDebugEnvironment.params.port = parseInt(ibe);
|
||||
extensionHostDebugEnvironment.params.break = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
untitledWorkspacesHome: URI;
|
||||
extensionTestsLocationURI?: URI;
|
||||
args: any;
|
||||
execPath!: string;
|
||||
cliPath!: string;
|
||||
appRoot: string;
|
||||
userHome!: string;
|
||||
userDataPath!: string;
|
||||
appNameLong: string;
|
||||
appQuality?: string;
|
||||
appSettingsHome!: URI;
|
||||
userRoamingDataHome: URI;
|
||||
settingsResource: URI;
|
||||
keybindingsResource: URI;
|
||||
keyboardLayoutResource: URI;
|
||||
argvResource: URI;
|
||||
settingsSyncPreviewResource: URI;
|
||||
userDataSyncLogResource: URI;
|
||||
machineSettingsHome!: URI;
|
||||
machineSettingsResource!: URI;
|
||||
globalStorageHome!: string;
|
||||
workspaceStorageHome!: string;
|
||||
backupHome: URI;
|
||||
backupWorkspacesPath!: string;
|
||||
workspacesHome!: string;
|
||||
isExtensionDevelopment!: boolean;
|
||||
disableExtensions!: boolean | string[];
|
||||
builtinExtensionsPath!: string;
|
||||
extensionsPath?: string;
|
||||
extensionDevelopmentLocationURI?: URI[];
|
||||
extensionTestsPath?: string;
|
||||
debugExtensionHost: IExtensionHostDebugParams;
|
||||
debugSearch!: IDebugParams;
|
||||
logExtensionHostCommunication!: boolean;
|
||||
isBuilt!: boolean;
|
||||
wait!: boolean;
|
||||
status!: boolean;
|
||||
log?: string;
|
||||
logsPath: string;
|
||||
verbose!: boolean;
|
||||
skipReleaseNotes!: boolean;
|
||||
mainIPCHandle!: string;
|
||||
sharedIPCHandle!: string;
|
||||
nodeCachedDataDir?: string;
|
||||
installSourcePath!: string;
|
||||
disableUpdates!: boolean;
|
||||
disableCrashReporter!: boolean;
|
||||
driverHandle?: string;
|
||||
driverVerbose!: boolean;
|
||||
galleryMachineIdResource?: URI;
|
||||
readonly logFile: URI;
|
||||
|
||||
get webviewExternalEndpoint(): string {
|
||||
// TODO: get fallback from product.json
|
||||
return (this.options.webviewEndpoint || 'https://{{uuid}}.vscode-webview-test.com/{{commit}}')
|
||||
.replace('{{commit}}', product.commit || 'c58aaab8a1cc22a7139b761166a0d4f37d41e998');
|
||||
}
|
||||
|
||||
get webviewResourceRoot(): string {
|
||||
return `${this.webviewExternalEndpoint}/vscode-resource/{{resource}}`;
|
||||
}
|
||||
|
||||
get webviewCspSource(): string {
|
||||
return this.webviewExternalEndpoint
|
||||
.replace('{{uuid}}', '*');
|
||||
return extensionHostDebugEnvironment;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See https://stackoverflow.com/a/25490531
|
||||
*/
|
||||
function getCookieValue(name: string): string | undefined {
|
||||
const m = document.cookie.match('(^|[^;]+)\\s*' + name + '\\s*=\\s*([^;]+)');
|
||||
return m ? m.pop() : undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user