Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ea680fae
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,发现更多精彩内容 >>
提交
ea680fae
编写于
4月 16, 2018
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update to use more consistent WebviewPanel naming
上级
a322ceb0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
49 addition
and
49 deletion
+49
-49
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
+20
-20
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+12
-12
src/vs/workbench/api/node/extHostWebview.ts
src/vs/workbench/api/node/extHostWebview.ts
+15
-15
src/vs/workbench/test/electron-browser/api/extHostWebview.test.ts
...orkbench/test/electron-browser/api/extHostWebview.test.ts
+2
-2
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadWebview.ts
浏览文件 @
ea680fae
...
...
@@ -11,7 +11,7 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ILifecycleService
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
ExtHostContext
,
ExtHostWebviewsShape
,
IExtHostContext
,
MainContext
,
MainThreadWebviewsShape
,
WebviewHandle
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
ExtHostContext
,
ExtHostWebviewsShape
,
IExtHostContext
,
MainContext
,
MainThreadWebviewsShape
,
Webview
Panel
Handle
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
WebviewEditor
}
from
'
vs/workbench/parts/webview/electron-browser/webviewEditor
'
;
import
{
WebviewEditorInput
}
from
'
vs/workbench/parts/webview/electron-browser/webviewEditorInput
'
;
import
{
IWebviewEditorService
,
WebviewInputOptions
,
WebviewReviver
}
from
'
vs/workbench/parts/webview/electron-browser/webviewEditorService
'
;
...
...
@@ -34,10 +34,10 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
private
_toDispose
:
IDisposable
[]
=
[];
private
readonly
_proxy
:
ExtHostWebviewsShape
;
private
readonly
_webviews
=
new
Map
<
WebviewHandle
,
WebviewEditorInput
>
();
private
readonly
_webviews
=
new
Map
<
Webview
Panel
Handle
,
WebviewEditorInput
>
();
private
readonly
_revivers
=
new
Set
<
string
>
();
private
_activeWebview
:
WebviewHandle
|
undefined
=
undefined
;
private
_activeWebview
:
Webview
Panel
Handle
|
undefined
=
undefined
;
constructor
(
context
:
IExtHostContext
,
...
...
@@ -63,8 +63,8 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
this
.
_toDispose
=
dispose
(
this
.
_toDispose
);
}
$createWebview
(
handle
:
WebviewHandle
,
$createWebview
Panel
(
handle
:
Webview
Panel
Handle
,
viewType
:
string
,
title
:
string
,
column
:
Position
,
...
...
@@ -80,27 +80,27 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
this
.
_webviews
.
set
(
handle
,
webview
);
}
$disposeWebview
(
handle
:
WebviewHandle
):
void
{
$disposeWebview
(
handle
:
Webview
Panel
Handle
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
webview
.
dispose
();
}
$setTitle
(
handle
:
WebviewHandle
,
value
:
string
):
void
{
$setTitle
(
handle
:
Webview
Panel
Handle
,
value
:
string
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
webview
.
setName
(
value
);
}
$setHtml
(
handle
:
WebviewHandle
,
value
:
string
):
void
{
$setHtml
(
handle
:
Webview
Panel
Handle
,
value
:
string
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
webview
.
html
=
value
;
}
$reveal
(
handle
:
WebviewHandle
,
column
:
Position
):
void
{
$reveal
(
handle
:
Webview
Panel
Handle
,
column
:
Position
):
void
{
const
webview
=
this
.
getWebview
(
handle
);
this
.
_webviewService
.
revealWebview
(
webview
,
column
);
}
async
$sendMessage
(
handle
:
WebviewHandle
,
message
:
any
):
TPromise
<
boolean
>
{
async
$sendMessage
(
handle
:
Webview
Panel
Handle
,
message
:
any
):
TPromise
<
boolean
>
{
const
webview
=
this
.
getWebview
(
handle
);
const
editors
=
this
.
_editorService
.
getVisibleEditors
()
.
filter
(
e
=>
e
instanceof
WebviewEditor
)
...
...
@@ -129,7 +129,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
this
.
_webviews
.
set
(
handle
,
webview
);
webview
.
_events
=
this
.
createWebviewEventDelegate
(
handle
);
return
this
.
_proxy
.
$deserializeWebview
(
handle
,
webview
.
state
.
viewType
,
webview
.
getTitle
(),
webview
.
state
.
state
,
webview
.
position
,
webview
.
options
)
return
this
.
_proxy
.
$deserializeWebview
Panel
(
handle
,
webview
.
state
.
viewType
,
webview
.
getTitle
(),
webview
.
state
.
state
,
webview
.
position
,
webview
.
options
)
.
then
(
undefined
,
()
=>
{
webview
.
html
=
MainThreadWebviews
.
getDeserializationFailedContents
(
viewType
);
});
...
...
@@ -141,7 +141,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
}
private
_onWillShutdown
():
TPromise
<
boolean
>
{
const
toRevive
:
WebviewHandle
[]
=
[];
const
toRevive
:
Webview
Panel
Handle
[]
=
[];
this
.
_webviews
.
forEach
((
view
,
key
)
=>
{
if
(
this
.
canRevive
(
view
))
{
toRevive
.
push
(
key
);
...
...
@@ -150,7 +150,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
const
reviveResponses
=
toRevive
.
map
(
handle
=>
TPromise
.
any
([
this
.
_proxy
.
$serializeWebview
(
handle
).
then
(
this
.
_proxy
.
$serializeWebview
Panel
(
handle
).
then
(
state
=>
({
handle
,
state
}),
()
=>
({
handle
,
state
:
null
})),
TPromise
.
timeout
(
MainThreadWebviews
.
serializeTimeout
).
then
(()
=>
({
handle
,
state
:
null
}))
...
...
@@ -171,19 +171,19 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
});
}
private
createWebviewEventDelegate
(
handle
:
WebviewHandle
)
{
private
createWebviewEventDelegate
(
handle
:
Webview
Panel
Handle
)
{
return
{
onDidClickLink
:
uri
=>
this
.
onDidClickLink
(
handle
,
uri
),
onMessage
:
message
=>
this
.
_proxy
.
$onMessage
(
handle
,
message
),
onDispose
:
()
=>
{
this
.
_proxy
.
$onDidDisposeWebview
(
handle
).
then
(()
=>
{
this
.
_proxy
.
onDidDisposeWebviewPanel
(
handle
).
then
(()
=>
{
this
.
_webviews
.
delete
(
handle
);
});
}
};
}
private
getWebview
(
handle
:
WebviewHandle
):
WebviewEditorInput
{
private
getWebview
(
handle
:
Webview
Panel
Handle
):
WebviewEditorInput
{
const
webview
=
this
.
_webviews
.
get
(
handle
);
if
(
!
webview
)
{
throw
new
Error
(
'
Unknown webview handle:
'
+
handle
);
...
...
@@ -193,7 +193,7 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
private
onEditorsChanged
()
{
const
activeEditor
=
this
.
_editorService
.
getActiveEditor
();
let
newActiveWebview
:
{
input
:
WebviewEditorInput
,
handle
:
WebviewHandle
}
|
undefined
=
undefined
;
let
newActiveWebview
:
{
input
:
WebviewEditorInput
,
handle
:
Webview
Panel
Handle
}
|
undefined
=
undefined
;
if
(
activeEditor
&&
activeEditor
.
input
instanceof
WebviewEditorInput
)
{
for
(
const
handle
of
map
.
keys
(
this
.
_webviews
))
{
const
input
=
this
.
_webviews
.
get
(
handle
);
...
...
@@ -213,20 +213,20 @@ export class MainThreadWebviews implements MainThreadWebviewsShape, WebviewReviv
if
(
typeof
this
.
_activeWebview
!==
'
undefined
'
)
{
const
oldActiveWebview
=
this
.
_webviews
.
get
(
this
.
_activeWebview
);
if
(
oldActiveWebview
)
{
this
.
_proxy
.
$onDidChangeWebviewViewState
(
this
.
_activeWebview
,
false
,
oldActiveWebview
.
position
);
this
.
_proxy
.
$onDidChangeWebview
Panel
ViewState
(
this
.
_activeWebview
,
false
,
oldActiveWebview
.
position
);
}
}
// Then for newly active
if
(
newActiveWebview
)
{
this
.
_proxy
.
$onDidChangeWebviewViewState
(
newActiveWebview
.
handle
,
true
,
activeEditor
.
position
);
this
.
_proxy
.
$onDidChangeWebview
Panel
ViewState
(
newActiveWebview
.
handle
,
true
,
activeEditor
.
position
);
this
.
_activeWebview
=
newActiveWebview
.
handle
;
}
else
{
this
.
_activeWebview
=
undefined
;
}
}
private
onDidClickLink
(
handle
:
WebviewHandle
,
link
:
URI
):
void
{
private
onDidClickLink
(
handle
:
Webview
Panel
Handle
,
link
:
URI
):
void
{
if
(
!
link
)
{
return
;
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
ea680fae
...
...
@@ -347,26 +347,26 @@ export interface MainThreadTelemetryShape extends IDisposable {
$publicLog
(
eventName
:
string
,
data
?:
any
):
void
;
}
export
type
WebviewHandle
=
string
;
export
type
Webview
Panel
Handle
=
string
;
export
interface
MainThreadWebviewsShape
extends
IDisposable
{
$createWebview
(
handle
:
Webview
Handle
,
viewType
:
string
,
title
:
string
,
column
:
EditorPosition
,
options
:
vscode
.
WebviewPanelOptions
&
vscode
.
WebviewOptions
,
extensionFolderPath
:
string
):
void
;
$disposeWebview
(
handle
:
WebviewHandle
):
void
;
$reveal
(
handle
:
WebviewHandle
,
column
:
EditorPosition
):
void
;
$setTitle
(
handle
:
WebviewHandle
,
value
:
string
):
void
;
$setHtml
(
handle
:
WebviewHandle
,
value
:
string
):
void
;
$sendMessage
(
handle
:
WebviewHandle
,
value
:
any
):
Thenable
<
boolean
>
;
$createWebview
Panel
(
handle
:
WebviewPanel
Handle
,
viewType
:
string
,
title
:
string
,
column
:
EditorPosition
,
options
:
vscode
.
WebviewPanelOptions
&
vscode
.
WebviewOptions
,
extensionFolderPath
:
string
):
void
;
$disposeWebview
(
handle
:
Webview
Panel
Handle
):
void
;
$reveal
(
handle
:
Webview
Panel
Handle
,
column
:
EditorPosition
):
void
;
$setTitle
(
handle
:
Webview
Panel
Handle
,
value
:
string
):
void
;
$setHtml
(
handle
:
Webview
Panel
Handle
,
value
:
string
):
void
;
$sendMessage
(
handle
:
Webview
Panel
Handle
,
value
:
any
):
Thenable
<
boolean
>
;
$registerSerializer
(
viewType
:
string
):
void
;
$unregisterSerializer
(
viewType
:
string
):
void
;
}
export
interface
ExtHostWebviewsShape
{
$onMessage
(
handle
:
WebviewHandle
,
message
:
any
):
void
;
$onDidChangeWebview
ViewState
(
handle
:
Webview
Handle
,
active
:
boolean
,
position
:
EditorPosition
):
void
;
$onDidDisposeWebview
(
handle
:
Webview
Handle
):
Thenable
<
void
>
;
$deserializeWebview
(
newWebviewHandle
:
Webview
Handle
,
viewType
:
string
,
title
:
string
,
state
:
any
,
position
:
EditorPosition
,
options
:
vscode
.
WebviewOptions
):
Thenable
<
void
>
;
$serializeWebview
(
webviewHandle
:
Webview
Handle
):
Thenable
<
any
>
;
$onMessage
(
handle
:
Webview
Panel
Handle
,
message
:
any
):
void
;
$onDidChangeWebview
PanelViewState
(
handle
:
WebviewPanel
Handle
,
active
:
boolean
,
position
:
EditorPosition
):
void
;
onDidDisposeWebviewPanel
(
handle
:
WebviewPanel
Handle
):
Thenable
<
void
>
;
$deserializeWebview
Panel
(
newWebviewHandle
:
WebviewPanel
Handle
,
viewType
:
string
,
title
:
string
,
state
:
any
,
position
:
EditorPosition
,
options
:
vscode
.
WebviewOptions
):
Thenable
<
void
>
;
$serializeWebview
Panel
(
webviewHandle
:
WebviewPanel
Handle
):
Thenable
<
any
>
;
}
export
interface
MainThreadWorkspaceShape
extends
IDisposable
{
...
...
src/vs/workbench/api/node/extHostWebview.ts
浏览文件 @
ea680fae
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
MainContext
,
MainThreadWebviewsShape
,
IMainContext
,
ExtHostWebviewsShape
,
WebviewHandle
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadWebviewsShape
,
IMainContext
,
ExtHostWebviewsShape
,
Webview
Panel
Handle
}
from
'
./extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
typeConverters
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
...
...
@@ -12,7 +12,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
Disposable
}
from
'
./extHostTypes
'
;
export
class
ExtHostWebview
implements
vscode
.
Webview
{
private
readonly
_handle
:
WebviewHandle
;
private
readonly
_handle
:
Webview
Panel
Handle
;
private
readonly
_proxy
:
MainThreadWebviewsShape
;
private
_title
:
string
;
private
_html
:
string
;
...
...
@@ -26,7 +26,7 @@ export class ExtHostWebview implements vscode.Webview {
public
readonly
onDidChangeViewState
:
Event
<
vscode
.
WebviewPanelOnDidChangeViewStateEvent
>
=
this
.
onDidChangeViewStateEmitter
.
event
;
constructor
(
handle
:
WebviewHandle
,
handle
:
Webview
Panel
Handle
,
proxy
:
MainThreadWebviewsShape
,
title
:
string
,
options
:
vscode
.
WebviewOptions
...
...
@@ -91,7 +91,7 @@ export class ExtHostWebview implements vscode.Webview {
export
class
ExtHostWebviewPanel
implements
vscode
.
WebviewPanel
{
private
readonly
_handle
:
WebviewHandle
;
private
readonly
_handle
:
Webview
Panel
Handle
;
private
readonly
_viewType
:
string
;
private
readonly
_options
:
vscode
.
WebviewPanelOptions
;
private
readonly
_proxy
:
MainThreadWebviewsShape
;
...
...
@@ -108,7 +108,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel {
private
_webview
:
ExtHostWebview
;
constructor
(
handle
:
WebviewHandle
,
handle
:
Webview
Panel
Handle
,
proxy
:
MainThreadWebviewsShape
,
viewType
:
string
,
title
:
string
,
...
...
@@ -194,7 +194,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
private
readonly
_proxy
:
MainThreadWebviewsShape
;
private
readonly
_webviewPanels
=
new
Map
<
WebviewHandle
,
ExtHostWebviewPanel
>
();
private
readonly
_webviewPanels
=
new
Map
<
Webview
Panel
Handle
,
ExtHostWebviewPanel
>
();
private
readonly
_serializers
=
new
Map
<
string
,
vscode
.
WebviewPanelSerializer
>
();
constructor
(
...
...
@@ -211,7 +211,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
extensionFolderPath
:
string
):
vscode
.
WebviewPanel
{
const
handle
=
ExtHostWebviews
.
webviewHandlePool
++
+
''
;
this
.
_proxy
.
$createWebview
(
handle
,
viewType
,
title
,
typeConverters
.
fromViewColumn
(
viewColumn
),
options
,
extensionFolderPath
);
this
.
_proxy
.
$createWebview
Panel
(
handle
,
viewType
,
title
,
typeConverters
.
fromViewColumn
(
viewColumn
),
options
,
extensionFolderPath
);
const
panel
=
new
ExtHostWebviewPanel
(
handle
,
this
.
_proxy
,
viewType
,
title
,
viewColumn
,
options
,
options
);
this
.
_webviewPanels
.
set
(
handle
,
panel
);
...
...
@@ -235,14 +235,14 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
});
}
$onMessage
(
handle
:
WebviewHandle
,
message
:
any
):
void
{
$onMessage
(
handle
:
Webview
Panel
Handle
,
message
:
any
):
void
{
const
panel
=
this
.
getWebviewPanel
(
handle
);
if
(
panel
)
{
panel
.
webview
.
onMessageEmitter
.
fire
(
message
);
}
}
$onDidChangeWebview
ViewState
(
handle
:
Webview
Handle
,
visible
:
boolean
,
position
:
Position
):
void
{
$onDidChangeWebview
PanelViewState
(
handle
:
WebviewPanel
Handle
,
visible
:
boolean
,
position
:
Position
):
void
{
const
panel
=
this
.
getWebviewPanel
(
handle
);
if
(
panel
)
{
const
viewColumn
=
typeConverters
.
toViewColumn
(
position
);
...
...
@@ -254,7 +254,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
}
}
$onDidDisposeWebview
(
handle
:
Webview
Handle
):
Thenable
<
void
>
{
onDidDisposeWebviewPanel
(
handle
:
WebviewPanel
Handle
):
Thenable
<
void
>
{
const
panel
=
this
.
getWebviewPanel
(
handle
);
if
(
panel
)
{
panel
.
dispose
();
...
...
@@ -263,8 +263,8 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
return
TPromise
.
as
(
void
0
);
}
$deserializeWebview
(
webviewHandle
:
WebviewHandle
,
$deserializeWebview
Panel
(
webviewHandle
:
Webview
Panel
Handle
,
viewType
:
string
,
title
:
string
,
state
:
any
,
...
...
@@ -281,8 +281,8 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
return
serializer
.
deserializeWebviewPanel
(
revivedPanel
,
state
);
}
$serializeWebview
(
webviewHandle
:
WebviewHandle
$serializeWebview
Panel
(
webviewHandle
:
Webview
Panel
Handle
):
Thenable
<
any
>
{
const
panel
=
this
.
getWebviewPanel
(
webviewHandle
);
if
(
!
panel
)
{
...
...
@@ -297,7 +297,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape {
return
serialzer
.
serializeWebviewPanel
(
panel
);
}
private
getWebviewPanel
(
handle
:
WebviewHandle
):
ExtHostWebviewPanel
|
undefined
{
private
getWebviewPanel
(
handle
:
Webview
Panel
Handle
):
ExtHostWebviewPanel
|
undefined
{
return
this
.
_webviewPanels
.
get
(
handle
);
}
}
\ No newline at end of file
src/vs/workbench/test/electron-browser/api/extHostWebview.test.ts
浏览文件 @
ea680fae
...
...
@@ -36,7 +36,7 @@ suite('ExtHostWebview', function () {
const
serializerARegistration
=
extHostWebviews
.
registerWebviewPanelSerializer
(
viewType
,
serializerA
);
await
extHostWebviews
.
$deserializeWebview
(
'
x
'
,
viewType
,
'
title
'
,
{},
EditorPosition
.
ONE
,
{});
await
extHostWebviews
.
$deserializeWebview
Panel
(
'
x
'
,
viewType
,
'
title
'
,
{},
EditorPosition
.
ONE
,
{});
assert
.
strictEqual
(
lastInvokedDeserializer
,
serializerA
);
assert
.
throws
(
...
...
@@ -47,7 +47,7 @@ suite('ExtHostWebview', function () {
extHostWebviews
.
registerWebviewPanelSerializer
(
viewType
,
serializerB
);
await
extHostWebviews
.
$deserializeWebview
(
'
x
'
,
viewType
,
'
title
'
,
{},
EditorPosition
.
ONE
,
{});
await
extHostWebviews
.
$deserializeWebview
Panel
(
'
x
'
,
viewType
,
'
title
'
,
{},
EditorPosition
.
ONE
,
{});
assert
.
strictEqual
(
lastInvokedDeserializer
,
serializerB
);
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录