Merge from vscode 0a7364f00514c46c9caceece15e1f82f82e3712f

This commit is contained in:
ADS Merger
2020-07-22 03:06:57 +00:00
parent 53ec7585a9
commit 1b7b54ce14
229 changed files with 5099 additions and 3188 deletions

View File

@@ -21,8 +21,9 @@
globalThis.MonacoBootstrapWindow = factory();
}
}(this, function () {
const path = require.__$__nodeRequire('path');
const bootstrap = globalThis.MonacoBootstrap;
const preloadGlobals = globals();
const sandbox = preloadGlobals.context.sandbox;
const safeProcess = sandbox ? preloadGlobals.process : process;
/**
* @param {string[]} modulePaths
@@ -43,29 +44,33 @@
const configuration = JSON.parse(args['config'] || '{}') || {};
// Error handler
process.on('uncaughtException', function (error) {
safeProcess.on('uncaughtException', function (error) {
onUnexpectedError(error, enableDeveloperTools);
});
// Developer tools
const enableDeveloperTools = (process.env['VSCODE_DEV'] || !!configuration.extensionDevelopmentPath) && !configuration.extensionTestsPath;
const enableDeveloperTools = (safeProcess.env['VSCODE_DEV'] || !!configuration.extensionDevelopmentPath) && !configuration.extensionTestsPath;
let developerToolsUnbind;
if (enableDeveloperTools || (options && options.forceEnableDeveloperKeybindings)) {
developerToolsUnbind = registerDeveloperKeybindings(options && options.disallowReloadKeybinding);
}
// Correctly inherit the parent's environment
Object.assign(process.env, configuration.userEnv);
// Correctly inherit the parent's environment (TODO@sandbox non-sandboxed only)
if (!sandbox) {
Object.assign(safeProcess.env, configuration.userEnv);
}
// Enable ASAR support
bootstrap.enableASARSupport(path.join(configuration.appRoot, 'node_modules'));
// Enable ASAR support (TODO@sandbox non-sandboxed only)
if (!sandbox) {
globalThis.MonacoBootstrap.enableASARSupport(configuration.appRoot);
}
if (options && typeof options.canModifyDOM === 'function') {
options.canModifyDOM(configuration);
}
// Get the nls configuration into the process.env as early as possible.
const nlsConfig = bootstrap.setupNLS();
// Get the nls configuration into the process.env as early as possible (TODO@sandbox non-sandboxed only)
const nlsConfig = sandbox ? { availableLanguages: {} } : globalThis.MonacoBootstrap.setupNLS();
let locale = nlsConfig.availableLanguages['*'] || 'en';
if (locale === 'zh-tw') {
@@ -76,16 +81,20 @@
window.document.documentElement.setAttribute('lang', locale);
// do not advertise AMD to avoid confusing UMD modules loaded with nodejs
window['define'] = undefined;
// do not advertise AMD to avoid confusing UMD modules loaded with nodejs (TODO@sandbox non-sandboxed only)
if (!sandbox) {
window['define'] = undefined;
}
// replace the patched electron fs with the original node fs for all AMD code
require.define('fs', ['original-fs'], function (originalFS) { return originalFS; });
// 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; });
}
window['MonacoEnvironment'] = {};
const loaderConfig = {
baseUrl: `${bootstrap.uriFromPath(configuration.appRoot)}/out`,
baseUrl: `${uriFromPath(configuration.appRoot)}/out`,
'vs/nls': nlsConfig,
amdModulesPattern: /^(vs|sql)\//, // {{SQL CARBON EDIT}} include sql in regex
};
@@ -150,7 +159,7 @@
* @returns {() => void}
*/
function registerDeveloperKeybindings(disallowReloadKeybinding) {
const ipcRenderer = globals().ipcRenderer;
const ipcRenderer = preloadGlobals.ipcRenderer;
const extractKey = function (e) {
return [
@@ -163,9 +172,9 @@
};
// Devtools & reload support
const TOGGLE_DEV_TOOLS_KB = (process.platform === 'darwin' ? 'meta-alt-73' : 'ctrl-shift-73'); // mac: Cmd-Alt-I, rest: Ctrl-Shift-I
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 = (process.platform === 'darwin' ? 'meta-82' : 'ctrl-82'); // mac: Cmd-R, rest: Ctrl-R
const RELOAD_KB = (safeProcess.platform === 'darwin' ? 'meta-82' : 'ctrl-82'); // mac: Cmd-R, rest: Ctrl-R
let listener = function (e) {
const key = extractKey(e);
@@ -192,7 +201,7 @@
*/
function onUnexpectedError(error, enableDeveloperTools) {
if (enableDeveloperTools) {
const ipcRenderer = globals().ipcRenderer;
const ipcRenderer = preloadGlobals.ipcRenderer;
ipcRenderer.send('vscode:openDevTools');
}
@@ -211,6 +220,31 @@
return window.vscode;
}
/**
* TODO@sandbox this should not use the file:// protocol at all
* and be consolidated with the fileUriFromPath() method in
* bootstrap.js.
*
* @param {string} path
* @returns {string}
*/
function uriFromPath(path) {
let pathName = path.replace(/\\/g, '/');
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = `/${pathName}`;
}
/** @type {string} */
let uri;
if (safeProcess.platform === 'win32' && pathName.startsWith('//')) { // specially handle Windows UNC paths
uri = encodeURI(`file:${pathName}`);
} else {
uri = encodeURI(`file://${pathName}`);
}
return uri.replace(/#/g, '%23');
}
return {
load,
globals