@codingame/monaco-vscode-view-common-service-override 4.5.0-improve-code-splitting.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/fake.html +10 -0
- package/assets/index-no-csp.html +1230 -0
- package/assets/index.html +1231 -0
- package/assets/service-worker.js +457 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.js +5 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +11 -0
- package/package.json +32 -0
- package/tools/editorAssets.js +4 -0
- package/tools/url.js +10 -0
- package/viewCommon.d.ts +5 -0
- package/viewCommon.js +105 -0
- package/vscode/src/vs/base/browser/deviceAccess.js +61 -0
- package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +180 -0
- package/vscode/src/vs/base/browser/ui/grid/grid.js +494 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +6 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.js +1113 -0
- package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +12 -0
- package/vscode/src/vs/platform/webview/common/mimeTypes.js +24 -0
- package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +64 -0
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +907 -0
- package/vscode/src/vs/workbench/browser/actions/listCommands.js +764 -0
- package/vscode/src/vs/workbench/browser/actions/navigationActions.js +301 -0
- package/vscode/src/vs/workbench/browser/media/style.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +671 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +229 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/compositeBar.js +606 -0
- package/vscode/src/vs/workbench/browser/parts/compositePart.js +346 -0
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +246 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1403 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +188 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +523 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1030 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +391 -0
- package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +472 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +68 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +160 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +39 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +238 -0
- package/vscode/src/vs/workbench/browser/style.js +54 -0
- package/vscode/src/vs/workbench/browser/window.js +381 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +300 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +367 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +135 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +18 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +146 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +215 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +78 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +56 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +63 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +183 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +8 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +147 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +635 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +230 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +75 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +81 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +350 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +100 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +148 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +106 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +403 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +199 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +41 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +128 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +619 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +161 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +266 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +173 -0
- package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +195 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +38 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +41 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +283 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +362 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +133 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +314 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +96 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +98 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +656 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +65 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +59 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +143 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +121 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +234 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewService.js +45 -0
- package/vscode/src/vs/workbench/services/activity/browser/activityService.js +145 -0
- package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +341 -0
- package/vscode/src/vs/workbench/services/driver/browser/driver.js +186 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorPaneService.js +13 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +676 -0
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +1516 -0
- package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +6 -0
- package/vscode/src/vs/workbench/services/progress/browser/progressService.js +527 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +102 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +133 -0
- package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
- package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +603 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { getWindowById } from 'vscode/vscode/vs/base/browser/dom';
|
|
3
|
+
import { FastDomNode } from 'vscode/vscode/vs/base/browser/fastDomNode';
|
|
4
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
5
|
+
import { Disposable, MutableDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
6
|
+
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
7
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
8
|
+
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
9
|
+
import { KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_ENABLED } from 'vscode/vscode/vs/workbench/contrib/webview/browser/webview';
|
|
10
|
+
import { IWebviewService } from 'vscode/vscode/vs/workbench/contrib/webview/browser/webview.service';
|
|
11
|
+
|
|
12
|
+
let OverlayWebview = class OverlayWebview extends Disposable {
|
|
13
|
+
get window() { return getWindowById(this._windowId, true).window; }
|
|
14
|
+
constructor(initInfo, _layoutService, _webviewService, _baseContextKeyService) {
|
|
15
|
+
super();
|
|
16
|
+
this._layoutService = _layoutService;
|
|
17
|
+
this._webviewService = _webviewService;
|
|
18
|
+
this._baseContextKeyService = _baseContextKeyService;
|
|
19
|
+
this._isFirstLoad = true;
|
|
20
|
+
this._firstLoadPendingMessages = ( new Set());
|
|
21
|
+
this._webview = this._register(( new MutableDisposable()));
|
|
22
|
+
this._webviewEvents = this._register(( new DisposableStore()));
|
|
23
|
+
this._html = '';
|
|
24
|
+
this._initialScrollProgress = 0;
|
|
25
|
+
this._state = undefined;
|
|
26
|
+
this._owner = undefined;
|
|
27
|
+
this._windowId = undefined;
|
|
28
|
+
this._scopedContextKeyService = this._register(( new MutableDisposable()));
|
|
29
|
+
this._shouldShowFindWidgetOnRestore = false;
|
|
30
|
+
this._isDisposed = false;
|
|
31
|
+
this._onDidDispose = this._register(( new Emitter()));
|
|
32
|
+
this.onDidDispose = this._onDidDispose.event;
|
|
33
|
+
this._onDidFocus = this._register(( new Emitter()));
|
|
34
|
+
this.onDidFocus = this._onDidFocus.event;
|
|
35
|
+
this._onDidBlur = this._register(( new Emitter()));
|
|
36
|
+
this.onDidBlur = this._onDidBlur.event;
|
|
37
|
+
this._onDidClickLink = this._register(( new Emitter()));
|
|
38
|
+
this.onDidClickLink = this._onDidClickLink.event;
|
|
39
|
+
this._onDidReload = this._register(( new Emitter()));
|
|
40
|
+
this.onDidReload = this._onDidReload.event;
|
|
41
|
+
this._onDidScroll = this._register(( new Emitter()));
|
|
42
|
+
this.onDidScroll = this._onDidScroll.event;
|
|
43
|
+
this._onDidUpdateState = this._register(( new Emitter()));
|
|
44
|
+
this.onDidUpdateState = this._onDidUpdateState.event;
|
|
45
|
+
this._onMessage = this._register(( new Emitter()));
|
|
46
|
+
this.onMessage = this._onMessage.event;
|
|
47
|
+
this._onMissingCsp = this._register(( new Emitter()));
|
|
48
|
+
this.onMissingCsp = this._onMissingCsp.event;
|
|
49
|
+
this._onDidWheel = this._register(( new Emitter()));
|
|
50
|
+
this.onDidWheel = this._onDidWheel.event;
|
|
51
|
+
this._onFatalError = this._register(( new Emitter()));
|
|
52
|
+
this.onFatalError = this._onFatalError.event;
|
|
53
|
+
this.providedViewType = initInfo.providedViewType;
|
|
54
|
+
this.origin = initInfo.origin ?? generateUuid();
|
|
55
|
+
this._title = initInfo.title;
|
|
56
|
+
this._extension = initInfo.extension;
|
|
57
|
+
this._options = initInfo.options;
|
|
58
|
+
this._contentOptions = initInfo.contentOptions;
|
|
59
|
+
}
|
|
60
|
+
get isFocused() {
|
|
61
|
+
return !!this._webview.value?.isFocused;
|
|
62
|
+
}
|
|
63
|
+
dispose() {
|
|
64
|
+
this._isDisposed = true;
|
|
65
|
+
this._container?.domNode.remove();
|
|
66
|
+
this._container = undefined;
|
|
67
|
+
for (const msg of this._firstLoadPendingMessages) {
|
|
68
|
+
msg.resolve(false);
|
|
69
|
+
}
|
|
70
|
+
this._firstLoadPendingMessages.clear();
|
|
71
|
+
this._onDidDispose.fire();
|
|
72
|
+
super.dispose();
|
|
73
|
+
}
|
|
74
|
+
get container() {
|
|
75
|
+
if (this._isDisposed) {
|
|
76
|
+
throw new Error(`OverlayWebview has been disposed`);
|
|
77
|
+
}
|
|
78
|
+
if (!this._container) {
|
|
79
|
+
const node = document.createElement('div');
|
|
80
|
+
node.style.position = 'absolute';
|
|
81
|
+
node.style.overflow = 'hidden';
|
|
82
|
+
this._container = ( new FastDomNode(node));
|
|
83
|
+
this._container.setVisibility('hidden');
|
|
84
|
+
this._layoutService.getContainer(this.window).appendChild(node);
|
|
85
|
+
}
|
|
86
|
+
return this._container.domNode;
|
|
87
|
+
}
|
|
88
|
+
claim(owner, targetWindow, scopedContextKeyService) {
|
|
89
|
+
if (this._isDisposed) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const oldOwner = this._owner;
|
|
93
|
+
if (this._windowId !== targetWindow.vscodeWindowId) {
|
|
94
|
+
this.release(oldOwner);
|
|
95
|
+
this._webview.clear();
|
|
96
|
+
this._webviewEvents.clear();
|
|
97
|
+
this._container?.domNode.remove();
|
|
98
|
+
this._container = undefined;
|
|
99
|
+
}
|
|
100
|
+
this._owner = owner;
|
|
101
|
+
this._windowId = targetWindow.vscodeWindowId;
|
|
102
|
+
this._show(targetWindow);
|
|
103
|
+
if (oldOwner !== owner) {
|
|
104
|
+
const contextKeyService = (scopedContextKeyService || this._baseContextKeyService);
|
|
105
|
+
this._scopedContextKeyService.clear();
|
|
106
|
+
this._scopedContextKeyService.value = contextKeyService.createScoped(this.container);
|
|
107
|
+
const wasFindVisible = this._findWidgetVisible?.get();
|
|
108
|
+
this._findWidgetVisible?.reset();
|
|
109
|
+
this._findWidgetVisible = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE.bindTo(contextKeyService);
|
|
110
|
+
this._findWidgetVisible.set(!!wasFindVisible);
|
|
111
|
+
this._findWidgetEnabled?.reset();
|
|
112
|
+
this._findWidgetEnabled = KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_ENABLED.bindTo(contextKeyService);
|
|
113
|
+
this._findWidgetEnabled.set(!!this.options.enableFindWidget);
|
|
114
|
+
this._webview.value?.setContextKeyService(this._scopedContextKeyService.value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
release(owner) {
|
|
118
|
+
if (this._owner !== owner) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
this._scopedContextKeyService.clear();
|
|
122
|
+
this._owner = undefined;
|
|
123
|
+
if (this._container) {
|
|
124
|
+
this._container.setVisibility('hidden');
|
|
125
|
+
}
|
|
126
|
+
if (this._options.retainContextWhenHidden) {
|
|
127
|
+
this._shouldShowFindWidgetOnRestore = !!this._findWidgetVisible?.get();
|
|
128
|
+
this.hideFind(false);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this._webview.clear();
|
|
132
|
+
this._webviewEvents.clear();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
layoutWebviewOverElement(element, dimension, clippingContainer) {
|
|
136
|
+
if (!this._container || !this._container.domNode.parentElement) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const whenContainerStylesLoaded = this._layoutService.whenContainerStylesLoaded(this.window);
|
|
140
|
+
if (whenContainerStylesLoaded) {
|
|
141
|
+
whenContainerStylesLoaded.then(() => this.doLayoutWebviewOverElement(element, dimension, clippingContainer));
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
this.doLayoutWebviewOverElement(element, dimension, clippingContainer);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
doLayoutWebviewOverElement(element, dimension, clippingContainer) {
|
|
148
|
+
if (!this._container || !this._container.domNode.parentElement) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const frameRect = element.getBoundingClientRect();
|
|
152
|
+
const containerRect = this._container.domNode.parentElement.getBoundingClientRect();
|
|
153
|
+
const parentBorderTop = (containerRect.height - this._container.domNode.parentElement.clientHeight) / 2.0;
|
|
154
|
+
const parentBorderLeft = (containerRect.width - this._container.domNode.parentElement.clientWidth) / 2.0;
|
|
155
|
+
this._container.setTop(frameRect.top - containerRect.top - parentBorderTop);
|
|
156
|
+
this._container.setLeft(frameRect.left - containerRect.left - parentBorderLeft);
|
|
157
|
+
this._container.setWidth(dimension ? dimension.width : frameRect.width);
|
|
158
|
+
this._container.setHeight(dimension ? dimension.height : frameRect.height);
|
|
159
|
+
if (clippingContainer) {
|
|
160
|
+
const { top, left, right, bottom } = computeClippingRect(frameRect, clippingContainer);
|
|
161
|
+
this._container.domNode.style.clipPath = `polygon(${left}px ${top}px, ${right}px ${top}px, ${right}px ${bottom}px, ${left}px ${bottom}px)`;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
_show(targetWindow) {
|
|
165
|
+
if (this._isDisposed) {
|
|
166
|
+
throw new Error('OverlayWebview is disposed');
|
|
167
|
+
}
|
|
168
|
+
if (!this._webview.value) {
|
|
169
|
+
const webview = this._webviewService.createWebviewElement({
|
|
170
|
+
providedViewType: this.providedViewType,
|
|
171
|
+
origin: this.origin,
|
|
172
|
+
title: this._title,
|
|
173
|
+
options: this._options,
|
|
174
|
+
contentOptions: this._contentOptions,
|
|
175
|
+
extension: this.extension,
|
|
176
|
+
});
|
|
177
|
+
this._webview.value = webview;
|
|
178
|
+
webview.state = this._state;
|
|
179
|
+
if (this._scopedContextKeyService.value) {
|
|
180
|
+
this._webview.value.setContextKeyService(this._scopedContextKeyService.value);
|
|
181
|
+
}
|
|
182
|
+
if (this._html) {
|
|
183
|
+
webview.setHtml(this._html);
|
|
184
|
+
}
|
|
185
|
+
if (this._options.tryRestoreScrollPosition) {
|
|
186
|
+
webview.initialScrollProgress = this._initialScrollProgress;
|
|
187
|
+
}
|
|
188
|
+
this._findWidgetEnabled?.set(!!this.options.enableFindWidget);
|
|
189
|
+
webview.mountTo(this.container, targetWindow);
|
|
190
|
+
this._webviewEvents.clear();
|
|
191
|
+
this._webviewEvents.add(webview.onDidFocus(() => { this._onDidFocus.fire(); }));
|
|
192
|
+
this._webviewEvents.add(webview.onDidBlur(() => { this._onDidBlur.fire(); }));
|
|
193
|
+
this._webviewEvents.add(webview.onDidClickLink(x => { this._onDidClickLink.fire(x); }));
|
|
194
|
+
this._webviewEvents.add(webview.onMessage(x => { this._onMessage.fire(x); }));
|
|
195
|
+
this._webviewEvents.add(webview.onMissingCsp(x => { this._onMissingCsp.fire(x); }));
|
|
196
|
+
this._webviewEvents.add(webview.onDidWheel(x => { this._onDidWheel.fire(x); }));
|
|
197
|
+
this._webviewEvents.add(webview.onDidReload(() => { this._onDidReload.fire(); }));
|
|
198
|
+
this._webviewEvents.add(webview.onFatalError(x => { this._onFatalError.fire(x); }));
|
|
199
|
+
this._webviewEvents.add(webview.onDidScroll(x => {
|
|
200
|
+
this._initialScrollProgress = x.scrollYPercentage;
|
|
201
|
+
this._onDidScroll.fire(x);
|
|
202
|
+
}));
|
|
203
|
+
this._webviewEvents.add(webview.onDidUpdateState(state => {
|
|
204
|
+
this._state = state;
|
|
205
|
+
this._onDidUpdateState.fire(state);
|
|
206
|
+
}));
|
|
207
|
+
if (this._isFirstLoad) {
|
|
208
|
+
this._firstLoadPendingMessages.forEach(async (msg) => {
|
|
209
|
+
msg.resolve(await webview.postMessage(msg.message, msg.transfer));
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
this._isFirstLoad = false;
|
|
213
|
+
this._firstLoadPendingMessages.clear();
|
|
214
|
+
}
|
|
215
|
+
if (this.options.retainContextWhenHidden && this._shouldShowFindWidgetOnRestore) {
|
|
216
|
+
this.showFind(false);
|
|
217
|
+
this._shouldShowFindWidgetOnRestore = false;
|
|
218
|
+
}
|
|
219
|
+
this._container?.setVisibility('visible');
|
|
220
|
+
}
|
|
221
|
+
setHtml(html) {
|
|
222
|
+
this._html = html;
|
|
223
|
+
this._withWebview(webview => webview.setHtml(html));
|
|
224
|
+
}
|
|
225
|
+
setTitle(title) {
|
|
226
|
+
this._title = title;
|
|
227
|
+
this._withWebview(webview => webview.setTitle(title));
|
|
228
|
+
}
|
|
229
|
+
get initialScrollProgress() { return this._initialScrollProgress; }
|
|
230
|
+
set initialScrollProgress(value) {
|
|
231
|
+
this._initialScrollProgress = value;
|
|
232
|
+
this._withWebview(webview => webview.initialScrollProgress = value);
|
|
233
|
+
}
|
|
234
|
+
get state() { return this._state; }
|
|
235
|
+
set state(value) {
|
|
236
|
+
this._state = value;
|
|
237
|
+
this._withWebview(webview => webview.state = value);
|
|
238
|
+
}
|
|
239
|
+
get extension() { return this._extension; }
|
|
240
|
+
set extension(value) {
|
|
241
|
+
this._extension = value;
|
|
242
|
+
this._withWebview(webview => webview.extension = value);
|
|
243
|
+
}
|
|
244
|
+
get options() { return this._options; }
|
|
245
|
+
set options(value) { this._options = { customClasses: this._options.customClasses, ...value }; }
|
|
246
|
+
get contentOptions() { return this._contentOptions; }
|
|
247
|
+
set contentOptions(value) {
|
|
248
|
+
this._contentOptions = value;
|
|
249
|
+
this._withWebview(webview => webview.contentOptions = value);
|
|
250
|
+
}
|
|
251
|
+
set localResourcesRoot(resources) {
|
|
252
|
+
this._withWebview(webview => webview.localResourcesRoot = resources);
|
|
253
|
+
}
|
|
254
|
+
async postMessage(message, transfer) {
|
|
255
|
+
if (this._webview.value) {
|
|
256
|
+
return this._webview.value.postMessage(message, transfer);
|
|
257
|
+
}
|
|
258
|
+
if (this._isFirstLoad) {
|
|
259
|
+
let resolve;
|
|
260
|
+
const p = ( new Promise(r => resolve = r));
|
|
261
|
+
this._firstLoadPendingMessages.add({ message, transfer, resolve: resolve });
|
|
262
|
+
return p;
|
|
263
|
+
}
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
focus() { this._webview.value?.focus(); }
|
|
267
|
+
reload() { this._webview.value?.reload(); }
|
|
268
|
+
selectAll() { this._webview.value?.selectAll(); }
|
|
269
|
+
copy() { this._webview.value?.copy(); }
|
|
270
|
+
paste() { this._webview.value?.paste(); }
|
|
271
|
+
cut() { this._webview.value?.cut(); }
|
|
272
|
+
undo() { this._webview.value?.undo(); }
|
|
273
|
+
redo() { this._webview.value?.redo(); }
|
|
274
|
+
showFind(animated = true) {
|
|
275
|
+
if (this._webview.value) {
|
|
276
|
+
this._webview.value.showFind(animated);
|
|
277
|
+
this._findWidgetVisible?.set(true);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
hideFind(animated = true) {
|
|
281
|
+
this._findWidgetVisible?.reset();
|
|
282
|
+
this._webview.value?.hideFind(animated);
|
|
283
|
+
}
|
|
284
|
+
runFindAction(previous) { this._webview.value?.runFindAction(previous); }
|
|
285
|
+
_withWebview(f) {
|
|
286
|
+
if (this._webview.value) {
|
|
287
|
+
f(this._webview.value);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
windowDidDragStart() {
|
|
291
|
+
this._webview.value?.windowDidDragStart();
|
|
292
|
+
}
|
|
293
|
+
windowDidDragEnd() {
|
|
294
|
+
this._webview.value?.windowDidDragEnd();
|
|
295
|
+
}
|
|
296
|
+
setContextKeyService(contextKeyService) {
|
|
297
|
+
this._webview.value?.setContextKeyService(contextKeyService);
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
OverlayWebview = ( __decorate([
|
|
301
|
+
( __param(1, IWorkbenchLayoutService)),
|
|
302
|
+
( __param(2, IWebviewService)),
|
|
303
|
+
( __param(3, IContextKeyService))
|
|
304
|
+
], OverlayWebview));
|
|
305
|
+
function computeClippingRect(frameRect, clipper) {
|
|
306
|
+
const rootRect = clipper.getBoundingClientRect();
|
|
307
|
+
const top = Math.max(rootRect.top - frameRect.top, 0);
|
|
308
|
+
const right = Math.max(frameRect.width - (frameRect.right - rootRect.right), 0);
|
|
309
|
+
const bottom = Math.max(frameRect.height - (frameRect.bottom - rootRect.bottom), 0);
|
|
310
|
+
const left = Math.max(rootRect.left - frameRect.left, 0);
|
|
311
|
+
return { top, right, bottom, left };
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
export { OverlayWebview };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { isUNC } from 'vscode/vscode/vs/base/common/extpath';
|
|
2
|
+
import { Schemas } from 'vscode/vscode/vs/base/common/network';
|
|
3
|
+
import { normalize, sep } from 'vscode/vscode/vs/base/common/path';
|
|
4
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
5
|
+
import { FileOperationError } from 'vscode/vscode/vs/platform/files/common/files';
|
|
6
|
+
import { getWebviewContentMimeType } from '../../../../platform/webview/common/mimeTypes.js';
|
|
7
|
+
|
|
8
|
+
var WebviewResourceResponse;
|
|
9
|
+
( (function(WebviewResourceResponse) {
|
|
10
|
+
let Type;
|
|
11
|
+
( (function(Type) {
|
|
12
|
+
Type[Type["Success"] = 0] = "Success";
|
|
13
|
+
Type[Type["Failed"] = 1] = "Failed";
|
|
14
|
+
Type[Type["AccessDenied"] = 2] = "AccessDenied";
|
|
15
|
+
Type[Type["NotModified"] = 3] = "NotModified";
|
|
16
|
+
})(Type = WebviewResourceResponse.Type || (WebviewResourceResponse.Type = {})));
|
|
17
|
+
class StreamSuccess {
|
|
18
|
+
constructor(stream, etag, mtime, mimeType) {
|
|
19
|
+
this.stream = stream;
|
|
20
|
+
this.etag = etag;
|
|
21
|
+
this.mtime = mtime;
|
|
22
|
+
this.mimeType = mimeType;
|
|
23
|
+
this.type = Type.Success;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
WebviewResourceResponse.StreamSuccess = StreamSuccess;
|
|
27
|
+
WebviewResourceResponse.Failed = { type: Type.Failed };
|
|
28
|
+
WebviewResourceResponse.AccessDenied = { type: Type.AccessDenied };
|
|
29
|
+
class NotModified {
|
|
30
|
+
constructor(mimeType, mtime) {
|
|
31
|
+
this.mimeType = mimeType;
|
|
32
|
+
this.mtime = mtime;
|
|
33
|
+
this.type = Type.NotModified;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
WebviewResourceResponse.NotModified = NotModified;
|
|
37
|
+
})(WebviewResourceResponse || (WebviewResourceResponse = {})));
|
|
38
|
+
async function loadLocalResource(requestUri, options, fileService, logService, token) {
|
|
39
|
+
logService.debug(`loadLocalResource - begin. requestUri=${requestUri}`);
|
|
40
|
+
const resourceToLoad = getResourceToLoad(requestUri, options.roots);
|
|
41
|
+
logService.debug(`loadLocalResource - found resource to load. requestUri=${requestUri}, resourceToLoad=${resourceToLoad}`);
|
|
42
|
+
if (!resourceToLoad) {
|
|
43
|
+
return WebviewResourceResponse.AccessDenied;
|
|
44
|
+
}
|
|
45
|
+
const mime = getWebviewContentMimeType(requestUri);
|
|
46
|
+
try {
|
|
47
|
+
const result = await fileService.readFileStream(resourceToLoad, { etag: options.ifNoneMatch }, token);
|
|
48
|
+
return new WebviewResourceResponse.StreamSuccess(result.value, result.etag, result.mtime, mime);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (err instanceof FileOperationError) {
|
|
52
|
+
const result = err.fileOperationResult;
|
|
53
|
+
if (result === 2 ) {
|
|
54
|
+
return new WebviewResourceResponse.NotModified(mime, err.options?.mtime);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
logService.debug(`loadLocalResource - Error using fileReader. requestUri=${requestUri}`);
|
|
58
|
+
console.log(err);
|
|
59
|
+
return WebviewResourceResponse.Failed;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function getResourceToLoad(requestUri, roots) {
|
|
63
|
+
for (const root of roots) {
|
|
64
|
+
if (containsResource(root, requestUri)) {
|
|
65
|
+
return normalizeResourcePath(requestUri);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function containsResource(root, resource) {
|
|
71
|
+
if (root.scheme !== resource.scheme) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
let resourceFsPath = normalize(resource.fsPath);
|
|
75
|
+
let rootPath = normalize(root.fsPath + (root.fsPath.endsWith(sep) ? '' : sep));
|
|
76
|
+
if (isUNC(root.fsPath) && isUNC(resource.fsPath)) {
|
|
77
|
+
rootPath = rootPath.toLowerCase();
|
|
78
|
+
resourceFsPath = resourceFsPath.toLowerCase();
|
|
79
|
+
}
|
|
80
|
+
return resourceFsPath.startsWith(rootPath);
|
|
81
|
+
}
|
|
82
|
+
function normalizeResourcePath(resource) {
|
|
83
|
+
if (resource.scheme === Schemas.vscodeRemote) {
|
|
84
|
+
return ( URI.from({
|
|
85
|
+
scheme: Schemas.vscodeRemote,
|
|
86
|
+
authority: resource.authority,
|
|
87
|
+
path: '/vscode-resource',
|
|
88
|
+
query: JSON.stringify({
|
|
89
|
+
requestResourcePath: resource.path
|
|
90
|
+
})
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
return resource;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { WebviewResourceResponse, loadLocalResource };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { DEFAULT_FONT_FAMILY } from 'vscode/vscode/vs/base/browser/fonts';
|
|
3
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
+
import { EDITOR_FONT_DEFAULTS } from 'vscode/vscode/vs/editor/common/config/editorOptions';
|
|
6
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
7
|
+
import { getColorRegistry } from 'vscode/vscode/vs/platform/theme/common/colorUtils';
|
|
8
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
|
|
9
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
10
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
|
|
11
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
|
|
12
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
|
|
13
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
|
|
14
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
15
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
|
|
16
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
17
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
18
|
+
import { ColorScheme } from 'vscode/vscode/vs/platform/theme/common/theme';
|
|
19
|
+
import { IWorkbenchThemeService } from 'vscode/vscode/vs/workbench/services/themes/common/workbenchThemeService.service';
|
|
20
|
+
|
|
21
|
+
let WebviewThemeDataProvider = class WebviewThemeDataProvider extends Disposable {
|
|
22
|
+
constructor(_themeService, _configurationService) {
|
|
23
|
+
super();
|
|
24
|
+
this._themeService = _themeService;
|
|
25
|
+
this._configurationService = _configurationService;
|
|
26
|
+
this._cachedWebViewThemeData = undefined;
|
|
27
|
+
this._onThemeDataChanged = this._register(( new Emitter()));
|
|
28
|
+
this.onThemeDataChanged = this._onThemeDataChanged.event;
|
|
29
|
+
this._register(this._themeService.onDidColorThemeChange(() => {
|
|
30
|
+
this._reset();
|
|
31
|
+
}));
|
|
32
|
+
const webviewConfigurationKeys = ['editor.fontFamily', 'editor.fontWeight', 'editor.fontSize'];
|
|
33
|
+
this._register(this._configurationService.onDidChangeConfiguration(e => {
|
|
34
|
+
if (( webviewConfigurationKeys.some(key => e.affectsConfiguration(key)))) {
|
|
35
|
+
this._reset();
|
|
36
|
+
}
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
getTheme() {
|
|
40
|
+
return this._themeService.getColorTheme();
|
|
41
|
+
}
|
|
42
|
+
getWebviewThemeData() {
|
|
43
|
+
if (!this._cachedWebViewThemeData) {
|
|
44
|
+
const configuration = this._configurationService.getValue('editor');
|
|
45
|
+
const editorFontFamily = configuration.fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
|
|
46
|
+
const editorFontWeight = configuration.fontWeight || EDITOR_FONT_DEFAULTS.fontWeight;
|
|
47
|
+
const editorFontSize = configuration.fontSize || EDITOR_FONT_DEFAULTS.fontSize;
|
|
48
|
+
const theme = this._themeService.getColorTheme();
|
|
49
|
+
const exportedColors = getColorRegistry().getColors().reduce((colors, entry) => {
|
|
50
|
+
const color = theme.getColor(entry.id);
|
|
51
|
+
if (color) {
|
|
52
|
+
colors['vscode-' + entry.id.replace('.', '-')] = ( color.toString());
|
|
53
|
+
}
|
|
54
|
+
return colors;
|
|
55
|
+
}, {});
|
|
56
|
+
const styles = {
|
|
57
|
+
'vscode-font-family': DEFAULT_FONT_FAMILY,
|
|
58
|
+
'vscode-font-weight': 'normal',
|
|
59
|
+
'vscode-font-size': '13px',
|
|
60
|
+
'vscode-editor-font-family': editorFontFamily,
|
|
61
|
+
'vscode-editor-font-weight': editorFontWeight,
|
|
62
|
+
'vscode-editor-font-size': editorFontSize + 'px',
|
|
63
|
+
...exportedColors
|
|
64
|
+
};
|
|
65
|
+
const activeTheme = ApiThemeClassName.fromTheme(theme);
|
|
66
|
+
this._cachedWebViewThemeData = { styles, activeTheme, themeLabel: theme.label, themeId: theme.settingsId };
|
|
67
|
+
}
|
|
68
|
+
return this._cachedWebViewThemeData;
|
|
69
|
+
}
|
|
70
|
+
_reset() {
|
|
71
|
+
this._cachedWebViewThemeData = undefined;
|
|
72
|
+
this._onThemeDataChanged.fire();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
WebviewThemeDataProvider = ( __decorate([
|
|
76
|
+
( __param(0, IWorkbenchThemeService)),
|
|
77
|
+
( __param(1, IConfigurationService))
|
|
78
|
+
], WebviewThemeDataProvider));
|
|
79
|
+
var ApiThemeClassName;
|
|
80
|
+
( (function(ApiThemeClassName) {
|
|
81
|
+
ApiThemeClassName["light"] = "vscode-light";
|
|
82
|
+
ApiThemeClassName["dark"] = "vscode-dark";
|
|
83
|
+
ApiThemeClassName["highContrast"] = "vscode-high-contrast";
|
|
84
|
+
ApiThemeClassName["highContrastLight"] = "vscode-high-contrast-light";
|
|
85
|
+
})(ApiThemeClassName || (ApiThemeClassName = {})));
|
|
86
|
+
( (function(ApiThemeClassName) {
|
|
87
|
+
function fromTheme(theme) {
|
|
88
|
+
switch (theme.type) {
|
|
89
|
+
case ColorScheme.LIGHT: return ApiThemeClassName.light;
|
|
90
|
+
case ColorScheme.DARK: return ApiThemeClassName.dark;
|
|
91
|
+
case ColorScheme.HIGH_CONTRAST_DARK: return ApiThemeClassName.highContrast;
|
|
92
|
+
case ColorScheme.HIGH_CONTRAST_LIGHT: return ApiThemeClassName.highContrastLight;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
ApiThemeClassName.fromTheme = fromTheme;
|
|
96
|
+
})(ApiThemeClassName || (ApiThemeClassName = {})));
|
|
97
|
+
|
|
98
|
+
export { WebviewThemeDataProvider };
|