mirror of
https://github.com/coder/code-server.git
synced 2025-07-29 04:52:53 +08:00
chore(vscode): update to 1.53.2
These conflicts will be resolved in the following commits. We do it this way so that PR review is possible.
This commit is contained in:
74
lib/vscode/src/bootstrap-window.js
vendored
74
lib/vscode/src/bootstrap-window.js
vendored
@ -27,6 +27,7 @@
|
||||
const webFrame = preloadGlobals.webFrame;
|
||||
const safeProcess = preloadGlobals.process;
|
||||
const configuration = parseWindowConfiguration();
|
||||
const useCustomProtocol = sandbox || 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
|
||||
@ -34,7 +35,7 @@
|
||||
|
||||
/**
|
||||
* @param {string[]} modulePaths
|
||||
* @param {(result, configuration: object) => any} resultCallback
|
||||
* @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) {
|
||||
@ -77,27 +78,39 @@
|
||||
window.document.documentElement.setAttribute('lang', locale);
|
||||
|
||||
// do not advertise AMD to avoid confusing UMD modules loaded with nodejs
|
||||
if (!sandbox) {
|
||||
if (!useCustomProtocol) {
|
||||
window['define'] = undefined;
|
||||
}
|
||||
|
||||
// replace the patched electron fs with the original node fs for all AMD code (TODO@sandbox non-sandboxed only)
|
||||
if (!sandbox) {
|
||||
require.define('fs', ['original-fs'], function (originalFS) { return originalFS; });
|
||||
require.define('fs', [], function () { return require.__$__nodeRequire('original-fs'); });
|
||||
}
|
||||
|
||||
window['MonacoEnvironment'] = {};
|
||||
|
||||
const baseUrl = sandbox ?
|
||||
const baseUrl = useCustomProtocol ?
|
||||
`${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out` :
|
||||
`${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32' })}/out`;
|
||||
|
||||
const loaderConfig = {
|
||||
baseUrl,
|
||||
'vs/nls': nlsConfig,
|
||||
preferScriptTags: sandbox
|
||||
preferScriptTags: useCustomProtocol
|
||||
};
|
||||
|
||||
// use a trusted types policy when loading via script tags
|
||||
if (loaderConfig.preferScriptTags) {
|
||||
loaderConfig.trustedTypesPolicy = window.trustedTypes?.createPolicy('amdLoader', {
|
||||
createScriptURL(value) {
|
||||
if (value.startsWith(window.location.origin)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`Invalid script url: ${value}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Enable loading of node modules:
|
||||
// - sandbox: we list paths of webpacked modules to help the loader
|
||||
// - non-sandbox: we signal that any module that does not begin with
|
||||
@ -145,10 +158,9 @@
|
||||
try {
|
||||
|
||||
// Wait for process environment being fully resolved
|
||||
const perf = perfLib();
|
||||
perf.mark('willWaitForShellEnv');
|
||||
performance.mark('code/willWaitForShellEnv');
|
||||
await whenEnvResolved;
|
||||
perf.mark('didWaitForShellEnv');
|
||||
performance.mark('code/didWaitForShellEnv');
|
||||
|
||||
// Callback only after process environment is resolved
|
||||
const callbackResult = resultCallback(result, configuration);
|
||||
@ -166,7 +178,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the contents of the `INativeWindowConfiguration` that
|
||||
* Parses the contents of the window condiguration that
|
||||
* is passed into the URL from the `electron-main` side.
|
||||
*
|
||||
* @returns {{
|
||||
@ -195,22 +207,26 @@
|
||||
function registerDeveloperKeybindings(disallowReloadKeybinding) {
|
||||
const ipcRenderer = preloadGlobals.ipcRenderer;
|
||||
|
||||
const extractKey = function (e) {
|
||||
return [
|
||||
e.ctrlKey ? 'ctrl-' : '',
|
||||
e.metaKey ? 'meta-' : '',
|
||||
e.altKey ? 'alt-' : '',
|
||||
e.shiftKey ? 'shift-' : '',
|
||||
e.keyCode
|
||||
].join('');
|
||||
};
|
||||
const extractKey =
|
||||
/**
|
||||
* @param {KeyboardEvent} e
|
||||
*/
|
||||
function (e) {
|
||||
return [
|
||||
e.ctrlKey ? 'ctrl-' : '',
|
||||
e.metaKey ? 'meta-' : '',
|
||||
e.altKey ? 'alt-' : '',
|
||||
e.shiftKey ? 'shift-' : '',
|
||||
e.keyCode
|
||||
].join('');
|
||||
};
|
||||
|
||||
// Devtools & reload support
|
||||
const TOGGLE_DEV_TOOLS_KB = (safeProcess.platform === 'darwin' ? 'meta-alt-73' : 'ctrl-shift-73'); // mac: Cmd-Alt-I, rest: Ctrl-Shift-I
|
||||
const TOGGLE_DEV_TOOLS_KB_ALT = '123'; // F12
|
||||
const RELOAD_KB = (safeProcess.platform === 'darwin' ? 'meta-82' : 'ctrl-82'); // mac: Cmd-R, rest: Ctrl-R
|
||||
|
||||
/** @type {((e: any) => void) | undefined} */
|
||||
/** @type {((e: KeyboardEvent) => void) | undefined} */
|
||||
let listener = function (e) {
|
||||
const key = extractKey(e);
|
||||
if (key === TOGGLE_DEV_TOOLS_KB || key === TOGGLE_DEV_TOOLS_KB_ALT) {
|
||||
@ -263,26 +279,8 @@
|
||||
return window.vscode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {{ mark: (name: string) => void }}
|
||||
*/
|
||||
function perfLib() {
|
||||
globalThis.MonacoPerformanceMarks = globalThis.MonacoPerformanceMarks || [];
|
||||
|
||||
return {
|
||||
/**
|
||||
* @param {string} name
|
||||
*/
|
||||
mark(name) {
|
||||
globalThis.MonacoPerformanceMarks.push(name, Date.now());
|
||||
performance.mark(name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
load,
|
||||
globals,
|
||||
perfLib
|
||||
globals
|
||||
};
|
||||
}));
|
||||
|
Reference in New Issue
Block a user