Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
70e8e31f
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,体验更适合开发者的 AI 搜索 >>
提交
70e8e31f
编写于
4月 14, 2020
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
web - add API to execute command
上级
e6e87b51
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
19 deletion
+62
-19
src/vs/workbench/browser/web.main.ts
src/vs/workbench/browser/web.main.ts
+18
-6
src/vs/workbench/electron-browser/desktop.main.ts
src/vs/workbench/electron-browser/desktop.main.ts
+2
-2
src/vs/workbench/workbench.web.api.ts
src/vs/workbench/workbench.web.api.ts
+42
-11
未找到文件。
src/vs/workbench/browser/web.main.ts
浏览文件 @
70e8e31f
...
...
@@ -33,7 +33,7 @@ import { WorkspaceService } from 'vs/workbench/services/configuration/browser/co
import
{
ConfigurationCache
}
from
'
vs/workbench/services/configuration/browser/configurationCache
'
;
import
{
ISignService
}
from
'
vs/platform/sign/common/sign
'
;
import
{
SignService
}
from
'
vs/platform/sign/browser/signService
'
;
import
{
IWorkbenchConstructionOptions
,
IWorkspace
}
from
'
vs/workbench/workbench.web.api
'
;
import
{
IWorkbenchConstructionOptions
,
IWorkspace
,
IWorkbench
}
from
'
vs/workbench/workbench.web.api
'
;
import
{
FileUserDataProvider
}
from
'
vs/workbench/services/userData/common/fileUserDataProvider
'
;
import
{
BACKUPS
}
from
'
vs/platform/environment/common/environment
'
;
import
{
joinPath
}
from
'
vs/base/common/resources
'
;
...
...
@@ -51,6 +51,7 @@ import { getWorkspaceIdentifier } from 'vs/workbench/services/workspaces/browser
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
InMemoryFileSystemProvider
}
from
'
vs/platform/files/common/inMemoryFilesystemProvider
'
;
import
{
WebResourceIdentityService
,
IResourceIdentityService
}
from
'
vs/platform/resource/common/resourceIdentityService
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
class
BrowserMain
extends
Disposable
{
...
...
@@ -61,7 +62,7 @@ class BrowserMain extends Disposable {
super
();
}
async
open
():
Promise
<
void
>
{
async
open
():
Promise
<
IWorkbench
>
{
const
services
=
await
this
.
initServices
();
await
domContentLoaded
();
...
...
@@ -86,7 +87,18 @@ class BrowserMain extends Disposable {
}
// Startup
workbench
.
startup
();
const
instantiationService
=
workbench
.
startup
();
// Return API Facade
return
instantiationService
.
invokeFunction
(
accessor
=>
{
const
commandService
=
accessor
.
get
(
ICommandService
);
return
{
commands
:
{
executeCommand
:
(
command
,
...
args
)
=>
commandService
.
executeCommand
(
command
,
...
args
)
}
};
});
}
private
registerListeners
(
workbench
:
Workbench
,
storageService
:
BrowserStorageService
):
void
{
...
...
@@ -335,8 +347,8 @@ class BrowserMain extends Disposable {
}
}
export
function
main
(
domElement
:
HTMLElement
,
options
:
IWorkbenchConstructionOptions
):
Promise
<
void
>
{
const
renderer
=
new
BrowserMain
(
domElement
,
options
);
export
function
main
(
domElement
:
HTMLElement
,
options
:
IWorkbenchConstructionOptions
):
Promise
<
IWorkbench
>
{
const
workbench
=
new
BrowserMain
(
domElement
,
options
);
return
renderer
.
open
();
return
workbench
.
open
();
}
src/vs/workbench/electron-browser/desktop.main.ts
浏览文件 @
70e8e31f
...
...
@@ -338,7 +338,7 @@ class DesktopMain extends Disposable {
}
export
function
main
(
configuration
:
INativeWindowConfiguration
):
Promise
<
void
>
{
const
renderer
=
new
DesktopMain
(
configuration
);
const
workbench
=
new
DesktopMain
(
configuration
);
return
renderer
.
open
();
return
workbench
.
open
();
}
src/vs/workbench/workbench.web.api.ts
浏览文件 @
70e8e31f
...
...
@@ -35,33 +35,37 @@ interface IExternalUriResolver {
(
uri
:
URI
):
Promise
<
URI
>
;
}
interface
TunnelOptions
{
interface
ITunnelFactory
{
(
tunnelOptions
:
ITunnelOptions
):
Promise
<
ITunnel
>
|
undefined
;
}
interface
ITunnelOptions
{
remoteAddress
:
{
port
:
number
,
host
:
string
};
/**
* The desired local port. If this port can't be used, then another will be chosen.
*/
localAddressPort
?:
number
;
label
?:
string
;
}
interface
Tunnel
extends
IDisposable
{
interface
I
Tunnel
extends
IDisposable
{
remoteAddress
:
{
port
:
number
,
host
:
string
};
/**
* The complete local address(ex. localhost:1234)
*/
localAddress
:
string
;
/**
* Implementers of Tunnel should fire onDidDispose when dispose is called.
*/
onDidDispose
:
Event
<
void
>
;
}
interface
ITunnelFactory
{
(
tunnelOptions
:
TunnelOptions
):
Thenable
<
Tunnel
>
|
undefined
;
}
interface
IShowCandidate
{
(
host
:
string
,
port
:
number
,
detail
:
string
):
Thenable
<
boolean
>
;
interface
IShowPortCandidate
{
(
host
:
string
,
port
:
number
,
detail
:
string
):
Promise
<
boolean
>
;
}
interface
ICommand
{
...
...
@@ -126,7 +130,7 @@ interface IWorkbenchConstructionOptions {
/**
* Support for filtering candidate ports
*/
readonly
showCandidate
?:
IShowCandidate
;
readonly
showCandidate
?:
IShow
Port
Candidate
;
//#endregion
...
...
@@ -195,14 +199,30 @@ interface IWorkbenchConstructionOptions {
//#endregion
}
interface
IWorkbench
{
commands
:
{
/**
* Allows to execute any command if known with the provided arguments.
*
* @param command Identifier of the command to execute.
* @param rest Parameters passed to the command function.
* @return A promise that resolves to the returned value of the given command.
*/
executeCommand
<
T
>
(
command
:
string
,
...
rest
:
any
[]):
Promise
<
T
|
undefined
>
;
}
}
/**
* Creates the workbench with the provided options in the provided container.
*
* @param domElement the container to create the workbench in
* @param options for setting up the workbench
*
* @returns the workbench API facade.
*/
let
created
=
false
;
async
function
create
(
domElement
:
HTMLElement
,
options
:
IWorkbenchConstructionOptions
):
Promise
<
void
>
{
async
function
create
(
domElement
:
HTMLElement
,
options
:
IWorkbenchConstructionOptions
):
Promise
<
IWorkbench
>
{
// Assert that the workbench is not created more than once. We currently
// do not support this and require a full context switch to clean-up.
...
...
@@ -213,7 +233,7 @@ async function create(domElement: HTMLElement, options: IWorkbenchConstructionOp
}
// Startup workbench
await
main
(
domElement
,
options
);
const
workbench
=
await
main
(
domElement
,
options
);
// Register commands if any
if
(
Array
.
isArray
(
options
.
commands
))
{
...
...
@@ -225,6 +245,8 @@ async function create(domElement: HTMLElement, options: IWorkbenchConstructionOp
});
}
}
return
workbench
;
}
export
{
...
...
@@ -232,6 +254,7 @@ export {
// Factory
create
,
IWorkbenchConstructionOptions
,
IWorkbench
,
// Basic Types
URI
,
...
...
@@ -281,6 +304,14 @@ export {
// External Uris
IExternalUriResolver
,
// Tunnel
ITunnelFactory
,
ITunnel
,
ITunnelOptions
,
// Ports
IShowPortCandidate
,
// Commands
ICommand
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录