Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
51ba70d4
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,发现更多精彩内容 >>
提交
51ba70d4
编写于
8月 26, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Undo split of serializers into own main thread class
The serializers belong with the panels, not in their own class
上级
4d88b39b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
76 addition
and
117 deletion
+76
-117
src/vs/workbench/api/browser/mainThreadWebviewPanelsAndViews.ts
.../workbench/api/browser/mainThreadWebviewPanelsAndViews.ts
+72
-8
src/vs/workbench/api/browser/mainThreadWebviewSerializer.ts
src/vs/workbench/api/browser/mainThreadWebviewSerializer.ts
+0
-105
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+2
-2
src/vs/workbench/api/common/extHostWebviewSerializer.ts
src/vs/workbench/api/common/extHostWebviewSerializer.ts
+1
-1
未找到文件。
src/vs/workbench/api/browser/mainThreadWebviewPanelsAndViews.ts
浏览文件 @
51ba70d4
...
...
@@ -3,23 +3,25 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Disposable
,
DisposableStore
,
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
MainThreadCustomEditors
}
from
'
vs/workbench/api/browser/mainThreadCustomEditors
'
;
import
{
MainThreadWebviews
,
reviveWebviewExtension
,
reviveWebviewOptions
}
from
'
vs/workbench/api/browser/mainThreadWebviews
'
;
import
{
MainThreadWebviewSerializers
}
from
'
vs/workbench/api/browser/mainThreadWebviewSerializer
'
;
import
{
MainThreadWebviewsViews
}
from
'
vs/workbench/api/browser/mainThreadWebviewViews
'
;
import
*
as
extHostProtocol
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
editorGroupToViewColumn
,
EditorViewColumn
,
viewColumnToEditorGroup
}
from
'
vs/workbench/api/common/shared/editor
'
;
import
{
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
CustomEditorInput
}
from
'
vs/workbench/contrib/customEditor/browser/customEditorInput
'
;
import
{
WebviewIcons
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
WebviewInput
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInput
'
;
import
{
ICreateWebViewShowOptions
,
IWebviewWorkbenchService
,
WebviewInputOptions
}
from
'
vs/workbench/contrib/webview/browser/webviewWorkbenchService
'
;
import
{
IEditorGroup
,
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
extHostNamedCustomer
}
from
'
../common/extHostCustomers
'
;
/**
...
...
@@ -78,9 +80,10 @@ class WebviewViewTypeTransformer {
@
extHostNamedCustomer
(
extHostProtocol
.
MainContext
.
MainThreadWebviewService
)
export
class
MainThreadWebviewPanelsAndViews
extends
Disposable
implements
extHostProtocol
.
MainThreadWebviewPanelsAndViewsShape
{
p
ublic
readonly
webviewPanelViewType
=
new
WebviewViewTypeTransformer
(
'
mainThreadWebview-
'
);
p
rivate
readonly
webviewPanelViewType
=
new
WebviewViewTypeTransformer
(
'
mainThreadWebview-
'
);
private
readonly
_proxy
:
extHostProtocol
.
ExtHostWebviewsShape
;
private
readonly
_proxyPanels
:
extHostProtocol
.
ExtHostWebviewPanelsShape
;
private
readonly
_webviewInputs
=
new
WebviewInputStore
();
...
...
@@ -89,10 +92,11 @@ export class MainThreadWebviewPanelsAndViews extends Disposable implements extHo
private
readonly
_mainThreadWebviews
:
MainThreadWebviews
;
private
readonly
serializers
:
MainThreadWebviewSerializers
;
private
readonly
_revivers
=
new
Map
<
string
,
IDisposable
>
()
;
constructor
(
context
:
extHostProtocol
.
IExtHostContext
,
@
IExtensionService
extensionService
:
IExtensionService
,
@
IEditorGroupsService
private
readonly
_editorGroupService
:
IEditorGroupsService
,
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
ITelemetryService
private
readonly
_telemetryService
:
ITelemetryService
,
...
...
@@ -102,6 +106,7 @@ export class MainThreadWebviewPanelsAndViews extends Disposable implements extHo
super
();
this
.
_proxy
=
context
.
getProxy
(
extHostProtocol
.
ExtHostContext
.
ExtHostWebviews
);
this
.
_proxyPanels
=
context
.
getProxy
(
extHostProtocol
.
ExtHostContext
.
ExtHostWebviewPanels
);
this
.
_mainThreadWebviews
=
this
.
_instantiationService
.
createInstance
(
MainThreadWebviews
,
context
);
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadWebviews
,
this
.
_mainThreadWebviews
);
...
...
@@ -112,8 +117,6 @@ export class MainThreadWebviewPanelsAndViews extends Disposable implements extHo
const
customEditors
=
this
.
_instantiationService
.
createInstance
(
MainThreadCustomEditors
,
this
.
_mainThreadWebviews
,
this
,
context
);
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadCustomEditors
,
customEditors
);
this
.
serializers
=
this
.
_instantiationService
.
createInstance
(
MainThreadWebviewSerializers
,
this
.
_mainThreadWebviews
,
this
,
context
);
this
.
_register
(
_editorService
.
onDidActiveEditorChange
(()
=>
{
const
activeInput
=
this
.
_editorService
.
activeEditor
;
if
(
activeInput
instanceof
DiffEditorInput
&&
activeInput
.
primary
instanceof
WebviewInput
&&
activeInput
.
secondary
instanceof
WebviewInput
)
{
...
...
@@ -126,6 +129,24 @@ export class MainThreadWebviewPanelsAndViews extends Disposable implements extHo
this
.
_register
(
_editorService
.
onDidVisibleEditorsChange
(()
=>
{
this
.
updateWebviewViewStates
(
this
.
_editorService
.
activeEditor
);
}));
// This reviver's only job is to activate extensions.
// This should trigger the real reviver to be registered from the extension host side.
this
.
_register
(
_webviewWorkbenchService
.
registerResolver
({
canResolve
:
(
webview
:
WebviewInput
)
=>
{
if
(
webview
instanceof
CustomEditorInput
)
{
extensionService
.
activateByEvent
(
`onCustomEditor:
${
webview
.
viewType
}
`
);
return
false
;
}
const
viewType
=
this
.
webviewPanelViewType
.
toExternal
(
webview
.
viewType
);
if
(
typeof
viewType
===
'
string
'
)
{
extensionService
.
activateByEvent
(
`onWebviewPanel:
${
viewType
}
`
);
}
return
false
;
},
resolveWebview
:
()
=>
{
throw
new
Error
(
'
not implemented
'
);
}
}));
}
dispose
()
{
...
...
@@ -205,12 +226,55 @@ export class MainThreadWebviewPanelsAndViews extends Disposable implements extHo
}
}
public
$registerSerializer
(
viewType
:
string
):
void
{
this
.
serializers
.
$registerSerializer
(
viewType
);
public
$registerSerializer
(
viewType
:
string
)
:
void
{
if
(
this
.
_revivers
.
has
(
viewType
))
{
throw
new
Error
(
`Reviver for
${
viewType
}
already registered`
);
}
this
.
_revivers
.
set
(
viewType
,
this
.
_webviewWorkbenchService
.
registerResolver
({
canResolve
:
(
webviewInput
)
=>
{
return
webviewInput
.
viewType
===
this
.
webviewPanelViewType
.
fromExternal
(
viewType
);
},
resolveWebview
:
async
(
webviewInput
):
Promise
<
void
>
=>
{
const
viewType
=
this
.
webviewPanelViewType
.
toExternal
(
webviewInput
.
viewType
);
if
(
!
viewType
)
{
webviewInput
.
webview
.
html
=
this
.
_mainThreadWebviews
.
getWebviewResolvedFailedContent
(
webviewInput
.
viewType
);
return
;
}
const
handle
=
webviewInput
.
id
;
this
.
addWebviewInput
(
handle
,
webviewInput
);
let
state
=
undefined
;
if
(
webviewInput
.
webview
.
state
)
{
try
{
state
=
JSON
.
parse
(
webviewInput
.
webview
.
state
);
}
catch
(
e
)
{
console
.
error
(
'
Could not load webview state
'
,
e
,
webviewInput
.
webview
.
state
);
}
}
try
{
await
this
.
_proxyPanels
.
$deserializeWebviewPanel
(
handle
,
viewType
,
webviewInput
.
getTitle
(),
state
,
editorGroupToViewColumn
(
this
.
_editorGroupService
,
webviewInput
.
group
||
0
),
webviewInput
.
webview
.
options
);
}
catch
(
error
)
{
onUnexpectedError
(
error
);
webviewInput
.
webview
.
html
=
this
.
_mainThreadWebviews
.
getWebviewResolvedFailedContent
(
viewType
);
}
}
}));
}
public
$unregisterSerializer
(
viewType
:
string
):
void
{
this
.
serializers
.
$unregisterSerializer
(
viewType
);
const
reviver
=
this
.
_revivers
.
get
(
viewType
);
if
(
!
reviver
)
{
throw
new
Error
(
`No reviver for
${
viewType
}
registered`
);
}
reviver
.
dispose
();
this
.
_revivers
.
delete
(
viewType
);
}
private
registerWebviewFromDiffEditorListeners
(
diffEditorInput
:
DiffEditorInput
):
void
{
...
...
src/vs/workbench/api/browser/mainThreadWebviewSerializer.ts
已删除
100644 → 0
浏览文件 @
4d88b39b
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
type
{
MainThreadWebviewPanelsAndViews
}
from
'
vs/workbench/api/browser/mainThreadWebviewPanelsAndViews
'
;
import
{
MainThreadWebviews
}
from
'
vs/workbench/api/browser/mainThreadWebviews
'
;
import
*
as
extHostProtocol
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
editorGroupToViewColumn
}
from
'
vs/workbench/api/common/shared/editor
'
;
import
{
CustomEditorInput
}
from
'
vs/workbench/contrib/customEditor/browser/customEditorInput
'
;
import
{
WebviewInput
}
from
'
vs/workbench/contrib/webview/browser/webviewEditorInput
'
;
import
{
IWebviewWorkbenchService
}
from
'
vs/workbench/contrib/webview/browser/webviewWorkbenchService
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
export
class
MainThreadWebviewSerializers
extends
Disposable
{
private
readonly
_proxy
:
extHostProtocol
.
ExtHostWebviewSerializerShape
;
private
readonly
_revivers
=
new
Map
<
string
,
IDisposable
>
();
constructor
(
private
readonly
mainThreadWebviews
:
MainThreadWebviews
,
private
readonly
mainThreadWebviewsPanelsAndViews
:
MainThreadWebviewPanelsAndViews
,
context
:
extHostProtocol
.
IExtHostContext
,
@
IExtensionService
extensionService
:
IExtensionService
,
@
IEditorGroupsService
private
readonly
_editorGroupService
:
IEditorGroupsService
,
@
IWebviewWorkbenchService
private
readonly
_webviewWorkbenchService
:
IWebviewWorkbenchService
,
)
{
super
();
this
.
_proxy
=
context
.
getProxy
(
extHostProtocol
.
ExtHostContext
.
ExtHostWebviewSerializer
);
// This reviver's only job is to activate extensions.
// This should trigger the real reviver to be registered from the extension host side.
this
.
_register
(
_webviewWorkbenchService
.
registerResolver
({
canResolve
:
(
webview
:
WebviewInput
)
=>
{
if
(
webview
instanceof
CustomEditorInput
)
{
extensionService
.
activateByEvent
(
`onCustomEditor:
${
webview
.
viewType
}
`
);
return
false
;
}
const
viewType
=
this
.
mainThreadWebviewsPanelsAndViews
.
webviewPanelViewType
.
toExternal
(
webview
.
viewType
);
if
(
typeof
viewType
===
'
string
'
)
{
extensionService
.
activateByEvent
(
`onWebviewPanel:
${
viewType
}
`
);
}
return
false
;
},
resolveWebview
:
()
=>
{
throw
new
Error
(
'
not implemented
'
);
}
}));
}
public
$registerSerializer
(
viewType
:
string
)
:
void
{
if
(
this
.
_revivers
.
has
(
viewType
))
{
throw
new
Error
(
`Reviver for
${
viewType
}
already registered`
);
}
this
.
_revivers
.
set
(
viewType
,
this
.
_webviewWorkbenchService
.
registerResolver
({
canResolve
:
(
webviewInput
)
=>
{
return
webviewInput
.
viewType
===
this
.
mainThreadWebviewsPanelsAndViews
.
webviewPanelViewType
.
fromExternal
(
viewType
);
},
resolveWebview
:
async
(
webviewInput
):
Promise
<
void
>
=>
{
const
viewType
=
this
.
mainThreadWebviewsPanelsAndViews
.
webviewPanelViewType
.
toExternal
(
webviewInput
.
viewType
);
if
(
!
viewType
)
{
webviewInput
.
webview
.
html
=
this
.
mainThreadWebviews
.
getWebviewResolvedFailedContent
(
webviewInput
.
viewType
);
return
;
}
const
handle
=
webviewInput
.
id
;
this
.
mainThreadWebviewsPanelsAndViews
.
addWebviewInput
(
handle
,
webviewInput
);
let
state
=
undefined
;
if
(
webviewInput
.
webview
.
state
)
{
try
{
state
=
JSON
.
parse
(
webviewInput
.
webview
.
state
);
}
catch
(
e
)
{
console
.
error
(
'
Could not load webview state
'
,
e
,
webviewInput
.
webview
.
state
);
}
}
try
{
await
this
.
_proxy
.
$deserializeWebviewPanel
(
handle
,
viewType
,
webviewInput
.
getTitle
(),
state
,
editorGroupToViewColumn
(
this
.
_editorGroupService
,
webviewInput
.
group
||
0
),
webviewInput
.
webview
.
options
);
}
catch
(
error
)
{
onUnexpectedError
(
error
);
webviewInput
.
webview
.
html
=
this
.
mainThreadWebviews
.
getWebviewResolvedFailedContent
(
viewType
);
}
}
}));
}
public
$unregisterSerializer
(
viewType
:
string
):
void
{
const
reviver
=
this
.
_revivers
.
get
(
viewType
);
if
(
!
reviver
)
{
throw
new
Error
(
`No reviver for
${
viewType
}
registered`
);
}
reviver
.
dispose
();
this
.
_revivers
.
delete
(
viewType
);
}
}
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
51ba70d4
...
...
@@ -145,7 +145,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const
extHostAuthentication
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostAuthentication
,
new
ExtHostAuthentication
(
rpcProtocol
));
const
extHostTimeline
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostTimeline
,
new
ExtHostTimeline
(
rpcProtocol
,
extHostCommands
));
const
extHostWebviews
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWebviews
,
new
ExtHostWebviews
(
rpcProtocol
,
initData
.
environment
,
extHostWorkspace
,
extHostLogService
,
extHostApiDeprecation
));
const
extHostWebviewSerializers
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWebview
Serializer
,
new
ExtHostWebviewSerializer
(
rpcProtocol
,
extHostWebviews
));
const
extHostWebviewSerializers
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWebview
Panels
,
new
ExtHostWebviewSerializer
(
rpcProtocol
,
extHostWebviews
));
const
extHostCustomEditors
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostCustomEditors
,
new
ExtHostCustomEditors
(
rpcProtocol
,
extHostDocuments
,
extensionStoragePaths
,
extHostWebviews
));
const
extHostWebviewViews
=
rpcProtocol
.
set
(
ExtHostContext
.
ExtHostWebviewViews
,
new
ExtHostWebviewViews
(
rpcProtocol
,
extHostWebviews
));
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
51ba70d4
...
...
@@ -656,7 +656,7 @@ export interface ExtHostWebviewsShape {
$onDidDisposeWebviewPanel
(
handle
:
WebviewPanelHandle
):
Promise
<
void
>
;
}
export
interface
ExtHostWebview
Serializer
Shape
{
export
interface
ExtHostWebview
Panels
Shape
{
$deserializeWebviewPanel
(
newWebviewHandle
:
WebviewPanelHandle
,
viewType
:
string
,
title
:
string
,
state
:
any
,
position
:
EditorViewColumn
,
options
:
modes
.
IWebviewOptions
&
modes
.
IWebviewPanelOptions
):
Promise
<
void
>
;
}
...
...
@@ -1764,7 +1764,7 @@ export const ExtHostContext = {
ExtHostWorkspace
:
createExtId
<
ExtHostWorkspaceShape
>
(
'
ExtHostWorkspace
'
),
ExtHostWindow
:
createExtId
<
ExtHostWindowShape
>
(
'
ExtHostWindow
'
),
ExtHostWebviews
:
createExtId
<
ExtHostWebviewsShape
>
(
'
ExtHostWebviews
'
),
ExtHostWebview
Serializer
:
createExtId
<
ExtHostWebviewSerializerShape
>
(
'
ExtHostWebviewSerializer
'
),
ExtHostWebview
Panels
:
createExtId
<
ExtHostWebviewPanelsShape
>
(
'
ExtHostWebviewPanels
'
),
ExtHostCustomEditors
:
createExtId
<
ExtHostCustomEditorsShape
>
(
'
ExtHostCustomEditors
'
),
ExtHostWebviewViews
:
createExtId
<
ExtHostWebviewViewsShape
>
(
'
ExtHostWebviewViews
'
),
ExtHostEditorInsets
:
createExtId
<
ExtHostEditorInsetsShape
>
(
'
ExtHostEditorInsets
'
),
...
...
src/vs/workbench/api/common/extHostWebviewSerializer.ts
浏览文件 @
51ba70d4
...
...
@@ -11,7 +11,7 @@ import type * as vscode from 'vscode';
import
*
as
extHostProtocol
from
'
./extHost.protocol
'
;
import
*
as
extHostTypes
from
'
./extHostTypes
'
;
export
class
ExtHostWebviewSerializer
implements
extHostProtocol
.
ExtHostWebview
Serializer
Shape
{
export
class
ExtHostWebviewSerializer
implements
extHostProtocol
.
ExtHostWebview
Panels
Shape
{
private
readonly
_proxy
:
extHostProtocol
.
MainThreadWebviewPanelsAndViewsShape
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录