Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
72cbf699
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,发现更多精彩内容 >>
提交
72cbf699
编写于
8月 26, 2020
作者:
M
Matt Bierner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split out main thread webview panels into own class/file
上级
7e4ccf16
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
50 addition
and
31 deletion
+50
-31
src/vs/workbench/api/browser/extensionHost.contribution.ts
src/vs/workbench/api/browser/extensionHost.contribution.ts
+1
-1
src/vs/workbench/api/browser/mainThreadCustomEditors.ts
src/vs/workbench/api/browser/mainThreadCustomEditors.ts
+4
-4
src/vs/workbench/api/browser/mainThreadWebviewManager.ts
src/vs/workbench/api/browser/mainThreadWebviewManager.ts
+35
-0
src/vs/workbench/api/browser/mainThreadWebviewPanels.ts
src/vs/workbench/api/browser/mainThreadWebviewPanels.ts
+2
-18
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+2
-2
src/vs/workbench/api/common/extHostWebview.ts
src/vs/workbench/api/common/extHostWebview.ts
+4
-4
src/vs/workbench/test/browser/api/extHostWebview.test.ts
src/vs/workbench/test/browser/api/extHostWebview.test.ts
+2
-2
未找到文件。
src/vs/workbench/api/browser/extensionHost.contribution.ts
浏览文件 @
72cbf699
...
...
@@ -54,7 +54,7 @@ import './mainThreadTreeViews';
import
'
./mainThreadDownloadService
'
;
import
'
./mainThreadUrls
'
;
import
'
./mainThreadWindow
'
;
import
'
./mainThreadWebview
PanelsAndViews
'
;
import
'
./mainThreadWebview
Manager
'
;
import
'
./mainThreadWorkspace
'
;
import
'
./mainThreadComments
'
;
import
'
./mainThreadNotebook
'
;
...
...
src/vs/workbench/api/browser/mainThreadCustomEditors.ts
浏览文件 @
72cbf699
...
...
@@ -19,7 +19,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
IUndoRedoService
,
UndoRedoElementType
}
from
'
vs/platform/undoRedo/common/undoRedo
'
;
import
type
{
MainThreadWebviewPanelsAndViews
}
from
'
vs/workbench/api/browser/mainThreadWebviewPanelsAndView
s
'
;
import
{
MainThreadWebviewPanels
}
from
'
vs/workbench/api/browser/mainThreadWebviewPanel
s
'
;
import
{
MainThreadWebviews
,
reviveWebviewExtension
}
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
'
;
...
...
@@ -49,7 +49,7 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc
constructor
(
private
readonly
mainThreadWebview
:
MainThreadWebviews
,
private
readonly
mainThreadWebviewPanels
AndViews
:
MainThreadWebviewPanelsAndView
s
,
private
readonly
mainThreadWebviewPanels
:
MainThreadWebviewPanel
s
,
context
:
extHostProtocol
.
IExtHostContext
,
@
IWorkingCopyService
workingCopyService
:
IWorkingCopyService
,
@
IWorkingCopyFileService
workingCopyFileService
:
IWorkingCopyFileService
,
...
...
@@ -121,7 +121,7 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc
const
handle
=
webviewInput
.
id
;
const
resource
=
webviewInput
.
resource
;
this
.
mainThreadWebviewPanels
AndViews
.
addWebviewInput
(
handle
,
webviewInput
);
this
.
mainThreadWebviewPanels
.
addWebviewInput
(
handle
,
webviewInput
);
webviewInput
.
webview
.
options
=
options
;
webviewInput
.
webview
.
extension
=
extension
;
...
...
@@ -210,7 +210,7 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc
case
CustomEditorModelType
.
Custom
:
{
const
model
=
MainThreadCustomEditorModel
.
create
(
this
.
_instantiationService
,
this
.
_proxyCustomEditors
,
viewType
,
resource
,
options
,
()
=>
{
return
Array
.
from
(
this
.
mainThreadWebviewPanels
AndViews
.
webviewInputs
)
return
Array
.
from
(
this
.
mainThreadWebviewPanels
.
webviewInputs
)
.
filter
(
editor
=>
editor
instanceof
CustomEditorInput
&&
isEqual
(
editor
.
resource
,
resource
))
as
CustomEditorInput
[];
},
cancellation
,
this
.
_backupService
);
return
this
.
_customEditorService
.
models
.
add
(
resource
,
viewType
,
model
);
...
...
src/vs/workbench/api/browser/mainThreadWebviewManager.ts
0 → 100644
浏览文件 @
72cbf699
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
MainThreadCustomEditors
}
from
'
vs/workbench/api/browser/mainThreadCustomEditors
'
;
import
{
MainThreadWebviewPanels
}
from
'
vs/workbench/api/browser/mainThreadWebviewPanels
'
;
import
{
MainThreadWebviews
}
from
'
vs/workbench/api/browser/mainThreadWebviews
'
;
import
{
MainThreadWebviewsViews
}
from
'
vs/workbench/api/browser/mainThreadWebviewViews
'
;
import
*
as
extHostProtocol
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
extHostCustomer
}
from
'
../common/extHostCustomers
'
;
@
extHostCustomer
export
class
MainThreadWebviewManager
extends
Disposable
{
constructor
(
context
:
extHostProtocol
.
IExtHostContext
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
)
{
super
();
const
webviews
=
this
.
_register
(
instantiationService
.
createInstance
(
MainThreadWebviews
,
context
));
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadWebviews
,
webviews
);
const
webviewPanels
=
this
.
_register
(
instantiationService
.
createInstance
(
MainThreadWebviewPanels
,
webviews
,
context
));
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadWebviewPanels
,
webviewPanels
);
const
customEditors
=
this
.
_register
(
instantiationService
.
createInstance
(
MainThreadCustomEditors
,
webviews
,
webviewPanels
,
context
));
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadCustomEditors
,
customEditors
);
const
webviewViews
=
this
.
_register
(
instantiationService
.
createInstance
(
MainThreadWebviewsViews
,
webviews
,
context
));
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadWebviewViews
,
webviewViews
);
}
}
src/vs/workbench/api/browser/mainThreadWebviewPanels
AndViews
.ts
→
src/vs/workbench/api/browser/mainThreadWebviewPanels.ts
浏览文件 @
72cbf699
...
...
@@ -6,11 +6,8 @@
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
{
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
'
;
...
...
@@ -22,7 +19,6 @@ import { ICreateWebViewShowOptions, IWebviewWorkbenchService, WebviewInputOption
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
'
;
/**
* Bi-directional map between webview handles and inputs.
...
...
@@ -77,8 +73,7 @@ class WebviewViewTypeTransformer {
}
}
@
extHostNamedCustomer
(
extHostProtocol
.
MainContext
.
MainThreadWebviewService
)
export
class
MainThreadWebviewPanelsAndViews
extends
Disposable
implements
extHostProtocol
.
MainThreadWebviewPanelsAndViewsShape
{
export
class
MainThreadWebviewPanels
extends
Disposable
implements
extHostProtocol
.
MainThreadWebviewPanelsShape
{
private
readonly
webviewPanelViewType
=
new
WebviewViewTypeTransformer
(
'
mainThreadWebview-
'
);
...
...
@@ -89,32 +84,21 @@ export class MainThreadWebviewPanelsAndViews extends Disposable implements extHo
private
readonly
_editorProviders
=
new
Map
<
string
,
IDisposable
>
();
private
readonly
_webviewFromDiffEditorHandles
=
new
Set
<
string
>
();
private
readonly
_mainThreadWebviews
:
MainThreadWebviews
;
private
readonly
_revivers
=
new
Map
<
string
,
IDisposable
>
();
constructor
(
private
readonly
_mainThreadWebviews
:
MainThreadWebviews
,
context
:
extHostProtocol
.
IExtHostContext
,
@
IExtensionService
extensionService
:
IExtensionService
,
@
IEditorGroupsService
private
readonly
_editorGroupService
:
IEditorGroupsService
,
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
ITelemetryService
private
readonly
_telemetryService
:
ITelemetryService
,
@
IWebviewWorkbenchService
private
readonly
_webviewWorkbenchService
:
IWebviewWorkbenchService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
)
{
super
();
this
.
_proxy
=
context
.
getProxy
(
extHostProtocol
.
ExtHostContext
.
ExtHostWebviewPanels
);
this
.
_mainThreadWebviews
=
this
.
_instantiationService
.
createInstance
(
MainThreadWebviews
,
context
);
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadWebviews
,
this
.
_mainThreadWebviews
);
const
webviewViews
=
this
.
_instantiationService
.
createInstance
(
MainThreadWebviewsViews
,
this
.
_mainThreadWebviews
,
context
);
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadWebviewViews
,
webviewViews
);
const
customEditors
=
this
.
_instantiationService
.
createInstance
(
MainThreadCustomEditors
,
this
.
_mainThreadWebviews
,
this
,
context
);
context
.
set
(
extHostProtocol
.
MainContext
.
MainThreadCustomEditors
,
customEditors
);
this
.
_register
(
_editorService
.
onDidActiveEditorChange
(()
=>
{
const
activeInput
=
this
.
_editorService
.
activeEditor
;
if
(
activeInput
instanceof
DiffEditorInput
&&
activeInput
.
primary
instanceof
WebviewInput
&&
activeInput
.
secondary
instanceof
WebviewInput
)
{
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
72cbf699
...
...
@@ -614,7 +614,7 @@ export interface MainThreadWebviewsShape extends IDisposable {
$postMessage
(
handle
:
WebviewHandle
,
value
:
any
):
Promise
<
boolean
>
}
export
interface
MainThreadWebviewPanels
AndViews
Shape
extends
IDisposable
{
export
interface
MainThreadWebviewPanelsShape
extends
IDisposable
{
$createWebviewPanel
(
extension
:
WebviewExtensionDescription
,
handle
:
WebviewHandle
,
viewType
:
string
,
title
:
string
,
showOptions
:
WebviewPanelShowOptions
,
options
:
modes
.
IWebviewPanelOptions
&
modes
.
IWebviewOptions
):
void
;
$disposeWebview
(
handle
:
WebviewHandle
):
void
;
$reveal
(
handle
:
WebviewHandle
,
showOptions
:
WebviewPanelShowOptions
):
void
;
...
...
@@ -1720,8 +1720,8 @@ export const MainContext = {
MainThreadStorage
:
createMainId
<
MainThreadStorageShape
>
(
'
MainThreadStorage
'
),
MainThreadTelemetry
:
createMainId
<
MainThreadTelemetryShape
>
(
'
MainThreadTelemetry
'
),
MainThreadTerminalService
:
createMainId
<
MainThreadTerminalServiceShape
>
(
'
MainThreadTerminalService
'
),
MainThreadWebviewService
:
createMainId
<
MainThreadWebviewPanelsAndViewsShape
>
(
'
MainThreadWebviewService
'
),
MainThreadWebviews
:
createMainId
<
MainThreadWebviewsShape
>
(
'
MainThreadWebviews
'
),
MainThreadWebviewPanels
:
createMainId
<
MainThreadWebviewPanelsShape
>
(
'
MainThreadWebviewPanels
'
),
MainThreadWebviewViews
:
createMainId
<
MainThreadWebviewViewsShape
>
(
'
MainThreadWebviewViews
'
),
MainThreadCustomEditors
:
createMainId
<
MainThreadCustomEditorsShape
>
(
'
MainThreadCustomEditors
'
),
MainThreadUrls
:
createMainId
<
MainThreadUrlsShape
>
(
'
MainThreadUrls
'
),
...
...
src/vs/workbench/api/common/extHostWebview.ts
浏览文件 @
72cbf699
...
...
@@ -122,7 +122,7 @@ type IconPath = URI | { light: URI, dark: URI };
class
ExtHostWebviewPanel
extends
Disposable
implements
vscode
.
WebviewPanel
{
readonly
#
handle
:
extHostProtocol
.
WebviewHandle
;
readonly
#
proxy
:
extHostProtocol
.
MainThreadWebviewPanels
AndViews
Shape
;
readonly
#
proxy
:
extHostProtocol
.
MainThreadWebviewPanelsShape
;
readonly
#
viewType
:
string
;
readonly
#
webview
:
ExtHostWebview
;
...
...
@@ -143,7 +143,7 @@ class ExtHostWebviewPanel extends Disposable implements vscode.WebviewPanel {
constructor
(
handle
:
extHostProtocol
.
WebviewHandle
,
proxy
:
extHostProtocol
.
MainThreadWebviewPanels
AndViews
Shape
,
proxy
:
extHostProtocol
.
MainThreadWebviewPanelsShape
,
viewType
:
string
,
title
:
string
,
viewColumn
:
vscode
.
ViewColumn
|
undefined
,
...
...
@@ -269,7 +269,7 @@ export class ExtHostWebviews implements extHostProtocol.ExtHostWebviewsShape, ex
return
generateUuid
();
}
private
readonly
_proxy
:
extHostProtocol
.
MainThreadWebviewPanels
AndViews
Shape
;
private
readonly
_proxy
:
extHostProtocol
.
MainThreadWebviewPanelsShape
;
private
readonly
_webviewProxy
:
extHostProtocol
.
MainThreadWebviewsShape
;
private
readonly
_webviews
=
new
Map
<
extHostProtocol
.
WebviewHandle
,
ExtHostWebview
>
();
...
...
@@ -287,7 +287,7 @@ export class ExtHostWebviews implements extHostProtocol.ExtHostWebviewsShape, ex
private
readonly
_logService
:
ILogService
,
private
readonly
_deprecationService
:
IExtHostApiDeprecationService
,
)
{
this
.
_proxy
=
mainContext
.
getProxy
(
extHostProtocol
.
MainContext
.
MainThreadWebview
Service
);
this
.
_proxy
=
mainContext
.
getProxy
(
extHostProtocol
.
MainContext
.
MainThreadWebview
Panels
);
this
.
_webviewProxy
=
mainContext
.
getProxy
(
extHostProtocol
.
MainContext
.
MainThreadWebviews
);
}
...
...
src/vs/workbench/test/browser/api/extHostWebview.test.ts
浏览文件 @
72cbf699
...
...
@@ -8,7 +8,7 @@ import { URI } from 'vs/base/common/uri';
import
{
mock
}
from
'
vs/base/test/common/mock
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
NullLogService
}
from
'
vs/platform/log/common/log
'
;
import
{
MainThreadWebview
PanelsAndViews
}
from
'
vs/workbench/api/browser/mainThreadWebviewPanelsAndViews
'
;
import
{
MainThreadWebview
Manager
}
from
'
vs/workbench/api/browser/mainThreadWebviewManager
'
;
import
{
IExtHostContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
NullApiDeprecationService
}
from
'
vs/workbench/api/common/extHostApiDeprecationService
'
;
import
{
IExtHostRpcService
}
from
'
vs/workbench/api/common/extHostRpcService
'
;
...
...
@@ -150,7 +150,7 @@ suite('ExtHostWebview', () => {
function
createNoopMainThreadWebviews
()
{
return
new
class
extends
mock
<
MainThreadWebview
PanelsAndViews
>
()
{
return
new
class
extends
mock
<
MainThreadWebview
Manager
>
()
{
$createWebviewPanel
()
{
/* noop */
}
$registerSerializer
()
{
/* noop */
}
$unregisterSerializer
()
{
/* noop */
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录