Archived
1
0

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:
Joe Previte
2021-02-25 11:27:27 -07:00
1900 changed files with 83066 additions and 64589 deletions

View File

@ -21,6 +21,7 @@ const vfs = require('vinyl-fs');
const uuid = require('uuid');
const extensions = require('../../build/lib/extensions');
const { getBuiltInExtensions } = require('../../build/lib/builtInExtensions');
const APP_ROOT = path.join(__dirname, '..', '..');
const BUILTIN_EXTENSIONS_ROOT = path.join(APP_ROOT, 'extensions');
@ -28,6 +29,14 @@ const BUILTIN_MARKETPLACE_EXTENSIONS_ROOT = path.join(APP_ROOT, '.build', 'built
const WEB_DEV_EXTENSIONS_ROOT = path.join(APP_ROOT, '.build', 'builtInWebDevExtensions');
const WEB_MAIN = path.join(APP_ROOT, 'src', 'vs', 'code', 'browser', 'workbench', 'workbench-dev.html');
// This is useful to simulate real world CORS
const ALLOWED_CORS_ORIGINS = [
'http://localhost:8081',
'http://127.0.0.1:8081',
'http://localhost:8080',
'http://127.0.0.1:8080',
];
const WEB_PLAYGROUND_VERSION = '0.0.10';
const args = minimist(process.argv, {
@ -37,7 +46,6 @@ const args = minimist(process.argv, {
'verbose',
'wrap-iframe',
'enable-sync',
'trusted-types'
],
string: [
'scheme',
@ -54,7 +62,6 @@ if (args.help) {
'yarn web [options]\n' +
' --no-launch Do not open VSCode web in the browser\n' +
' --wrap-iframe Wrap the Web Worker Extension Host in an iframe\n' +
' --trusted-types Enable trusted types (report only)\n' +
' --enable-sync Enable sync by default\n' +
' --scheme Protocol (https or http)\n' +
' --host Remote host\n' +
@ -82,6 +89,8 @@ const exists = (path) => util.promisify(fs.exists)(path);
const readFile = (path) => util.promisify(fs.readFile)(path);
async function getBuiltInExtensionInfos() {
await getBuiltInExtensions();
const allExtensions = [];
/** @type {Object.<string, string>} */
const locations = {};
@ -281,6 +290,17 @@ secondaryServer.on('error', err => {
console.error(err);
});
/**
* @param {import('http').IncomingMessage} req
*/
function addCORSReplyHeader(req) {
if (typeof req.headers['origin'] !== 'string') {
// not a CORS request
return false;
}
return (ALLOWED_CORS_ORIGINS.indexOf(req.headers['origin']) >= 0);
}
/**
* @param {import('http').IncomingMessage} req
* @param {import('http').ServerResponse} res
@ -291,9 +311,10 @@ async function handleStatic(req, res, parsedUrl) {
if (/^\/static\/extensions\//.test(parsedUrl.pathname)) {
const relativePath = decodeURIComponent(parsedUrl.pathname.substr('/static/extensions/'.length));
const filePath = getExtensionFilePath(relativePath, (await builtInExtensionsPromise).locations);
const responseHeaders = {
'Access-Control-Allow-Origin': '*'
};
const responseHeaders = {};
if (addCORSReplyHeader(req)) {
responseHeaders['Access-Control-Allow-Origin'] = '*';
}
if (!filePath) {
return serveError(req, res, 400, `Bad request.`, responseHeaders);
}
@ -315,9 +336,10 @@ async function handleExtension(req, res, parsedUrl) {
// Strip `/extension/` from the path
const relativePath = decodeURIComponent(parsedUrl.pathname.substr('/extension/'.length));
const filePath = getExtensionFilePath(relativePath, (await commandlineProvidedExtensionsPromise).locations);
const responseHeaders = {
'Access-Control-Allow-Origin': '*'
};
const responseHeaders = {};
if (addCORSReplyHeader(req)) {
responseHeaders['Access-Control-Allow-Origin'] = '*';
}
if (!filePath) {
return serveError(req, res, 400, `Bad request.`, responseHeaders);
}
@ -377,11 +399,18 @@ async function handleRoot(req, res) {
fancyLog(`${ansiColors.magenta('Additional extensions')}: ${staticExtensions.map(e => path.basename(e.extensionLocation.path)).join(', ') || 'None'}`);
}
const secondaryHost = (
req.headers['host']
? req.headers['host'].replace(':' + PORT, ':' + SECONDARY_PORT)
: `${HOST}:${SECONDARY_PORT}`
);
const webConfigJSON = {
folderUri: folderUri,
staticExtensions,
enableSyncByDefault: args['enable-sync'],
webWorkerExtensionHostIframeSrc: `${SCHEME}://${HOST}:${SECONDARY_PORT}/static/out/vs/workbench/services/extensions/worker/httpWebWorkerExtensionHostIframe.html`
settingsSyncOptions: {
enabled: args['enable-sync']
},
webWorkerExtensionHostIframeSrc: `${SCHEME}://${secondaryHost}/static/out/vs/workbench/services/extensions/worker/httpWebWorkerExtensionHostIframe.html`
};
if (args['wrap-iframe']) {
webConfigJSON._wrapWebWorkerExtHostInIframe = true;
@ -404,12 +433,10 @@ async function handleRoot(req, res) {
.replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '')
.replace('{{WEBVIEW_ENDPOINT}}', '');
const headers = { 'Content-Type': 'text/html' };
if (args['trusted-types']) {
headers['Content-Security-Policy-Report-Only'] = 'require-trusted-types-for \'script\';';
}
const headers = {
'Content-Type': 'text/html',
'Content-Security-Policy': 'require-trusted-types-for \'script\';'
};
res.writeHead(200, headers);
return res.end(data);
}