/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ //@ts-check 'use strict'; const perf = require('../../../base/common/performance'); perf.mark('renderer/started'); const bootstrapWindow = require('../../../../bootstrap-window'); // Setup shell environment process['lazyEnv'] = getLazyEnv(); // Load workbench main bootstrapWindow.load([ 'vs/workbench/workbench.main', 'vs/nls!vs/workbench/workbench.main', 'vs/css!vs/workbench/workbench.main' ], function (workbench, configuration) { perf.mark('didLoadWorkbenchMain'); return process['lazyEnv'].then(function () { perf.mark('main/startup'); // @ts-ignore return require('vs/workbench/electron-browser/main').startup(configuration); }); }, { removeDeveloperKeybindingsAfterLoad: true, canModifyDOM: function (windowConfig) { showPartsSplash(windowConfig); }, beforeLoaderConfig: function (windowConfig, loaderConfig) { const onNodeCachedData = window['MonacoEnvironment'].onNodeCachedData = []; loaderConfig.onNodeCachedData = function () { onNodeCachedData.push(arguments); }; loaderConfig.recordStats = !!windowConfig.performance; }, beforeRequire: function () { perf.mark('willLoadWorkbenchMain'); } }); /** * @param {object} configuration */ function showPartsSplash(configuration) { perf.mark('willShowPartsSplash'); // TODO@Ben remove me after a while perf.mark('willAccessLocalStorage'); let storage = window.localStorage; perf.mark('didAccessLocalStorage'); let data; try { perf.mark('willReadLocalStorage'); let raw = storage.getItem('storage://global/parts-splash-data'); perf.mark('didReadLocalStorage'); data = JSON.parse(raw); } catch (e) { // ignore } // high contrast mode has been turned on from the outside, e.g OS -> ignore stored colors and layouts if (data && configuration.highContrast && data.baseTheme !== 'hc-black') { data = undefined; } // developing an extension -> ignore stored layouts if (data && configuration.extensionDevelopmentPath) { data.layoutInfo = undefined; } // minimal color configuration (works with or without persisted data) const baseTheme = data ? data.baseTheme : configuration.highContrast ? 'hc-black' : 'vs-dark'; const shellBackground = data ? data.colorInfo.editorBackground : configuration.highContrast ? '#000000' : '#1E1E1E'; const shellForeground = data ? data.colorInfo.foreground : configuration.highContrast ? '#FFFFFF' : '#CCCCCC'; const style = document.createElement('style'); style.className = 'initialShellColors'; document.head.appendChild(style); document.body.className = `monaco-shell ${baseTheme}`; style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`; if (data && data.layoutInfo) { // restore parts if possible (we might not always store layout info) const { id, layoutInfo, colorInfo } = data; const splash = document.createElement('div'); splash.id = id; // ensure there is enough space layoutInfo.sideBarWidth = Math.min(layoutInfo.sideBarWidth, window.innerWidth - (layoutInfo.activityBarWidth + layoutInfo.editorPartMinWidth)); if (configuration.folderUri || configuration.workspace) { // folder or workspace -> status bar color, sidebar splash.innerHTML = `
`; } else { // empty -> speical status bar color, no sidebar splash.innerHTML = ` `; } document.body.appendChild(splash); } perf.mark('didShowPartsSplash'); } /** * @returns {Promise