Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
76b73311
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
76b73311
编写于
9月 17, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sandbox - make platform.ts fit for sandbox usages
上级
f65e2fbd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
42 deletion
+76
-42
src/vs/base/common/platform.ts
src/vs/base/common/platform.ts
+33
-14
src/vs/base/common/process.ts
src/vs/base/common/process.ts
+11
-14
src/vs/base/parts/sandbox/electron-browser/preload.js
src/vs/base/parts/sandbox/electron-browser/preload.js
+13
-4
src/vs/base/parts/sandbox/electron-sandbox/globals.ts
src/vs/base/parts/sandbox/electron-sandbox/globals.ts
+18
-9
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
+1
-1
未找到文件。
src/vs/base/common/platform.ts
浏览文件 @
76b73311
...
@@ -26,15 +26,16 @@ export interface IProcessEnvironment {
...
@@ -26,15 +26,16 @@ export interface IProcessEnvironment {
[
key
:
string
]:
string
;
[
key
:
string
]:
string
;
}
}
interface
INodeProcess
{
export
interface
INodeProcess
{
platform
:
string
;
platform
:
'
win32
'
|
'
linux
'
|
'
darwin
'
;
env
:
IProcessEnvironment
;
env
:
IProcessEnvironment
;
getuid
():
number
;
nextTick
:
Function
;
nextTick
:
Function
;
versions
?:
{
versions
?:
{
electron
?:
string
;
electron
?:
string
;
};
};
type
?:
string
;
type
?:
string
;
getuid
():
number
;
cwd
():
string
;
}
}
declare
const
process
:
INodeProcess
;
declare
const
process
:
INodeProcess
;
declare
const
global
:
any
;
declare
const
global
:
any
;
...
@@ -47,9 +48,20 @@ interface INavigator {
...
@@ -47,9 +48,20 @@ interface INavigator {
declare
const
navigator
:
INavigator
;
declare
const
navigator
:
INavigator
;
declare
const
self
:
any
;
declare
const
self
:
any
;
const
isElectronRenderer
=
(
typeof
process
!==
'
undefined
'
&&
typeof
process
.
versions
!==
'
undefined
'
&&
typeof
process
.
versions
.
electron
!==
'
undefined
'
&&
process
.
type
===
'
renderer
'
);
const
_globals
=
(
typeof
self
===
'
object
'
?
self
:
typeof
global
===
'
object
'
?
global
:
{}
as
any
);
let
nodeProcess
:
INodeProcess
|
undefined
=
undefined
;
if
(
typeof
process
!==
'
undefined
'
)
{
// Native environment (non-sandboxed)
nodeProcess
=
process
;
}
else
if
(
typeof
_globals
.
vscode
!==
'
undefined
'
)
{
// Native envionment (sandboxed)
nodeProcess
=
_globals
.
vscode
.
process
;
}
const
isElectronRenderer
=
typeof
nodeProcess
?.
versions
?.
electron
===
'
string
'
&&
nodeProcess
.
type
===
'
renderer
'
;
//
OS detection
//
Web environment
if
(
typeof
navigator
===
'
object
'
&&
!
isElectronRenderer
)
{
if
(
typeof
navigator
===
'
object
'
&&
!
isElectronRenderer
)
{
_userAgent
=
navigator
.
userAgent
;
_userAgent
=
navigator
.
userAgent
;
_isWindows
=
_userAgent
.
indexOf
(
'
Windows
'
)
>=
0
;
_isWindows
=
_userAgent
.
indexOf
(
'
Windows
'
)
>=
0
;
...
@@ -59,13 +71,16 @@ if (typeof navigator === 'object' && !isElectronRenderer) {
...
@@ -59,13 +71,16 @@ if (typeof navigator === 'object' && !isElectronRenderer) {
_isWeb
=
true
;
_isWeb
=
true
;
_locale
=
navigator
.
language
;
_locale
=
navigator
.
language
;
_language
=
_locale
;
_language
=
_locale
;
}
else
if
(
typeof
process
===
'
object
'
)
{
}
_isWindows
=
(
process
.
platform
===
'
win32
'
);
_isMacintosh
=
(
process
.
platform
===
'
darwin
'
);
// Native environment
_isLinux
=
(
process
.
platform
===
'
linux
'
);
else
if
(
typeof
nodeProcess
===
'
object
'
)
{
_isWindows
=
(
nodeProcess
.
platform
===
'
win32
'
);
_isMacintosh
=
(
nodeProcess
.
platform
===
'
darwin
'
);
_isLinux
=
(
nodeProcess
.
platform
===
'
linux
'
);
_locale
=
LANGUAGE_DEFAULT
;
_locale
=
LANGUAGE_DEFAULT
;
_language
=
LANGUAGE_DEFAULT
;
_language
=
LANGUAGE_DEFAULT
;
const
rawNlsConfig
=
p
rocess
.
env
[
'
VSCODE_NLS_CONFIG
'
];
const
rawNlsConfig
=
nodeP
rocess
.
env
[
'
VSCODE_NLS_CONFIG
'
];
if
(
rawNlsConfig
)
{
if
(
rawNlsConfig
)
{
try
{
try
{
const
nlsConfig
:
NLSConfig
=
JSON
.
parse
(
rawNlsConfig
);
const
nlsConfig
:
NLSConfig
=
JSON
.
parse
(
rawNlsConfig
);
...
@@ -80,6 +95,11 @@ if (typeof navigator === 'object' && !isElectronRenderer) {
...
@@ -80,6 +95,11 @@ if (typeof navigator === 'object' && !isElectronRenderer) {
_isNative
=
true
;
_isNative
=
true
;
}
}
// Unknown environment
else
{
console
.
error
(
'
Unable to resolve platform.
'
);
}
export
const
enum
Platform
{
export
const
enum
Platform
{
Web
,
Web
,
Mac
,
Mac
,
...
@@ -114,7 +134,7 @@ export const platform = _platform;
...
@@ -114,7 +134,7 @@ export const platform = _platform;
export
const
userAgent
=
_userAgent
;
export
const
userAgent
=
_userAgent
;
export
function
isRootUser
():
boolean
{
export
function
isRootUser
():
boolean
{
return
_isNative
&&
!
_isWindows
&&
(
p
rocess
.
getuid
()
===
0
);
return
!!
nodeProcess
&&
!
_isWindows
&&
(
nodeP
rocess
.
getuid
()
===
0
);
}
}
/**
/**
...
@@ -157,7 +177,6 @@ export const locale = _locale;
...
@@ -157,7 +177,6 @@ export const locale = _locale;
*/
*/
export
const
translationsConfigFile
=
_translationsConfigFile
;
export
const
translationsConfigFile
=
_translationsConfigFile
;
const
_globals
=
(
typeof
self
===
'
object
'
?
self
:
typeof
global
===
'
object
'
?
global
:
{}
as
any
);
export
const
globals
:
any
=
_globals
;
export
const
globals
:
any
=
_globals
;
interface
ISetImmediate
{
interface
ISetImmediate
{
...
@@ -196,8 +215,8 @@ export const setImmediate: ISetImmediate = (function defineSetImmediate() {
...
@@ -196,8 +215,8 @@ export const setImmediate: ISetImmediate = (function defineSetImmediate() {
globals
.
postMessage
({
vscodeSetImmediateId
:
myId
},
'
*
'
);
globals
.
postMessage
({
vscodeSetImmediateId
:
myId
},
'
*
'
);
};
};
}
}
if
(
typeof
process
!==
'
undefined
'
&&
typeof
process
.
nextTick
===
'
function
'
)
{
if
(
nodeProcess
)
{
return
process
.
nextTick
.
bind
(
p
rocess
);
return
nodeProcess
.
nextTick
.
bind
(
nodeP
rocess
);
}
}
const
_promise
=
Promise
.
resolve
();
const
_promise
=
Promise
.
resolve
();
return
(
callback
:
(...
args
:
any
[])
=>
void
)
=>
_promise
.
then
(
callback
);
return
(
callback
:
(...
args
:
any
[])
=>
void
)
=>
_promise
.
then
(
callback
);
...
...
src/vs/base/common/process.ts
浏览文件 @
76b73311
...
@@ -3,19 +3,11 @@
...
@@ -3,19 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
{
isWindows
,
isMacintosh
,
setImmediate
,
IProcessEnvironment
,
global
s
}
from
'
vs/base/common/platform
'
;
import
{
isWindows
,
isMacintosh
,
setImmediate
,
globals
,
INodeProces
s
}
from
'
vs/base/common/platform
'
;
export
interface
IProcess
{
declare
const
process
:
INodeProcess
;
platform
:
'
win32
'
|
'
linux
'
|
'
darwin
'
;
env
:
IProcessEnvironment
;
cwd
():
string
;
let
safeProcess
:
INodeProcess
;
nextTick
(
callback
:
(...
args
:
any
[])
=>
void
):
void
;
}
declare
const
process
:
IProcess
;
let
safeProcess
:
IProcess
;
// Native node.js environment
// Native node.js environment
if
(
typeof
process
!==
'
undefined
'
)
{
if
(
typeof
process
!==
'
undefined
'
)
{
...
@@ -30,10 +22,15 @@ else if (typeof globals.vscode !== 'undefined') {
...
@@ -30,10 +22,15 @@ else if (typeof globals.vscode !== 'undefined') {
// Web environment
// Web environment
else
{
else
{
safeProcess
=
{
safeProcess
=
{
cwd
():
string
{
return
'
/
'
;
},
env
:
Object
.
create
(
null
),
// Supported
get
platform
():
'
win32
'
|
'
linux
'
|
'
darwin
'
{
return
isWindows
?
'
win32
'
:
isMacintosh
?
'
darwin
'
:
'
linux
'
;
},
get
platform
():
'
win32
'
|
'
linux
'
|
'
darwin
'
{
return
isWindows
?
'
win32
'
:
isMacintosh
?
'
darwin
'
:
'
linux
'
;
},
nextTick
(
callback
:
(...
args
:
any
[])
=>
void
):
void
{
return
setImmediate
(
callback
);
}
nextTick
(
callback
:
(...
args
:
any
[])
=>
void
):
void
{
return
setImmediate
(
callback
);
},
// Unsupported
get
env
()
{
return
Object
.
create
(
null
);
},
cwd
():
string
{
return
'
/
'
;
},
getuid
():
number
{
return
-
1
;
}
};
};
}
}
...
...
src/vs/base/parts/sandbox/electron-browser/preload.js
浏览文件 @
76b73311
...
@@ -98,9 +98,10 @@
...
@@ -98,9 +98,10 @@
* Support for a subset of access to node.js global `process`.
* Support for a subset of access to node.js global `process`.
*/
*/
process
:
{
process
:
{
platform
:
process
.
platform
,
get
platform
()
{
return
process
.
platform
;
},
env
:
process
.
env
,
get
env
()
{
return
process
.
env
;
},
versions
:
process
.
versions
,
get
versions
()
{
return
process
.
versions
;
},
get
type
()
{
return
'
renderer
'
;
},
_whenEnvResolved
:
undefined
,
_whenEnvResolved
:
undefined
,
whenEnvResolved
:
whenEnvResolved
:
...
@@ -136,6 +137,14 @@
...
@@ -136,6 +137,14 @@
return
process
.
cwd
();
return
process
.
cwd
();
},
},
getuid
:
/**
* @returns the numeric user identity of the process
*/
function
()
{
return
process
.
getuid
();
},
getProcessMemoryInfo
:
getProcessMemoryInfo
:
/**
/**
* @returns {Promise<import('electron').ProcessMemoryInfo>}
* @returns {Promise<import('electron').ProcessMemoryInfo>}
...
@@ -160,7 +169,7 @@
...
@@ -160,7 +169,7 @@
* Some information about the context we are running in.
* Some information about the context we are running in.
*/
*/
context
:
{
context
:
{
sandbox
:
process
.
argv
.
includes
(
'
--enable-sandbox
'
)
get
sandbox
()
{
return
process
.
argv
.
includes
(
'
--enable-sandbox
'
);
}
}
}
};
};
...
...
src/vs/base/parts/sandbox/electron-sandbox/globals.ts
浏览文件 @
76b73311
...
@@ -4,8 +4,7 @@
...
@@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
*--------------------------------------------------------------------------------------------*/
import
type
{
ProcessMemoryInfo
}
from
'
vs/base/parts/sandbox/common/electronTypes
'
;
import
type
{
ProcessMemoryInfo
}
from
'
vs/base/parts/sandbox/common/electronTypes
'
;
import
type
{
IProcess
}
from
'
vs/base/common/process
'
;
import
{
globals
,
INodeProcess
}
from
'
vs/base/common/platform
'
;
import
{
globals
}
from
'
vs/base/common/platform
'
;
export
const
ipcRenderer
=
globals
.
vscode
.
ipcRenderer
as
{
export
const
ipcRenderer
=
globals
.
vscode
.
ipcRenderer
as
{
...
@@ -75,7 +74,7 @@ export const crashReporter = globals.vscode.crashReporter as {
...
@@ -75,7 +74,7 @@ export const crashReporter = globals.vscode.crashReporter as {
addExtraParameter
(
key
:
string
,
value
:
string
):
void
;
addExtraParameter
(
key
:
string
,
value
:
string
):
void
;
};
};
export
const
process
=
globals
.
vscode
.
process
as
IProcess
&
{
export
const
process
=
globals
.
vscode
.
process
as
I
Node
Process
&
{
/**
/**
* The process.platform property returns a string identifying the operating system platform
* The process.platform property returns a string identifying the operating system platform
...
@@ -84,7 +83,17 @@ export const process = globals.vscode.process as IProcess & {
...
@@ -84,7 +83,17 @@ export const process = globals.vscode.process as IProcess & {
platform
:
'
win32
'
|
'
linux
'
|
'
darwin
'
;
platform
:
'
win32
'
|
'
linux
'
|
'
darwin
'
;
/**
/**
* The process.env property returns an object containing the user environment. See environ(7).
* The type will always be Electron renderer.
*/
type
:
'
renderer
'
;
/**
* A list of versions for the current node.js/electron configuration.
*/
versions
:
{
[
key
:
string
]:
string
|
undefined
};
/**
* The process.env property returns an object containing the user environment.
*/
*/
env
:
{
[
key
:
string
]:
string
|
undefined
};
env
:
{
[
key
:
string
]:
string
|
undefined
};
...
@@ -93,6 +102,11 @@ export const process = globals.vscode.process as IProcess & {
...
@@ -93,6 +102,11 @@ export const process = globals.vscode.process as IProcess & {
*/
*/
cwd
():
string
;
cwd
():
string
;
/**
* Returns the numeric user identity of the process.
*/
getuid
():
number
;
/**
/**
* Allows to await resolving the full process environment by checking for the shell environment
* 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).
* of the OS in certain cases (e.g. when the app is started from the Dock on macOS).
...
@@ -125,11 +139,6 @@ export const process = globals.vscode.process as IProcess & {
...
@@ -125,11 +139,6 @@ export const process = globals.vscode.process as IProcess & {
* process on macOS.
* process on macOS.
*/
*/
getProcessMemoryInfo
:
()
=>
Promise
<
ProcessMemoryInfo
>
;
getProcessMemoryInfo
:
()
=>
Promise
<
ProcessMemoryInfo
>
;
/**
* A list of versions for the current node.js/electron configuration.
*/
versions
:
{
[
key
:
string
]:
string
|
undefined
};
};
};
export
const
context
=
globals
.
vscode
.
context
as
{
export
const
context
=
globals
.
vscode
.
context
as
{
...
...
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
浏览文件 @
76b73311
...
@@ -91,6 +91,7 @@ export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnviro
...
@@ -91,6 +91,7 @@ export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnviro
get
userDataSyncHome
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
syncHome
'
);
}
get
userDataSyncHome
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
syncHome
'
);
}
get
tmpDir
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
tmp
'
);
}
get
tmpDir
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
tmp
'
);
}
get
backupWorkspaceHome
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
Backups
'
,
'
workspace
'
);
}
get
backupWorkspaceHome
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
Backups
'
,
'
workspace
'
);
}
get
logsPath
():
string
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
logs
'
).
path
;
}
options
?:
IWorkbenchConstructionOptions
|
undefined
;
options
?:
IWorkbenchConstructionOptions
|
undefined
;
logExtensionHostCommunication
?:
boolean
|
undefined
;
logExtensionHostCommunication
?:
boolean
|
undefined
;
...
@@ -107,7 +108,6 @@ export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnviro
...
@@ -107,7 +108,6 @@ export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnviro
disableExtensions
:
boolean
|
string
[]
=
[];
disableExtensions
:
boolean
|
string
[]
=
[];
extensionDevelopmentLocationURI
?:
URI
[]
|
undefined
;
extensionDevelopmentLocationURI
?:
URI
[]
|
undefined
;
extensionTestsLocationURI
?:
URI
|
undefined
;
extensionTestsLocationURI
?:
URI
|
undefined
;
logsPath
:
string
=
undefined
!
;
logLevel
?:
string
|
undefined
;
logLevel
?:
string
|
undefined
;
args
:
NativeParsedArgs
=
Object
.
create
(
null
);
args
:
NativeParsedArgs
=
Object
.
create
(
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录