mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 06:51:53 +01:00
window - use IPC to transport window config and drop URL query param (#120096)
This commit is contained in:
32
src/bootstrap-window.js
vendored
32
src/bootstrap-window.js
vendored
@@ -25,19 +25,21 @@
|
||||
const preloadGlobals = globals();
|
||||
const webFrame = preloadGlobals.webFrame;
|
||||
const safeProcess = preloadGlobals.process;
|
||||
const configuration = parseWindowConfiguration();
|
||||
const useCustomProtocol = safeProcess.sandboxed || typeof safeProcess.env['ENABLE_VSCODE_BROWSER_CODE_LOADING'] === 'string';
|
||||
|
||||
// Start to resolve process.env before anything gets load
|
||||
// so that we can run loading and resolving in parallel
|
||||
const whenEnvResolved = safeProcess.resolveEnv(configuration.userEnv);
|
||||
const whenEnvResolved = safeProcess.resolveEnv();
|
||||
|
||||
/**
|
||||
* @param {string[]} modulePaths
|
||||
* @param {(result: unknown, configuration: object) => Promise<unknown> | undefined} resultCallback
|
||||
* @param {{ forceEnableDeveloperKeybindings?: boolean, disallowReloadKeybinding?: boolean, removeDeveloperKeybindingsAfterLoad?: boolean, canModifyDOM?: (config: object) => void, beforeLoaderConfig?: (config: object, loaderConfig: object) => void, beforeRequire?: () => void }=} options
|
||||
*/
|
||||
function load(modulePaths, resultCallback, options) {
|
||||
async function load(modulePaths, resultCallback, options) {
|
||||
performance.mark('code/willWaitForWindowConfig');
|
||||
const configuration = await preloadGlobals.context.configuration;
|
||||
performance.mark('code/didWaitForWindowConfig');
|
||||
|
||||
// Apply zoom level early before even building the
|
||||
// window DOM elements to avoid UI flicker. We always
|
||||
@@ -180,30 +182,6 @@
|
||||
}, onUnexpectedError);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the contents of the window condiguration that
|
||||
* is passed into the URL from the `electron-main` side.
|
||||
*
|
||||
* @returns {{
|
||||
* isInitialStartup?: boolean,
|
||||
* zoomLevel?: number,
|
||||
* extensionDevelopmentPath?: string[],
|
||||
* extensionTestsPath?: string,
|
||||
* userEnv?: { [key: string]: string | undefined },
|
||||
* appRoot: string,
|
||||
* nodeCachedDataDir?: string
|
||||
* }}
|
||||
*/
|
||||
function parseWindowConfiguration() {
|
||||
const rawConfiguration = (window.location.search || '').split(/[?&]/)
|
||||
.filter(function (param) { return !!param; })
|
||||
.map(function (param) { return param.split('='); })
|
||||
.filter(function (param) { return param.length === 2; })
|
||||
.reduce(function (r, param) { r[param[0]] = decodeURIComponent(param[1]); return r; }, {});
|
||||
|
||||
return JSON.parse(rawConfiguration['config'] || '{}') || {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean | undefined} disallowReloadKeybinding
|
||||
* @returns {() => void}
|
||||
|
||||
Reference in New Issue
Block a user