diff --git a/.eslintrc.json b/.eslintrc.json index 27a94df6dcce2..a78e8562a5933 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1133,8 +1133,18 @@ "restrictions": [] }, { - "target": "src/{bootstrap-cli.ts,bootstrap-esm.ts,bootstrap-fork.ts,bootstrap-node.ts,bootstrap-import.ts,bootstrap-meta.ts,bootstrap-window.ts,cli.ts,main.ts,server-cli.ts,server-main.ts,bootstrap-server.ts}", + "target": "src/bootstrap-window.ts", "restrictions": [] + }, + { + "target": "src/{bootstrap-cli.ts,bootstrap-esm.ts,bootstrap-fork.ts,bootstrap-import.ts,bootstrap-meta.ts,bootstrap-node.ts,bootstrap-server.ts,cli.ts,main.ts,server-cli.ts,server-main.ts}", + "restrictions": [ + "vs/**/common/*", + "vs/**/node/*", + "vs/nls.js", + "src/*.js", + "*" // node.js + ] } ] } diff --git a/build/buildfile.js b/build/buildfile.js index f4a2a5e322a0f..eee9ecbcefded 100644 --- a/build/buildfile.js +++ b/build/buildfile.js @@ -26,20 +26,17 @@ function createModuleDescription(name, exclude) { * @param {string} name */ function createEditorWorkerModuleDescription(name) { - const description = createModuleDescription(name, ['vs/base/common/worker/simpleWorker', 'vs/editor/common/services/editorSimpleWorker']); - description.name = `${description.name}.esm`; - - return description; + return createModuleDescription(name, ['vs/base/common/worker/simpleWorker', 'vs/editor/common/services/editorSimpleWorker']); } -exports.workerEditor = createEditorWorkerModuleDescription('vs/editor/common/services/editorSimpleWorker'); -exports.workerExtensionHost = createEditorWorkerModuleDescription('vs/workbench/api/worker/extensionHostWorker'); -exports.workerNotebook = createEditorWorkerModuleDescription('vs/workbench/contrib/notebook/common/services/notebookSimpleWorker'); -exports.workerLanguageDetection = createEditorWorkerModuleDescription('vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker'); -exports.workerLocalFileSearch = createEditorWorkerModuleDescription('vs/workbench/services/search/worker/localFileSearch'); -exports.workerProfileAnalysis = createEditorWorkerModuleDescription('vs/platform/profiling/electron-sandbox/profileAnalysisWorker'); -exports.workerOutputLinks = createEditorWorkerModuleDescription('vs/workbench/contrib/output/common/outputLinkComputer'); -exports.workerBackgroundTokenization = createEditorWorkerModuleDescription('vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker'); +exports.workerEditor = createEditorWorkerModuleDescription('vs/editor/common/services/editorSimpleWorkerMain'); +exports.workerExtensionHost = createEditorWorkerModuleDescription('vs/workbench/api/worker/extensionHostWorkerMain'); +exports.workerNotebook = createEditorWorkerModuleDescription('vs/workbench/contrib/notebook/common/services/notebookSimpleWorkerMain'); +exports.workerLanguageDetection = createEditorWorkerModuleDescription('vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorkerMain'); +exports.workerLocalFileSearch = createEditorWorkerModuleDescription('vs/workbench/services/search/worker/localFileSearchMain'); +exports.workerProfileAnalysis = createEditorWorkerModuleDescription('vs/platform/profiling/electron-sandbox/profileAnalysisWorkerMain'); +exports.workerOutputLinks = createEditorWorkerModuleDescription('vs/workbench/contrib/output/common/outputLinkComputerMain'); +exports.workerBackgroundTokenization = createEditorWorkerModuleDescription('vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.workerMain'); exports.workbenchDesktop = [ createModuleDescription('vs/workbench/contrib/debug/node/telemetryApp'), diff --git a/src/bootstrap-esm.ts b/src/bootstrap-esm.ts index b0c6d142a4f42..7256c0230e5bc 100644 --- a/src/bootstrap-esm.ts +++ b/src/bootstrap-esm.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import * as path from 'path'; import * as fs from 'fs'; import { fileURLToPath } from 'url'; diff --git a/src/bootstrap-fork.ts b/src/bootstrap-fork.ts index 3303d442ee712..aa523399126cc 100644 --- a/src/bootstrap-fork.ts +++ b/src/bootstrap-fork.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import * as performance from './vs/base/common/performance.js'; import { removeGlobalNodeJsModuleLookupPaths, devInjectNodeModuleLookupPath } from './bootstrap-node.js'; import { load } from './bootstrap-esm.js'; diff --git a/src/bootstrap-import.ts b/src/bootstrap-import.ts index c280170efb9b8..8869058159d33 100644 --- a/src/bootstrap-import.ts +++ b/src/bootstrap-import.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - // ********************************************************************* // * * // * We need this to redirect to node_modules from the remote-folder. * diff --git a/src/bootstrap-meta.ts b/src/bootstrap-meta.ts index c17716c8d3133..2e704fd570420 100644 --- a/src/bootstrap-meta.ts +++ b/src/bootstrap-meta.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import { createRequire } from 'node:module'; import type { IProductConfiguration } from './vs/base/common/product.js'; diff --git a/src/bootstrap-node.ts b/src/bootstrap-node.ts index 0fc29f14d2cf2..c0d5cd3693cfe 100644 --- a/src/bootstrap-node.ts +++ b/src/bootstrap-node.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import * as path from 'path'; import * as fs from 'fs'; import { fileURLToPath } from 'url'; diff --git a/src/bootstrap-window.ts b/src/bootstrap-window.ts index c9f49fe111317..1b2cedf68b4dd 100644 --- a/src/bootstrap-window.ts +++ b/src/bootstrap-window.ts @@ -8,32 +8,27 @@ (function () { type ISandboxConfiguration = import('vs/base/parts/sandbox/common/sandboxTypes.js').ISandboxConfiguration; + type ILoadResult = import('vs/platform/window/electron-sandbox/window.js').ILoadResult; type ILoadOptions = import('vs/platform/window/electron-sandbox/window.js').ILoadOptions; type IMainWindowSandboxGlobals = import('./vs/base/parts/sandbox/electron-sandbox/globals.js').IMainWindowSandboxGlobals; const preloadGlobals: IMainWindowSandboxGlobals = (window as any).vscode; // defined by preload.ts const safeProcess = preloadGlobals.process; - // increase number of stack frames(from 10, https://github.com/v8/v8/wiki/Stack-Trace-API) - Error.stackTraceLimit = 100; - - async function load(esModule: string, resultCallback: (result: any, configuration: T) => Promise | undefined, options: ILoadOptions): Promise { + async function load(esModule: string, options: ILoadOptions): Promise> { // Window Configuration from Preload Script const configuration = await resolveWindowConfiguration(); - // Signal can modify DOM - options?.canModifyDOM?.(configuration); + // Signal before import() + options?.beforeImport?.(configuration); // Developer settings - const { enableDeveloperKeybindings, removeDeveloperKeybindingsAfterLoad, developerDeveloperKeybindingsDisposable } = setupDeveloperKeybindings(configuration, options); + const { enableDeveloperKeybindings, removeDeveloperKeybindingsAfterLoad, developerDeveloperKeybindingsDisposable, forceDisableShowDevtoolsOnError } = setupDeveloperKeybindings(configuration, options); // NLS setupNLS(configuration); - // Signal before import() - options?.beforeImport?.(configuration); - // Compute base URL and set as global const baseUrl = new URL(`${fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out/`); globalThis._VSCODE_FILE_ROOT = baseUrl.toString(); @@ -45,16 +40,15 @@ try { const result = await import(new URL(`${esModule}.js`, baseUrl).href); - const callbackResult = resultCallback(result, configuration); - if (callbackResult instanceof Promise) { - await callbackResult; - - if (developerDeveloperKeybindingsDisposable && removeDeveloperKeybindingsAfterLoad) { - developerDeveloperKeybindingsDisposable(); - } + if (developerDeveloperKeybindingsDisposable && removeDeveloperKeybindingsAfterLoad) { + developerDeveloperKeybindingsDisposable(); } + + return { result, configuration }; } catch (error) { - onUnexpectedError(error, enableDeveloperKeybindings); + onUnexpectedError(error, enableDeveloperKeybindings && !forceDisableShowDevtoolsOnError); + + throw error; } } @@ -74,11 +68,13 @@ const { forceEnableDeveloperKeybindings, disallowReloadKeybinding, - removeDeveloperKeybindingsAfterLoad + removeDeveloperKeybindingsAfterLoad, + forceDisableShowDevtoolsOnError } = typeof options?.configureDeveloperSettings === 'function' ? options.configureDeveloperSettings(configuration) : { forceEnableDeveloperKeybindings: false, disallowReloadKeybinding: false, - removeDeveloperKeybindingsAfterLoad: false + removeDeveloperKeybindingsAfterLoad: false, + forceDisableShowDevtoolsOnError: false }; const isDev = !!safeProcess.env['VSCODE_DEV']; @@ -91,7 +87,8 @@ return { enableDeveloperKeybindings, removeDeveloperKeybindingsAfterLoad, - developerDeveloperKeybindingsDisposable + developerDeveloperKeybindingsDisposable, + forceDisableShowDevtoolsOnError }; } diff --git a/src/cli.ts b/src/cli.ts index 8ffb6fd14268e..cead01847d665 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import './bootstrap-cli.js'; // this MUST come before other imports as it changes global state import * as path from 'path'; import { fileURLToPath } from 'url'; diff --git a/src/main.ts b/src/main.ts index 3d08e8d64172b..f676dca148c61 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import * as path from 'path'; import * as fs from 'original-fs'; import * as os from 'os'; diff --git a/src/server-cli.ts b/src/server-cli.ts index c9de28372e41e..fabe8900b3f17 100644 --- a/src/server-cli.ts +++ b/src/server-cli.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import './bootstrap-server.js'; // this MUST come before other imports as it changes global state import * as path from 'path'; import { fileURLToPath } from 'url'; diff --git a/src/server-main.ts b/src/server-main.ts index 3b6f45f2f9688..d70a856f854e8 100644 --- a/src/server-main.ts +++ b/src/server-main.ts @@ -3,8 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -/* eslint-disable local/code-import-patterns */ - import './bootstrap-server.js'; // this MUST come before other imports as it changes global state import * as path from 'path'; import * as http from 'http'; diff --git a/src/tsconfig.json b/src/tsconfig.json index 6865667ad285a..88d3daa0f295e 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -26,31 +26,10 @@ ] }, "include": [ - "./bootstrap-esm.ts", - "./bootstrap-cli.ts", - "./bootstrap-fork.ts", - "./bootstrap-import.ts", - "./bootstrap-meta.ts", - "./bootstrap-node.ts", - "./bootstrap-server.ts", - "./bootstrap-window.ts", - "./cli.ts", - "./main.ts", - "./server-main.ts", - "./server-cli.ts", - "./vs/base/common/jsonc.ts", - "./vs/base/common/performance.ts", - "./vs/base/node/unc.ts", - "./vs/base/node/nls.ts", - "./vs/platform/environment/node/userDataPath.ts", - "./vs/base/parts/sandbox/electron-sandbox/preload-aux.ts", - "./vs/base/parts/sandbox/electron-sandbox/preload.ts", - "./vs/code/electron-sandbox/processExplorer/processExplorer.ts", - "./vs/code/electron-sandbox/workbench/workbench.ts", - "./vs/workbench/contrib/issue/electron-sandbox/issueReporter.ts", + "./*.ts", "./typings", "./vs/**/*.ts", - "vscode-dts/vscode.proposed.*.d.ts", - "vscode-dts/vscode.d.ts" + "./vscode-dts/vscode.proposed.*.d.ts", + "./vscode-dts/vscode.d.ts" ] } diff --git a/src/vs/base/browser/defaultWorkerFactory.ts b/src/vs/base/browser/defaultWorkerFactory.ts index c72296fd7001f..f6054bf640259 100644 --- a/src/vs/base/browser/defaultWorkerFactory.ts +++ b/src/vs/base/browser/defaultWorkerFactory.ts @@ -119,7 +119,7 @@ class WebWorker extends Disposable implements IWorker { private readonly label: string; private worker: Promise | null; - constructor(esmWorkerLocation: URI | undefined, amdModuleId: string, id: number, label: string, onMessageCallback: IWorkerCallback, onErrorCallback: (err: any) => void) { + constructor(esmWorkerLocation: URI | undefined, moduleId: string, id: number, label: string, onMessageCallback: IWorkerCallback, onErrorCallback: (err: any) => void) { super(); this.id = id; this.label = label; @@ -129,7 +129,7 @@ class WebWorker extends Disposable implements IWorker { } else { this.worker = Promise.resolve(workerOrPromise); } - this.postMessage(amdModuleId, []); + this.postMessage(moduleId, []); this.worker.then((w) => { w.onmessage = function (ev) { onMessageCallback(ev.data); @@ -171,10 +171,10 @@ export class WorkerDescriptor implements IWorkerDescriptor { public readonly esmModuleLocation: URI | undefined; constructor( - public readonly amdModuleId: string, + public readonly moduleId: string, readonly label: string | undefined, ) { - this.esmModuleLocation = FileAccess.asBrowserUri(`${amdModuleId}.esm.js` as AppResourcePath); + this.esmModuleLocation = FileAccess.asBrowserUri(`${moduleId}Main.js` as AppResourcePath); } } @@ -194,7 +194,7 @@ class DefaultWorkerFactory implements IWorkerFactory { throw this._webWorkerFailedBeforeError; } - return new WebWorker(desc.esmModuleLocation, desc.amdModuleId, workerId, desc.label || 'anonymous' + workerId, onMessageCallback, (err) => { + return new WebWorker(desc.esmModuleLocation, desc.moduleId, workerId, desc.label || 'anonymous' + workerId, onMessageCallback, (err) => { logOnceWebWorkerWarning(err); this._webWorkerFailedBeforeError = err; onErrorCallback(err); @@ -202,7 +202,7 @@ class DefaultWorkerFactory implements IWorkerFactory { } } -export function createWebWorker(amdModuleId: string, label: string | undefined): IWorkerClient; +export function createWebWorker(moduleId: string, label: string | undefined): IWorkerClient; export function createWebWorker(workerDescriptor: IWorkerDescriptor): IWorkerClient; export function createWebWorker(arg0: string | IWorkerDescriptor, arg1?: string | undefined): IWorkerClient { const workerDescriptor = (typeof arg0 === 'string' ? new WorkerDescriptor(arg0, arg1) : arg0); diff --git a/src/vs/base/common/worker/simpleWorker.ts b/src/vs/base/common/worker/simpleWorker.ts index 6b55d53d1e169..70a328db53f22 100644 --- a/src/vs/base/common/worker/simpleWorker.ts +++ b/src/vs/base/common/worker/simpleWorker.ts @@ -29,7 +29,7 @@ export interface IWorkerFactory { } export interface IWorkerDescriptor { - readonly amdModuleId: string; + readonly moduleId: string; readonly esmModuleLocation: URI | undefined; readonly label: string | undefined; } @@ -332,7 +332,7 @@ export class SimpleWorkerClient extends Disposable implements this._worker = this._register(workerFactory.create( { - amdModuleId: 'vs/base/common/worker/simpleWorker', + moduleId: 'vs/base/common/worker/simpleWorker', esmModuleLocation: workerDescriptor.esmModuleLocation, label: workerDescriptor.label }, @@ -375,12 +375,12 @@ export class SimpleWorkerClient extends Disposable implements this._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [ this._worker.getId(), JSON.parse(JSON.stringify(loaderConfiguration)), - workerDescriptor.amdModuleId, + workerDescriptor.moduleId, ]); this.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; }); this._onModuleLoaded.catch((e) => { - this._onError('Worker failed to load ' + workerDescriptor.amdModuleId, e); + this._onError('Worker failed to load ' + workerDescriptor.moduleId, e); }); } diff --git a/src/vs/code/electron-sandbox/processExplorer/processExplorer.ts b/src/vs/code/electron-sandbox/processExplorer/processExplorer.ts index 11c86bbfe9236..6df8c102be947 100644 --- a/src/vs/code/electron-sandbox/processExplorer/processExplorer.ts +++ b/src/vs/code/electron-sandbox/processExplorer/processExplorer.ts @@ -5,18 +5,21 @@ /* eslint-disable no-restricted-globals */ -(function () { +(async function () { type IBootstrapWindow = import('vs/platform/window/electron-sandbox/window.js').IBootstrapWindow; + type IProcessExplorerMain = import('vs/code/electron-sandbox/processExplorer/processExplorerMain.js').IProcessExplorerMain; + type ProcessExplorerWindowConfiguration = import('vs/platform/issue/common/issue.js').ProcessExplorerWindowConfiguration; + const bootstrapWindow: IBootstrapWindow = (window as any).MonacoBootstrapWindow; // defined by bootstrap-window.ts - bootstrapWindow.load('vs/code/electron-sandbox/processExplorer/processExplorerMain', function (processExplorer, configuration) { - return processExplorer.startup(configuration); - }, { + const { result, configuration } = await bootstrapWindow.load('vs/code/electron-sandbox/processExplorer/processExplorerMain', { configureDeveloperSettings: function () { return { forceEnableDeveloperKeybindings: true }; }, }); + + result.startup(configuration); }()); diff --git a/src/vs/code/electron-sandbox/processExplorer/processExplorerMain.ts b/src/vs/code/electron-sandbox/processExplorer/processExplorerMain.ts index 6ee7d3e296353..d9f79c61fbb9f 100644 --- a/src/vs/code/electron-sandbox/processExplorer/processExplorerMain.ts +++ b/src/vs/code/electron-sandbox/processExplorer/processExplorerMain.ts @@ -591,6 +591,10 @@ function createCodiconStyleSheet() { delayer.schedule(); } +export interface IProcessExplorerMain { + startup(configuration: ProcessExplorerWindowConfiguration): void; +} + export function startup(configuration: ProcessExplorerWindowConfiguration): void { const platformClass = configuration.data.platform === 'win32' ? 'windows' : configuration.data.platform === 'linux' ? 'linux' : 'mac'; mainWindow.document.body.classList.add(platformClass); // used by our fonts diff --git a/src/vs/code/electron-sandbox/workbench/workbench.ts b/src/vs/code/electron-sandbox/workbench/workbench.ts index 011514bdbfb7a..280cee11697b4 100644 --- a/src/vs/code/electron-sandbox/workbench/workbench.ts +++ b/src/vs/code/electron-sandbox/workbench/workbench.ts @@ -5,72 +5,22 @@ /* eslint-disable no-restricted-globals */ -(function () { +(async function () { + + // Add a perf entry right from the top + performance.mark('code/didStartRenderer'); type INativeWindowConfiguration = import('vs/platform/window/common/window.ts').INativeWindowConfiguration; - type NativeParsedArgs = import('vs/platform/environment/common/argv.js').NativeParsedArgs; type IBootstrapWindow = import('vs/platform/window/electron-sandbox/window.js').IBootstrapWindow; type IMainWindowSandboxGlobals = import('vs/base/parts/sandbox/electron-sandbox/globals.js').IMainWindowSandboxGlobals; + type IDesktopMain = import('vs/workbench/electron-sandbox/desktop.main.js').IDesktopMain; const bootstrapWindow: IBootstrapWindow = (window as any).MonacoBootstrapWindow; // defined by bootstrap-window.ts const preloadGlobals: IMainWindowSandboxGlobals = (window as any).vscode; // defined by preload.ts - // Add a perf entry right from the top - performance.mark('code/didStartRenderer'); - - // Load workbench main JS and CSS all in parallel. This is an - // optimization to prevent a waterfall of loading to happen, because - // we know for a fact that workbench.desktop.main will depend on - // the related CSS counterpart. - bootstrapWindow.load('vs/workbench/workbench.desktop.main', - function (desktopMain, configuration) { - - // Mark start of workbench - performance.mark('code/didLoadWorkbenchMain'); - - return desktopMain.main(configuration); - }, - { - configureDeveloperSettings: function (windowConfig) { - return { - // disable automated devtools opening on error when running extension tests - // as this can lead to nondeterministic test execution (devtools steals focus) - forceDisableShowDevtoolsOnError: typeof windowConfig.extensionTestsPath === 'string' || windowConfig['enable-smoke-test-driver'] === true, - // enable devtools keybindings in extension development window - forceEnableDeveloperKeybindings: Array.isArray(windowConfig.extensionDevelopmentPath) && windowConfig.extensionDevelopmentPath.length > 0, - removeDeveloperKeybindingsAfterLoad: true - }; - }, - canModifyDOM: function (windowConfig) { - showSplash(windowConfig); - }, - beforeImport: function (windowConfig) { - performance.mark('code/willLoadWorkbenchMain'); - - // Code windows have a `vscodeWindowId` property to identify them - Object.defineProperty(window, 'vscodeWindowId', { - get: () => windowConfig.windowId - }); + //#region Splash Screen Helpers - // It looks like browsers only lazily enable - // the element when needed. Since we - // leverage canvas elements in our code in many - // locations, we try to help the browser to - // initialize canvas when it is idle, right - // before we wait for the scripts to be loaded. - window.requestIdleCallback(() => { - const canvas = document.createElement('canvas'); - const context = canvas.getContext('2d'); - context?.clearRect(0, 0, canvas.width, canvas.height); - canvas.remove(); - }, { timeout: 50 }); - } - } - ); - - //#region Helpers - - function showSplash(configuration: INativeWindowConfiguration & NativeParsedArgs) { + function showSplash(configuration: INativeWindowConfiguration) { performance.mark('code/willShowPartsSplash'); let data = configuration.partsSplash; @@ -275,4 +225,50 @@ } //#endregion + + const { result, configuration } = await bootstrapWindow.load('vs/workbench/workbench.desktop.main', + { + configureDeveloperSettings: function (windowConfig) { + return { + // disable automated devtools opening on error when running extension tests + // as this can lead to nondeterministic test execution (devtools steals focus) + forceDisableShowDevtoolsOnError: typeof windowConfig.extensionTestsPath === 'string' || windowConfig['enable-smoke-test-driver'] === true, + // enable devtools keybindings in extension development window + removeDeveloperKeybindingsAfterLoad: true + }; + }, + beforeImport: function (windowConfig) { + + // Show our splash as early as possible + showSplash(windowConfig); + + // Code windows have a `vscodeWindowId` property to identify them + Object.defineProperty(window, 'vscodeWindowId', { + get: () => windowConfig.windowId + }); + + // It looks like browsers only lazily enable + // the element when needed. Since we + // leverage canvas elements in our code in many + // locations, we try to help the browser to + // initialize canvas when it is idle, right + // before we wait for the scripts to be loaded. + window.requestIdleCallback(() => { + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + context?.clearRect(0, 0, canvas.width, canvas.height); + canvas.remove(); + }, { timeout: 50 }); + + // Track import() perf + performance.mark('code/willLoadWorkbenchMain'); + } + } + ); + + // Mark start of workbench + performance.mark('code/didLoadWorkbenchMain'); + + // Load workbench + result.main(configuration); }()); diff --git a/src/vs/editor/common/services/editorSimpleWorker.esm.ts b/src/vs/editor/common/services/editorSimpleWorkerMain.ts similarity index 100% rename from src/vs/editor/common/services/editorSimpleWorker.esm.ts rename to src/vs/editor/common/services/editorSimpleWorkerMain.ts diff --git a/src/vs/editor/standalone/browser/standaloneServices.ts b/src/vs/editor/standalone/browser/standaloneServices.ts index 085ca6352f21e..0e6637019c194 100644 --- a/src/vs/editor/standalone/browser/standaloneServices.ts +++ b/src/vs/editor/standalone/browser/standaloneServices.ts @@ -1077,7 +1077,7 @@ class StandaloneContextMenuService extends ContextMenuService { } export const standaloneEditorWorkerDescriptor: IWorkerDescriptor = { - amdModuleId: 'vs/editor/common/services/editorSimpleWorker', + moduleId: 'vs/editor/common/services/editorSimpleWorker', esmModuleLocation: undefined, label: 'editorWorkerService' }; diff --git a/src/vs/editor/standalone/browser/standaloneWebWorker.ts b/src/vs/editor/standalone/browser/standaloneWebWorker.ts index 22d073a4850aa..5f1d0947c9409 100644 --- a/src/vs/editor/standalone/browser/standaloneWebWorker.ts +++ b/src/vs/editor/standalone/browser/standaloneWebWorker.ts @@ -71,7 +71,7 @@ class MonacoWebWorkerImpl extends EditorWorkerClient implement constructor(modelService: IModelService, opts: IWebWorkerOptions) { const workerDescriptor: IWorkerDescriptor = { - amdModuleId: standaloneEditorWorkerDescriptor.amdModuleId, + moduleId: standaloneEditorWorkerDescriptor.moduleId, esmModuleLocation: standaloneEditorWorkerDescriptor.esmModuleLocation, label: opts.label, }; diff --git a/src/vs/platform/profiling/electron-sandbox/profileAnalysisWorker.esm.ts b/src/vs/platform/profiling/electron-sandbox/profileAnalysisWorkerMain.ts similarity index 100% rename from src/vs/platform/profiling/electron-sandbox/profileAnalysisWorker.esm.ts rename to src/vs/platform/profiling/electron-sandbox/profileAnalysisWorkerMain.ts diff --git a/src/vs/platform/window/electron-sandbox/window.ts b/src/vs/platform/window/electron-sandbox/window.ts index 233f3cdeb78a3..c9914e2117e55 100644 --- a/src/vs/platform/window/electron-sandbox/window.ts +++ b/src/vs/platform/window/electron-sandbox/window.ts @@ -73,16 +73,19 @@ export interface ILoadOptions void; beforeImport?: (config: T) => void; } +export interface ILoadResult { + readonly result: M; + readonly configuration: T; +} + export interface IBootstrapWindow { - load( + load( esModule: string, - resultCallback: (result: any, configuration: T) => Promise | undefined, options: ILoadOptions - ): Promise; + ): Promise>; } //#endregion diff --git a/src/vs/workbench/api/worker/extensionHostWorker.esm.ts b/src/vs/workbench/api/worker/extensionHostWorkerMain.ts similarity index 100% rename from src/vs/workbench/api/worker/extensionHostWorker.esm.ts rename to src/vs/workbench/api/worker/extensionHostWorkerMain.ts diff --git a/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.ts b/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.ts index 3aeee60b74a27..629a6185ccb73 100644 --- a/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.ts +++ b/src/vs/workbench/contrib/issue/electron-sandbox/issueReporter.ts @@ -5,14 +5,15 @@ /* eslint-disable no-restricted-globals */ -(function () { +(async function () { type IBootstrapWindow = import('vs/platform/window/electron-sandbox/window.js').IBootstrapWindow; + type IIssueReporterMain = import('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain').IIssueReporterMain; + type OldIssueReporterWindowConfiguration = import('vs/platform/issue/common/issue.js').OldIssueReporterWindowConfiguration; + const bootstrapWindow: IBootstrapWindow = (window as any).MonacoBootstrapWindow; // defined by bootstrap-window.ts - bootstrapWindow.load('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain', function (issueReporter, configuration) { - return issueReporter.startup(configuration); - }, { + const { result, configuration } = await bootstrapWindow.load('vs/workbench/contrib/issue/electron-sandbox/issueReporterMain', { configureDeveloperSettings: function () { return { forceEnableDeveloperKeybindings: true, @@ -20,4 +21,6 @@ }; } }); + + result.startup(configuration); }()); diff --git a/src/vs/workbench/contrib/issue/electron-sandbox/issueReporterMain.ts b/src/vs/workbench/contrib/issue/electron-sandbox/issueReporterMain.ts index f8c92af7fa9b7..fa1628e3be887 100644 --- a/src/vs/workbench/contrib/issue/electron-sandbox/issueReporterMain.ts +++ b/src/vs/workbench/contrib/issue/electron-sandbox/issueReporterMain.ts @@ -21,8 +21,11 @@ import BaseHtml from '../browser/issueReporterPage.js'; import { IProcessMainService, IIssueMainService, OldIssueReporterWindowConfiguration } from '../../../../platform/issue/common/issue.js'; import { IssueReporter } from './issueReporterService.js'; +export interface IIssueReporterMain { + startup(configuration: OldIssueReporterWindowConfiguration): void; +} -export function startup(configuration: OldIssueReporterWindowConfiguration) { +export function startup(configuration: OldIssueReporterWindowConfiguration): void { const platformClass = isWindows ? 'windows' : isLinux ? 'linux' : 'mac'; mainWindow.document.body.classList.add(platformClass); // used by our fonts diff --git a/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.esm.ts b/src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorkerMain.ts similarity index 100% rename from src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.esm.ts rename to src/vs/workbench/contrib/notebook/common/services/notebookSimpleWorkerMain.ts diff --git a/src/vs/workbench/contrib/output/common/outputLinkComputer.esm.ts b/src/vs/workbench/contrib/output/common/outputLinkComputerMain.ts similarity index 100% rename from src/vs/workbench/contrib/output/common/outputLinkComputer.esm.ts rename to src/vs/workbench/contrib/output/common/outputLinkComputerMain.ts diff --git a/src/vs/workbench/electron-sandbox/desktop.main.ts b/src/vs/workbench/electron-sandbox/desktop.main.ts index 24d89f630d0b2..40cfd9c7ec3a7 100644 --- a/src/vs/workbench/electron-sandbox/desktop.main.ts +++ b/src/vs/workbench/electron-sandbox/desktop.main.ts @@ -397,6 +397,10 @@ export class DesktopMain extends Disposable { } } +export interface IDesktopMain { + main(configuration: INativeWindowConfiguration): Promise; +} + export function main(configuration: INativeWindowConfiguration): Promise { const workbench = new DesktopMain(configuration); diff --git a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts index 7776811b727fa..54fc51bb873cd 100644 --- a/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts +++ b/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts @@ -186,7 +186,7 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost iframe.contentWindow!.postMessage({ type: event.data.type, data: { - workerUrl: FileAccess.asBrowserUri('vs/workbench/api/worker/extensionHostWorker.esm.js').toString(true), + workerUrl: FileAccess.asBrowserUri('vs/workbench/api/worker/extensionHostWorkerMain.js').toString(true), fileRoot: globalThis._VSCODE_FILE_ROOT, nls: { messages: getNLSMessages(), diff --git a/src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.esm.ts b/src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorkerMain.ts similarity index 100% rename from src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.esm.ts rename to src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorkerMain.ts diff --git a/src/vs/workbench/services/search/worker/localFileSearch.esm.ts b/src/vs/workbench/services/search/worker/localFileSearchMain.ts similarity index 100% rename from src/vs/workbench/services/search/worker/localFileSearch.esm.ts rename to src/vs/workbench/services/search/worker/localFileSearchMain.ts diff --git a/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker.esm.ts b/src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.workerMain.ts similarity index 100% rename from src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker.esm.ts rename to src/vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.workerMain.ts