sandbox - prefer sandbox types over node.js types

This commit is contained in:
Benjamin Pasero
2021-04-06 09:51:14 +02:00
parent 584d0acaf1
commit 30f0d188c7
4 changed files with 26 additions and 26 deletions

18
src/bootstrap.js vendored
View File

@@ -173,7 +173,7 @@
/**
* @returns {typeof import('./vs/base/parts/sandbox/electron-sandbox/globals') | undefined}
*/
function safeGlobals() {
function safeSandboxGlobals() {
const globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {});
return globals.vscode;
@@ -183,13 +183,13 @@
* @returns {import('./vs/base/parts/sandbox/electron-sandbox/globals').ISandboxNodeProcess | NodeJS.Process}
*/
function safeProcess() {
if (typeof process !== 'undefined') {
return process; // Native environment (non-sandboxed)
const sandboxGlobals = safeSandboxGlobals();
if (sandboxGlobals) {
return sandboxGlobals.process; // Native environment (sandboxed)
}
const globals = safeGlobals();
if (globals) {
return globals.process; // Native environment (sandboxed)
if (typeof process !== 'undefined') {
return process; // Native environment (non-sandboxed)
}
return undefined;
@@ -199,9 +199,9 @@
* @returns {import('./vs/base/parts/sandbox/electron-sandbox/electronTypes').IpcRenderer | undefined}
*/
function safeIpcRenderer() {
const globals = safeGlobals();
if (globals) {
return globals.ipcRenderer;
const sandboxGlobals = safeSandboxGlobals();
if (sandboxGlobals) {
return sandboxGlobals.ipcRenderer;
}
return undefined;