mirror of
https://github.com/coder/code-server.git
synced 2025-08-01 10:56:25 +08:00
chore(vscode): update to 1.56.0
This commit is contained in:
@ -6,17 +6,22 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @typedef {import('./vs/base/common/product').IProductConfiguration} IProductConfiguration
|
||||
* @typedef {import('./vs/base/node/languagePacks').NLSConfiguration} NLSConfiguration
|
||||
* @typedef {import('./vs/platform/environment/common/argv').NativeParsedArgs} NativeParsedArgs
|
||||
*/
|
||||
|
||||
const perf = require('./vs/base/common/performance');
|
||||
perf.mark('code/didStartMain');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const { getNLSConfiguration } = require('./vs/base/node/languagePacks');
|
||||
const bootstrap = require('./bootstrap');
|
||||
const bootstrapNode = require('./bootstrap-node');
|
||||
const { getUserDataPath } = require('./vs/platform/environment/node/userDataPath');
|
||||
/** @type {Partial<import('./vs/platform/product/common/productService').IProductConfiguration>} */
|
||||
/** @type {Partial<IProductConfiguration>} */
|
||||
const product = require('../product.json');
|
||||
const { app, protocol, crashReporter } = require('electron');
|
||||
|
||||
@ -39,7 +44,9 @@ app.setPath('userData', userDataPath);
|
||||
const argvConfig = configureCommandlineSwitchesSync(args);
|
||||
|
||||
// Configure crash reporter
|
||||
perf.mark('code/willStartCrashReporter');
|
||||
configureCrashReporter();
|
||||
perf.mark('code/didStartCrashReporter');
|
||||
|
||||
// Set logs path before app 'ready' event if running portable
|
||||
// to ensure that no 'logs' folder is created on disk at a
|
||||
@ -53,10 +60,7 @@ if (portable && portable.isPortable) {
|
||||
protocol.registerSchemesAsPrivileged([
|
||||
{
|
||||
scheme: 'vscode-webview',
|
||||
privileges: { standard: true, secure: true, supportFetchAPI: true, corsEnabled: true }
|
||||
}, {
|
||||
scheme: 'vscode-webview-resource',
|
||||
privileges: { secure: true, standard: true, supportFetchAPI: true, corsEnabled: true }
|
||||
privileges: { standard: true, secure: true, supportFetchAPI: true, corsEnabled: true, allowServiceWorkers: true, }
|
||||
},
|
||||
{
|
||||
scheme: 'vscode-file',
|
||||
@ -74,13 +78,14 @@ const nodeCachedDataDir = getNodeCachedDir();
|
||||
* Support user defined locale: load it early before app('ready')
|
||||
* to have more things running in parallel.
|
||||
*
|
||||
* @type {Promise<import('./vs/base/node/languagePacks').NLSConfiguration> | undefined}
|
||||
* @type {Promise<NLSConfiguration> | undefined}
|
||||
*/
|
||||
let nlsConfigurationPromise = undefined;
|
||||
|
||||
const metaDataFile = path.join(__dirname, 'nls.metadata.json');
|
||||
const locale = getUserDefinedLocale(argvConfig);
|
||||
if (locale) {
|
||||
const { getNLSConfiguration } = require('./vs/base/node/languagePacks');
|
||||
nlsConfigurationPromise = getNLSConfiguration(product.commit, userDataPath, metaDataFile, locale);
|
||||
}
|
||||
|
||||
@ -104,7 +109,7 @@ app.once('ready', function () {
|
||||
* Main startup routine
|
||||
*
|
||||
* @param {string | undefined} cachedDataDir
|
||||
* @param {import('./vs/base/node/languagePacks').NLSConfiguration} nlsConfig
|
||||
* @param {NLSConfiguration} nlsConfig
|
||||
*/
|
||||
function startup(cachedDataDir, nlsConfig) {
|
||||
nlsConfig._languagePackSupport = true;
|
||||
@ -132,7 +137,7 @@ async function onReady() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./vs/platform/environment/common/argv').NativeParsedArgs} cliArgs
|
||||
* @param {NativeParsedArgs} cliArgs
|
||||
*/
|
||||
function configureCommandlineSwitchesSync(cliArgs) {
|
||||
const SUPPORTED_ELECTRON_SWITCHES = [
|
||||
@ -159,16 +164,18 @@ function configureCommandlineSwitchesSync(cliArgs) {
|
||||
'enable-proposed-api',
|
||||
|
||||
// TODO@sandbox remove me once testing is done on `vscode-file` protocol
|
||||
// (all traces of `enable-browser-code-loading` and `ENABLE_VSCODE_BROWSER_CODE_LOADING`)
|
||||
// (all traces of `enable-browser-code-loading` and `VSCODE_BROWSER_CODE_LOADING`)
|
||||
'enable-browser-code-loading',
|
||||
|
||||
// Log level to use. Default is 'info'. Allowed values are 'critical', 'error', 'warn', 'info', 'debug', 'trace', 'off'.
|
||||
'log-level',
|
||||
'log-level'
|
||||
];
|
||||
|
||||
// Read argv config
|
||||
const argvConfig = readArgvConfigSync();
|
||||
|
||||
let browserCodeLoadingStrategy = undefined;
|
||||
|
||||
Object.keys(argvConfig).forEach(argvKey => {
|
||||
const argvValue = argvConfig[argvKey];
|
||||
|
||||
@ -204,8 +211,10 @@ function configureCommandlineSwitchesSync(cliArgs) {
|
||||
break;
|
||||
|
||||
case 'enable-browser-code-loading':
|
||||
if (typeof argvValue === 'string') {
|
||||
process.env['ENABLE_VSCODE_BROWSER_CODE_LOADING'] = argvValue;
|
||||
if (argvValue === false) {
|
||||
browserCodeLoadingStrategy = undefined;
|
||||
} else if (typeof argvValue === 'string') {
|
||||
browserCodeLoadingStrategy = argvValue;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -224,9 +233,9 @@ function configureCommandlineSwitchesSync(cliArgs) {
|
||||
app.commandLine.appendSwitch('js-flags', jsFlags);
|
||||
}
|
||||
|
||||
// Support __sandbox flag
|
||||
if (cliArgs.__sandbox) {
|
||||
process.env['ENABLE_VSCODE_BROWSER_CODE_LOADING'] = 'bypassHeatCheck';
|
||||
// Configure vscode-file:// code loading environment
|
||||
if (cliArgs.__sandbox || browserCodeLoadingStrategy) {
|
||||
process.env['VSCODE_BROWSER_CODE_LOADING'] = browserCodeLoadingStrategy || 'bypassHeatCheck';
|
||||
}
|
||||
|
||||
return argvConfig;
|
||||
@ -411,7 +420,7 @@ function configureCrashReporter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('./vs/platform/environment/common/argv').NativeParsedArgs} cliArgs
|
||||
* @param {NativeParsedArgs} cliArgs
|
||||
* @returns {string | null}
|
||||
*/
|
||||
function getJSFlags(cliArgs) {
|
||||
@ -431,7 +440,7 @@ function getJSFlags(cliArgs) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {import('./vs/platform/environment/common/argv').NativeParsedArgs}
|
||||
* @returns {NativeParsedArgs}
|
||||
*/
|
||||
function parseCLIArgs() {
|
||||
const minimist = require('minimist');
|
||||
@ -549,7 +558,7 @@ function mkdirp(dir) {
|
||||
/**
|
||||
* Resolve the NLS configuration
|
||||
*
|
||||
* @return {Promise<import('./vs/base/node/languagePacks').NLSConfiguration>}
|
||||
* @return {Promise<NLSConfiguration>}
|
||||
*/
|
||||
async function resolveNlsConfiguration() {
|
||||
|
||||
@ -569,6 +578,7 @@ async function resolveNlsConfiguration() {
|
||||
// See above the comment about the loader and case sensitiviness
|
||||
appLocale = appLocale.toLowerCase();
|
||||
|
||||
const { getNLSConfiguration } = require('./vs/base/node/languagePacks');
|
||||
nlsConfiguration = await getNLSConfiguration(product.commit, userDataPath, metaDataFile, appLocale);
|
||||
if (!nlsConfiguration) {
|
||||
nlsConfiguration = { locale: appLocale, availableLanguages: {} };
|
||||
|
Reference in New Issue
Block a user