Merge from vscode merge-base (#22780)

* Revert "Revert "Merge from vscode merge-base (#22769)" (#22779)"

This reverts commit 47a1745180.

* Fix notebook download task

* Remove done call from extensions-ci
This commit is contained in:
Karl Burtram
2023-04-19 21:48:46 -07:00
committed by GitHub
parent decbe8dded
commit e7d3d047ec
2389 changed files with 92155 additions and 42602 deletions

72
src/bootstrap-fork.js vendored
View File

@@ -88,15 +88,6 @@ function pipeLoggingToParent() {
}
}
// Add the stack trace as payload if we are told so. We remove the message and the 2 top frames
// to start the stacktrace where the console message was being written
if (process.env['VSCODE_LOG_STACK'] === 'true') {
const stack = new Error().stack;
if (stack) {
argsArray.push({ __$stack: stack.split('\n').slice(3).join('\n') });
}
}
try {
const res = JSON.stringify(argsArray, function (key, value) {
@@ -155,13 +146,8 @@ function pipeLoggingToParent() {
safeSend({ type: '__$console', severity, arguments: args });
}
let isMakingConsoleCall = false;
/**
* Wraps a console message so that it is transmitted to the renderer. If
* native logging is turned on, the original console message will be written
* as well. This is needed since the console methods are "magic" in V8 and
* are the only methods that allow later introspection of logged variables.
* Wraps a console message so that it is transmitted to the renderer.
*
* The wrapped property is not defined with `writable: false` to avoid
* throwing errors, but rather a no-op setting. See https://github.com/microsoft/vscode-extension-telemetry/issues/88
@@ -170,26 +156,10 @@ function pipeLoggingToParent() {
* @param {'log' | 'warn' | 'error'} severity
*/
function wrapConsoleMethod(method, severity) {
if (process.env['VSCODE_LOG_NATIVE'] === 'true') {
const original = console[method];
const stream = method === 'error' || method === 'warn' ? process.stderr : process.stdout;
Object.defineProperty(console, method, {
set: () => { },
get: () => function () {
safeSendConsoleMessage(severity, safeToArray(arguments));
isMakingConsoleCall = true;
stream.write('\nSTART_NATIVE_LOG\n');
original.apply(console, arguments);
stream.write('\nEND_NATIVE_LOG\n');
isMakingConsoleCall = false;
},
});
} else {
Object.defineProperty(console, method, {
set: () => { },
get: () => function () { safeSendConsoleMessage(severity, safeToArray(arguments)); },
});
}
Object.defineProperty(console, method, {
set: () => { },
get: () => function () { safeSendConsoleMessage(severity, safeToArray(arguments)); },
});
}
/**
@@ -211,13 +181,11 @@ function pipeLoggingToParent() {
Object.defineProperty(stream, 'write', {
set: () => { },
get: () => (chunk, encoding, callback) => {
if (!isMakingConsoleCall) {
buf += chunk.toString(encoding);
const eol = buf.length > MAX_STREAM_BUFFER_LENGTH ? buf.length : buf.lastIndexOf('\n');
if (eol !== -1) {
console[severity](buf.slice(0, eol));
buf = buf.slice(eol + 1);
}
buf += chunk.toString(encoding);
const eol = buf.length > MAX_STREAM_BUFFER_LENGTH ? buf.length : buf.lastIndexOf('\n');
if (eol !== -1) {
console[severity](buf.slice(0, eol));
buf = buf.slice(eol + 1);
}
original.call(stream, chunk, encoding, callback);
@@ -231,7 +199,7 @@ function pipeLoggingToParent() {
wrapConsoleMethod('log', 'log');
wrapConsoleMethod('warn', 'warn');
wrapConsoleMethod('error', 'error');
} else if (process.env['VSCODE_LOG_NATIVE'] !== 'true') {
} else {
console.log = function () { /* ignore */ };
console.warn = function () { /* ignore */ };
console.info = function () { /* ignore */ };
@@ -273,17 +241,13 @@ function listenForMessagePort() {
// We need to listen for the 'port' event as soon as possible,
// otherwise we might miss the event. But we should also be
// prepared in case the event arrives late.
// @ts-ignore
if (process.parentPort) {
// @ts-ignore
process.parentPort.on('message', (e) => {
if (global.vscodePortsCallback) {
global.vscodePortsCallback(e.ports);
} else {
global.vscodePorts = e.ports;
}
});
}
process.on('port', (e) => {
if (global.vscodePortsCallback) {
global.vscodePortsCallback(e.ports);
} else {
global.vscodePorts = e.ports;
}
});
}
//#endregion