Update to VS Code 1.52.1
This commit is contained in:
@ -35,6 +35,17 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} channel
|
||||
* @param {any[]} args
|
||||
* @returns {Promise<any> | undefined}
|
||||
*/
|
||||
invoke(channel, ...args) {
|
||||
if (validateIPC(channel)) {
|
||||
return ipcRenderer.invoke(channel, ...args);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} channel
|
||||
* @param {(event: import('electron').IpcRendererEvent, ...args: any[]) => void} listener
|
||||
@ -97,80 +108,48 @@
|
||||
|
||||
/**
|
||||
* Support for a subset of access to node.js global `process`.
|
||||
*
|
||||
* Note: when `sandbox` is enabled, the only properties available
|
||||
* are https://github.com/electron/electron/blob/master/docs/api/process.md#sandbox
|
||||
*/
|
||||
process: {
|
||||
get platform() { return process.platform; },
|
||||
get env() { return process.env; },
|
||||
get versions() { return process.versions; },
|
||||
get type() { return 'renderer'; },
|
||||
get execPath() { return process.execPath; },
|
||||
|
||||
_whenEnvResolved: undefined,
|
||||
whenEnvResolved:
|
||||
/**
|
||||
* @returns when the shell environment has been resolved.
|
||||
*/
|
||||
function () {
|
||||
if (!this._whenEnvResolved) {
|
||||
this._whenEnvResolved = resolveEnv();
|
||||
}
|
||||
/**
|
||||
* @param {{[key: string]: string}} userEnv
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
resolveEnv(userEnv) {
|
||||
return resolveEnv(userEnv);
|
||||
},
|
||||
|
||||
return this._whenEnvResolved;
|
||||
},
|
||||
/**
|
||||
* @returns {Promise<import('electron').ProcessMemoryInfo>}
|
||||
*/
|
||||
getProcessMemoryInfo() {
|
||||
return process.getProcessMemoryInfo();
|
||||
},
|
||||
|
||||
nextTick:
|
||||
/**
|
||||
* Adds callback to the "next tick queue". This queue is fully drained
|
||||
* after the current operation on the JavaScript stack runs to completion
|
||||
* and before the event loop is allowed to continue.
|
||||
*
|
||||
* @param {Function} callback
|
||||
* @param {any[]} args
|
||||
*/
|
||||
function nextTick(callback, ...args) {
|
||||
return process.nextTick(callback, ...args);
|
||||
},
|
||||
|
||||
cwd:
|
||||
/**
|
||||
* @returns the current working directory.
|
||||
*/
|
||||
function () {
|
||||
return process.cwd();
|
||||
},
|
||||
|
||||
getuid:
|
||||
/**
|
||||
* @returns the numeric user identity of the process
|
||||
*/
|
||||
function () {
|
||||
return process.getuid();
|
||||
},
|
||||
|
||||
getProcessMemoryInfo:
|
||||
/**
|
||||
* @returns {Promise<import('electron').ProcessMemoryInfo>}
|
||||
*/
|
||||
function () {
|
||||
return process.getProcessMemoryInfo();
|
||||
},
|
||||
|
||||
on:
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {() => void} callback
|
||||
*/
|
||||
function (type, callback) {
|
||||
if (validateProcessEventType(type)) {
|
||||
process.on(type, callback);
|
||||
}
|
||||
/**
|
||||
* @param {string} type
|
||||
* @param {() => void} callback
|
||||
*/
|
||||
on(type, callback) {
|
||||
if (validateProcessEventType(type)) {
|
||||
process.on(type, callback);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Some information about the context we are running in.
|
||||
*/
|
||||
context: {
|
||||
get sandbox() { return process.argv.includes('--enable-sandbox'); }
|
||||
get sandbox() { return process.sandboxed; }
|
||||
}
|
||||
};
|
||||
|
||||
@ -197,6 +176,7 @@
|
||||
|
||||
/**
|
||||
* @param {string} channel
|
||||
* @returns {true | never}
|
||||
*/
|
||||
function validateIPC(channel) {
|
||||
if (!channel || !channel.startsWith('vscode:')) {
|
||||
@ -218,32 +198,40 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @type {Promise<void> | undefined} */
|
||||
let resolvedEnv = undefined;
|
||||
|
||||
/**
|
||||
* If VSCode is not run from a terminal, we should resolve additional
|
||||
* shell specific environment from the OS shell to ensure we are seeing
|
||||
* all development related environment variables. We do this from the
|
||||
* main process because it may involve spawning a shell.
|
||||
*
|
||||
* @param {{[key: string]: string}} userEnv
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
function resolveEnv() {
|
||||
return new Promise(function (resolve) {
|
||||
const handle = setTimeout(function () {
|
||||
console.warn('Preload: Unable to resolve shell environment in a reasonable time');
|
||||
function resolveEnv(userEnv) {
|
||||
if (!resolvedEnv) {
|
||||
|
||||
// It took too long to fetch the shell environment, return
|
||||
resolve();
|
||||
}, 3000);
|
||||
// Apply `userEnv` directly
|
||||
Object.assign(process.env, userEnv);
|
||||
|
||||
ipcRenderer.once('vscode:acceptShellEnv', function (event, shellEnv) {
|
||||
clearTimeout(handle);
|
||||
// Resolve `shellEnv` from the main side
|
||||
resolvedEnv = new Promise(function (resolve) {
|
||||
ipcRenderer.once('vscode:acceptShellEnv', function (event, shellEnv) {
|
||||
|
||||
// Assign all keys of the shell environment to our process environment
|
||||
Object.assign(process.env, shellEnv);
|
||||
// Assign all keys of the shell environment to our process environment
|
||||
// But make sure that the user environment wins in the end
|
||||
Object.assign(process.env, shellEnv, userEnv);
|
||||
|
||||
resolve();
|
||||
resolve();
|
||||
});
|
||||
|
||||
ipcRenderer.send('vscode:fetchShellEnv');
|
||||
});
|
||||
}
|
||||
|
||||
ipcRenderer.send('vscode:fetchShellEnv');
|
||||
});
|
||||
return resolvedEnv;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
@ -12,45 +12,45 @@ export interface ISandboxNodeProcess extends INodeProcess {
|
||||
* The process.platform property returns a string identifying the operating system platform
|
||||
* on which the Node.js process is running.
|
||||
*/
|
||||
platform: 'win32' | 'linux' | 'darwin';
|
||||
readonly platform: 'win32' | 'linux' | 'darwin';
|
||||
|
||||
/**
|
||||
* The type will always be Electron renderer.
|
||||
*/
|
||||
type: 'renderer';
|
||||
readonly type: 'renderer';
|
||||
|
||||
/**
|
||||
* A list of versions for the current node.js/electron configuration.
|
||||
*/
|
||||
versions: { [key: string]: string | undefined };
|
||||
readonly versions: { [key: string]: string | undefined };
|
||||
|
||||
/**
|
||||
* The process.env property returns an object containing the user environment.
|
||||
*/
|
||||
env: IProcessEnvironment;
|
||||
readonly env: IProcessEnvironment;
|
||||
|
||||
/**
|
||||
* The current working directory.
|
||||
* The `execPath` will be the location of the executable of this application.
|
||||
*/
|
||||
cwd(): string;
|
||||
readonly execPath: string;
|
||||
|
||||
/**
|
||||
* Returns the numeric user identity of the process.
|
||||
* Resolve the true process environment to use and apply it to `process.env`.
|
||||
*
|
||||
* There are different layers of environment that will apply:
|
||||
* - `process.env`: this is the actual environment of the process before this method
|
||||
* - `shellEnv` : if the program was not started from a terminal, we resolve all shell
|
||||
* variables to get the same experience as if the program was started from
|
||||
* a terminal (Linux, macOS)
|
||||
* - `userEnv` : this is instance specific environment, e.g. if the user started the program
|
||||
* from a terminal and changed certain variables
|
||||
*
|
||||
* The order of overwrites is `process.env` < `shellEnv` < `userEnv`.
|
||||
*
|
||||
* It is critical that every process awaits this method early on startup to get the right
|
||||
* set of environment in `process.env`.
|
||||
*/
|
||||
getuid(): number;
|
||||
|
||||
/**
|
||||
* Allows to await resolving the full process environment by checking for the shell environment
|
||||
* of the OS in certain cases (e.g. when the app is started from the Dock on macOS).
|
||||
*/
|
||||
whenEnvResolved(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Adds callback to the "next tick queue". This queue is fully drained
|
||||
* after the current operation on the JavaScript stack runs to completion
|
||||
* and before the event loop is allowed to continue.
|
||||
*/
|
||||
nextTick(callback: (...args: any[]) => void, ...args: any[]): void;
|
||||
resolveEnv(userEnv: IProcessEnvironment): Promise<void>;
|
||||
|
||||
/**
|
||||
* A listener on the process. Only a small subset of listener types are allowed.
|
||||
|
Reference in New Issue
Block a user