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 {
[
key
:
string
]:
string
;
}
interface
INodeProcess
{
platform
:
string
;
export
interface
INodeProcess
{
platform
:
'
win32
'
|
'
linux
'
|
'
darwin
'
;
env
:
IProcessEnvironment
;
getuid
():
number
;
nextTick
:
Function
;
versions
?:
{
electron
?:
string
;
};
type
?:
string
;
getuid
():
number
;
cwd
():
string
;
}
declare
const
process
:
INodeProcess
;
declare
const
global
:
any
;
...
...
@@ -47,9 +48,20 @@ interface INavigator {
declare
const
navigator
:
INavigator
;
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
)
{
_userAgent
=
navigator
.
userAgent
;
_isWindows
=
_userAgent
.
indexOf
(
'
Windows
'
)
>=
0
;
...
...
@@ -59,13 +71,16 @@ if (typeof navigator === 'object' && !isElectronRenderer) {
_isWeb
=
true
;
_locale
=
navigator
.
language
;
_language
=
_locale
;
}
else
if
(
typeof
process
===
'
object
'
)
{
_isWindows
=
(
process
.
platform
===
'
win32
'
);
_isMacintosh
=
(
process
.
platform
===
'
darwin
'
);
_isLinux
=
(
process
.
platform
===
'
linux
'
);
}
// Native environment
else
if
(
typeof
nodeProcess
===
'
object
'
)
{
_isWindows
=
(
nodeProcess
.
platform
===
'
win32
'
);
_isMacintosh
=
(
nodeProcess
.
platform
===
'
darwin
'
);
_isLinux
=
(
nodeProcess
.
platform
===
'
linux
'
);
_locale
=
LANGUAGE_DEFAULT
;
_language
=
LANGUAGE_DEFAULT
;
const
rawNlsConfig
=
p
rocess
.
env
[
'
VSCODE_NLS_CONFIG
'
];
const
rawNlsConfig
=
nodeP
rocess
.
env
[
'
VSCODE_NLS_CONFIG
'
];
if
(
rawNlsConfig
)
{
try
{
const
nlsConfig
:
NLSConfig
=
JSON
.
parse
(
rawNlsConfig
);
...
...
@@ -80,6 +95,11 @@ if (typeof navigator === 'object' && !isElectronRenderer) {
_isNative
=
true
;
}
// Unknown environment
else
{
console
.
error
(
'
Unable to resolve platform.
'
);
}
export
const
enum
Platform
{
Web
,
Mac
,
...
...
@@ -114,7 +134,7 @@ export const platform = _platform;
export
const
userAgent
=
_userAgent
;
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;
*/
export
const
translationsConfigFile
=
_translationsConfigFile
;
const
_globals
=
(
typeof
self
===
'
object
'
?
self
:
typeof
global
===
'
object
'
?
global
:
{}
as
any
);
export
const
globals
:
any
=
_globals
;
interface
ISetImmediate
{
...
...
@@ -196,8 +215,8 @@ export const setImmediate: ISetImmediate = (function defineSetImmediate() {
globals
.
postMessage
({
vscodeSetImmediateId
:
myId
},
'
*
'
);
};
}
if
(
typeof
process
!==
'
undefined
'
&&
typeof
process
.
nextTick
===
'
function
'
)
{
return
process
.
nextTick
.
bind
(
p
rocess
);
if
(
nodeProcess
)
{
return
nodeProcess
.
nextTick
.
bind
(
nodeP
rocess
);
}
const
_promise
=
Promise
.
resolve
();
return
(
callback
:
(...
args
:
any
[])
=>
void
)
=>
_promise
.
then
(
callback
);
...
...
src/vs/base/common/process.ts
浏览文件 @
76b73311
...
...
@@ -3,19 +3,11 @@
* 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
{
platform
:
'
win32
'
|
'
linux
'
|
'
darwin
'
;
env
:
IProcessEnvironment
;
declare
const
process
:
INodeProcess
;
cwd
():
string
;
nextTick
(
callback
:
(...
args
:
any
[])
=>
void
):
void
;
}
declare
const
process
:
IProcess
;
let
safeProcess
:
IProcess
;
let
safeProcess
:
INodeProcess
;
// Native node.js environment
if
(
typeof
process
!==
'
undefined
'
)
{
...
...
@@ -30,10 +22,15 @@ else if (typeof globals.vscode !== 'undefined') {
// Web environment
else
{
safeProcess
=
{
cwd
():
string
{
return
'
/
'
;
},
env
:
Object
.
create
(
null
),
// Supported
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 @@
* Support for a subset of access to node.js global `process`.
*/
process
:
{
platform
:
process
.
platform
,
env
:
process
.
env
,
versions
:
process
.
versions
,
get
platform
()
{
return
process
.
platform
;
},
get
env
()
{
return
process
.
env
;
},
get
versions
()
{
return
process
.
versions
;
},
get
type
()
{
return
'
renderer
'
;
},
_whenEnvResolved
:
undefined
,
whenEnvResolved
:
...
...
@@ -136,6 +137,14 @@
return
process
.
cwd
();
},
getuid
:
/**
* @returns the numeric user identity of the process
*/
function
()
{
return
process
.
getuid
();
},
getProcessMemoryInfo
:
/**
* @returns {Promise<import('electron').ProcessMemoryInfo>}
...
...
@@ -160,7 +169,7 @@
* Some information about the context we are running in.
*/
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 @@
*--------------------------------------------------------------------------------------------*/
import
type
{
ProcessMemoryInfo
}
from
'
vs/base/parts/sandbox/common/electronTypes
'
;
import
type
{
IProcess
}
from
'
vs/base/common/process
'
;
import
{
globals
}
from
'
vs/base/common/platform
'
;
import
{
globals
,
INodeProcess
}
from
'
vs/base/common/platform
'
;
export
const
ipcRenderer
=
globals
.
vscode
.
ipcRenderer
as
{
...
...
@@ -75,7 +74,7 @@ export const crashReporter = globals.vscode.crashReporter as {
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
...
...
@@ -84,7 +83,17 @@ export const process = globals.vscode.process as IProcess & {
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
};
...
...
@@ -93,6 +102,11 @@ export const process = globals.vscode.process as IProcess & {
*/
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
* 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 & {
* process on macOS.
*/
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
{
...
...
src/vs/workbench/electron-sandbox/sandbox.simpleservices.ts
浏览文件 @
76b73311
...
...
@@ -91,6 +91,7 @@ export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnviro
get
userDataSyncHome
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
syncHome
'
);
}
get
tmpDir
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
tmp
'
);
}
get
backupWorkspaceHome
():
URI
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
Backups
'
,
'
workspace
'
);
}
get
logsPath
():
string
{
return
joinPath
(
this
.
userRoamingDataHome
,
'
logs
'
).
path
;
}
options
?:
IWorkbenchConstructionOptions
|
undefined
;
logExtensionHostCommunication
?:
boolean
|
undefined
;
...
...
@@ -107,7 +108,6 @@ export class SimpleWorkbenchEnvironmentService implements INativeWorkbenchEnviro
disableExtensions
:
boolean
|
string
[]
=
[];
extensionDevelopmentLocationURI
?:
URI
[]
|
undefined
;
extensionTestsLocationURI
?:
URI
|
undefined
;
logsPath
:
string
=
undefined
!
;
logLevel
?:
string
|
undefined
;
args
:
NativeParsedArgs
=
Object
.
create
(
null
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录